Skip to content

Commit

Permalink
feat(serverless_jobs): add method to get jobs limits (scaleway#2275)
Browse files Browse the repository at this point in the history
  • Loading branch information
scaleway-bot authored Oct 23, 2024
1 parent 2a6e720 commit c5019eb
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions api/jobs/v1alpha1/jobs_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,17 @@ type GetJobRunRequest struct {
JobRunID string `json:"-"`
}

// GetJobsLimitsRequest: get jobs limits request.
type GetJobsLimitsRequest struct {
// Region: region to target. If none is passed will use default region from the config.
Region scw.Region `json:"-"`
}

// JobsLimits: jobs limits.
type JobsLimits struct {
SecretsPerJobDefinition uint32 `json:"secrets_per_job_definition"`
}

// ListJobDefinitionSecretsRequest: list job definition secrets request.
type ListJobDefinitionSecretsRequest struct {
// Region: region to target. If none is passed will use default region from the config.
Expand Down Expand Up @@ -1162,3 +1173,30 @@ func (s *API) ListJobsResources(req *ListJobsResourcesRequest, opts ...scw.Reque
}
return &resp, nil
}

// GetJobsLimits: Get jobs limits for the console.
func (s *API) GetJobsLimits(req *GetJobsLimitsRequest, opts ...scw.RequestOption) (*JobsLimits, error) {
var err error

if req.Region == "" {
defaultRegion, _ := s.client.GetDefaultRegion()
req.Region = defaultRegion
}

if fmt.Sprint(req.Region) == "" {
return nil, errors.New("field Region cannot be empty in request")
}

scwReq := &scw.ScalewayRequest{
Method: "GET",
Path: "/serverless-jobs/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/jobs-limits",
}

var resp JobsLimits

err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}

0 comments on commit c5019eb

Please sign in to comment.