Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(serverless_jobs): add method to get jobs limits #2275

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}