Пример #1
0
func (p Resource) initServices() {
	services.GetTenantService()
	services.GetTokenService()
	services.GetUserService()
	services.GetRoleService()
	services.GetAuthService()
}
Пример #2
0
func (p *Resource) TenantIdHandler(req *restful.Request, resp *restful.Response) {
	logrus.Infoln("TenantIdHandler is called!")

	token := req.HeaderParameter("X-Auth-Token")
	userId := req.QueryParameter("userId")

	ret, errorCode, err := services.GetTenantService().GetTenantId(token, userId)
	if err != nil {
		response.WriteStatusError(errorCode, err, resp)
		return
	}

	response.WriteResponse(ret, resp)
}
Пример #3
0
// TenantListHandler parses the http request and return a tenant.
// Usage :
//		GET /v1/tenant
//		GET /v1/tenant/{ParamID}
// Params :
//		ParamID : Storage identifier of the tenant
// If successful,response code will be set to 201.
func (p *Resource) TenantListHandler(req *restful.Request, resp *restful.Response) {
	logrus.Infof("TenantListHandler is called!")

	token := req.HeaderParameter("X-Auth-Token")
	limitnum := queryIntParam(req, "limit", 10)
	skipnum := queryIntParam(req, "skip", 0)
	sort := req.QueryParameter("sort")

	ret, count, errorCode, err := services.GetTenantService().TenantList(token, limitnum, skipnum, sort)
	if err != nil {
		response.WriteStatusError(errorCode, err, resp)
		return
	}

	p.successList(ret, limitnum, count, req, resp)
}
Пример #4
0
func (p *Resource) TenantDetailHandler(req *restful.Request, resp *restful.Response) {
	logrus.Infof("TenantDetailHandler is called!")

	token := req.HeaderParameter("X-Auth-Token")
	id := req.PathParameter(ParamID)
	if len(id) <= 0 {
		logrus.Warnln("tenant id should not be null for tenant detail operation")
		response.WriteStatusError(services.TENANT_ERROR_GET, errors.New("tenant id should not be null for get tenant operation"), resp)
		return
	}

	ret, errorCode, err := services.GetTenantService().TenantDetail(token, id)
	if err != nil {
		response.WriteStatusError(errorCode, err, resp)
		return
	}

	response.WriteResponse(ret, resp)
}