Example #1
0
func GetOrgQuotas(c *middleware.Context) *rbody.ApiResponse {
	var quotas []m.OrgQuotaDTO
	var err error
	org := c.ParamsInt64("orgId")
	if setting.Quota.Enabled {
		quotas, err = sqlstore.GetOrgQuotas(org)
		if err != nil {
			return rbody.ErrResp(500, err)
		}
	} else {
		quotas = []m.OrgQuotaDTO{
			{
				OrgId:  org,
				Target: "endpoint",
				Limit:  -1,
				Used:   -1,
			},
			{
				OrgId:  org,
				Target: "probe",
				Limit:  -1,
				Used:   -1,
			},
		}
	}

	return rbody.OkResp("quotas", quotas)
}
Example #2
0
func UpdateOrgQuota(c *middleware.Context) *rbody.ApiResponse {
	orgId := c.ParamsInt64(":orgId")
	target := c.Params(":target")
	limit := c.ParamsInt64(":limit")

	if _, ok := setting.Quota.Org.ToMap()[target]; !ok {
		return rbody.NotFound
	}

	quota := m.OrgQuotaDTO{
		OrgId:  orgId,
		Target: target,
		Limit:  limit,
	}
	err := sqlstore.UpdateOrgQuota(&quota)
	if err != nil {
		return rbody.ErrResp(500, err)
	}
	return rbody.OkResp("quota", quota)
}