diff --git a/services/git/api_default.go b/services/git/api_default.go index f756e7d55..8fdb19ca5 100644 --- a/services/git/api_default.go +++ b/services/git/api_default.go @@ -117,6 +117,25 @@ type DefaultApi interface { */ ListInstancesExecute(ctx context.Context, projectId string) (*ListInstances, error) + /* + ListRunnerLabels Returns the details for the given STACKIT Git RunnerLabels. + Type of runners we can use for running jobs. + + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId Project identifier. + @return ApiListRunnerLabelsRequest + */ + ListRunnerLabels(ctx context.Context, projectId string) ApiListRunnerLabelsRequest + /* + ListRunnerLabelsExecute executes the request + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId Project identifier. + @return ListRunnerLabels + + */ + ListRunnerLabelsExecute(ctx context.Context, projectId string) (*ListRunnerLabels, error) /* PatchInstance Patch Instance. Patches the Instance. @@ -162,6 +181,10 @@ type ApiListInstancesRequest interface { Execute() (*ListInstances, error) } +type ApiListRunnerLabelsRequest interface { + Execute() (*ListRunnerLabels, error) +} + type ApiPatchInstanceRequest interface { PatchOperation(patchOperation []PatchOperation) ApiPatchInstanceRequest Execute() (*Instance, error) @@ -1000,6 +1023,165 @@ func (a *APIClient) ListInstancesExecute(ctx context.Context, projectId string) return r.Execute() } +type ListRunnerLabelsRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string +} + +func (r ListRunnerLabelsRequest) Execute() (*ListRunnerLabels, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *ListRunnerLabels + ) + a := r.apiService + client, ok := a.client.(*APIClient) + if !ok { + return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient") + } + localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ListRunnerLabels") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1beta/projects/{projectId}/runner-labels" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if strlen(r.projectId) < 36 { + return localVarReturnValue, fmt.Errorf("projectId must have at least 36 elements") + } + if strlen(r.projectId) > 36 { + return localVarReturnValue, fmt.Errorf("projectId must have less than 36 elements") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v GenericErrorResponse + err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 401 { + var v UnauthorizedResponse + err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v GenericErrorResponse + err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + } + return localVarReturnValue, newErr + } + + err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +/* +ListRunnerLabels: Returns the details for the given STACKIT Git RunnerLabels. + +Type of runners we can use for running jobs. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId Project identifier. + @return ApiListRunnerLabelsRequest +*/ +func (a *APIClient) ListRunnerLabels(ctx context.Context, projectId string) ApiListRunnerLabelsRequest { + return ListRunnerLabelsRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + } +} + +func (a *APIClient) ListRunnerLabelsExecute(ctx context.Context, projectId string) (*ListRunnerLabels, error) { + r := ListRunnerLabelsRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + } + return r.Execute() +} + type PatchInstanceRequest struct { ctx context.Context apiService *DefaultApiService diff --git a/services/git/api_default_test.go b/services/git/api_default_test.go index 4273838d6..2de3a78b3 100644 --- a/services/git/api_default_test.go +++ b/services/git/api_default_test.go @@ -284,6 +284,58 @@ func Test_git_DefaultApiService(t *testing.T) { } }) + t.Run("Test DefaultApiService ListRunnerLabels", func(t *testing.T) { + _apiUrlPath := "/v1beta/projects/{projectId}/runner-labels" + projectIdValue := randString(36) + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + data := ListRunnerLabels{} + w.Header().Add("Content-Type", "application/json") + json.NewEncoder(w).Encode(data) + }) + testServer := httptest.NewServer(testDefaultApiServeMux) + defer testServer.Close() + + configuration := &config.Configuration{ + DefaultHeader: make(map[string]string), + UserAgent: "OpenAPI-Generator/1.0.0/go", + Debug: false, + Region: "test_region", + Servers: config.ServerConfigurations{ + { + URL: testServer.URL, + Description: "Localhost for git_DefaultApi", + Variables: map[string]config.ServerVariable{ + "region": { + DefaultValue: "test_region.", + EnumValues: []string{ + "test_region.", + }, + }, + }, + }, + }, + OperationServers: map[string]config.ServerConfigurations{}, + } + apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication()) + if err != nil { + t.Fatalf("creating API client: %v", err) + } + + projectId := projectIdValue + + resp, reqErr := apiClient.ListRunnerLabels(context.Background(), projectId).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if IsNil(resp) { + t.Fatalf("response not present") + } + }) + t.Run("Test DefaultApiService PatchInstance", func(t *testing.T) { _apiUrlPath := "/v1beta/projects/{projectId}/instances/{instanceId}" projectIdValue := randString(36) diff --git a/services/git/model_list_flavors.go b/services/git/model_list_flavors.go index 6c3e5a276..e516f42e2 100644 --- a/services/git/model_list_flavors.go +++ b/services/git/model_list_flavors.go @@ -37,7 +37,7 @@ func setListFlavorsGetFlavorsAttributeType(arg *ListFlavorsGetFlavorsAttributeTy *arg = &val } -// ListFlavors A list of STACKIT Git flavors. +// ListFlavors A list of STACKIT Git Flavors. type ListFlavors struct { // REQUIRED Flavors ListFlavorsGetFlavorsAttributeType `json:"flavors" required:"true"` diff --git a/services/git/model_list_runner_labels.go b/services/git/model_list_runner_labels.go new file mode 100644 index 000000000..d1643372f --- /dev/null +++ b/services/git/model_list_runner_labels.go @@ -0,0 +1,125 @@ +/* +STACKIT Git API + +STACKIT Git management API. + +API version: 1beta.0.4 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package git + +import ( + "encoding/json" +) + +// checks if the ListRunnerLabels type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ListRunnerLabels{} + +/* + types and functions for runner-labels +*/ + +// isArray +type ListRunnerLabelsGetRunnerLabelsAttributeType = *[]RunnerLabel +type ListRunnerLabelsGetRunnerLabelsArgType = []RunnerLabel +type ListRunnerLabelsGetRunnerLabelsRetType = []RunnerLabel + +func getListRunnerLabelsGetRunnerLabelsAttributeTypeOk(arg ListRunnerLabelsGetRunnerLabelsAttributeType) (ret ListRunnerLabelsGetRunnerLabelsRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setListRunnerLabelsGetRunnerLabelsAttributeType(arg *ListRunnerLabelsGetRunnerLabelsAttributeType, val ListRunnerLabelsGetRunnerLabelsRetType) { + *arg = &val +} + +// ListRunnerLabels A list of STACKIT Git RunnerLabels. +type ListRunnerLabels struct { + // REQUIRED + RunnerLabels ListRunnerLabelsGetRunnerLabelsAttributeType `json:"runner-labels" required:"true"` +} + +type _ListRunnerLabels ListRunnerLabels + +// NewListRunnerLabels instantiates a new ListRunnerLabels object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewListRunnerLabels(runnerLabels ListRunnerLabelsGetRunnerLabelsArgType) *ListRunnerLabels { + this := ListRunnerLabels{} + setListRunnerLabelsGetRunnerLabelsAttributeType(&this.RunnerLabels, runnerLabels) + return &this +} + +// NewListRunnerLabelsWithDefaults instantiates a new ListRunnerLabels object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewListRunnerLabelsWithDefaults() *ListRunnerLabels { + this := ListRunnerLabels{} + return &this +} + +// GetRunnerLabels returns the RunnerLabels field value +func (o *ListRunnerLabels) GetRunnerLabels() (ret ListRunnerLabelsGetRunnerLabelsRetType) { + ret, _ = o.GetRunnerLabelsOk() + return ret +} + +// GetRunnerLabelsOk returns a tuple with the RunnerLabels field value +// and a boolean to check if the value has been set. +func (o *ListRunnerLabels) GetRunnerLabelsOk() (ret ListRunnerLabelsGetRunnerLabelsRetType, ok bool) { + return getListRunnerLabelsGetRunnerLabelsAttributeTypeOk(o.RunnerLabels) +} + +// SetRunnerLabels sets field value +func (o *ListRunnerLabels) SetRunnerLabels(v ListRunnerLabelsGetRunnerLabelsRetType) { + setListRunnerLabelsGetRunnerLabelsAttributeType(&o.RunnerLabels, v) +} + +func (o ListRunnerLabels) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getListRunnerLabelsGetRunnerLabelsAttributeTypeOk(o.RunnerLabels); ok { + toSerialize["RunnerLabels"] = val + } + return toSerialize, nil +} + +type NullableListRunnerLabels struct { + value *ListRunnerLabels + isSet bool +} + +func (v NullableListRunnerLabels) Get() *ListRunnerLabels { + return v.value +} + +func (v *NullableListRunnerLabels) Set(val *ListRunnerLabels) { + v.value = val + v.isSet = true +} + +func (v NullableListRunnerLabels) IsSet() bool { + return v.isSet +} + +func (v *NullableListRunnerLabels) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableListRunnerLabels(val *ListRunnerLabels) *NullableListRunnerLabels { + return &NullableListRunnerLabels{value: val, isSet: true} +} + +func (v NullableListRunnerLabels) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableListRunnerLabels) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/git/model_list_runner_labels_test.go b/services/git/model_list_runner_labels_test.go new file mode 100644 index 000000000..e39c866ed --- /dev/null +++ b/services/git/model_list_runner_labels_test.go @@ -0,0 +1,11 @@ +/* +STACKIT Git API + +STACKIT Git management API. + +API version: 1beta.0.4 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package git diff --git a/services/git/model_runner_label.go b/services/git/model_runner_label.go new file mode 100644 index 000000000..79036859c --- /dev/null +++ b/services/git/model_runner_label.go @@ -0,0 +1,217 @@ +/* +STACKIT Git API + +STACKIT Git management API. + +API version: 1beta.0.4 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package git + +import ( + "encoding/json" +) + +// checks if the RunnerLabel type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &RunnerLabel{} + +/* + types and functions for description +*/ + +// isNotNullableString +type RunnerLabelGetDescriptionAttributeType = *string + +func getRunnerLabelGetDescriptionAttributeTypeOk(arg RunnerLabelGetDescriptionAttributeType) (ret RunnerLabelGetDescriptionRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setRunnerLabelGetDescriptionAttributeType(arg *RunnerLabelGetDescriptionAttributeType, val RunnerLabelGetDescriptionRetType) { + *arg = &val +} + +type RunnerLabelGetDescriptionArgType = string +type RunnerLabelGetDescriptionRetType = string + +/* + types and functions for id +*/ + +// isNotNullableString +type RunnerLabelGetIdAttributeType = *string + +func getRunnerLabelGetIdAttributeTypeOk(arg RunnerLabelGetIdAttributeType) (ret RunnerLabelGetIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setRunnerLabelGetIdAttributeType(arg *RunnerLabelGetIdAttributeType, val RunnerLabelGetIdRetType) { + *arg = &val +} + +type RunnerLabelGetIdArgType = string +type RunnerLabelGetIdRetType = string + +/* + types and functions for label +*/ + +// isNotNullableString +type RunnerLabelGetLabelAttributeType = *string + +func getRunnerLabelGetLabelAttributeTypeOk(arg RunnerLabelGetLabelAttributeType) (ret RunnerLabelGetLabelRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setRunnerLabelGetLabelAttributeType(arg *RunnerLabelGetLabelAttributeType, val RunnerLabelGetLabelRetType) { + *arg = &val +} + +type RunnerLabelGetLabelArgType = string +type RunnerLabelGetLabelRetType = string + +// RunnerLabel Describes a STACKIT Git RunnerLabel. +type RunnerLabel struct { + // RunnerLabel description. + // REQUIRED + Description RunnerLabelGetDescriptionAttributeType `json:"description" required:"true"` + // RunnerLabel id. + // REQUIRED + Id RunnerLabelGetIdAttributeType `json:"id" required:"true"` + // RunnerLabel label. + // REQUIRED + Label RunnerLabelGetLabelAttributeType `json:"label" required:"true"` +} + +type _RunnerLabel RunnerLabel + +// NewRunnerLabel instantiates a new RunnerLabel object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewRunnerLabel(description RunnerLabelGetDescriptionArgType, id RunnerLabelGetIdArgType, label RunnerLabelGetLabelArgType) *RunnerLabel { + this := RunnerLabel{} + setRunnerLabelGetDescriptionAttributeType(&this.Description, description) + setRunnerLabelGetIdAttributeType(&this.Id, id) + setRunnerLabelGetLabelAttributeType(&this.Label, label) + return &this +} + +// NewRunnerLabelWithDefaults instantiates a new RunnerLabel object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewRunnerLabelWithDefaults() *RunnerLabel { + this := RunnerLabel{} + return &this +} + +// GetDescription returns the Description field value +func (o *RunnerLabel) GetDescription() (ret RunnerLabelGetDescriptionRetType) { + ret, _ = o.GetDescriptionOk() + return ret +} + +// GetDescriptionOk returns a tuple with the Description field value +// and a boolean to check if the value has been set. +func (o *RunnerLabel) GetDescriptionOk() (ret RunnerLabelGetDescriptionRetType, ok bool) { + return getRunnerLabelGetDescriptionAttributeTypeOk(o.Description) +} + +// SetDescription sets field value +func (o *RunnerLabel) SetDescription(v RunnerLabelGetDescriptionRetType) { + setRunnerLabelGetDescriptionAttributeType(&o.Description, v) +} + +// GetId returns the Id field value +func (o *RunnerLabel) GetId() (ret RunnerLabelGetIdRetType) { + ret, _ = o.GetIdOk() + return ret +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *RunnerLabel) GetIdOk() (ret RunnerLabelGetIdRetType, ok bool) { + return getRunnerLabelGetIdAttributeTypeOk(o.Id) +} + +// SetId sets field value +func (o *RunnerLabel) SetId(v RunnerLabelGetIdRetType) { + setRunnerLabelGetIdAttributeType(&o.Id, v) +} + +// GetLabel returns the Label field value +func (o *RunnerLabel) GetLabel() (ret RunnerLabelGetLabelRetType) { + ret, _ = o.GetLabelOk() + return ret +} + +// GetLabelOk returns a tuple with the Label field value +// and a boolean to check if the value has been set. +func (o *RunnerLabel) GetLabelOk() (ret RunnerLabelGetLabelRetType, ok bool) { + return getRunnerLabelGetLabelAttributeTypeOk(o.Label) +} + +// SetLabel sets field value +func (o *RunnerLabel) SetLabel(v RunnerLabelGetLabelRetType) { + setRunnerLabelGetLabelAttributeType(&o.Label, v) +} + +func (o RunnerLabel) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getRunnerLabelGetDescriptionAttributeTypeOk(o.Description); ok { + toSerialize["Description"] = val + } + if val, ok := getRunnerLabelGetIdAttributeTypeOk(o.Id); ok { + toSerialize["Id"] = val + } + if val, ok := getRunnerLabelGetLabelAttributeTypeOk(o.Label); ok { + toSerialize["Label"] = val + } + return toSerialize, nil +} + +type NullableRunnerLabel struct { + value *RunnerLabel + isSet bool +} + +func (v NullableRunnerLabel) Get() *RunnerLabel { + return v.value +} + +func (v *NullableRunnerLabel) Set(val *RunnerLabel) { + v.value = val + v.isSet = true +} + +func (v NullableRunnerLabel) IsSet() bool { + return v.isSet +} + +func (v *NullableRunnerLabel) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableRunnerLabel(val *RunnerLabel) *NullableRunnerLabel { + return &NullableRunnerLabel{value: val, isSet: true} +} + +func (v NullableRunnerLabel) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableRunnerLabel) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/git/model_runner_label_test.go b/services/git/model_runner_label_test.go new file mode 100644 index 000000000..e39c866ed --- /dev/null +++ b/services/git/model_runner_label_test.go @@ -0,0 +1,11 @@ +/* +STACKIT Git API + +STACKIT Git management API. + +API version: 1beta.0.4 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package git