From 7bd37ebdb23fe8a8ffec2de123effa1b788f0533 Mon Sep 17 00:00:00 2001 From: Jason Peterson Date: Mon, 1 Jul 2024 15:43:47 -0400 Subject: [PATCH] Sdk update 20240701 151344 (#22) Signed-off-by: Jason Peterson Co-authored-by: whitesource-ets[bot] <328400+whitesource-ets[bot]@users.noreply.github.ibm.com> Co-authored-by: Michael Magrian Co-authored-by: Enrico Regge Co-authored-by: John Sartore Co-authored-by: semantic-release-bot Co-authored-by: whitesource-ets[bot] <409986+whitesource-ets[bot]@users.noreply.github.ibm.com> Co-authored-by: whitesource-ets[bot] --- README.md | 8 +- codeenginev2/code_engine_v2.go | 4110 ++++++++--- codeenginev2/code_engine_v2_examples_test.go | 422 +- .../code_engine_v2_integration_test.go | 563 +- codeenginev2/code_engine_v2_test.go | 6235 ++++++++++++----- common/version.go | 2 +- example/v2/README.md | 12 + example/v2/example_v2.go | 94 + 8 files changed, 8161 insertions(+), 3285 deletions(-) diff --git a/README.md b/README.md index 1374b37..45086a9 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ [![Build Status](https://travis-ci.com/IBM/code-engine-go-sdk.svg?branch=main)](https://travis-ci.com/IBM/code-engine-go-sdk) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) -# IBM Cloud Code Engine Go SDK 4.3.0 +# IBM Cloud Code Engine Go SDK 4.4.0 Go client library to interact with the [Code Engine API](https://cloud.ibm.com/apidocs/codeengine). ## Table of Contents @@ -17,7 +17,7 @@ Go client library to interact with the [Code Engine API](https://cloud.ibm.com/a -- [IBM Cloud Code Engine Go SDK 4.3.0](#ibm-cloud-code-engine-go-sdk-310) +- [IBM Cloud Code Engine Go SDK 4.4.0](#ibm-cloud-code-engine-go-sdk-310) - [Table of Contents](#table-of-contents) - [Overview](#overview) - [Prerequisites](#prerequisites) @@ -52,7 +52,7 @@ Service Name | Package name * Go version 1.18 or above. ## Installation -The current version of this SDK: 4.3.0 +The current version of this SDK: 4.4.0 There are a few different ways to download and install the Code Engine Go SDK project for use by your Go application: @@ -85,7 +85,7 @@ to your `Gopkg.toml` file. Here is an example: ``` [[constraint]] name = "github.com/IBM/code-engine-go-sdk" - version = "4.3.0" + version = "4.4.0" ``` diff --git a/codeenginev2/code_engine_v2.go b/codeenginev2/code_engine_v2.go index d1a17bc..ae7aecf 100644 --- a/codeenginev2/code_engine_v2.go +++ b/codeenginev2/code_engine_v2.go @@ -15,7 +15,7 @@ */ /* - * IBM OpenAPI SDK Code Generator Version: 3.84.1-55f6d880-20240110-194020 + * IBM OpenAPI SDK Code Generator Version: 3.86.0-bc6f14b3-20240221-193958 */ // Package codeenginev2 : Operations and models for the CodeEngineV2 service @@ -1086,6 +1086,74 @@ func (codeEngine *CodeEngineV2) DeleteAppRevisionWithContext(ctx context.Context return } +// ListAppInstances : List application instances +// List all instances of an application. +func (codeEngine *CodeEngineV2) ListAppInstances(listAppInstancesOptions *ListAppInstancesOptions) (result *AppInstanceList, response *core.DetailedResponse, err error) { + return codeEngine.ListAppInstancesWithContext(context.Background(), listAppInstancesOptions) +} + +// ListAppInstancesWithContext is an alternate form of the ListAppInstances method which supports a Context parameter +func (codeEngine *CodeEngineV2) ListAppInstancesWithContext(ctx context.Context, listAppInstancesOptions *ListAppInstancesOptions) (result *AppInstanceList, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(listAppInstancesOptions, "listAppInstancesOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(listAppInstancesOptions, "listAppInstancesOptions") + if err != nil { + return + } + + pathParamsMap := map[string]string{ + "project_id": *listAppInstancesOptions.ProjectID, + "app_name": *listAppInstancesOptions.AppName, + } + + builder := core.NewRequestBuilder(core.GET) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = codeEngine.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/apps/{app_name}/instances`, pathParamsMap) + if err != nil { + return + } + + for headerName, headerValue := range listAppInstancesOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "ListAppInstances") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") + + if listAppInstancesOptions.Limit != nil { + builder.AddQuery("limit", fmt.Sprint(*listAppInstancesOptions.Limit)) + } + if listAppInstancesOptions.Start != nil { + builder.AddQuery("start", fmt.Sprint(*listAppInstancesOptions.Start)) + } + + request, err := builder.Build() + if err != nil { + return + } + + var rawResponse map[string]json.RawMessage + response, err = codeEngine.Service.Request(request, &rawResponse) + if err != nil { + return + } + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalAppInstanceList) + if err != nil { + return + } + response.Result = result + } + + return +} + // ListJobs : List jobs // List all jobs in a project. func (codeEngine *CodeEngineV2) ListJobs(listJobsOptions *ListJobsOptions) (result *JobList, response *core.DetailedResponse, err error) { @@ -1749,50 +1817,102 @@ func (codeEngine *CodeEngineV2) DeleteJobRunWithContext(ctx context.Context, del return } -// ListBindings : List bindings -// List all bindings in a project. -func (codeEngine *CodeEngineV2) ListBindings(listBindingsOptions *ListBindingsOptions) (result *BindingList, response *core.DetailedResponse, err error) { - return codeEngine.ListBindingsWithContext(context.Background(), listBindingsOptions) +// ListFunctionRuntimes : List the function runtimes +// List all valid function runtimes. +func (codeEngine *CodeEngineV2) ListFunctionRuntimes(listFunctionRuntimesOptions *ListFunctionRuntimesOptions) (result *FunctionRuntimeList, response *core.DetailedResponse, err error) { + return codeEngine.ListFunctionRuntimesWithContext(context.Background(), listFunctionRuntimesOptions) } -// ListBindingsWithContext is an alternate form of the ListBindings method which supports a Context parameter -func (codeEngine *CodeEngineV2) ListBindingsWithContext(ctx context.Context, listBindingsOptions *ListBindingsOptions) (result *BindingList, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(listBindingsOptions, "listBindingsOptions cannot be nil") +// ListFunctionRuntimesWithContext is an alternate form of the ListFunctionRuntimes method which supports a Context parameter +func (codeEngine *CodeEngineV2) ListFunctionRuntimesWithContext(ctx context.Context, listFunctionRuntimesOptions *ListFunctionRuntimesOptions) (result *FunctionRuntimeList, response *core.DetailedResponse, err error) { + err = core.ValidateStruct(listFunctionRuntimesOptions, "listFunctionRuntimesOptions") if err != nil { return } - err = core.ValidateStruct(listBindingsOptions, "listBindingsOptions") + + builder := core.NewRequestBuilder(core.GET) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = codeEngine.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/function_runtimes`, nil) + if err != nil { + return + } + + for headerName, headerValue := range listFunctionRuntimesOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "ListFunctionRuntimes") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") + + request, err := builder.Build() + if err != nil { + return + } + + var rawResponse map[string]json.RawMessage + response, err = codeEngine.Service.Request(request, &rawResponse) + if err != nil { + return + } + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalFunctionRuntimeList) + if err != nil { + return + } + response.Result = result + } + + return +} + +// ListFunctions : List functions +// List all functions in a project. +func (codeEngine *CodeEngineV2) ListFunctions(listFunctionsOptions *ListFunctionsOptions) (result *FunctionList, response *core.DetailedResponse, err error) { + return codeEngine.ListFunctionsWithContext(context.Background(), listFunctionsOptions) +} + +// ListFunctionsWithContext is an alternate form of the ListFunctions method which supports a Context parameter +func (codeEngine *CodeEngineV2) ListFunctionsWithContext(ctx context.Context, listFunctionsOptions *ListFunctionsOptions) (result *FunctionList, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(listFunctionsOptions, "listFunctionsOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(listFunctionsOptions, "listFunctionsOptions") if err != nil { return } pathParamsMap := map[string]string{ - "project_id": *listBindingsOptions.ProjectID, + "project_id": *listFunctionsOptions.ProjectID, } builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = codeEngine.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/bindings`, pathParamsMap) + _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/functions`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range listBindingsOptions.Headers { + for headerName, headerValue := range listFunctionsOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "ListBindings") + sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "ListFunctions") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") - if listBindingsOptions.Limit != nil { - builder.AddQuery("limit", fmt.Sprint(*listBindingsOptions.Limit)) + if listFunctionsOptions.Limit != nil { + builder.AddQuery("limit", fmt.Sprint(*listFunctionsOptions.Limit)) } - if listBindingsOptions.Start != nil { - builder.AddQuery("start", fmt.Sprint(*listBindingsOptions.Start)) + if listFunctionsOptions.Start != nil { + builder.AddQuery("start", fmt.Sprint(*listFunctionsOptions.Start)) } request, err := builder.Build() @@ -1806,7 +1926,7 @@ func (codeEngine *CodeEngineV2) ListBindingsWithContext(ctx context.Context, lis return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBindingList) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalFunctionList) if err != nil { return } @@ -1816,41 +1936,40 @@ func (codeEngine *CodeEngineV2) ListBindingsWithContext(ctx context.Context, lis return } -// CreateBinding : Create a binding -// Create a binding. Creating a service binding with a Code Engine app will update the app, creating a new revision. For -// more information see the [documentaion](https://cloud.ibm.com/docs/codeengine?topic=codeengine-service-binding). -func (codeEngine *CodeEngineV2) CreateBinding(createBindingOptions *CreateBindingOptions) (result *Binding, response *core.DetailedResponse, err error) { - return codeEngine.CreateBindingWithContext(context.Background(), createBindingOptions) +// CreateFunction : Create a function +// Create a function. +func (codeEngine *CodeEngineV2) CreateFunction(createFunctionOptions *CreateFunctionOptions) (result *Function, response *core.DetailedResponse, err error) { + return codeEngine.CreateFunctionWithContext(context.Background(), createFunctionOptions) } -// CreateBindingWithContext is an alternate form of the CreateBinding method which supports a Context parameter -func (codeEngine *CodeEngineV2) CreateBindingWithContext(ctx context.Context, createBindingOptions *CreateBindingOptions) (result *Binding, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(createBindingOptions, "createBindingOptions cannot be nil") +// CreateFunctionWithContext is an alternate form of the CreateFunction method which supports a Context parameter +func (codeEngine *CodeEngineV2) CreateFunctionWithContext(ctx context.Context, createFunctionOptions *CreateFunctionOptions) (result *Function, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(createFunctionOptions, "createFunctionOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(createBindingOptions, "createBindingOptions") + err = core.ValidateStruct(createFunctionOptions, "createFunctionOptions") if err != nil { return } pathParamsMap := map[string]string{ - "project_id": *createBindingOptions.ProjectID, + "project_id": *createFunctionOptions.ProjectID, } builder := core.NewRequestBuilder(core.POST) builder = builder.WithContext(ctx) builder.EnableGzipCompression = codeEngine.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/bindings`, pathParamsMap) + _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/functions`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range createBindingOptions.Headers { + for headerName, headerValue := range createFunctionOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "CreateBinding") + sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "CreateFunction") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -1858,14 +1977,44 @@ func (codeEngine *CodeEngineV2) CreateBindingWithContext(ctx context.Context, cr builder.AddHeader("Content-Type", "application/json") body := make(map[string]interface{}) - if createBindingOptions.Component != nil { - body["component"] = createBindingOptions.Component + if createFunctionOptions.CodeReference != nil { + body["code_reference"] = createFunctionOptions.CodeReference } - if createBindingOptions.Prefix != nil { - body["prefix"] = createBindingOptions.Prefix + if createFunctionOptions.Name != nil { + body["name"] = createFunctionOptions.Name } - if createBindingOptions.SecretName != nil { - body["secret_name"] = createBindingOptions.SecretName + if createFunctionOptions.Runtime != nil { + body["runtime"] = createFunctionOptions.Runtime + } + if createFunctionOptions.CodeBinary != nil { + body["code_binary"] = createFunctionOptions.CodeBinary + } + if createFunctionOptions.CodeMain != nil { + body["code_main"] = createFunctionOptions.CodeMain + } + if createFunctionOptions.CodeSecret != nil { + body["code_secret"] = createFunctionOptions.CodeSecret + } + if createFunctionOptions.ManagedDomainMappings != nil { + body["managed_domain_mappings"] = createFunctionOptions.ManagedDomainMappings + } + if createFunctionOptions.RunEnvVariables != nil { + body["run_env_variables"] = createFunctionOptions.RunEnvVariables + } + if createFunctionOptions.ScaleConcurrency != nil { + body["scale_concurrency"] = createFunctionOptions.ScaleConcurrency + } + if createFunctionOptions.ScaleCpuLimit != nil { + body["scale_cpu_limit"] = createFunctionOptions.ScaleCpuLimit + } + if createFunctionOptions.ScaleDownDelay != nil { + body["scale_down_delay"] = createFunctionOptions.ScaleDownDelay + } + if createFunctionOptions.ScaleMaxExecutionTime != nil { + body["scale_max_execution_time"] = createFunctionOptions.ScaleMaxExecutionTime + } + if createFunctionOptions.ScaleMemoryLimit != nil { + body["scale_memory_limit"] = createFunctionOptions.ScaleMemoryLimit } _, err = builder.SetBodyContentJSON(body) if err != nil { @@ -1883,7 +2032,7 @@ func (codeEngine *CodeEngineV2) CreateBindingWithContext(ctx context.Context, cr return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBinding) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalFunction) if err != nil { return } @@ -1893,41 +2042,41 @@ func (codeEngine *CodeEngineV2) CreateBindingWithContext(ctx context.Context, cr return } -// GetBinding : Get a binding -// Display the details of a binding. -func (codeEngine *CodeEngineV2) GetBinding(getBindingOptions *GetBindingOptions) (result *Binding, response *core.DetailedResponse, err error) { - return codeEngine.GetBindingWithContext(context.Background(), getBindingOptions) +// GetFunction : Get a function +// Display the details of a function. +func (codeEngine *CodeEngineV2) GetFunction(getFunctionOptions *GetFunctionOptions) (result *Function, response *core.DetailedResponse, err error) { + return codeEngine.GetFunctionWithContext(context.Background(), getFunctionOptions) } -// GetBindingWithContext is an alternate form of the GetBinding method which supports a Context parameter -func (codeEngine *CodeEngineV2) GetBindingWithContext(ctx context.Context, getBindingOptions *GetBindingOptions) (result *Binding, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(getBindingOptions, "getBindingOptions cannot be nil") +// GetFunctionWithContext is an alternate form of the GetFunction method which supports a Context parameter +func (codeEngine *CodeEngineV2) GetFunctionWithContext(ctx context.Context, getFunctionOptions *GetFunctionOptions) (result *Function, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getFunctionOptions, "getFunctionOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(getBindingOptions, "getBindingOptions") + err = core.ValidateStruct(getFunctionOptions, "getFunctionOptions") if err != nil { return } pathParamsMap := map[string]string{ - "project_id": *getBindingOptions.ProjectID, - "id": *getBindingOptions.ID, + "project_id": *getFunctionOptions.ProjectID, + "name": *getFunctionOptions.Name, } builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = codeEngine.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/bindings/{id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/functions/{name}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range getBindingOptions.Headers { + for headerName, headerValue := range getFunctionOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "GetBinding") + sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "GetFunction") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -1944,7 +2093,7 @@ func (codeEngine *CodeEngineV2) GetBindingWithContext(ctx context.Context, getBi return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBinding) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalFunction) if err != nil { return } @@ -1954,41 +2103,41 @@ func (codeEngine *CodeEngineV2) GetBindingWithContext(ctx context.Context, getBi return } -// DeleteBinding : Delete a binding -// Delete a binding. -func (codeEngine *CodeEngineV2) DeleteBinding(deleteBindingOptions *DeleteBindingOptions) (response *core.DetailedResponse, err error) { - return codeEngine.DeleteBindingWithContext(context.Background(), deleteBindingOptions) +// DeleteFunction : Delete a function +// Delete a function. +func (codeEngine *CodeEngineV2) DeleteFunction(deleteFunctionOptions *DeleteFunctionOptions) (response *core.DetailedResponse, err error) { + return codeEngine.DeleteFunctionWithContext(context.Background(), deleteFunctionOptions) } -// DeleteBindingWithContext is an alternate form of the DeleteBinding method which supports a Context parameter -func (codeEngine *CodeEngineV2) DeleteBindingWithContext(ctx context.Context, deleteBindingOptions *DeleteBindingOptions) (response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(deleteBindingOptions, "deleteBindingOptions cannot be nil") +// DeleteFunctionWithContext is an alternate form of the DeleteFunction method which supports a Context parameter +func (codeEngine *CodeEngineV2) DeleteFunctionWithContext(ctx context.Context, deleteFunctionOptions *DeleteFunctionOptions) (response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(deleteFunctionOptions, "deleteFunctionOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(deleteBindingOptions, "deleteBindingOptions") + err = core.ValidateStruct(deleteFunctionOptions, "deleteFunctionOptions") if err != nil { return } pathParamsMap := map[string]string{ - "project_id": *deleteBindingOptions.ProjectID, - "id": *deleteBindingOptions.ID, + "project_id": *deleteFunctionOptions.ProjectID, + "name": *deleteFunctionOptions.Name, } builder := core.NewRequestBuilder(core.DELETE) builder = builder.WithContext(ctx) builder.EnableGzipCompression = codeEngine.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/bindings/{id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/functions/{name}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range deleteBindingOptions.Headers { + for headerName, headerValue := range deleteFunctionOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "DeleteBinding") + sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "DeleteFunction") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -2003,50 +2152,53 @@ func (codeEngine *CodeEngineV2) DeleteBindingWithContext(ctx context.Context, de return } -// ListBuilds : List builds -// List all builds in a project. -func (codeEngine *CodeEngineV2) ListBuilds(listBuildsOptions *ListBuildsOptions) (result *BuildList, response *core.DetailedResponse, err error) { - return codeEngine.ListBuildsWithContext(context.Background(), listBuildsOptions) +// UpdateFunction : Update a function +// Update the given function. +func (codeEngine *CodeEngineV2) UpdateFunction(updateFunctionOptions *UpdateFunctionOptions) (result *Function, response *core.DetailedResponse, err error) { + return codeEngine.UpdateFunctionWithContext(context.Background(), updateFunctionOptions) } -// ListBuildsWithContext is an alternate form of the ListBuilds method which supports a Context parameter -func (codeEngine *CodeEngineV2) ListBuildsWithContext(ctx context.Context, listBuildsOptions *ListBuildsOptions) (result *BuildList, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(listBuildsOptions, "listBuildsOptions cannot be nil") +// UpdateFunctionWithContext is an alternate form of the UpdateFunction method which supports a Context parameter +func (codeEngine *CodeEngineV2) UpdateFunctionWithContext(ctx context.Context, updateFunctionOptions *UpdateFunctionOptions) (result *Function, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(updateFunctionOptions, "updateFunctionOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(listBuildsOptions, "listBuildsOptions") + err = core.ValidateStruct(updateFunctionOptions, "updateFunctionOptions") if err != nil { return } pathParamsMap := map[string]string{ - "project_id": *listBuildsOptions.ProjectID, + "project_id": *updateFunctionOptions.ProjectID, + "name": *updateFunctionOptions.Name, } - builder := core.NewRequestBuilder(core.GET) + builder := core.NewRequestBuilder(core.PATCH) builder = builder.WithContext(ctx) builder.EnableGzipCompression = codeEngine.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/builds`, pathParamsMap) + _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/functions/{name}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range listBuildsOptions.Headers { + for headerName, headerValue := range updateFunctionOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "ListBuilds") + sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "UpdateFunction") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") - - if listBuildsOptions.Limit != nil { - builder.AddQuery("limit", fmt.Sprint(*listBuildsOptions.Limit)) + builder.AddHeader("Content-Type", "application/merge-patch+json") + if updateFunctionOptions.IfMatch != nil { + builder.AddHeader("If-Match", fmt.Sprint(*updateFunctionOptions.IfMatch)) } - if listBuildsOptions.Start != nil { - builder.AddQuery("start", fmt.Sprint(*listBuildsOptions.Start)) + + _, err = builder.SetBodyContentJSON(updateFunctionOptions.Function) + if err != nil { + return } request, err := builder.Build() @@ -2060,7 +2212,7 @@ func (codeEngine *CodeEngineV2) ListBuildsWithContext(ctx context.Context, listB return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBuildList) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalFunction) if err != nil { return } @@ -2070,82 +2222,123 @@ func (codeEngine *CodeEngineV2) ListBuildsWithContext(ctx context.Context, listB return } -// CreateBuild : Create a build -// Create a build. -func (codeEngine *CodeEngineV2) CreateBuild(createBuildOptions *CreateBuildOptions) (result *Build, response *core.DetailedResponse, err error) { - return codeEngine.CreateBuildWithContext(context.Background(), createBuildOptions) +// ListBindings : List bindings +// List all bindings in a project. +func (codeEngine *CodeEngineV2) ListBindings(listBindingsOptions *ListBindingsOptions) (result *BindingList, response *core.DetailedResponse, err error) { + return codeEngine.ListBindingsWithContext(context.Background(), listBindingsOptions) } -// CreateBuildWithContext is an alternate form of the CreateBuild method which supports a Context parameter -func (codeEngine *CodeEngineV2) CreateBuildWithContext(ctx context.Context, createBuildOptions *CreateBuildOptions) (result *Build, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(createBuildOptions, "createBuildOptions cannot be nil") +// ListBindingsWithContext is an alternate form of the ListBindings method which supports a Context parameter +func (codeEngine *CodeEngineV2) ListBindingsWithContext(ctx context.Context, listBindingsOptions *ListBindingsOptions) (result *BindingList, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(listBindingsOptions, "listBindingsOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(createBuildOptions, "createBuildOptions") + err = core.ValidateStruct(listBindingsOptions, "listBindingsOptions") if err != nil { return } pathParamsMap := map[string]string{ - "project_id": *createBuildOptions.ProjectID, + "project_id": *listBindingsOptions.ProjectID, } - builder := core.NewRequestBuilder(core.POST) + builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = codeEngine.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/builds`, pathParamsMap) + _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/bindings`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range createBuildOptions.Headers { + for headerName, headerValue := range listBindingsOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "CreateBuild") + sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "ListBindings") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") - builder.AddHeader("Content-Type", "application/json") - body := make(map[string]interface{}) - if createBuildOptions.Name != nil { - body["name"] = createBuildOptions.Name - } - if createBuildOptions.OutputImage != nil { - body["output_image"] = createBuildOptions.OutputImage - } - if createBuildOptions.OutputSecret != nil { - body["output_secret"] = createBuildOptions.OutputSecret - } - if createBuildOptions.StrategyType != nil { - body["strategy_type"] = createBuildOptions.StrategyType + if listBindingsOptions.Limit != nil { + builder.AddQuery("limit", fmt.Sprint(*listBindingsOptions.Limit)) } - if createBuildOptions.SourceContextDir != nil { - body["source_context_dir"] = createBuildOptions.SourceContextDir + if listBindingsOptions.Start != nil { + builder.AddQuery("start", fmt.Sprint(*listBindingsOptions.Start)) } - if createBuildOptions.SourceRevision != nil { - body["source_revision"] = createBuildOptions.SourceRevision + + request, err := builder.Build() + if err != nil { + return } - if createBuildOptions.SourceSecret != nil { - body["source_secret"] = createBuildOptions.SourceSecret + + var rawResponse map[string]json.RawMessage + response, err = codeEngine.Service.Request(request, &rawResponse) + if err != nil { + return } - if createBuildOptions.SourceType != nil { - body["source_type"] = createBuildOptions.SourceType + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBindingList) + if err != nil { + return + } + response.Result = result } - if createBuildOptions.SourceURL != nil { - body["source_url"] = createBuildOptions.SourceURL + + return +} + +// CreateBinding : Create a binding +// Create a binding. Creating a service binding with a Code Engine app will update the app, creating a new revision. For +// more information see the [documentaion](https://cloud.ibm.com/docs/codeengine?topic=codeengine-service-binding). +func (codeEngine *CodeEngineV2) CreateBinding(createBindingOptions *CreateBindingOptions) (result *Binding, response *core.DetailedResponse, err error) { + return codeEngine.CreateBindingWithContext(context.Background(), createBindingOptions) +} + +// CreateBindingWithContext is an alternate form of the CreateBinding method which supports a Context parameter +func (codeEngine *CodeEngineV2) CreateBindingWithContext(ctx context.Context, createBindingOptions *CreateBindingOptions) (result *Binding, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(createBindingOptions, "createBindingOptions cannot be nil") + if err != nil { + return } - if createBuildOptions.StrategySize != nil { - body["strategy_size"] = createBuildOptions.StrategySize + err = core.ValidateStruct(createBindingOptions, "createBindingOptions") + if err != nil { + return } - if createBuildOptions.StrategySpecFile != nil { - body["strategy_spec_file"] = createBuildOptions.StrategySpecFile + + pathParamsMap := map[string]string{ + "project_id": *createBindingOptions.ProjectID, } - if createBuildOptions.Timeout != nil { - body["timeout"] = createBuildOptions.Timeout + + builder := core.NewRequestBuilder(core.POST) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = codeEngine.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/bindings`, pathParamsMap) + if err != nil { + return + } + + for headerName, headerValue := range createBindingOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "CreateBinding") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") + builder.AddHeader("Content-Type", "application/json") + + body := make(map[string]interface{}) + if createBindingOptions.Component != nil { + body["component"] = createBindingOptions.Component + } + if createBindingOptions.Prefix != nil { + body["prefix"] = createBindingOptions.Prefix + } + if createBindingOptions.SecretName != nil { + body["secret_name"] = createBindingOptions.SecretName } _, err = builder.SetBodyContentJSON(body) if err != nil { @@ -2163,7 +2356,7 @@ func (codeEngine *CodeEngineV2) CreateBuildWithContext(ctx context.Context, crea return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBuild) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBinding) if err != nil { return } @@ -2173,41 +2366,41 @@ func (codeEngine *CodeEngineV2) CreateBuildWithContext(ctx context.Context, crea return } -// GetBuild : Get a build -// Display the details of a build. -func (codeEngine *CodeEngineV2) GetBuild(getBuildOptions *GetBuildOptions) (result *Build, response *core.DetailedResponse, err error) { - return codeEngine.GetBuildWithContext(context.Background(), getBuildOptions) +// GetBinding : Get a binding +// Display the details of a binding. +func (codeEngine *CodeEngineV2) GetBinding(getBindingOptions *GetBindingOptions) (result *Binding, response *core.DetailedResponse, err error) { + return codeEngine.GetBindingWithContext(context.Background(), getBindingOptions) } -// GetBuildWithContext is an alternate form of the GetBuild method which supports a Context parameter -func (codeEngine *CodeEngineV2) GetBuildWithContext(ctx context.Context, getBuildOptions *GetBuildOptions) (result *Build, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(getBuildOptions, "getBuildOptions cannot be nil") +// GetBindingWithContext is an alternate form of the GetBinding method which supports a Context parameter +func (codeEngine *CodeEngineV2) GetBindingWithContext(ctx context.Context, getBindingOptions *GetBindingOptions) (result *Binding, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getBindingOptions, "getBindingOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(getBuildOptions, "getBuildOptions") + err = core.ValidateStruct(getBindingOptions, "getBindingOptions") if err != nil { return } pathParamsMap := map[string]string{ - "project_id": *getBuildOptions.ProjectID, - "name": *getBuildOptions.Name, + "project_id": *getBindingOptions.ProjectID, + "id": *getBindingOptions.ID, } builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = codeEngine.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/builds/{name}`, pathParamsMap) + _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/bindings/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range getBuildOptions.Headers { + for headerName, headerValue := range getBindingOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "GetBuild") + sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "GetBinding") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -2224,7 +2417,7 @@ func (codeEngine *CodeEngineV2) GetBuildWithContext(ctx context.Context, getBuil return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBuild) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBinding) if err != nil { return } @@ -2234,41 +2427,41 @@ func (codeEngine *CodeEngineV2) GetBuildWithContext(ctx context.Context, getBuil return } -// DeleteBuild : Delete a build -// Delete a build. -func (codeEngine *CodeEngineV2) DeleteBuild(deleteBuildOptions *DeleteBuildOptions) (response *core.DetailedResponse, err error) { - return codeEngine.DeleteBuildWithContext(context.Background(), deleteBuildOptions) +// DeleteBinding : Delete a binding +// Delete a binding. +func (codeEngine *CodeEngineV2) DeleteBinding(deleteBindingOptions *DeleteBindingOptions) (response *core.DetailedResponse, err error) { + return codeEngine.DeleteBindingWithContext(context.Background(), deleteBindingOptions) } -// DeleteBuildWithContext is an alternate form of the DeleteBuild method which supports a Context parameter -func (codeEngine *CodeEngineV2) DeleteBuildWithContext(ctx context.Context, deleteBuildOptions *DeleteBuildOptions) (response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(deleteBuildOptions, "deleteBuildOptions cannot be nil") +// DeleteBindingWithContext is an alternate form of the DeleteBinding method which supports a Context parameter +func (codeEngine *CodeEngineV2) DeleteBindingWithContext(ctx context.Context, deleteBindingOptions *DeleteBindingOptions) (response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(deleteBindingOptions, "deleteBindingOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(deleteBuildOptions, "deleteBuildOptions") + err = core.ValidateStruct(deleteBindingOptions, "deleteBindingOptions") if err != nil { return } pathParamsMap := map[string]string{ - "project_id": *deleteBuildOptions.ProjectID, - "name": *deleteBuildOptions.Name, + "project_id": *deleteBindingOptions.ProjectID, + "id": *deleteBindingOptions.ID, } builder := core.NewRequestBuilder(core.DELETE) builder = builder.WithContext(ctx) builder.EnableGzipCompression = codeEngine.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/builds/{name}`, pathParamsMap) + _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/bindings/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range deleteBuildOptions.Headers { + for headerName, headerValue := range deleteBindingOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "DeleteBuild") + sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "DeleteBinding") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -2283,53 +2476,50 @@ func (codeEngine *CodeEngineV2) DeleteBuildWithContext(ctx context.Context, dele return } -// UpdateBuild : Update a build -// Update a build. -func (codeEngine *CodeEngineV2) UpdateBuild(updateBuildOptions *UpdateBuildOptions) (result *Build, response *core.DetailedResponse, err error) { - return codeEngine.UpdateBuildWithContext(context.Background(), updateBuildOptions) +// ListBuilds : List builds +// List all builds in a project. +func (codeEngine *CodeEngineV2) ListBuilds(listBuildsOptions *ListBuildsOptions) (result *BuildList, response *core.DetailedResponse, err error) { + return codeEngine.ListBuildsWithContext(context.Background(), listBuildsOptions) } -// UpdateBuildWithContext is an alternate form of the UpdateBuild method which supports a Context parameter -func (codeEngine *CodeEngineV2) UpdateBuildWithContext(ctx context.Context, updateBuildOptions *UpdateBuildOptions) (result *Build, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(updateBuildOptions, "updateBuildOptions cannot be nil") +// ListBuildsWithContext is an alternate form of the ListBuilds method which supports a Context parameter +func (codeEngine *CodeEngineV2) ListBuildsWithContext(ctx context.Context, listBuildsOptions *ListBuildsOptions) (result *BuildList, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(listBuildsOptions, "listBuildsOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(updateBuildOptions, "updateBuildOptions") + err = core.ValidateStruct(listBuildsOptions, "listBuildsOptions") if err != nil { return } pathParamsMap := map[string]string{ - "project_id": *updateBuildOptions.ProjectID, - "name": *updateBuildOptions.Name, + "project_id": *listBuildsOptions.ProjectID, } - builder := core.NewRequestBuilder(core.PATCH) + builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = codeEngine.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/builds/{name}`, pathParamsMap) + _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/builds`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range updateBuildOptions.Headers { + for headerName, headerValue := range listBuildsOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "UpdateBuild") + sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "ListBuilds") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") - builder.AddHeader("Content-Type", "application/merge-patch+json") - if updateBuildOptions.IfMatch != nil { - builder.AddHeader("If-Match", fmt.Sprint(*updateBuildOptions.IfMatch)) - } - _, err = builder.SetBodyContentJSON(updateBuildOptions.Build) - if err != nil { - return + if listBuildsOptions.Limit != nil { + builder.AddQuery("limit", fmt.Sprint(*listBuildsOptions.Limit)) + } + if listBuildsOptions.Start != nil { + builder.AddQuery("start", fmt.Sprint(*listBuildsOptions.Start)) } request, err := builder.Build() @@ -2343,7 +2533,7 @@ func (codeEngine *CodeEngineV2) UpdateBuildWithContext(ctx context.Context, upda return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBuild) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBuildList) if err != nil { return } @@ -2353,53 +2543,86 @@ func (codeEngine *CodeEngineV2) UpdateBuildWithContext(ctx context.Context, upda return } -// ListBuildRuns : List build runs -// List all build runs in a project. -func (codeEngine *CodeEngineV2) ListBuildRuns(listBuildRunsOptions *ListBuildRunsOptions) (result *BuildRunList, response *core.DetailedResponse, err error) { - return codeEngine.ListBuildRunsWithContext(context.Background(), listBuildRunsOptions) +// CreateBuild : Create a build +// Create a build. +func (codeEngine *CodeEngineV2) CreateBuild(createBuildOptions *CreateBuildOptions) (result *Build, response *core.DetailedResponse, err error) { + return codeEngine.CreateBuildWithContext(context.Background(), createBuildOptions) } -// ListBuildRunsWithContext is an alternate form of the ListBuildRuns method which supports a Context parameter -func (codeEngine *CodeEngineV2) ListBuildRunsWithContext(ctx context.Context, listBuildRunsOptions *ListBuildRunsOptions) (result *BuildRunList, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(listBuildRunsOptions, "listBuildRunsOptions cannot be nil") +// CreateBuildWithContext is an alternate form of the CreateBuild method which supports a Context parameter +func (codeEngine *CodeEngineV2) CreateBuildWithContext(ctx context.Context, createBuildOptions *CreateBuildOptions) (result *Build, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(createBuildOptions, "createBuildOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(listBuildRunsOptions, "listBuildRunsOptions") + err = core.ValidateStruct(createBuildOptions, "createBuildOptions") if err != nil { return } pathParamsMap := map[string]string{ - "project_id": *listBuildRunsOptions.ProjectID, + "project_id": *createBuildOptions.ProjectID, } - builder := core.NewRequestBuilder(core.GET) + builder := core.NewRequestBuilder(core.POST) builder = builder.WithContext(ctx) builder.EnableGzipCompression = codeEngine.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/build_runs`, pathParamsMap) + _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/builds`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range listBuildRunsOptions.Headers { + for headerName, headerValue := range createBuildOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "ListBuildRuns") + sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "CreateBuild") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") + builder.AddHeader("Content-Type", "application/json") - if listBuildRunsOptions.BuildName != nil { - builder.AddQuery("build_name", fmt.Sprint(*listBuildRunsOptions.BuildName)) + body := make(map[string]interface{}) + if createBuildOptions.Name != nil { + body["name"] = createBuildOptions.Name } - if listBuildRunsOptions.Limit != nil { - builder.AddQuery("limit", fmt.Sprint(*listBuildRunsOptions.Limit)) + if createBuildOptions.OutputImage != nil { + body["output_image"] = createBuildOptions.OutputImage } - if listBuildRunsOptions.Start != nil { - builder.AddQuery("start", fmt.Sprint(*listBuildRunsOptions.Start)) + if createBuildOptions.OutputSecret != nil { + body["output_secret"] = createBuildOptions.OutputSecret + } + if createBuildOptions.StrategyType != nil { + body["strategy_type"] = createBuildOptions.StrategyType + } + if createBuildOptions.SourceContextDir != nil { + body["source_context_dir"] = createBuildOptions.SourceContextDir + } + if createBuildOptions.SourceRevision != nil { + body["source_revision"] = createBuildOptions.SourceRevision + } + if createBuildOptions.SourceSecret != nil { + body["source_secret"] = createBuildOptions.SourceSecret + } + if createBuildOptions.SourceType != nil { + body["source_type"] = createBuildOptions.SourceType + } + if createBuildOptions.SourceURL != nil { + body["source_url"] = createBuildOptions.SourceURL + } + if createBuildOptions.StrategySize != nil { + body["strategy_size"] = createBuildOptions.StrategySize + } + if createBuildOptions.StrategySpecFile != nil { + body["strategy_spec_file"] = createBuildOptions.StrategySpecFile + } + if createBuildOptions.Timeout != nil { + body["timeout"] = createBuildOptions.Timeout + } + _, err = builder.SetBodyContentJSON(body) + if err != nil { + return } request, err := builder.Build() @@ -2413,7 +2636,7 @@ func (codeEngine *CodeEngineV2) ListBuildRunsWithContext(ctx context.Context, li return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBuildRunList) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBuild) if err != nil { return } @@ -2423,93 +2646,45 @@ func (codeEngine *CodeEngineV2) ListBuildRunsWithContext(ctx context.Context, li return } -// CreateBuildRun : Create a build run -// Create a build run. -func (codeEngine *CodeEngineV2) CreateBuildRun(createBuildRunOptions *CreateBuildRunOptions) (result *BuildRun, response *core.DetailedResponse, err error) { - return codeEngine.CreateBuildRunWithContext(context.Background(), createBuildRunOptions) +// GetBuild : Get a build +// Display the details of a build. +func (codeEngine *CodeEngineV2) GetBuild(getBuildOptions *GetBuildOptions) (result *Build, response *core.DetailedResponse, err error) { + return codeEngine.GetBuildWithContext(context.Background(), getBuildOptions) } -// CreateBuildRunWithContext is an alternate form of the CreateBuildRun method which supports a Context parameter -func (codeEngine *CodeEngineV2) CreateBuildRunWithContext(ctx context.Context, createBuildRunOptions *CreateBuildRunOptions) (result *BuildRun, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(createBuildRunOptions, "createBuildRunOptions cannot be nil") +// GetBuildWithContext is an alternate form of the GetBuild method which supports a Context parameter +func (codeEngine *CodeEngineV2) GetBuildWithContext(ctx context.Context, getBuildOptions *GetBuildOptions) (result *Build, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getBuildOptions, "getBuildOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(createBuildRunOptions, "createBuildRunOptions") + err = core.ValidateStruct(getBuildOptions, "getBuildOptions") if err != nil { return } pathParamsMap := map[string]string{ - "project_id": *createBuildRunOptions.ProjectID, + "project_id": *getBuildOptions.ProjectID, + "name": *getBuildOptions.Name, } - builder := core.NewRequestBuilder(core.POST) + builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = codeEngine.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/build_runs`, pathParamsMap) + _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/builds/{name}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range createBuildRunOptions.Headers { + for headerName, headerValue := range getBuildOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "CreateBuildRun") + sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "GetBuild") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") - builder.AddHeader("Content-Type", "application/json") - - body := make(map[string]interface{}) - if createBuildRunOptions.BuildName != nil { - body["build_name"] = createBuildRunOptions.BuildName - } - if createBuildRunOptions.Name != nil { - body["name"] = createBuildRunOptions.Name - } - if createBuildRunOptions.OutputImage != nil { - body["output_image"] = createBuildRunOptions.OutputImage - } - if createBuildRunOptions.OutputSecret != nil { - body["output_secret"] = createBuildRunOptions.OutputSecret - } - if createBuildRunOptions.ServiceAccount != nil { - body["service_account"] = createBuildRunOptions.ServiceAccount - } - if createBuildRunOptions.SourceContextDir != nil { - body["source_context_dir"] = createBuildRunOptions.SourceContextDir - } - if createBuildRunOptions.SourceRevision != nil { - body["source_revision"] = createBuildRunOptions.SourceRevision - } - if createBuildRunOptions.SourceSecret != nil { - body["source_secret"] = createBuildRunOptions.SourceSecret - } - if createBuildRunOptions.SourceType != nil { - body["source_type"] = createBuildRunOptions.SourceType - } - if createBuildRunOptions.SourceURL != nil { - body["source_url"] = createBuildRunOptions.SourceURL - } - if createBuildRunOptions.StrategySize != nil { - body["strategy_size"] = createBuildRunOptions.StrategySize - } - if createBuildRunOptions.StrategySpecFile != nil { - body["strategy_spec_file"] = createBuildRunOptions.StrategySpecFile - } - if createBuildRunOptions.StrategyType != nil { - body["strategy_type"] = createBuildRunOptions.StrategyType - } - if createBuildRunOptions.Timeout != nil { - body["timeout"] = createBuildRunOptions.Timeout - } - _, err = builder.SetBodyContentJSON(body) - if err != nil { - return - } request, err := builder.Build() if err != nil { @@ -2522,7 +2697,7 @@ func (codeEngine *CodeEngineV2) CreateBuildRunWithContext(ctx context.Context, c return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBuildRun) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBuild) if err != nil { return } @@ -2532,160 +2707,172 @@ func (codeEngine *CodeEngineV2) CreateBuildRunWithContext(ctx context.Context, c return } -// GetBuildRun : Get a build run -// Display the details of a build run. -func (codeEngine *CodeEngineV2) GetBuildRun(getBuildRunOptions *GetBuildRunOptions) (result *BuildRun, response *core.DetailedResponse, err error) { - return codeEngine.GetBuildRunWithContext(context.Background(), getBuildRunOptions) +// DeleteBuild : Delete a build +// Delete a build. +func (codeEngine *CodeEngineV2) DeleteBuild(deleteBuildOptions *DeleteBuildOptions) (response *core.DetailedResponse, err error) { + return codeEngine.DeleteBuildWithContext(context.Background(), deleteBuildOptions) } -// GetBuildRunWithContext is an alternate form of the GetBuildRun method which supports a Context parameter -func (codeEngine *CodeEngineV2) GetBuildRunWithContext(ctx context.Context, getBuildRunOptions *GetBuildRunOptions) (result *BuildRun, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(getBuildRunOptions, "getBuildRunOptions cannot be nil") +// DeleteBuildWithContext is an alternate form of the DeleteBuild method which supports a Context parameter +func (codeEngine *CodeEngineV2) DeleteBuildWithContext(ctx context.Context, deleteBuildOptions *DeleteBuildOptions) (response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(deleteBuildOptions, "deleteBuildOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(getBuildRunOptions, "getBuildRunOptions") + err = core.ValidateStruct(deleteBuildOptions, "deleteBuildOptions") if err != nil { return } pathParamsMap := map[string]string{ - "project_id": *getBuildRunOptions.ProjectID, - "name": *getBuildRunOptions.Name, + "project_id": *deleteBuildOptions.ProjectID, + "name": *deleteBuildOptions.Name, } - builder := core.NewRequestBuilder(core.GET) + builder := core.NewRequestBuilder(core.DELETE) builder = builder.WithContext(ctx) builder.EnableGzipCompression = codeEngine.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/build_runs/{name}`, pathParamsMap) + _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/builds/{name}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range getBuildRunOptions.Headers { + for headerName, headerValue := range deleteBuildOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "GetBuildRun") + sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "DeleteBuild") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } - builder.AddHeader("Accept", "application/json") request, err := builder.Build() if err != nil { return } - var rawResponse map[string]json.RawMessage - response, err = codeEngine.Service.Request(request, &rawResponse) - if err != nil { - return - } - if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBuildRun) - if err != nil { - return - } - response.Result = result - } + response, err = codeEngine.Service.Request(request, nil) return } -// DeleteBuildRun : Delete a build run -// Delete a build run. -func (codeEngine *CodeEngineV2) DeleteBuildRun(deleteBuildRunOptions *DeleteBuildRunOptions) (response *core.DetailedResponse, err error) { - return codeEngine.DeleteBuildRunWithContext(context.Background(), deleteBuildRunOptions) +// UpdateBuild : Update a build +// Update a build. +func (codeEngine *CodeEngineV2) UpdateBuild(updateBuildOptions *UpdateBuildOptions) (result *Build, response *core.DetailedResponse, err error) { + return codeEngine.UpdateBuildWithContext(context.Background(), updateBuildOptions) } -// DeleteBuildRunWithContext is an alternate form of the DeleteBuildRun method which supports a Context parameter -func (codeEngine *CodeEngineV2) DeleteBuildRunWithContext(ctx context.Context, deleteBuildRunOptions *DeleteBuildRunOptions) (response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(deleteBuildRunOptions, "deleteBuildRunOptions cannot be nil") +// UpdateBuildWithContext is an alternate form of the UpdateBuild method which supports a Context parameter +func (codeEngine *CodeEngineV2) UpdateBuildWithContext(ctx context.Context, updateBuildOptions *UpdateBuildOptions) (result *Build, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(updateBuildOptions, "updateBuildOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(deleteBuildRunOptions, "deleteBuildRunOptions") + err = core.ValidateStruct(updateBuildOptions, "updateBuildOptions") if err != nil { return } pathParamsMap := map[string]string{ - "project_id": *deleteBuildRunOptions.ProjectID, - "name": *deleteBuildRunOptions.Name, + "project_id": *updateBuildOptions.ProjectID, + "name": *updateBuildOptions.Name, } - builder := core.NewRequestBuilder(core.DELETE) + builder := core.NewRequestBuilder(core.PATCH) builder = builder.WithContext(ctx) builder.EnableGzipCompression = codeEngine.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/build_runs/{name}`, pathParamsMap) + _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/builds/{name}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range deleteBuildRunOptions.Headers { + for headerName, headerValue := range updateBuildOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "DeleteBuildRun") + sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "UpdateBuild") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } + builder.AddHeader("Accept", "application/json") + builder.AddHeader("Content-Type", "application/merge-patch+json") + if updateBuildOptions.IfMatch != nil { + builder.AddHeader("If-Match", fmt.Sprint(*updateBuildOptions.IfMatch)) + } + + _, err = builder.SetBodyContentJSON(updateBuildOptions.Build) + if err != nil { + return + } request, err := builder.Build() if err != nil { return } - response, err = codeEngine.Service.Request(request, nil) + var rawResponse map[string]json.RawMessage + response, err = codeEngine.Service.Request(request, &rawResponse) + if err != nil { + return + } + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBuild) + if err != nil { + return + } + response.Result = result + } return } -// ListConfigMaps : List config maps -// List all config maps in a project. -func (codeEngine *CodeEngineV2) ListConfigMaps(listConfigMapsOptions *ListConfigMapsOptions) (result *ConfigMapList, response *core.DetailedResponse, err error) { - return codeEngine.ListConfigMapsWithContext(context.Background(), listConfigMapsOptions) +// ListBuildRuns : List build runs +// List all build runs in a project. +func (codeEngine *CodeEngineV2) ListBuildRuns(listBuildRunsOptions *ListBuildRunsOptions) (result *BuildRunList, response *core.DetailedResponse, err error) { + return codeEngine.ListBuildRunsWithContext(context.Background(), listBuildRunsOptions) } -// ListConfigMapsWithContext is an alternate form of the ListConfigMaps method which supports a Context parameter -func (codeEngine *CodeEngineV2) ListConfigMapsWithContext(ctx context.Context, listConfigMapsOptions *ListConfigMapsOptions) (result *ConfigMapList, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(listConfigMapsOptions, "listConfigMapsOptions cannot be nil") +// ListBuildRunsWithContext is an alternate form of the ListBuildRuns method which supports a Context parameter +func (codeEngine *CodeEngineV2) ListBuildRunsWithContext(ctx context.Context, listBuildRunsOptions *ListBuildRunsOptions) (result *BuildRunList, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(listBuildRunsOptions, "listBuildRunsOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(listConfigMapsOptions, "listConfigMapsOptions") + err = core.ValidateStruct(listBuildRunsOptions, "listBuildRunsOptions") if err != nil { return } pathParamsMap := map[string]string{ - "project_id": *listConfigMapsOptions.ProjectID, + "project_id": *listBuildRunsOptions.ProjectID, } builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = codeEngine.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/config_maps`, pathParamsMap) + _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/build_runs`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range listConfigMapsOptions.Headers { + for headerName, headerValue := range listBuildRunsOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "ListConfigMaps") + sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "ListBuildRuns") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") - if listConfigMapsOptions.Limit != nil { - builder.AddQuery("limit", fmt.Sprint(*listConfigMapsOptions.Limit)) + if listBuildRunsOptions.BuildName != nil { + builder.AddQuery("build_name", fmt.Sprint(*listBuildRunsOptions.BuildName)) } - if listConfigMapsOptions.Start != nil { - builder.AddQuery("start", fmt.Sprint(*listConfigMapsOptions.Start)) + if listBuildRunsOptions.Limit != nil { + builder.AddQuery("limit", fmt.Sprint(*listBuildRunsOptions.Limit)) + } + if listBuildRunsOptions.Start != nil { + builder.AddQuery("start", fmt.Sprint(*listBuildRunsOptions.Start)) } request, err := builder.Build() @@ -2699,7 +2886,7 @@ func (codeEngine *CodeEngineV2) ListConfigMapsWithContext(ctx context.Context, l return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalConfigMapList) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBuildRunList) if err != nil { return } @@ -2709,40 +2896,40 @@ func (codeEngine *CodeEngineV2) ListConfigMapsWithContext(ctx context.Context, l return } -// CreateConfigMap : Create a config map -// Create a config map. -func (codeEngine *CodeEngineV2) CreateConfigMap(createConfigMapOptions *CreateConfigMapOptions) (result *ConfigMap, response *core.DetailedResponse, err error) { - return codeEngine.CreateConfigMapWithContext(context.Background(), createConfigMapOptions) +// CreateBuildRun : Create a build run +// Create a build run. +func (codeEngine *CodeEngineV2) CreateBuildRun(createBuildRunOptions *CreateBuildRunOptions) (result *BuildRun, response *core.DetailedResponse, err error) { + return codeEngine.CreateBuildRunWithContext(context.Background(), createBuildRunOptions) } -// CreateConfigMapWithContext is an alternate form of the CreateConfigMap method which supports a Context parameter -func (codeEngine *CodeEngineV2) CreateConfigMapWithContext(ctx context.Context, createConfigMapOptions *CreateConfigMapOptions) (result *ConfigMap, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(createConfigMapOptions, "createConfigMapOptions cannot be nil") +// CreateBuildRunWithContext is an alternate form of the CreateBuildRun method which supports a Context parameter +func (codeEngine *CodeEngineV2) CreateBuildRunWithContext(ctx context.Context, createBuildRunOptions *CreateBuildRunOptions) (result *BuildRun, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(createBuildRunOptions, "createBuildRunOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(createConfigMapOptions, "createConfigMapOptions") + err = core.ValidateStruct(createBuildRunOptions, "createBuildRunOptions") if err != nil { return } pathParamsMap := map[string]string{ - "project_id": *createConfigMapOptions.ProjectID, + "project_id": *createBuildRunOptions.ProjectID, } builder := core.NewRequestBuilder(core.POST) builder = builder.WithContext(ctx) builder.EnableGzipCompression = codeEngine.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/config_maps`, pathParamsMap) + _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/build_runs`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range createConfigMapOptions.Headers { + for headerName, headerValue := range createBuildRunOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "CreateConfigMap") + sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "CreateBuildRun") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -2750,11 +2937,47 @@ func (codeEngine *CodeEngineV2) CreateConfigMapWithContext(ctx context.Context, builder.AddHeader("Content-Type", "application/json") body := make(map[string]interface{}) - if createConfigMapOptions.Name != nil { - body["name"] = createConfigMapOptions.Name + if createBuildRunOptions.BuildName != nil { + body["build_name"] = createBuildRunOptions.BuildName } - if createConfigMapOptions.Data != nil { - body["data"] = createConfigMapOptions.Data + if createBuildRunOptions.Name != nil { + body["name"] = createBuildRunOptions.Name + } + if createBuildRunOptions.OutputImage != nil { + body["output_image"] = createBuildRunOptions.OutputImage + } + if createBuildRunOptions.OutputSecret != nil { + body["output_secret"] = createBuildRunOptions.OutputSecret + } + if createBuildRunOptions.ServiceAccount != nil { + body["service_account"] = createBuildRunOptions.ServiceAccount + } + if createBuildRunOptions.SourceContextDir != nil { + body["source_context_dir"] = createBuildRunOptions.SourceContextDir + } + if createBuildRunOptions.SourceRevision != nil { + body["source_revision"] = createBuildRunOptions.SourceRevision + } + if createBuildRunOptions.SourceSecret != nil { + body["source_secret"] = createBuildRunOptions.SourceSecret + } + if createBuildRunOptions.SourceType != nil { + body["source_type"] = createBuildRunOptions.SourceType + } + if createBuildRunOptions.SourceURL != nil { + body["source_url"] = createBuildRunOptions.SourceURL + } + if createBuildRunOptions.StrategySize != nil { + body["strategy_size"] = createBuildRunOptions.StrategySize + } + if createBuildRunOptions.StrategySpecFile != nil { + body["strategy_spec_file"] = createBuildRunOptions.StrategySpecFile + } + if createBuildRunOptions.StrategyType != nil { + body["strategy_type"] = createBuildRunOptions.StrategyType + } + if createBuildRunOptions.Timeout != nil { + body["timeout"] = createBuildRunOptions.Timeout } _, err = builder.SetBodyContentJSON(body) if err != nil { @@ -2772,7 +2995,7 @@ func (codeEngine *CodeEngineV2) CreateConfigMapWithContext(ctx context.Context, return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalConfigMap) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBuildRun) if err != nil { return } @@ -2782,119 +3005,45 @@ func (codeEngine *CodeEngineV2) CreateConfigMapWithContext(ctx context.Context, return } -// GetConfigMap : Get a config map -// Display the details of a config map. -func (codeEngine *CodeEngineV2) GetConfigMap(getConfigMapOptions *GetConfigMapOptions) (result *ConfigMap, response *core.DetailedResponse, err error) { - return codeEngine.GetConfigMapWithContext(context.Background(), getConfigMapOptions) -} - -// GetConfigMapWithContext is an alternate form of the GetConfigMap method which supports a Context parameter -func (codeEngine *CodeEngineV2) GetConfigMapWithContext(ctx context.Context, getConfigMapOptions *GetConfigMapOptions) (result *ConfigMap, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(getConfigMapOptions, "getConfigMapOptions cannot be nil") - if err != nil { - return - } - err = core.ValidateStruct(getConfigMapOptions, "getConfigMapOptions") - if err != nil { - return - } - - pathParamsMap := map[string]string{ - "project_id": *getConfigMapOptions.ProjectID, - "name": *getConfigMapOptions.Name, - } - - builder := core.NewRequestBuilder(core.GET) - builder = builder.WithContext(ctx) - builder.EnableGzipCompression = codeEngine.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/config_maps/{name}`, pathParamsMap) - if err != nil { - return - } - - for headerName, headerValue := range getConfigMapOptions.Headers { - builder.AddHeader(headerName, headerValue) - } - - sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "GetConfigMap") - for headerName, headerValue := range sdkHeaders { - builder.AddHeader(headerName, headerValue) - } - builder.AddHeader("Accept", "application/json") - - request, err := builder.Build() - if err != nil { - return - } - - var rawResponse map[string]json.RawMessage - response, err = codeEngine.Service.Request(request, &rawResponse) - if err != nil { - return - } - if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalConfigMap) - if err != nil { - return - } - response.Result = result - } - - return -} - -// ReplaceConfigMap : Update a config map -// Update a config map. -func (codeEngine *CodeEngineV2) ReplaceConfigMap(replaceConfigMapOptions *ReplaceConfigMapOptions) (result *ConfigMap, response *core.DetailedResponse, err error) { - return codeEngine.ReplaceConfigMapWithContext(context.Background(), replaceConfigMapOptions) +// GetBuildRun : Get a build run +// Display the details of a build run. +func (codeEngine *CodeEngineV2) GetBuildRun(getBuildRunOptions *GetBuildRunOptions) (result *BuildRun, response *core.DetailedResponse, err error) { + return codeEngine.GetBuildRunWithContext(context.Background(), getBuildRunOptions) } -// ReplaceConfigMapWithContext is an alternate form of the ReplaceConfigMap method which supports a Context parameter -func (codeEngine *CodeEngineV2) ReplaceConfigMapWithContext(ctx context.Context, replaceConfigMapOptions *ReplaceConfigMapOptions) (result *ConfigMap, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(replaceConfigMapOptions, "replaceConfigMapOptions cannot be nil") +// GetBuildRunWithContext is an alternate form of the GetBuildRun method which supports a Context parameter +func (codeEngine *CodeEngineV2) GetBuildRunWithContext(ctx context.Context, getBuildRunOptions *GetBuildRunOptions) (result *BuildRun, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getBuildRunOptions, "getBuildRunOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(replaceConfigMapOptions, "replaceConfigMapOptions") + err = core.ValidateStruct(getBuildRunOptions, "getBuildRunOptions") if err != nil { return } pathParamsMap := map[string]string{ - "project_id": *replaceConfigMapOptions.ProjectID, - "name": *replaceConfigMapOptions.Name, + "project_id": *getBuildRunOptions.ProjectID, + "name": *getBuildRunOptions.Name, } - builder := core.NewRequestBuilder(core.PUT) + builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = codeEngine.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/config_maps/{name}`, pathParamsMap) + _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/build_runs/{name}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range replaceConfigMapOptions.Headers { + for headerName, headerValue := range getBuildRunOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "ReplaceConfigMap") + sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "GetBuildRun") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") - builder.AddHeader("Content-Type", "application/json") - if replaceConfigMapOptions.IfMatch != nil { - builder.AddHeader("If-Match", fmt.Sprint(*replaceConfigMapOptions.IfMatch)) - } - - body := make(map[string]interface{}) - if replaceConfigMapOptions.Data != nil { - body["data"] = replaceConfigMapOptions.Data - } - _, err = builder.SetBodyContentJSON(body) - if err != nil { - return - } request, err := builder.Build() if err != nil { @@ -2907,7 +3056,7 @@ func (codeEngine *CodeEngineV2) ReplaceConfigMapWithContext(ctx context.Context, return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalConfigMap) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBuildRun) if err != nil { return } @@ -2917,41 +3066,41 @@ func (codeEngine *CodeEngineV2) ReplaceConfigMapWithContext(ctx context.Context, return } -// DeleteConfigMap : Delete a config map -// Delete a config map. -func (codeEngine *CodeEngineV2) DeleteConfigMap(deleteConfigMapOptions *DeleteConfigMapOptions) (response *core.DetailedResponse, err error) { - return codeEngine.DeleteConfigMapWithContext(context.Background(), deleteConfigMapOptions) +// DeleteBuildRun : Delete a build run +// Delete a build run. +func (codeEngine *CodeEngineV2) DeleteBuildRun(deleteBuildRunOptions *DeleteBuildRunOptions) (response *core.DetailedResponse, err error) { + return codeEngine.DeleteBuildRunWithContext(context.Background(), deleteBuildRunOptions) } -// DeleteConfigMapWithContext is an alternate form of the DeleteConfigMap method which supports a Context parameter -func (codeEngine *CodeEngineV2) DeleteConfigMapWithContext(ctx context.Context, deleteConfigMapOptions *DeleteConfigMapOptions) (response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(deleteConfigMapOptions, "deleteConfigMapOptions cannot be nil") +// DeleteBuildRunWithContext is an alternate form of the DeleteBuildRun method which supports a Context parameter +func (codeEngine *CodeEngineV2) DeleteBuildRunWithContext(ctx context.Context, deleteBuildRunOptions *DeleteBuildRunOptions) (response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(deleteBuildRunOptions, "deleteBuildRunOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(deleteConfigMapOptions, "deleteConfigMapOptions") + err = core.ValidateStruct(deleteBuildRunOptions, "deleteBuildRunOptions") if err != nil { return } pathParamsMap := map[string]string{ - "project_id": *deleteConfigMapOptions.ProjectID, - "name": *deleteConfigMapOptions.Name, + "project_id": *deleteBuildRunOptions.ProjectID, + "name": *deleteBuildRunOptions.Name, } builder := core.NewRequestBuilder(core.DELETE) builder = builder.WithContext(ctx) builder.EnableGzipCompression = codeEngine.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/config_maps/{name}`, pathParamsMap) + _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/build_runs/{name}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range deleteConfigMapOptions.Headers { + for headerName, headerValue := range deleteBuildRunOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "DeleteConfigMap") + sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "DeleteBuildRun") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -2966,50 +3115,50 @@ func (codeEngine *CodeEngineV2) DeleteConfigMapWithContext(ctx context.Context, return } -// ListSecrets : List secrets -// List all secrets in a project. -func (codeEngine *CodeEngineV2) ListSecrets(listSecretsOptions *ListSecretsOptions) (result *SecretList, response *core.DetailedResponse, err error) { - return codeEngine.ListSecretsWithContext(context.Background(), listSecretsOptions) +// ListDomainMappings : List domain mappings +// List all domain mappings in a project. +func (codeEngine *CodeEngineV2) ListDomainMappings(listDomainMappingsOptions *ListDomainMappingsOptions) (result *DomainMappingList, response *core.DetailedResponse, err error) { + return codeEngine.ListDomainMappingsWithContext(context.Background(), listDomainMappingsOptions) } -// ListSecretsWithContext is an alternate form of the ListSecrets method which supports a Context parameter -func (codeEngine *CodeEngineV2) ListSecretsWithContext(ctx context.Context, listSecretsOptions *ListSecretsOptions) (result *SecretList, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(listSecretsOptions, "listSecretsOptions cannot be nil") +// ListDomainMappingsWithContext is an alternate form of the ListDomainMappings method which supports a Context parameter +func (codeEngine *CodeEngineV2) ListDomainMappingsWithContext(ctx context.Context, listDomainMappingsOptions *ListDomainMappingsOptions) (result *DomainMappingList, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(listDomainMappingsOptions, "listDomainMappingsOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(listSecretsOptions, "listSecretsOptions") + err = core.ValidateStruct(listDomainMappingsOptions, "listDomainMappingsOptions") if err != nil { return } pathParamsMap := map[string]string{ - "project_id": *listSecretsOptions.ProjectID, + "project_id": *listDomainMappingsOptions.ProjectID, } builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = codeEngine.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/secrets`, pathParamsMap) + _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/domain_mappings`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range listSecretsOptions.Headers { + for headerName, headerValue := range listDomainMappingsOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "ListSecrets") + sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "ListDomainMappings") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") - if listSecretsOptions.Limit != nil { - builder.AddQuery("limit", fmt.Sprint(*listSecretsOptions.Limit)) + if listDomainMappingsOptions.Limit != nil { + builder.AddQuery("limit", fmt.Sprint(*listDomainMappingsOptions.Limit)) } - if listSecretsOptions.Start != nil { - builder.AddQuery("start", fmt.Sprint(*listSecretsOptions.Start)) + if listDomainMappingsOptions.Start != nil { + builder.AddQuery("start", fmt.Sprint(*listDomainMappingsOptions.Start)) } request, err := builder.Build() @@ -3023,7 +3172,7 @@ func (codeEngine *CodeEngineV2) ListSecretsWithContext(ctx context.Context, list return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalSecretList) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalDomainMappingList) if err != nil { return } @@ -3033,40 +3182,40 @@ func (codeEngine *CodeEngineV2) ListSecretsWithContext(ctx context.Context, list return } -// CreateSecret : Create a secret -// Create a secret. -func (codeEngine *CodeEngineV2) CreateSecret(createSecretOptions *CreateSecretOptions) (result *Secret, response *core.DetailedResponse, err error) { - return codeEngine.CreateSecretWithContext(context.Background(), createSecretOptions) +// CreateDomainMapping : Create a domain mapping +// Create a domain mapping. +func (codeEngine *CodeEngineV2) CreateDomainMapping(createDomainMappingOptions *CreateDomainMappingOptions) (result *DomainMapping, response *core.DetailedResponse, err error) { + return codeEngine.CreateDomainMappingWithContext(context.Background(), createDomainMappingOptions) } -// CreateSecretWithContext is an alternate form of the CreateSecret method which supports a Context parameter -func (codeEngine *CodeEngineV2) CreateSecretWithContext(ctx context.Context, createSecretOptions *CreateSecretOptions) (result *Secret, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(createSecretOptions, "createSecretOptions cannot be nil") +// CreateDomainMappingWithContext is an alternate form of the CreateDomainMapping method which supports a Context parameter +func (codeEngine *CodeEngineV2) CreateDomainMappingWithContext(ctx context.Context, createDomainMappingOptions *CreateDomainMappingOptions) (result *DomainMapping, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(createDomainMappingOptions, "createDomainMappingOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(createSecretOptions, "createSecretOptions") + err = core.ValidateStruct(createDomainMappingOptions, "createDomainMappingOptions") if err != nil { return } pathParamsMap := map[string]string{ - "project_id": *createSecretOptions.ProjectID, + "project_id": *createDomainMappingOptions.ProjectID, } builder := core.NewRequestBuilder(core.POST) builder = builder.WithContext(ctx) builder.EnableGzipCompression = codeEngine.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/secrets`, pathParamsMap) + _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/domain_mappings`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range createSecretOptions.Headers { + for headerName, headerValue := range createDomainMappingOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "CreateSecret") + sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "CreateDomainMapping") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -3074,20 +3223,14 @@ func (codeEngine *CodeEngineV2) CreateSecretWithContext(ctx context.Context, cre builder.AddHeader("Content-Type", "application/json") body := make(map[string]interface{}) - if createSecretOptions.Format != nil { - body["format"] = createSecretOptions.Format - } - if createSecretOptions.Name != nil { - body["name"] = createSecretOptions.Name - } - if createSecretOptions.Data != nil { - body["data"] = createSecretOptions.Data + if createDomainMappingOptions.Component != nil { + body["component"] = createDomainMappingOptions.Component } - if createSecretOptions.ServiceAccess != nil { - body["service_access"] = createSecretOptions.ServiceAccess + if createDomainMappingOptions.Name != nil { + body["name"] = createDomainMappingOptions.Name } - if createSecretOptions.ServiceOperator != nil { - body["service_operator"] = createSecretOptions.ServiceOperator + if createDomainMappingOptions.TlsSecret != nil { + body["tls_secret"] = createDomainMappingOptions.TlsSecret } _, err = builder.SetBodyContentJSON(body) if err != nil { @@ -3105,7 +3248,7 @@ func (codeEngine *CodeEngineV2) CreateSecretWithContext(ctx context.Context, cre return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalSecret) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalDomainMapping) if err != nil { return } @@ -3115,41 +3258,41 @@ func (codeEngine *CodeEngineV2) CreateSecretWithContext(ctx context.Context, cre return } -// GetSecret : Get a secret -// Get a secret. -func (codeEngine *CodeEngineV2) GetSecret(getSecretOptions *GetSecretOptions) (result *Secret, response *core.DetailedResponse, err error) { - return codeEngine.GetSecretWithContext(context.Background(), getSecretOptions) +// GetDomainMapping : Get a domain mapping +// Get domain mapping. +func (codeEngine *CodeEngineV2) GetDomainMapping(getDomainMappingOptions *GetDomainMappingOptions) (result *DomainMapping, response *core.DetailedResponse, err error) { + return codeEngine.GetDomainMappingWithContext(context.Background(), getDomainMappingOptions) } -// GetSecretWithContext is an alternate form of the GetSecret method which supports a Context parameter -func (codeEngine *CodeEngineV2) GetSecretWithContext(ctx context.Context, getSecretOptions *GetSecretOptions) (result *Secret, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(getSecretOptions, "getSecretOptions cannot be nil") +// GetDomainMappingWithContext is an alternate form of the GetDomainMapping method which supports a Context parameter +func (codeEngine *CodeEngineV2) GetDomainMappingWithContext(ctx context.Context, getDomainMappingOptions *GetDomainMappingOptions) (result *DomainMapping, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getDomainMappingOptions, "getDomainMappingOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(getSecretOptions, "getSecretOptions") + err = core.ValidateStruct(getDomainMappingOptions, "getDomainMappingOptions") if err != nil { return } pathParamsMap := map[string]string{ - "project_id": *getSecretOptions.ProjectID, - "name": *getSecretOptions.Name, + "project_id": *getDomainMappingOptions.ProjectID, + "name": *getDomainMappingOptions.Name, } builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = codeEngine.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/secrets/{name}`, pathParamsMap) + _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/domain_mappings/{name}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range getSecretOptions.Headers { + for headerName, headerValue := range getDomainMappingOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "GetSecret") + sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "GetDomainMapping") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -3166,7 +3309,7 @@ func (codeEngine *CodeEngineV2) GetSecretWithContext(ctx context.Context, getSec return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalSecret) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalDomainMapping) if err != nil { return } @@ -3176,176 +3319,169 @@ func (codeEngine *CodeEngineV2) GetSecretWithContext(ctx context.Context, getSec return } -// ReplaceSecret : Update a secret -// Update a secret. -func (codeEngine *CodeEngineV2) ReplaceSecret(replaceSecretOptions *ReplaceSecretOptions) (result *Secret, response *core.DetailedResponse, err error) { - return codeEngine.ReplaceSecretWithContext(context.Background(), replaceSecretOptions) +// DeleteDomainMapping : Delete a domain mapping +// Delete a domain mapping. +func (codeEngine *CodeEngineV2) DeleteDomainMapping(deleteDomainMappingOptions *DeleteDomainMappingOptions) (response *core.DetailedResponse, err error) { + return codeEngine.DeleteDomainMappingWithContext(context.Background(), deleteDomainMappingOptions) } -// ReplaceSecretWithContext is an alternate form of the ReplaceSecret method which supports a Context parameter -func (codeEngine *CodeEngineV2) ReplaceSecretWithContext(ctx context.Context, replaceSecretOptions *ReplaceSecretOptions) (result *Secret, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(replaceSecretOptions, "replaceSecretOptions cannot be nil") +// DeleteDomainMappingWithContext is an alternate form of the DeleteDomainMapping method which supports a Context parameter +func (codeEngine *CodeEngineV2) DeleteDomainMappingWithContext(ctx context.Context, deleteDomainMappingOptions *DeleteDomainMappingOptions) (response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(deleteDomainMappingOptions, "deleteDomainMappingOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(replaceSecretOptions, "replaceSecretOptions") + err = core.ValidateStruct(deleteDomainMappingOptions, "deleteDomainMappingOptions") if err != nil { return } pathParamsMap := map[string]string{ - "project_id": *replaceSecretOptions.ProjectID, - "name": *replaceSecretOptions.Name, + "project_id": *deleteDomainMappingOptions.ProjectID, + "name": *deleteDomainMappingOptions.Name, } - builder := core.NewRequestBuilder(core.PUT) + builder := core.NewRequestBuilder(core.DELETE) builder = builder.WithContext(ctx) builder.EnableGzipCompression = codeEngine.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/secrets/{name}`, pathParamsMap) + _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/domain_mappings/{name}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range replaceSecretOptions.Headers { + for headerName, headerValue := range deleteDomainMappingOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "ReplaceSecret") + sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "DeleteDomainMapping") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } - builder.AddHeader("Accept", "application/json") - builder.AddHeader("Content-Type", "application/json") - if replaceSecretOptions.IfMatch != nil { - builder.AddHeader("If-Match", fmt.Sprint(*replaceSecretOptions.IfMatch)) - } - - body := make(map[string]interface{}) - if replaceSecretOptions.Format != nil { - body["format"] = replaceSecretOptions.Format - } - if replaceSecretOptions.Data != nil { - body["data"] = replaceSecretOptions.Data - } - _, err = builder.SetBodyContentJSON(body) - if err != nil { - return - } request, err := builder.Build() if err != nil { return } - var rawResponse map[string]json.RawMessage - response, err = codeEngine.Service.Request(request, &rawResponse) - if err != nil { - return - } - if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalSecret) - if err != nil { - return - } - response.Result = result - } + response, err = codeEngine.Service.Request(request, nil) return } -// DeleteSecret : Delete a secret -// Delete a secret. -func (codeEngine *CodeEngineV2) DeleteSecret(deleteSecretOptions *DeleteSecretOptions) (response *core.DetailedResponse, err error) { - return codeEngine.DeleteSecretWithContext(context.Background(), deleteSecretOptions) +// UpdateDomainMapping : Update a domain mapping +// Update a domain mapping. +func (codeEngine *CodeEngineV2) UpdateDomainMapping(updateDomainMappingOptions *UpdateDomainMappingOptions) (result *DomainMapping, response *core.DetailedResponse, err error) { + return codeEngine.UpdateDomainMappingWithContext(context.Background(), updateDomainMappingOptions) } -// DeleteSecretWithContext is an alternate form of the DeleteSecret method which supports a Context parameter -func (codeEngine *CodeEngineV2) DeleteSecretWithContext(ctx context.Context, deleteSecretOptions *DeleteSecretOptions) (response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(deleteSecretOptions, "deleteSecretOptions cannot be nil") +// UpdateDomainMappingWithContext is an alternate form of the UpdateDomainMapping method which supports a Context parameter +func (codeEngine *CodeEngineV2) UpdateDomainMappingWithContext(ctx context.Context, updateDomainMappingOptions *UpdateDomainMappingOptions) (result *DomainMapping, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(updateDomainMappingOptions, "updateDomainMappingOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(deleteSecretOptions, "deleteSecretOptions") + err = core.ValidateStruct(updateDomainMappingOptions, "updateDomainMappingOptions") if err != nil { return } pathParamsMap := map[string]string{ - "project_id": *deleteSecretOptions.ProjectID, - "name": *deleteSecretOptions.Name, + "project_id": *updateDomainMappingOptions.ProjectID, + "name": *updateDomainMappingOptions.Name, } - builder := core.NewRequestBuilder(core.DELETE) + builder := core.NewRequestBuilder(core.PATCH) builder = builder.WithContext(ctx) builder.EnableGzipCompression = codeEngine.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/secrets/{name}`, pathParamsMap) + _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/domain_mappings/{name}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range deleteSecretOptions.Headers { + for headerName, headerValue := range updateDomainMappingOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "DeleteSecret") + sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "UpdateDomainMapping") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } + builder.AddHeader("Accept", "application/json") + builder.AddHeader("Content-Type", "application/merge-patch+json") + if updateDomainMappingOptions.IfMatch != nil { + builder.AddHeader("If-Match", fmt.Sprint(*updateDomainMappingOptions.IfMatch)) + } + + _, err = builder.SetBodyContentJSON(updateDomainMappingOptions.DomainMapping) + if err != nil { + return + } request, err := builder.Build() if err != nil { return } - response, err = codeEngine.Service.Request(request, nil) + var rawResponse map[string]json.RawMessage + response, err = codeEngine.Service.Request(request, &rawResponse) + if err != nil { + return + } + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalDomainMapping) + if err != nil { + return + } + response.Result = result + } return } -// ListDomainMappings : List domain mappings -// List all domain mappings in a project. -func (codeEngine *CodeEngineV2) ListDomainMappings(listDomainMappingsOptions *ListDomainMappingsOptions) (result *DomainMappingList, response *core.DetailedResponse, err error) { - return codeEngine.ListDomainMappingsWithContext(context.Background(), listDomainMappingsOptions) +// ListConfigMaps : List config maps +// List all config maps in a project. +func (codeEngine *CodeEngineV2) ListConfigMaps(listConfigMapsOptions *ListConfigMapsOptions) (result *ConfigMapList, response *core.DetailedResponse, err error) { + return codeEngine.ListConfigMapsWithContext(context.Background(), listConfigMapsOptions) } -// ListDomainMappingsWithContext is an alternate form of the ListDomainMappings method which supports a Context parameter -func (codeEngine *CodeEngineV2) ListDomainMappingsWithContext(ctx context.Context, listDomainMappingsOptions *ListDomainMappingsOptions) (result *DomainMappingList, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(listDomainMappingsOptions, "listDomainMappingsOptions cannot be nil") +// ListConfigMapsWithContext is an alternate form of the ListConfigMaps method which supports a Context parameter +func (codeEngine *CodeEngineV2) ListConfigMapsWithContext(ctx context.Context, listConfigMapsOptions *ListConfigMapsOptions) (result *ConfigMapList, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(listConfigMapsOptions, "listConfigMapsOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(listDomainMappingsOptions, "listDomainMappingsOptions") + err = core.ValidateStruct(listConfigMapsOptions, "listConfigMapsOptions") if err != nil { return } pathParamsMap := map[string]string{ - "project_id": *listDomainMappingsOptions.ProjectID, + "project_id": *listConfigMapsOptions.ProjectID, } builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = codeEngine.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/domain_mappings`, pathParamsMap) + _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/config_maps`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range listDomainMappingsOptions.Headers { + for headerName, headerValue := range listConfigMapsOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "ListDomainMappings") + sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "ListConfigMaps") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") - if listDomainMappingsOptions.Limit != nil { - builder.AddQuery("limit", fmt.Sprint(*listDomainMappingsOptions.Limit)) + if listConfigMapsOptions.Limit != nil { + builder.AddQuery("limit", fmt.Sprint(*listConfigMapsOptions.Limit)) } - if listDomainMappingsOptions.Start != nil { - builder.AddQuery("start", fmt.Sprint(*listDomainMappingsOptions.Start)) + if listConfigMapsOptions.Start != nil { + builder.AddQuery("start", fmt.Sprint(*listConfigMapsOptions.Start)) } request, err := builder.Build() @@ -3359,7 +3495,7 @@ func (codeEngine *CodeEngineV2) ListDomainMappingsWithContext(ctx context.Contex return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalDomainMappingList) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalConfigMapList) if err != nil { return } @@ -3369,40 +3505,40 @@ func (codeEngine *CodeEngineV2) ListDomainMappingsWithContext(ctx context.Contex return } -// CreateDomainMapping : Create a domain mapping -// Create a domain mapping. -func (codeEngine *CodeEngineV2) CreateDomainMapping(createDomainMappingOptions *CreateDomainMappingOptions) (result *DomainMapping, response *core.DetailedResponse, err error) { - return codeEngine.CreateDomainMappingWithContext(context.Background(), createDomainMappingOptions) +// CreateConfigMap : Create a config map +// Create a config map. +func (codeEngine *CodeEngineV2) CreateConfigMap(createConfigMapOptions *CreateConfigMapOptions) (result *ConfigMap, response *core.DetailedResponse, err error) { + return codeEngine.CreateConfigMapWithContext(context.Background(), createConfigMapOptions) } -// CreateDomainMappingWithContext is an alternate form of the CreateDomainMapping method which supports a Context parameter -func (codeEngine *CodeEngineV2) CreateDomainMappingWithContext(ctx context.Context, createDomainMappingOptions *CreateDomainMappingOptions) (result *DomainMapping, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(createDomainMappingOptions, "createDomainMappingOptions cannot be nil") +// CreateConfigMapWithContext is an alternate form of the CreateConfigMap method which supports a Context parameter +func (codeEngine *CodeEngineV2) CreateConfigMapWithContext(ctx context.Context, createConfigMapOptions *CreateConfigMapOptions) (result *ConfigMap, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(createConfigMapOptions, "createConfigMapOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(createDomainMappingOptions, "createDomainMappingOptions") + err = core.ValidateStruct(createConfigMapOptions, "createConfigMapOptions") if err != nil { return } pathParamsMap := map[string]string{ - "project_id": *createDomainMappingOptions.ProjectID, + "project_id": *createConfigMapOptions.ProjectID, } builder := core.NewRequestBuilder(core.POST) builder = builder.WithContext(ctx) builder.EnableGzipCompression = codeEngine.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/domain_mappings`, pathParamsMap) + _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/config_maps`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range createDomainMappingOptions.Headers { + for headerName, headerValue := range createConfigMapOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "CreateDomainMapping") + sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "CreateConfigMap") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -3410,14 +3546,11 @@ func (codeEngine *CodeEngineV2) CreateDomainMappingWithContext(ctx context.Conte builder.AddHeader("Content-Type", "application/json") body := make(map[string]interface{}) - if createDomainMappingOptions.Component != nil { - body["component"] = createDomainMappingOptions.Component - } - if createDomainMappingOptions.Name != nil { - body["name"] = createDomainMappingOptions.Name + if createConfigMapOptions.Name != nil { + body["name"] = createConfigMapOptions.Name } - if createDomainMappingOptions.TlsSecret != nil { - body["tls_secret"] = createDomainMappingOptions.TlsSecret + if createConfigMapOptions.Data != nil { + body["data"] = createConfigMapOptions.Data } _, err = builder.SetBodyContentJSON(body) if err != nil { @@ -3435,7 +3568,7 @@ func (codeEngine *CodeEngineV2) CreateDomainMappingWithContext(ctx context.Conte return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalDomainMapping) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalConfigMap) if err != nil { return } @@ -3445,41 +3578,41 @@ func (codeEngine *CodeEngineV2) CreateDomainMappingWithContext(ctx context.Conte return } -// GetDomainMapping : Get a domain mapping -// Get domain mapping. -func (codeEngine *CodeEngineV2) GetDomainMapping(getDomainMappingOptions *GetDomainMappingOptions) (result *DomainMapping, response *core.DetailedResponse, err error) { - return codeEngine.GetDomainMappingWithContext(context.Background(), getDomainMappingOptions) +// GetConfigMap : Get a config map +// Display the details of a config map. +func (codeEngine *CodeEngineV2) GetConfigMap(getConfigMapOptions *GetConfigMapOptions) (result *ConfigMap, response *core.DetailedResponse, err error) { + return codeEngine.GetConfigMapWithContext(context.Background(), getConfigMapOptions) } -// GetDomainMappingWithContext is an alternate form of the GetDomainMapping method which supports a Context parameter -func (codeEngine *CodeEngineV2) GetDomainMappingWithContext(ctx context.Context, getDomainMappingOptions *GetDomainMappingOptions) (result *DomainMapping, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(getDomainMappingOptions, "getDomainMappingOptions cannot be nil") +// GetConfigMapWithContext is an alternate form of the GetConfigMap method which supports a Context parameter +func (codeEngine *CodeEngineV2) GetConfigMapWithContext(ctx context.Context, getConfigMapOptions *GetConfigMapOptions) (result *ConfigMap, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getConfigMapOptions, "getConfigMapOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(getDomainMappingOptions, "getDomainMappingOptions") + err = core.ValidateStruct(getConfigMapOptions, "getConfigMapOptions") if err != nil { return } pathParamsMap := map[string]string{ - "project_id": *getDomainMappingOptions.ProjectID, - "name": *getDomainMappingOptions.Name, + "project_id": *getConfigMapOptions.ProjectID, + "name": *getConfigMapOptions.Name, } builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = codeEngine.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/domain_mappings/{name}`, pathParamsMap) + _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/config_maps/{name}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range getDomainMappingOptions.Headers { + for headerName, headerValue := range getConfigMapOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "GetDomainMapping") + sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "GetConfigMap") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -3496,7 +3629,7 @@ func (codeEngine *CodeEngineV2) GetDomainMappingWithContext(ctx context.Context, return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalDomainMapping) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalConfigMap) if err != nil { return } @@ -3506,104 +3639,175 @@ func (codeEngine *CodeEngineV2) GetDomainMappingWithContext(ctx context.Context, return } -// DeleteDomainMapping : Delete a domain mapping -// Delete a domain mapping. -func (codeEngine *CodeEngineV2) DeleteDomainMapping(deleteDomainMappingOptions *DeleteDomainMappingOptions) (response *core.DetailedResponse, err error) { - return codeEngine.DeleteDomainMappingWithContext(context.Background(), deleteDomainMappingOptions) +// ReplaceConfigMap : Update a config map +// Update a config map. +func (codeEngine *CodeEngineV2) ReplaceConfigMap(replaceConfigMapOptions *ReplaceConfigMapOptions) (result *ConfigMap, response *core.DetailedResponse, err error) { + return codeEngine.ReplaceConfigMapWithContext(context.Background(), replaceConfigMapOptions) } -// DeleteDomainMappingWithContext is an alternate form of the DeleteDomainMapping method which supports a Context parameter -func (codeEngine *CodeEngineV2) DeleteDomainMappingWithContext(ctx context.Context, deleteDomainMappingOptions *DeleteDomainMappingOptions) (response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(deleteDomainMappingOptions, "deleteDomainMappingOptions cannot be nil") +// ReplaceConfigMapWithContext is an alternate form of the ReplaceConfigMap method which supports a Context parameter +func (codeEngine *CodeEngineV2) ReplaceConfigMapWithContext(ctx context.Context, replaceConfigMapOptions *ReplaceConfigMapOptions) (result *ConfigMap, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(replaceConfigMapOptions, "replaceConfigMapOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(deleteDomainMappingOptions, "deleteDomainMappingOptions") + err = core.ValidateStruct(replaceConfigMapOptions, "replaceConfigMapOptions") if err != nil { return } pathParamsMap := map[string]string{ - "project_id": *deleteDomainMappingOptions.ProjectID, - "name": *deleteDomainMappingOptions.Name, + "project_id": *replaceConfigMapOptions.ProjectID, + "name": *replaceConfigMapOptions.Name, } - builder := core.NewRequestBuilder(core.DELETE) + builder := core.NewRequestBuilder(core.PUT) builder = builder.WithContext(ctx) builder.EnableGzipCompression = codeEngine.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/domain_mappings/{name}`, pathParamsMap) + _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/config_maps/{name}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range deleteDomainMappingOptions.Headers { + for headerName, headerValue := range replaceConfigMapOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "DeleteDomainMapping") + sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "ReplaceConfigMap") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } + builder.AddHeader("Accept", "application/json") + builder.AddHeader("Content-Type", "application/json") + if replaceConfigMapOptions.IfMatch != nil { + builder.AddHeader("If-Match", fmt.Sprint(*replaceConfigMapOptions.IfMatch)) + } + + body := make(map[string]interface{}) + if replaceConfigMapOptions.Data != nil { + body["data"] = replaceConfigMapOptions.Data + } + _, err = builder.SetBodyContentJSON(body) + if err != nil { + return + } request, err := builder.Build() if err != nil { return } - response, err = codeEngine.Service.Request(request, nil) + var rawResponse map[string]json.RawMessage + response, err = codeEngine.Service.Request(request, &rawResponse) + if err != nil { + return + } + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalConfigMap) + if err != nil { + return + } + response.Result = result + } return } -// UpdateDomainMapping : Update a domain mapping -// Update a domain mapping. -func (codeEngine *CodeEngineV2) UpdateDomainMapping(updateDomainMappingOptions *UpdateDomainMappingOptions) (result *DomainMapping, response *core.DetailedResponse, err error) { - return codeEngine.UpdateDomainMappingWithContext(context.Background(), updateDomainMappingOptions) +// DeleteConfigMap : Delete a config map +// Delete a config map. +func (codeEngine *CodeEngineV2) DeleteConfigMap(deleteConfigMapOptions *DeleteConfigMapOptions) (response *core.DetailedResponse, err error) { + return codeEngine.DeleteConfigMapWithContext(context.Background(), deleteConfigMapOptions) } -// UpdateDomainMappingWithContext is an alternate form of the UpdateDomainMapping method which supports a Context parameter -func (codeEngine *CodeEngineV2) UpdateDomainMappingWithContext(ctx context.Context, updateDomainMappingOptions *UpdateDomainMappingOptions) (result *DomainMapping, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(updateDomainMappingOptions, "updateDomainMappingOptions cannot be nil") +// DeleteConfigMapWithContext is an alternate form of the DeleteConfigMap method which supports a Context parameter +func (codeEngine *CodeEngineV2) DeleteConfigMapWithContext(ctx context.Context, deleteConfigMapOptions *DeleteConfigMapOptions) (response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(deleteConfigMapOptions, "deleteConfigMapOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(updateDomainMappingOptions, "updateDomainMappingOptions") + err = core.ValidateStruct(deleteConfigMapOptions, "deleteConfigMapOptions") if err != nil { return } pathParamsMap := map[string]string{ - "project_id": *updateDomainMappingOptions.ProjectID, - "name": *updateDomainMappingOptions.Name, - } + "project_id": *deleteConfigMapOptions.ProjectID, + "name": *deleteConfigMapOptions.Name, + } - builder := core.NewRequestBuilder(core.PATCH) + builder := core.NewRequestBuilder(core.DELETE) builder = builder.WithContext(ctx) builder.EnableGzipCompression = codeEngine.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/domain_mappings/{name}`, pathParamsMap) + _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/config_maps/{name}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range updateDomainMappingOptions.Headers { + for headerName, headerValue := range deleteConfigMapOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "UpdateDomainMapping") + sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "DeleteConfigMap") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } - builder.AddHeader("Accept", "application/json") - builder.AddHeader("Content-Type", "application/merge-patch+json") - if updateDomainMappingOptions.IfMatch != nil { - builder.AddHeader("If-Match", fmt.Sprint(*updateDomainMappingOptions.IfMatch)) + + request, err := builder.Build() + if err != nil { + return } - _, err = builder.SetBodyContentJSON(updateDomainMappingOptions.DomainMapping) + response, err = codeEngine.Service.Request(request, nil) + + return +} + +// ListSecrets : List secrets +// List all secrets in a project. +func (codeEngine *CodeEngineV2) ListSecrets(listSecretsOptions *ListSecretsOptions) (result *SecretList, response *core.DetailedResponse, err error) { + return codeEngine.ListSecretsWithContext(context.Background(), listSecretsOptions) +} + +// ListSecretsWithContext is an alternate form of the ListSecrets method which supports a Context parameter +func (codeEngine *CodeEngineV2) ListSecretsWithContext(ctx context.Context, listSecretsOptions *ListSecretsOptions) (result *SecretList, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(listSecretsOptions, "listSecretsOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(listSecretsOptions, "listSecretsOptions") + if err != nil { + return + } + + pathParamsMap := map[string]string{ + "project_id": *listSecretsOptions.ProjectID, + } + + builder := core.NewRequestBuilder(core.GET) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = codeEngine.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/secrets`, pathParamsMap) if err != nil { return } + for headerName, headerValue := range listSecretsOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "ListSecrets") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") + + if listSecretsOptions.Limit != nil { + builder.AddQuery("limit", fmt.Sprint(*listSecretsOptions.Limit)) + } + if listSecretsOptions.Start != nil { + builder.AddQuery("start", fmt.Sprint(*listSecretsOptions.Start)) + } + request, err := builder.Build() if err != nil { return @@ -3615,7 +3819,7 @@ func (codeEngine *CodeEngineV2) UpdateDomainMappingWithContext(ctx context.Conte return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalDomainMapping) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalSecretList) if err != nil { return } @@ -3625,89 +3829,358 @@ func (codeEngine *CodeEngineV2) UpdateDomainMappingWithContext(ctx context.Conte return } -// App : App is the response model for app resources. -type App struct { - // Reference to a build that is associated with the application. - Build *string `json:"build,omitempty"` - - // Reference to a buildrun that is associated with the application. - BuildRun *string `json:"build_run,omitempty"` - - // The timestamp when the resource was created. - CreatedAt *string `json:"created_at,omitempty"` - - // Optional URL to invoke app. Depending on visibility this is accessible publicly or in the private network only. - // Empty in case 'managed_domain_mappings' is set to 'local'. - Endpoint *string `json:"endpoint,omitempty"` +// CreateSecret : Create a secret +// Create a secret. +func (codeEngine *CodeEngineV2) CreateSecret(createSecretOptions *CreateSecretOptions) (result *Secret, response *core.DetailedResponse, err error) { + return codeEngine.CreateSecretWithContext(context.Background(), createSecretOptions) +} - // URL to app that is only visible within the project. - EndpointInternal *string `json:"endpoint_internal,omitempty"` +// CreateSecretWithContext is an alternate form of the CreateSecret method which supports a Context parameter +func (codeEngine *CodeEngineV2) CreateSecretWithContext(ctx context.Context, createSecretOptions *CreateSecretOptions) (result *Secret, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(createSecretOptions, "createSecretOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(createSecretOptions, "createSecretOptions") + if err != nil { + return + } - // The version of the app instance, which is used to achieve optimistic locking. - EntityTag *string `json:"entity_tag" validate:"required"` + pathParamsMap := map[string]string{ + "project_id": *createSecretOptions.ProjectID, + } - // When you provision a new app, a URL is created identifying the location of the instance. - Href *string `json:"href,omitempty"` + builder := core.NewRequestBuilder(core.POST) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = codeEngine.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/secrets`, pathParamsMap) + if err != nil { + return + } - // The identifier of the resource. - ID *string `json:"id,omitempty"` + for headerName, headerValue := range createSecretOptions.Headers { + builder.AddHeader(headerName, headerValue) + } - // Optional port the app listens on. While the app will always be exposed via port `443` for end users, this port is - // used to connect to the port that is exposed by the container image. - ImagePort *int64 `json:"image_port,omitempty"` + sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "CreateSecret") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") + builder.AddHeader("Content-Type", "application/json") - // The name of the image that is used for this app. The format is `REGISTRY/NAMESPACE/REPOSITORY:TAG` where `REGISTRY` - // and `TAG` are optional. If `REGISTRY` is not specified, the default is `docker.io`. If `TAG` is not specified, the - // default is `latest`. If the image reference points to a registry that requires authentication, make sure to also - // specify the property `image_secret`. - ImageReference *string `json:"image_reference" validate:"required"` + body := make(map[string]interface{}) + if createSecretOptions.Format != nil { + body["format"] = createSecretOptions.Format + } + if createSecretOptions.Name != nil { + body["name"] = createSecretOptions.Name + } + if createSecretOptions.Data != nil { + body["data"] = createSecretOptions.Data + } + if createSecretOptions.ServiceAccess != nil { + body["service_access"] = createSecretOptions.ServiceAccess + } + if createSecretOptions.ServiceOperator != nil { + body["service_operator"] = createSecretOptions.ServiceOperator + } + _, err = builder.SetBodyContentJSON(body) + if err != nil { + return + } - // Optional name of the image registry access secret. The image registry access secret is used to authenticate with a - // private registry when you download the container image. If the image reference points to a registry that requires - // authentication, the app will be created but cannot reach the ready status, until this property is provided, too. - ImageSecret *string `json:"image_secret,omitempty"` + request, err := builder.Build() + if err != nil { + return + } - // Optional value controlling which of the system managed domain mappings will be setup for the application. Valid - // values are 'local_public', 'local_private' and 'local'. Visibility can only be 'local_private' if the project - // supports application private visibility. - ManagedDomainMappings *string `json:"managed_domain_mappings" validate:"required"` + var rawResponse map[string]json.RawMessage + response, err = codeEngine.Service.Request(request, &rawResponse) + if err != nil { + return + } + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalSecret) + if err != nil { + return + } + response.Result = result + } - // The name of the app. - Name *string `json:"name" validate:"required"` + return +} - // Response model for probes. - ProbeLiveness *Probe `json:"probe_liveness,omitempty"` +// GetSecret : Get a secret +// Get a secret. +func (codeEngine *CodeEngineV2) GetSecret(getSecretOptions *GetSecretOptions) (result *Secret, response *core.DetailedResponse, err error) { + return codeEngine.GetSecretWithContext(context.Background(), getSecretOptions) +} - // Response model for probes. - ProbeReadiness *Probe `json:"probe_readiness,omitempty"` +// GetSecretWithContext is an alternate form of the GetSecret method which supports a Context parameter +func (codeEngine *CodeEngineV2) GetSecretWithContext(ctx context.Context, getSecretOptions *GetSecretOptions) (result *Secret, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getSecretOptions, "getSecretOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(getSecretOptions, "getSecretOptions") + if err != nil { + return + } - // The ID of the project the resource is located in. - ProjectID *string `json:"project_id,omitempty"` + pathParamsMap := map[string]string{ + "project_id": *getSecretOptions.ProjectID, + "name": *getSecretOptions.Name, + } - // The region of the project the resource is located in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', - // 'eu-gb', 'jp-osa', 'jp-tok', 'us-east', 'us-south'. - Region *string `json:"region,omitempty"` + builder := core.NewRequestBuilder(core.GET) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = codeEngine.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/secrets/{name}`, pathParamsMap) + if err != nil { + return + } - // The type of the app. - ResourceType *string `json:"resource_type,omitempty"` + for headerName, headerValue := range getSecretOptions.Headers { + builder.AddHeader(headerName, headerValue) + } - // Optional arguments for the app that are passed to start the container. If not specified an empty string array will - // be applied and the arguments specified by the container image, will be used to start the container. - RunArguments []string `json:"run_arguments" validate:"required"` + sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "GetSecret") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") - // Optional user ID (UID) to run the app (e.g., `1001`). - RunAsUser *int64 `json:"run_as_user,omitempty"` + request, err := builder.Build() + if err != nil { + return + } - // Optional commands for the app that are passed to start the container. If not specified an empty string array will be - // applied and the command specified by the container image, will be used to start the container. - RunCommands []string `json:"run_commands" validate:"required"` + var rawResponse map[string]json.RawMessage + response, err = codeEngine.Service.Request(request, &rawResponse) + if err != nil { + return + } + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalSecret) + if err != nil { + return + } + response.Result = result + } - // References to config maps, secrets or literal values, which are exposed as environment variables in the application. - RunEnvVariables []EnvVar `json:"run_env_variables" validate:"required"` + return +} - // Optional name of the service account. For built-in service accounts, you can use the shortened names `manager` , - // `none`, `reader`, and `writer`. - RunServiceAccount *string `json:"run_service_account,omitempty"` +// ReplaceSecret : Update a secret +// Update a secret. +func (codeEngine *CodeEngineV2) ReplaceSecret(replaceSecretOptions *ReplaceSecretOptions) (result *Secret, response *core.DetailedResponse, err error) { + return codeEngine.ReplaceSecretWithContext(context.Background(), replaceSecretOptions) +} + +// ReplaceSecretWithContext is an alternate form of the ReplaceSecret method which supports a Context parameter +func (codeEngine *CodeEngineV2) ReplaceSecretWithContext(ctx context.Context, replaceSecretOptions *ReplaceSecretOptions) (result *Secret, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(replaceSecretOptions, "replaceSecretOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(replaceSecretOptions, "replaceSecretOptions") + if err != nil { + return + } + + pathParamsMap := map[string]string{ + "project_id": *replaceSecretOptions.ProjectID, + "name": *replaceSecretOptions.Name, + } + + builder := core.NewRequestBuilder(core.PUT) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = codeEngine.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/secrets/{name}`, pathParamsMap) + if err != nil { + return + } + + for headerName, headerValue := range replaceSecretOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "ReplaceSecret") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") + builder.AddHeader("Content-Type", "application/json") + if replaceSecretOptions.IfMatch != nil { + builder.AddHeader("If-Match", fmt.Sprint(*replaceSecretOptions.IfMatch)) + } + + body := make(map[string]interface{}) + if replaceSecretOptions.Format != nil { + body["format"] = replaceSecretOptions.Format + } + if replaceSecretOptions.Data != nil { + body["data"] = replaceSecretOptions.Data + } + _, err = builder.SetBodyContentJSON(body) + if err != nil { + return + } + + request, err := builder.Build() + if err != nil { + return + } + + var rawResponse map[string]json.RawMessage + response, err = codeEngine.Service.Request(request, &rawResponse) + if err != nil { + return + } + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalSecret) + if err != nil { + return + } + response.Result = result + } + + return +} + +// DeleteSecret : Delete a secret +// Delete a secret. +func (codeEngine *CodeEngineV2) DeleteSecret(deleteSecretOptions *DeleteSecretOptions) (response *core.DetailedResponse, err error) { + return codeEngine.DeleteSecretWithContext(context.Background(), deleteSecretOptions) +} + +// DeleteSecretWithContext is an alternate form of the DeleteSecret method which supports a Context parameter +func (codeEngine *CodeEngineV2) DeleteSecretWithContext(ctx context.Context, deleteSecretOptions *DeleteSecretOptions) (response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(deleteSecretOptions, "deleteSecretOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(deleteSecretOptions, "deleteSecretOptions") + if err != nil { + return + } + + pathParamsMap := map[string]string{ + "project_id": *deleteSecretOptions.ProjectID, + "name": *deleteSecretOptions.Name, + } + + builder := core.NewRequestBuilder(core.DELETE) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = codeEngine.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(codeEngine.Service.Options.URL, `/projects/{project_id}/secrets/{name}`, pathParamsMap) + if err != nil { + return + } + + for headerName, headerValue := range deleteSecretOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("code_engine", "V2", "DeleteSecret") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + + request, err := builder.Build() + if err != nil { + return + } + + response, err = codeEngine.Service.Request(request, nil) + + return +} + +// App : App is the response model for app resources. +type App struct { + // Reference to a build that is associated with the application. + Build *string `json:"build,omitempty"` + + // Reference to a build run that is associated with the application. + BuildRun *string `json:"build_run,omitempty"` + + // The timestamp when the resource was created. + CreatedAt *string `json:"created_at,omitempty"` + + // Optional URL to invoke the app. Depending on visibility, this is accessible publicly or in the private network + // only. Empty in case 'managed_domain_mappings' is set to 'local'. + Endpoint *string `json:"endpoint,omitempty"` + + // The URL to the app that is only visible within the project. + EndpointInternal *string `json:"endpoint_internal,omitempty"` + + // The version of the app instance, which is used to achieve optimistic locking. + EntityTag *string `json:"entity_tag" validate:"required"` + + // When you provision a new app, a URL is created identifying the location of the instance. + Href *string `json:"href,omitempty"` + + // The identifier of the resource. + ID *string `json:"id,omitempty"` + + // Optional port the app listens on. While the app will always be exposed via port `443` for end users, this port is + // used to connect to the port that is exposed by the container image. + ImagePort *int64 `json:"image_port,omitempty"` + + // The name of the image that is used for this app. The format is `REGISTRY/NAMESPACE/REPOSITORY:TAG` where `REGISTRY` + // and `TAG` are optional. If `REGISTRY` is not specified, the default is `docker.io`. If `TAG` is not specified, the + // default is `latest`. If the image reference points to a registry that requires authentication, make sure to also + // specify the property `image_secret`. + ImageReference *string `json:"image_reference" validate:"required"` + + // Optional name of the image registry access secret. The image registry access secret is used to authenticate with a + // private registry when you download the container image. If the image reference points to a registry that requires + // authentication, the app will be created but cannot reach the ready status, until this property is provided, too. + ImageSecret *string `json:"image_secret,omitempty"` + + // Optional value controlling which of the system managed domain mappings will be setup for the application. Valid + // values are 'local_public', 'local_private' and 'local'. Visibility can only be 'local_private' if the project + // supports application private visibility. + ManagedDomainMappings *string `json:"managed_domain_mappings" validate:"required"` + + // The name of the app. + Name *string `json:"name" validate:"required"` + + // Response model for probes. + ProbeLiveness *Probe `json:"probe_liveness,omitempty"` + + // Response model for probes. + ProbeReadiness *Probe `json:"probe_readiness,omitempty"` + + // The ID of the project in which the resource is located. + ProjectID *string `json:"project_id,omitempty"` + + // The region of the project the resource is located in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', + // 'eu-gb', 'jp-osa', 'jp-tok', 'us-east', 'us-south'. + Region *string `json:"region,omitempty"` + + // The type of the app. + ResourceType *string `json:"resource_type,omitempty"` + + // Optional arguments for the app that are passed to start the container. If not specified an empty string array will + // be applied and the arguments specified by the container image, will be used to start the container. + RunArguments []string `json:"run_arguments" validate:"required"` + + // Optional user ID (UID) to run the app. + RunAsUser *int64 `json:"run_as_user,omitempty"` + + // Optional commands for the app that are passed to start the container. If not specified an empty string array will be + // applied and the command specified by the container image, will be used to start the container. + RunCommands []string `json:"run_commands" validate:"required"` + + // References to config maps, secrets or literal values, which are exposed as environment variables in the application. + RunEnvVariables []EnvVar `json:"run_env_variables" validate:"required"` + + // Optional name of the service account. For built-in service accounts, you can use the shortened names `manager` , + // `none`, `reader`, and `writer`. + RunServiceAccount *string `json:"run_service_account,omitempty"` // Mounts of config maps or secrets. RunVolumeMounts []VolumeMount `json:"run_volume_mounts" validate:"required"` @@ -3724,7 +4197,7 @@ type App struct { // combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). ScaleCpuLimit *string `json:"scale_cpu_limit" validate:"required"` - // Optional amount of time in seconds that delays the scale down behavior for an app instance. + // Optional amount of time in seconds that delays the scale-down behavior for an app instance. ScaleDownDelay *int64 `json:"scale_down_delay,omitempty"` // Optional amount of ephemeral storage to set for the instance of the app. The amount specified as ephemeral storage, @@ -3948,37 +4421,228 @@ func UnmarshalApp(m map[string]json.RawMessage, result interface{}) (err error) return } -// AppList : Contains a list of apps and pagination information. -type AppList struct { - // List of all apps. - Apps []App `json:"apps" validate:"required"` +// AppInstance : AppInstance is the response model for app instance resources. +type AppInstance struct { + // The name of the application that is associated with this instance. + AppName *string `json:"app_name" validate:"required"` - // Describes properties needed to retrieve the first page of a result list. - First *ListFirstMetadata `json:"first,omitempty"` + // The timestamp when the resource was created. + CreatedAt *string `json:"created_at,omitempty"` - // Maximum number of resources per page. - Limit *int64 `json:"limit" validate:"required"` + // When you provision a new app instance, a URL is created identifying the location of the instance. + Href *string `json:"href,omitempty"` - // Describes properties needed to retrieve the next page of a result list. - Next *ListNextMetadata `json:"next,omitempty"` + // The identifier of the resource. + ID *string `json:"id,omitempty"` + + // The name of the app instance. + Name *string `json:"name,omitempty"` + + // The ID of the project in which the resource is located. + ProjectID *string `json:"project_id,omitempty"` + + // The region of the project the resource is located in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', + // 'eu-gb', 'jp-osa', 'jp-tok', 'us-east', 'us-south'. + Region *string `json:"region,omitempty"` + + // The type of the app instance. + ResourceType *string `json:"resource_type,omitempty"` + + // The number of restarts of the app instance. + Restarts *int64 `json:"restarts,omitempty"` + + // The name of the revision that is associated with this instance. + RevisionName *string `json:"revision_name" validate:"required"` + + // The number of CPU set for the instance. For valid values see [Supported memory and CPU + // combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). + ScaleCpuLimit *string `json:"scale_cpu_limit" validate:"required"` + + // The amount of ephemeral storage set for the instance. The amount specified as ephemeral storage, must not exceed the + // amount of `scale_memory_limit`. The units for specifying ephemeral storage are Megabyte (M) or Gigabyte (G), whereas + // G and M are the shorthand expressions for GB and MB. For more information see [Units of + // measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). + ScaleEphemeralStorageLimit *string `json:"scale_ephemeral_storage_limit" validate:"required"` + + // The amount of memory set for the instance. For valid values see [Supported memory and CPU + // combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). The units for specifying memory + // are Megabyte (M) or Gigabyte (G), whereas G and M are the shorthand expressions for GB and MB. For more information + // see [Units of measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). + ScaleMemoryLimit *string `json:"scale_memory_limit" validate:"required"` + + // The current status of the instance. + Status *string `json:"status,omitempty"` + + // The status of a container. + SystemContainer *ContainerStatus `json:"system_container,omitempty"` + + // The status of a container. + UserContainer *ContainerStatus `json:"user_container,omitempty"` } -// UnmarshalAppList unmarshals an instance of AppList from the specified map of raw messages. -func UnmarshalAppList(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(AppList) - err = core.UnmarshalModel(m, "apps", &obj.Apps, UnmarshalApp) +// Constants associated with the AppInstance.ResourceType property. +// The type of the app instance. +const ( + AppInstance_ResourceType_AppInstanceV2 = "app_instance_v2" +) + +// Constants associated with the AppInstance.Status property. +// The current status of the instance. +const ( + AppInstance_Status_Failed = "failed" + AppInstance_Status_Pending = "pending" + AppInstance_Status_Running = "running" + AppInstance_Status_Succeeded = "succeeded" +) + +// UnmarshalAppInstance unmarshals an instance of AppInstance from the specified map of raw messages. +func UnmarshalAppInstance(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(AppInstance) + err = core.UnmarshalPrimitive(m, "app_name", &obj.AppName) if err != nil { return } - err = core.UnmarshalModel(m, "first", &obj.First, UnmarshalListFirstMetadata) + err = core.UnmarshalPrimitive(m, "created_at", &obj.CreatedAt) if err != nil { return } - err = core.UnmarshalPrimitive(m, "limit", &obj.Limit) + err = core.UnmarshalPrimitive(m, "href", &obj.Href) if err != nil { return } - err = core.UnmarshalModel(m, "next", &obj.Next, UnmarshalListNextMetadata) + err = core.UnmarshalPrimitive(m, "id", &obj.ID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "name", &obj.Name) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "project_id", &obj.ProjectID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "region", &obj.Region) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "resource_type", &obj.ResourceType) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "restarts", &obj.Restarts) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "revision_name", &obj.RevisionName) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "scale_cpu_limit", &obj.ScaleCpuLimit) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "scale_ephemeral_storage_limit", &obj.ScaleEphemeralStorageLimit) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "scale_memory_limit", &obj.ScaleMemoryLimit) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "status", &obj.Status) + if err != nil { + return + } + err = core.UnmarshalModel(m, "system_container", &obj.SystemContainer, UnmarshalContainerStatus) + if err != nil { + return + } + err = core.UnmarshalModel(m, "user_container", &obj.UserContainer, UnmarshalContainerStatus) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// AppInstanceList : Contains a list of app instances and pagination information. +type AppInstanceList struct { + // Describes properties needed to retrieve the first page of a result list. + First *ListFirstMetadata `json:"first,omitempty"` + + // List of all app instances. + Instances []AppInstance `json:"instances" validate:"required"` + + // Maximum number of resources per page. + Limit *int64 `json:"limit" validate:"required"` + + // Describes properties needed to retrieve the next page of a result list. + Next *ListNextMetadata `json:"next,omitempty"` +} + +// UnmarshalAppInstanceList unmarshals an instance of AppInstanceList from the specified map of raw messages. +func UnmarshalAppInstanceList(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(AppInstanceList) + err = core.UnmarshalModel(m, "first", &obj.First, UnmarshalListFirstMetadata) + if err != nil { + return + } + err = core.UnmarshalModel(m, "instances", &obj.Instances, UnmarshalAppInstance) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "limit", &obj.Limit) + if err != nil { + return + } + err = core.UnmarshalModel(m, "next", &obj.Next, UnmarshalListNextMetadata) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// Retrieve the value to be passed to a request to access the next page of results +func (resp *AppInstanceList) GetNextStart() (*string, error) { + if core.IsNil(resp.Next) { + return nil, nil + } + return resp.Next.Start, nil +} + +// AppList : Contains a list of apps and pagination information. +type AppList struct { + // List of all apps. + Apps []App `json:"apps" validate:"required"` + + // Describes properties needed to retrieve the first page of a result list. + First *ListFirstMetadata `json:"first,omitempty"` + + // Maximum number of resources per page. + Limit *int64 `json:"limit" validate:"required"` + + // Describes properties needed to retrieve the next page of a result list. + Next *ListNextMetadata `json:"next,omitempty"` +} + +// UnmarshalAppList unmarshals an instance of AppList from the specified map of raw messages. +func UnmarshalAppList(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(AppList) + err = core.UnmarshalModel(m, "apps", &obj.Apps, UnmarshalApp) + if err != nil { + return + } + err = core.UnmarshalModel(m, "first", &obj.First, UnmarshalListFirstMetadata) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "limit", &obj.Limit) + if err != nil { + return + } + err = core.UnmarshalModel(m, "next", &obj.Next, UnmarshalListNextMetadata) if err != nil { return } @@ -4026,7 +4690,7 @@ type AppPatch struct { // be applied and the arguments specified by the container image, will be used to start the container. RunArguments []string `json:"run_arguments,omitempty"` - // Optional user ID (UID) to run the app (e.g., `1001`). + // Optional user ID (UID) to run the app. RunAsUser *int64 `json:"run_as_user,omitempty"` // Optional commands for the app that are passed to start the container. If not specified an empty string array will be @@ -4056,7 +4720,7 @@ type AppPatch struct { // combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). ScaleCpuLimit *string `json:"scale_cpu_limit,omitempty"` - // Optional amount of time in seconds that delays the scale down behavior for an app instance. + // Optional amount of time in seconds that delays the scale-down behavior for an app instance. ScaleDownDelay *int64 `json:"scale_down_delay,omitempty"` // Optional amount of ephemeral storage to set for the instance of the app. The amount specified as ephemeral storage, @@ -4245,7 +4909,7 @@ type AppRevision struct { // The name of the app revison. Name *string `json:"name,omitempty"` - // The ID of the project the resource is located in. + // The ID of the project in which the resource is located. ProjectID *string `json:"project_id,omitempty"` // The region of the project the resource is located in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', @@ -4259,7 +4923,7 @@ type AppRevision struct { // be applied and the arguments specified by the container image, will be used to start the container. RunArguments []string `json:"run_arguments" validate:"required"` - // Optional user ID (UID) to run the app (e.g., `1001`). + // Optional user ID (UID) to run the app. RunAsUser *int64 `json:"run_as_user,omitempty"` // Optional commands for the app that are passed to start the container. If not specified an empty string array will be @@ -4288,7 +4952,7 @@ type AppRevision struct { // combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). ScaleCpuLimit *string `json:"scale_cpu_limit" validate:"required"` - // Optional amount of time in seconds that delays the scale down behavior for an app instance. + // Optional amount of time in seconds that delays the scale-down behavior for an app instance. ScaleDownDelay *int64 `json:"scale_down_delay,omitempty"` // Optional amount of ephemeral storage to set for the instance of the app. The amount specified as ephemeral storage, @@ -4618,10 +5282,10 @@ type Binding struct { // The ID of the binding. ID *string `json:"id,omitempty"` - // The value that is set as prefix in the component that is bound. + // The value that is set as a prefix in the component that is bound. Prefix *string `json:"prefix" validate:"required"` - // The ID of the project the resource is located in. + // The ID of the project in which the resource is located. ProjectID *string `json:"project_id,omitempty"` // The type of the binding. @@ -4749,7 +5413,7 @@ type Build struct { // towards the specified container registry namespace. OutputSecret *string `json:"output_secret" validate:"required"` - // The ID of the project the resource is located in. + // The ID of the project in which the resource is located. ProjectID *string `json:"project_id,omitempty"` // The region of the project the resource is located in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', @@ -4759,7 +5423,7 @@ type Build struct { // The type of the build. ResourceType *string `json:"resource_type,omitempty"` - // Option directory in the repository that contains the buildpacks file or the Dockerfile. + // Optional directory in the repository that contains the buildpacks file or the Dockerfile. SourceContextDir *string `json:"source_context_dir,omitempty"` // Commit, tag, or branch in the source repository to pull. This field is optional if the `source_type` is `git` and @@ -4971,7 +5635,7 @@ type BuildPatch struct { // towards the specified container registry namespace. OutputSecret *string `json:"output_secret,omitempty"` - // Option directory in the repository that contains the buildpacks file or the Dockerfile. + // Optional directory in the repository that contains the buildpacks file or the Dockerfile. SourceContextDir *string `json:"source_context_dir,omitempty"` // Commit, tag, or branch in the source repository to pull. This field is optional if the `source_type` is `git` and @@ -5105,7 +5769,7 @@ type BuildRun struct { // towards the specified container registry namespace. OutputSecret *string `json:"output_secret,omitempty"` - // The ID of the project the resource is located in. + // The ID of the project in which the resource is located. ProjectID *string `json:"project_id,omitempty"` // The region of the project the resource is located in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', @@ -5115,10 +5779,11 @@ type BuildRun struct { // The type of the build run. ResourceType *string `json:"resource_type,omitempty"` - // Optional service account which is used for resource control. + // Optional service account, which is used for resource control.” or “Optional service account that is used for + // resource control. ServiceAccount *string `json:"service_account,omitempty"` - // Option directory in the repository that contains the buildpacks file or the Dockerfile. + // Optional directory in the repository that contains the buildpacks file or the Dockerfile. SourceContextDir *string `json:"source_context_dir,omitempty"` // Commit, tag, or branch in the source repository to pull. This field is optional if the `source_type` is `git` and @@ -5169,7 +5834,8 @@ const ( ) // Constants associated with the BuildRun.ServiceAccount property. -// Optional service account which is used for resource control. +// Optional service account, which is used for resource control.” or “Optional service account that is used for resource +// control. const ( BuildRun_ServiceAccount_Default = "default" BuildRun_ServiceAccount_Manager = "manager" @@ -5484,7 +6150,7 @@ type ConfigMap struct { // The name of the config map. Name *string `json:"name" validate:"required"` - // The ID of the project the resource is located in. + // The ID of the project in which the resource is located. ProjectID *string `json:"project_id,omitempty"` // The region of the project the resource is located in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', @@ -5544,9 +6210,9 @@ func UnmarshalConfigMap(m map[string]json.RawMessage, result interface{}) (err e return } -// ConfigMapList : Contains a list of configmaps and pagination information. +// ConfigMapList : Contains a list of config maps and pagination information. type ConfigMapList struct { - // List of all configmaps. + // List of all config maps. ConfigMaps []ConfigMap `json:"config_maps" validate:"required"` // Describes properties needed to retrieve the first page of a result list. @@ -5590,6 +6256,97 @@ func (resp *ConfigMapList) GetNextStart() (*string, error) { return resp.Next.Start, nil } +// ContainerStatus : The status of a container. +type ContainerStatus struct { + // Details of the observed container status. + CurrentState *ContainerStatusDetails `json:"current_state,omitempty"` + + // Details of the observed container status. + LastObservedState *ContainerStatusDetails `json:"last_observed_state,omitempty"` +} + +// UnmarshalContainerStatus unmarshals an instance of ContainerStatus from the specified map of raw messages. +func UnmarshalContainerStatus(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(ContainerStatus) + err = core.UnmarshalModel(m, "current_state", &obj.CurrentState, UnmarshalContainerStatusDetails) + if err != nil { + return + } + err = core.UnmarshalModel(m, "last_observed_state", &obj.LastObservedState, UnmarshalContainerStatusDetails) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// ContainerStatusDetails : Details of the observed container status. +type ContainerStatusDetails struct { + // The time the container terminated. Only populated in an observed failure state. + CompletedAt *string `json:"completed_at,omitempty"` + + // The status of the container. + ContainerStatus *string `json:"container_status,omitempty"` + + // The exit code of the last termination of the container. Only populated in an observed failure state. + ExitCode *int64 `json:"exit_code,omitempty"` + + // The reason the container is not yet running or has failed. Only populated in non-running states. + Reason *string `json:"reason,omitempty"` + + // The time the container started. + StartedAt *string `json:"started_at,omitempty"` +} + +// Constants associated with the ContainerStatusDetails.Reason property. +// The reason the container is not yet running or has failed. Only populated in non-running states. +const ( + ContainerStatusDetails_Reason_ContainerFailedExitCode0 = "container_failed_exit_code_0" + ContainerStatusDetails_Reason_ContainerFailedExitCode1 = "container_failed_exit_code_1" + ContainerStatusDetails_Reason_ContainerFailedExitCode139 = "container_failed_exit_code_139" + ContainerStatusDetails_Reason_ContainerFailedExitCode24 = "container_failed_exit_code_24" + ContainerStatusDetails_Reason_Deploying = "deploying" + ContainerStatusDetails_Reason_DeployingWaitingForResources = "deploying_waiting_for_resources" + ContainerStatusDetails_Reason_FetchImageFailedMissingPullCredentials = "fetch_image_failed_missing_pull_credentials" + ContainerStatusDetails_Reason_FetchImageFailedMissingPullSecret = "fetch_image_failed_missing_pull_secret" + ContainerStatusDetails_Reason_FetchImageFailedRegistryNotFound = "fetch_image_failed_registry_not_found" + ContainerStatusDetails_Reason_FetchImageFailedUnknownManifest = "fetch_image_failed_unknown_manifest" + ContainerStatusDetails_Reason_FetchImageFailedUnknownRepository = "fetch_image_failed_unknown_repository" + ContainerStatusDetails_Reason_FetchImageFailedWrongPullCredentials = "fetch_image_failed_wrong_pull_credentials" + ContainerStatusDetails_Reason_ImagePullBackOff = "image_pull_back_off" + ContainerStatusDetails_Reason_InitialScaleNeverAchieved = "initial_scale_never_achieved" + ContainerStatusDetails_Reason_InvalidTarHeaderImagePullErr = "invalid_tar_header_image_pull_err" + ContainerStatusDetails_Reason_Ready = "ready" + ContainerStatusDetails_Reason_Waiting = "waiting" +) + +// UnmarshalContainerStatusDetails unmarshals an instance of ContainerStatusDetails from the specified map of raw messages. +func UnmarshalContainerStatusDetails(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(ContainerStatusDetails) + err = core.UnmarshalPrimitive(m, "completed_at", &obj.CompletedAt) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "container_status", &obj.ContainerStatus) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "exit_code", &obj.ExitCode) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "reason", &obj.Reason) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "started_at", &obj.StartedAt) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + // CreateAppOptions : The CreateApp options. type CreateAppOptions struct { // The ID of the project. @@ -5628,7 +6385,7 @@ type CreateAppOptions struct { // be applied and the arguments specified by the container image, will be used to start the container. RunArguments []string `json:"run_arguments,omitempty"` - // Optional user ID (UID) to run the app (e.g., `1001`). + // Optional user ID (UID) to run the app. RunAsUser *int64 `json:"run_as_user,omitempty"` // Optional commands for the app that are passed to start the container. If not specified an empty string array will be @@ -5658,7 +6415,7 @@ type CreateAppOptions struct { // combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). ScaleCpuLimit *string `json:"scale_cpu_limit,omitempty"` - // Optional amount of time in seconds that delays the scale down behavior for an app instance. + // Optional amount of time in seconds that delays the scale-down behavior for an app instance. ScaleDownDelay *int64 `json:"scale_down_delay,omitempty"` // Optional amount of ephemeral storage to set for the instance of the app. The amount specified as ephemeral storage, @@ -5883,7 +6640,7 @@ type CreateBindingOptions struct { // Optional value that is set as prefix in the component that is bound. Will be generated if not provided. Prefix *string `json:"prefix" validate:"required"` - // The service access secret that is binding to a component. + // The service access secret that is bound to a component. SecretName *string `json:"secret_name" validate:"required"` // Allows users to set headers on API requests @@ -5948,7 +6705,7 @@ type CreateBuildOptions struct { // The strategy to use for building the image. StrategyType *string `json:"strategy_type" validate:"required"` - // Option directory in the repository that contains the buildpacks file or the Dockerfile. + // Optional directory in the repository that contains the buildpacks file or the Dockerfile. SourceContextDir *string `json:"source_context_dir,omitempty"` // Commit, tag, or branch in the source repository to pull. This field is optional if the `source_type` is `git` and @@ -6111,10 +6868,11 @@ type CreateBuildRunOptions struct { // towards the specified container registry namespace. OutputSecret *string `json:"output_secret,omitempty"` - // Optional service account which is used for resource control. + // Optional service account, which is used for resource control.” or “Optional service account that is used for + // resource control. ServiceAccount *string `json:"service_account,omitempty"` - // Option directory in the repository that contains the buildpacks file or the Dockerfile. + // Optional directory in the repository that contains the buildpacks file or the Dockerfile. SourceContextDir *string `json:"source_context_dir,omitempty"` // Commit, tag, or branch in the source repository to pull. This field is optional if the `source_type` is `git` and @@ -6156,7 +6914,8 @@ type CreateBuildRunOptions struct { } // Constants associated with the CreateBuildRunOptions.ServiceAccount property. -// Optional service account which is used for resource control. +// Optional service account, which is used for resource control.” or “Optional service account that is used for resource +// control. const ( CreateBuildRunOptions_ServiceAccount_Default = "default" CreateBuildRunOptions_ServiceAccount_Manager = "manager" @@ -6337,7 +7096,7 @@ type CreateDomainMappingOptions struct { // The name of the domain mapping. Name *string `json:"name" validate:"required"` - // The name of the TLS secret that holds the certificate and private key of this domain mapping. + // The name of the TLS secret that includes the certificate and private key of this domain mapping. TlsSecret *string `json:"tls_secret" validate:"required"` // Allows users to set headers on API requests @@ -6384,160 +7143,328 @@ func (options *CreateDomainMappingOptions) SetHeaders(param map[string]string) * return options } -// CreateJobOptions : The CreateJob options. -type CreateJobOptions struct { +// CreateFunctionOptions : The CreateFunction options. +type CreateFunctionOptions struct { // The ID of the project. ProjectID *string `json:"project_id" validate:"required,ne="` - // The name of the image that is used for this job. The format is `REGISTRY/NAMESPACE/REPOSITORY:TAG` where `REGISTRY` - // and `TAG` are optional. If `REGISTRY` is not specified, the default is `docker.io`. If `TAG` is not specified, the - // default is `latest`. If the image reference points to a registry that requires authentication, make sure to also - // specify the property `image_secret`. - ImageReference *string `json:"image_reference" validate:"required"` + // Specifies either a reference to a code bundle or the source code itself. To specify the source code, use the data + // URL scheme and include the source code as base64 encoded. The data URL scheme is defined in [RFC + // 2397](https://tools.ietf.org/html/rfc2397). + CodeReference *string `json:"code_reference" validate:"required"` - // The name of the job. Use a name that is unique within the project. + // The name of the function. Use a name that is unique within the project. Name *string `json:"name" validate:"required"` - // The name of the image registry access secret. The image registry access secret is used to authenticate with a - // private registry when you download the container image. If the image reference points to a registry that requires - // authentication, the job / job runs will be created but submitted job runs will fail, until this property is - // provided, too. This property must not be set on a job run, which references a job template. - ImageSecret *string `json:"image_secret,omitempty"` + // The managed runtime used to execute the injected code. + Runtime *string `json:"runtime" validate:"required"` - // Set arguments for the job that are passed to start job run containers. If not specified an empty string array will - // be applied and the arguments specified by the container image, will be used to start the container. - RunArguments []string `json:"run_arguments,omitempty"` + // Specifies whether the code is binary or not. Defaults to false when `code_reference` is set to a data URL. When + // `code_reference` is set to a code bundle URL, this field is always true. + CodeBinary *bool `json:"code_binary,omitempty"` - // The user ID (UID) to run the job (e.g., 1001). - RunAsUser *int64 `json:"run_as_user,omitempty"` + // Specifies the name of the function that should be invoked. + CodeMain *string `json:"code_main,omitempty"` - // Set commands for the job that are passed to start job run containers. If not specified an empty string array will be - // applied and the command specified by the container image, will be used to start the container. - RunCommands []string `json:"run_commands,omitempty"` + // The name of the secret that is used to access the specified `code_reference`. The secret is used to authenticate + // with a non-public endpoint that is specified as`code_reference`. + CodeSecret *string `json:"code_secret,omitempty"` + + // Optional value controlling which of the system managed domain mappings will be setup for the function. Valid values + // are 'local_public', 'local_private' and 'local'. Visibility can only be 'local_private' if the project supports + // function private visibility. + ManagedDomainMappings *string `json:"managed_domain_mappings,omitempty"` // Optional references to config maps, secrets or literal values. RunEnvVariables []EnvVarPrototype `json:"run_env_variables,omitempty"` - // The mode for runs of the job. Valid values are `task` and `daemon`. In `task` mode, the `max_execution_time` and - // `retry_limit` properties apply. In `daemon` mode, since there is no timeout and failed instances are restarted - // indefinitely, the `max_execution_time` and `retry_limit` properties are not allowed. - RunMode *string `json:"run_mode,omitempty"` - - // The name of the service account. For built-in service accounts, you can use the shortened names `manager`, `none`, - // `reader`, and `writer`. This property must not be set on a job run, which references a job template. - RunServiceAccount *string `json:"run_service_account,omitempty"` - - // Optional mounts of config maps or a secrets. - RunVolumeMounts []VolumeMountPrototype `json:"run_volume_mounts,omitempty"` - - // Define a custom set of array indices as comma-separated list containing single values and hyphen-separated ranges - // like `5,12-14,23,27`. Each instance can pick up its array index via environment variable `JOB_INDEX`. The number of - // unique array indices specified here determines the number of job instances to run. - ScaleArraySpec *string `json:"scale_array_spec,omitempty"` + // Number of parallel requests handled by a single instance, supported only by Node.js, default is `1`. + ScaleConcurrency *int64 `json:"scale_concurrency,omitempty"` - // Optional amount of CPU set for the instance of the job. For valid values see [Supported memory and CPU + // Optional amount of CPU set for the instance of the function. For valid values see [Supported memory and CPU // combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). ScaleCpuLimit *string `json:"scale_cpu_limit,omitempty"` - // Optional amount of ephemeral storage to set for the instance of the job. The amount specified as ephemeral storage, - // must not exceed the amount of `scale_memory_limit`. The units for specifying ephemeral storage are Megabyte (M) or - // Gigabyte (G), whereas G and M are the shorthand expressions for GB and MB. For more information see [Units of - // measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). - ScaleEphemeralStorageLimit *string `json:"scale_ephemeral_storage_limit,omitempty"` + // Optional amount of time in seconds that delays the scale down behavior for a function. + ScaleDownDelay *int64 `json:"scale_down_delay,omitempty"` - // The maximum execution time in seconds for runs of the job. This property can only be specified if `run_mode` is - // `task`. + // Timeout in secs after which the function is terminated. ScaleMaxExecutionTime *int64 `json:"scale_max_execution_time,omitempty"` - // Optional amount of memory set for the instance of the job. For valid values see [Supported memory and CPU + // Optional amount of memory set for the instance of the function. For valid values see [Supported memory and CPU // combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). The units for specifying memory // are Megabyte (M) or Gigabyte (G), whereas G and M are the shorthand expressions for GB and MB. For more information // see [Units of measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). ScaleMemoryLimit *string `json:"scale_memory_limit,omitempty"` - // The number of times to rerun an instance of the job before the job is marked as failed. This property can only be - // specified if `run_mode` is `task`. - ScaleRetryLimit *int64 `json:"scale_retry_limit,omitempty"` - // Allows users to set headers on API requests Headers map[string]string } -// Constants associated with the CreateJobOptions.RunMode property. -// The mode for runs of the job. Valid values are `task` and `daemon`. In `task` mode, the `max_execution_time` and -// `retry_limit` properties apply. In `daemon` mode, since there is no timeout and failed instances are restarted -// indefinitely, the `max_execution_time` and `retry_limit` properties are not allowed. -const ( - CreateJobOptions_RunMode_Daemon = "daemon" - CreateJobOptions_RunMode_Task = "task" -) - -// Constants associated with the CreateJobOptions.RunServiceAccount property. -// The name of the service account. For built-in service accounts, you can use the shortened names `manager`, `none`, -// `reader`, and `writer`. This property must not be set on a job run, which references a job template. +// Constants associated with the CreateFunctionOptions.ManagedDomainMappings property. +// Optional value controlling which of the system managed domain mappings will be setup for the function. Valid values +// are 'local_public', 'local_private' and 'local'. Visibility can only be 'local_private' if the project supports +// function private visibility. const ( - CreateJobOptions_RunServiceAccount_Default = "default" - CreateJobOptions_RunServiceAccount_Manager = "manager" - CreateJobOptions_RunServiceAccount_None = "none" - CreateJobOptions_RunServiceAccount_Reader = "reader" - CreateJobOptions_RunServiceAccount_Writer = "writer" + CreateFunctionOptions_ManagedDomainMappings_Local = "local" + CreateFunctionOptions_ManagedDomainMappings_LocalPrivate = "local_private" + CreateFunctionOptions_ManagedDomainMappings_LocalPublic = "local_public" ) -// NewCreateJobOptions : Instantiate CreateJobOptions -func (*CodeEngineV2) NewCreateJobOptions(projectID string, imageReference string, name string) *CreateJobOptions { - return &CreateJobOptions{ +// NewCreateFunctionOptions : Instantiate CreateFunctionOptions +func (*CodeEngineV2) NewCreateFunctionOptions(projectID string, codeReference string, name string, runtime string) *CreateFunctionOptions { + return &CreateFunctionOptions{ ProjectID: core.StringPtr(projectID), - ImageReference: core.StringPtr(imageReference), + CodeReference: core.StringPtr(codeReference), Name: core.StringPtr(name), + Runtime: core.StringPtr(runtime), } } // SetProjectID : Allow user to set ProjectID -func (_options *CreateJobOptions) SetProjectID(projectID string) *CreateJobOptions { +func (_options *CreateFunctionOptions) SetProjectID(projectID string) *CreateFunctionOptions { _options.ProjectID = core.StringPtr(projectID) return _options } -// SetImageReference : Allow user to set ImageReference -func (_options *CreateJobOptions) SetImageReference(imageReference string) *CreateJobOptions { - _options.ImageReference = core.StringPtr(imageReference) +// SetCodeReference : Allow user to set CodeReference +func (_options *CreateFunctionOptions) SetCodeReference(codeReference string) *CreateFunctionOptions { + _options.CodeReference = core.StringPtr(codeReference) return _options } // SetName : Allow user to set Name -func (_options *CreateJobOptions) SetName(name string) *CreateJobOptions { +func (_options *CreateFunctionOptions) SetName(name string) *CreateFunctionOptions { _options.Name = core.StringPtr(name) return _options } -// SetImageSecret : Allow user to set ImageSecret -func (_options *CreateJobOptions) SetImageSecret(imageSecret string) *CreateJobOptions { - _options.ImageSecret = core.StringPtr(imageSecret) +// SetRuntime : Allow user to set Runtime +func (_options *CreateFunctionOptions) SetRuntime(runtime string) *CreateFunctionOptions { + _options.Runtime = core.StringPtr(runtime) return _options } -// SetRunArguments : Allow user to set RunArguments -func (_options *CreateJobOptions) SetRunArguments(runArguments []string) *CreateJobOptions { - _options.RunArguments = runArguments +// SetCodeBinary : Allow user to set CodeBinary +func (_options *CreateFunctionOptions) SetCodeBinary(codeBinary bool) *CreateFunctionOptions { + _options.CodeBinary = core.BoolPtr(codeBinary) return _options } -// SetRunAsUser : Allow user to set RunAsUser -func (_options *CreateJobOptions) SetRunAsUser(runAsUser int64) *CreateJobOptions { - _options.RunAsUser = core.Int64Ptr(runAsUser) +// SetCodeMain : Allow user to set CodeMain +func (_options *CreateFunctionOptions) SetCodeMain(codeMain string) *CreateFunctionOptions { + _options.CodeMain = core.StringPtr(codeMain) return _options } -// SetRunCommands : Allow user to set RunCommands -func (_options *CreateJobOptions) SetRunCommands(runCommands []string) *CreateJobOptions { - _options.RunCommands = runCommands +// SetCodeSecret : Allow user to set CodeSecret +func (_options *CreateFunctionOptions) SetCodeSecret(codeSecret string) *CreateFunctionOptions { + _options.CodeSecret = core.StringPtr(codeSecret) return _options } -// SetRunEnvVariables : Allow user to set RunEnvVariables -func (_options *CreateJobOptions) SetRunEnvVariables(runEnvVariables []EnvVarPrototype) *CreateJobOptions { - _options.RunEnvVariables = runEnvVariables - return _options +// SetManagedDomainMappings : Allow user to set ManagedDomainMappings +func (_options *CreateFunctionOptions) SetManagedDomainMappings(managedDomainMappings string) *CreateFunctionOptions { + _options.ManagedDomainMappings = core.StringPtr(managedDomainMappings) + return _options +} + +// SetRunEnvVariables : Allow user to set RunEnvVariables +func (_options *CreateFunctionOptions) SetRunEnvVariables(runEnvVariables []EnvVarPrototype) *CreateFunctionOptions { + _options.RunEnvVariables = runEnvVariables + return _options +} + +// SetScaleConcurrency : Allow user to set ScaleConcurrency +func (_options *CreateFunctionOptions) SetScaleConcurrency(scaleConcurrency int64) *CreateFunctionOptions { + _options.ScaleConcurrency = core.Int64Ptr(scaleConcurrency) + return _options +} + +// SetScaleCpuLimit : Allow user to set ScaleCpuLimit +func (_options *CreateFunctionOptions) SetScaleCpuLimit(scaleCpuLimit string) *CreateFunctionOptions { + _options.ScaleCpuLimit = core.StringPtr(scaleCpuLimit) + return _options +} + +// SetScaleDownDelay : Allow user to set ScaleDownDelay +func (_options *CreateFunctionOptions) SetScaleDownDelay(scaleDownDelay int64) *CreateFunctionOptions { + _options.ScaleDownDelay = core.Int64Ptr(scaleDownDelay) + return _options +} + +// SetScaleMaxExecutionTime : Allow user to set ScaleMaxExecutionTime +func (_options *CreateFunctionOptions) SetScaleMaxExecutionTime(scaleMaxExecutionTime int64) *CreateFunctionOptions { + _options.ScaleMaxExecutionTime = core.Int64Ptr(scaleMaxExecutionTime) + return _options +} + +// SetScaleMemoryLimit : Allow user to set ScaleMemoryLimit +func (_options *CreateFunctionOptions) SetScaleMemoryLimit(scaleMemoryLimit string) *CreateFunctionOptions { + _options.ScaleMemoryLimit = core.StringPtr(scaleMemoryLimit) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *CreateFunctionOptions) SetHeaders(param map[string]string) *CreateFunctionOptions { + options.Headers = param + return options +} + +// CreateJobOptions : The CreateJob options. +type CreateJobOptions struct { + // The ID of the project. + ProjectID *string `json:"project_id" validate:"required,ne="` + + // The name of the image that is used for this job. The format is `REGISTRY/NAMESPACE/REPOSITORY:TAG` where `REGISTRY` + // and `TAG` are optional. If `REGISTRY` is not specified, the default is `docker.io`. If `TAG` is not specified, the + // default is `latest`. If the image reference points to a registry that requires authentication, make sure to also + // specify the property `image_secret`. + ImageReference *string `json:"image_reference" validate:"required"` + + // The name of the job. Use a name that is unique within the project. + Name *string `json:"name" validate:"required"` + + // The name of the image registry access secret. The image registry access secret is used to authenticate with a + // private registry when you download the container image. If the image reference points to a registry that requires + // authentication, the job / job runs will be created but submitted job runs will fail, until this property is + // provided, too. This property must not be set on a job run, which references a job template. + ImageSecret *string `json:"image_secret,omitempty"` + + // Set arguments for the job that are passed to start job run containers. If not specified an empty string array will + // be applied and the arguments specified by the container image, will be used to start the container. + RunArguments []string `json:"run_arguments,omitempty"` + + // The user ID (UID) to run the job. + RunAsUser *int64 `json:"run_as_user,omitempty"` + + // Set commands for the job that are passed to start job run containers. If not specified an empty string array will be + // applied and the command specified by the container image, will be used to start the container. + RunCommands []string `json:"run_commands,omitempty"` + + // Optional references to config maps, secrets or literal values. + RunEnvVariables []EnvVarPrototype `json:"run_env_variables,omitempty"` + + // The mode for runs of the job. Valid values are `task` and `daemon`. In `task` mode, the `max_execution_time` and + // `retry_limit` properties apply. In `daemon` mode, since there is no timeout and failed instances are restarted + // indefinitely, the `max_execution_time` and `retry_limit` properties are not allowed. + RunMode *string `json:"run_mode,omitempty"` + + // The name of the service account. For built-in service accounts, you can use the shortened names `manager`, `none`, + // `reader`, and `writer`. This property must not be set on a job run, which references a job template. + RunServiceAccount *string `json:"run_service_account,omitempty"` + + // Optional mounts of config maps or a secrets. + RunVolumeMounts []VolumeMountPrototype `json:"run_volume_mounts,omitempty"` + + // Define a custom set of array indices as a comma-separated list containing single values and hyphen-separated ranges, + // such as 5,12-14,23,27. Each instance gets its array index value from the environment variable JOB_INDEX. The number + // of unique array indices that you specify with this parameter determines the number of job instances to run. + ScaleArraySpec *string `json:"scale_array_spec,omitempty"` + + // Optional amount of CPU set for the instance of the job. For valid values see [Supported memory and CPU + // combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). + ScaleCpuLimit *string `json:"scale_cpu_limit,omitempty"` + + // Optional amount of ephemeral storage to set for the instance of the job. The amount specified as ephemeral storage, + // must not exceed the amount of `scale_memory_limit`. The units for specifying ephemeral storage are Megabyte (M) or + // Gigabyte (G), whereas G and M are the shorthand expressions for GB and MB. For more information see [Units of + // measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). + ScaleEphemeralStorageLimit *string `json:"scale_ephemeral_storage_limit,omitempty"` + + // The maximum execution time in seconds for runs of the job. This property can only be specified if `run_mode` is + // `task`. + ScaleMaxExecutionTime *int64 `json:"scale_max_execution_time,omitempty"` + + // Optional amount of memory set for the instance of the job. For valid values see [Supported memory and CPU + // combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). The units for specifying memory + // are Megabyte (M) or Gigabyte (G), whereas G and M are the shorthand expressions for GB and MB. For more information + // see [Units of measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). + ScaleMemoryLimit *string `json:"scale_memory_limit,omitempty"` + + // The number of times to rerun an instance of the job before the job is marked as failed. This property can only be + // specified if `run_mode` is `task`. + ScaleRetryLimit *int64 `json:"scale_retry_limit,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// Constants associated with the CreateJobOptions.RunMode property. +// The mode for runs of the job. Valid values are `task` and `daemon`. In `task` mode, the `max_execution_time` and +// `retry_limit` properties apply. In `daemon` mode, since there is no timeout and failed instances are restarted +// indefinitely, the `max_execution_time` and `retry_limit` properties are not allowed. +const ( + CreateJobOptions_RunMode_Daemon = "daemon" + CreateJobOptions_RunMode_Task = "task" +) + +// Constants associated with the CreateJobOptions.RunServiceAccount property. +// The name of the service account. For built-in service accounts, you can use the shortened names `manager`, `none`, +// `reader`, and `writer`. This property must not be set on a job run, which references a job template. +const ( + CreateJobOptions_RunServiceAccount_Default = "default" + CreateJobOptions_RunServiceAccount_Manager = "manager" + CreateJobOptions_RunServiceAccount_None = "none" + CreateJobOptions_RunServiceAccount_Reader = "reader" + CreateJobOptions_RunServiceAccount_Writer = "writer" +) + +// NewCreateJobOptions : Instantiate CreateJobOptions +func (*CodeEngineV2) NewCreateJobOptions(projectID string, imageReference string, name string) *CreateJobOptions { + return &CreateJobOptions{ + ProjectID: core.StringPtr(projectID), + ImageReference: core.StringPtr(imageReference), + Name: core.StringPtr(name), + } +} + +// SetProjectID : Allow user to set ProjectID +func (_options *CreateJobOptions) SetProjectID(projectID string) *CreateJobOptions { + _options.ProjectID = core.StringPtr(projectID) + return _options +} + +// SetImageReference : Allow user to set ImageReference +func (_options *CreateJobOptions) SetImageReference(imageReference string) *CreateJobOptions { + _options.ImageReference = core.StringPtr(imageReference) + return _options +} + +// SetName : Allow user to set Name +func (_options *CreateJobOptions) SetName(name string) *CreateJobOptions { + _options.Name = core.StringPtr(name) + return _options +} + +// SetImageSecret : Allow user to set ImageSecret +func (_options *CreateJobOptions) SetImageSecret(imageSecret string) *CreateJobOptions { + _options.ImageSecret = core.StringPtr(imageSecret) + return _options +} + +// SetRunArguments : Allow user to set RunArguments +func (_options *CreateJobOptions) SetRunArguments(runArguments []string) *CreateJobOptions { + _options.RunArguments = runArguments + return _options +} + +// SetRunAsUser : Allow user to set RunAsUser +func (_options *CreateJobOptions) SetRunAsUser(runAsUser int64) *CreateJobOptions { + _options.RunAsUser = core.Int64Ptr(runAsUser) + return _options +} + +// SetRunCommands : Allow user to set RunCommands +func (_options *CreateJobOptions) SetRunCommands(runCommands []string) *CreateJobOptions { + _options.RunCommands = runCommands + return _options +} + +// SetRunEnvVariables : Allow user to set RunEnvVariables +func (_options *CreateJobOptions) SetRunEnvVariables(runEnvVariables []EnvVarPrototype) *CreateJobOptions { + _options.RunEnvVariables = runEnvVariables + return _options } // SetRunMode : Allow user to set RunMode @@ -6628,7 +7555,7 @@ type CreateJobRunOptions struct { // be applied and the arguments specified by the container image, will be used to start the container. RunArguments []string `json:"run_arguments,omitempty"` - // The user ID (UID) to run the job (e.g., 1001). + // The user ID (UID) to run the job. RunAsUser *int64 `json:"run_as_user,omitempty"` // Set commands for the job that are passed to start job run containers. If not specified an empty string array will be @@ -6653,9 +7580,9 @@ type CreateJobRunOptions struct { // Optional value to override the JOB_ARRAY_SIZE environment variable for a job run. ScaleArraySizeVariableOverride *int64 `json:"scale_array_size_variable_override,omitempty"` - // Define a custom set of array indices as comma-separated list containing single values and hyphen-separated ranges - // like `5,12-14,23,27`. Each instance can pick up its array index via environment variable `JOB_INDEX`. The number of - // unique array indices specified here determines the number of job instances to run. + // Define a custom set of array indices as a comma-separated list containing single values and hyphen-separated ranges, + // such as 5,12-14,23,27. Each instance gets its array index value from the environment variable JOB_INDEX. The number + // of unique array indices that you specify with this parameter determines the number of job instances to run. ScaleArraySpec *string `json:"scale_array_spec,omitempty"` // Optional amount of CPU set for the instance of the job. For valid values see [Supported memory and CPU @@ -6898,10 +7825,10 @@ type CreateSecretOptions struct { // field can consists of any character and must not exceed a max length of 1048576 characters. Data SecretDataIntf `json:"data,omitempty"` - // Properties for Service Access Secret Prototypes. + // Properties for Service Access Secrets. ServiceAccess *ServiceAccessSecretPrototypeProps `json:"service_access,omitempty"` - // Properties for the IBM Cloud Operator Secret Prototype. + // Properties for the IBM Cloud Operator Secrets. ServiceOperator *OperatorSecretPrototypeProps `json:"service_operator,omitempty"` // Allows users to set headers on API requests @@ -7248,6 +8175,44 @@ func (options *DeleteDomainMappingOptions) SetHeaders(param map[string]string) * return options } +// DeleteFunctionOptions : The DeleteFunction options. +type DeleteFunctionOptions struct { + // The ID of the project. + ProjectID *string `json:"project_id" validate:"required,ne="` + + // The name of your function. + Name *string `json:"name" validate:"required,ne="` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewDeleteFunctionOptions : Instantiate DeleteFunctionOptions +func (*CodeEngineV2) NewDeleteFunctionOptions(projectID string, name string) *DeleteFunctionOptions { + return &DeleteFunctionOptions{ + ProjectID: core.StringPtr(projectID), + Name: core.StringPtr(name), + } +} + +// SetProjectID : Allow user to set ProjectID +func (_options *DeleteFunctionOptions) SetProjectID(projectID string) *DeleteFunctionOptions { + _options.ProjectID = core.StringPtr(projectID) + return _options +} + +// SetName : Allow user to set Name +func (_options *DeleteFunctionOptions) SetName(name string) *DeleteFunctionOptions { + _options.Name = core.StringPtr(name) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *DeleteFunctionOptions) SetHeaders(param map[string]string) *DeleteFunctionOptions { + options.Headers = param + return options +} + // DeleteJobOptions : The DeleteJob options. type DeleteJobOptions struct { // The ID of the project. @@ -7372,107 +8337,525 @@ func (*CodeEngineV2) NewDeleteSecretOptions(projectID string, name string) *Dele } } -// SetProjectID : Allow user to set ProjectID -func (_options *DeleteSecretOptions) SetProjectID(projectID string) *DeleteSecretOptions { - _options.ProjectID = core.StringPtr(projectID) - return _options -} - -// SetName : Allow user to set Name -func (_options *DeleteSecretOptions) SetName(name string) *DeleteSecretOptions { - _options.Name = core.StringPtr(name) - return _options -} +// SetProjectID : Allow user to set ProjectID +func (_options *DeleteSecretOptions) SetProjectID(projectID string) *DeleteSecretOptions { + _options.ProjectID = core.StringPtr(projectID) + return _options +} + +// SetName : Allow user to set Name +func (_options *DeleteSecretOptions) SetName(name string) *DeleteSecretOptions { + _options.Name = core.StringPtr(name) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *DeleteSecretOptions) SetHeaders(param map[string]string) *DeleteSecretOptions { + options.Headers = param + return options +} + +// DomainMapping : Response model for domain mapping definitions. +type DomainMapping struct { + // The value of the CNAME record that must be configured in the DNS settings of the domain, to route traffic properly + // to the target Code Engine region. + CnameTarget *string `json:"cname_target,omitempty"` + + // A reference to another component. + Component *ComponentRef `json:"component" validate:"required"` + + // The timestamp when the resource was created. + CreatedAt *string `json:"created_at,omitempty"` + + // The version of the domain mapping instance, which is used to achieve optimistic locking. + EntityTag *string `json:"entity_tag" validate:"required"` + + // When you provision a new domain mapping, a URL is created identifying the location of the instance. + Href *string `json:"href,omitempty"` + + // The identifier of the resource. + ID *string `json:"id,omitempty"` + + // The name of the domain mapping. + Name *string `json:"name" validate:"required"` + + // The ID of the project in which the resource is located. + ProjectID *string `json:"project_id,omitempty"` + + // The region of the project the resource is located in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', + // 'eu-gb', 'jp-osa', 'jp-tok', 'us-east', 'us-south'. + Region *string `json:"region,omitempty"` + + // The type of the Code Engine resource. + ResourceType *string `json:"resource_type,omitempty"` + + // The current status of the domain mapping. + Status *string `json:"status,omitempty"` + + // The detailed status of the domain mapping. + StatusDetails *DomainMappingStatus `json:"status_details,omitempty"` + + // The name of the TLS secret that includes the certificate and private key of this domain mapping. + TlsSecret *string `json:"tls_secret" validate:"required"` + + // Specifies whether the domain mapping is managed by the user or by Code Engine. + UserManaged *bool `json:"user_managed,omitempty"` + + // Specifies whether the domain mapping is reachable through the public internet, or private IBM network, or only + // through other components within the same Code Engine project. + Visibility *string `json:"visibility,omitempty"` +} + +// Constants associated with the DomainMapping.ResourceType property. +// The type of the Code Engine resource. +const ( + DomainMapping_ResourceType_DomainMappingV2 = "domain_mapping_v2" +) + +// Constants associated with the DomainMapping.Status property. +// The current status of the domain mapping. +const ( + DomainMapping_Status_Deploying = "deploying" + DomainMapping_Status_Failed = "failed" + DomainMapping_Status_Ready = "ready" +) + +// Constants associated with the DomainMapping.Visibility property. +// Specifies whether the domain mapping is reachable through the public internet, or private IBM network, or only +// through other components within the same Code Engine project. +const ( + DomainMapping_Visibility_Custom = "custom" + DomainMapping_Visibility_Private = "private" + DomainMapping_Visibility_Project = "project" + DomainMapping_Visibility_Public = "public" +) + +// UnmarshalDomainMapping unmarshals an instance of DomainMapping from the specified map of raw messages. +func UnmarshalDomainMapping(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(DomainMapping) + err = core.UnmarshalPrimitive(m, "cname_target", &obj.CnameTarget) + if err != nil { + return + } + err = core.UnmarshalModel(m, "component", &obj.Component, UnmarshalComponentRef) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "created_at", &obj.CreatedAt) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "entity_tag", &obj.EntityTag) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "href", &obj.Href) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "id", &obj.ID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "name", &obj.Name) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "project_id", &obj.ProjectID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "region", &obj.Region) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "resource_type", &obj.ResourceType) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "status", &obj.Status) + if err != nil { + return + } + err = core.UnmarshalModel(m, "status_details", &obj.StatusDetails, UnmarshalDomainMappingStatus) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "tls_secret", &obj.TlsSecret) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "user_managed", &obj.UserManaged) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "visibility", &obj.Visibility) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// DomainMappingList : Contains a list of domain mappings and pagination information. +type DomainMappingList struct { + // List of all domain mappings. + DomainMappings []DomainMapping `json:"domain_mappings" validate:"required"` + + // Describes properties needed to retrieve the first page of a result list. + First *ListFirstMetadata `json:"first,omitempty"` + + // Maximum number of resources per page. + Limit *int64 `json:"limit" validate:"required"` + + // Describes properties needed to retrieve the next page of a result list. + Next *ListNextMetadata `json:"next,omitempty"` +} + +// UnmarshalDomainMappingList unmarshals an instance of DomainMappingList from the specified map of raw messages. +func UnmarshalDomainMappingList(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(DomainMappingList) + err = core.UnmarshalModel(m, "domain_mappings", &obj.DomainMappings, UnmarshalDomainMapping) + if err != nil { + return + } + err = core.UnmarshalModel(m, "first", &obj.First, UnmarshalListFirstMetadata) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "limit", &obj.Limit) + if err != nil { + return + } + err = core.UnmarshalModel(m, "next", &obj.Next, UnmarshalListNextMetadata) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// Retrieve the value to be passed to a request to access the next page of results +func (resp *DomainMappingList) GetNextStart() (*string, error) { + if core.IsNil(resp.Next) { + return nil, nil + } + return resp.Next.Start, nil +} + +// DomainMappingPatch : Patch a domain mappings object. +type DomainMappingPatch struct { + // A reference to another component. + Component *ComponentRef `json:"component,omitempty"` + + // The name of the TLS secret that includes the certificate and private key of this domain mapping. + TlsSecret *string `json:"tls_secret,omitempty"` +} + +// UnmarshalDomainMappingPatch unmarshals an instance of DomainMappingPatch from the specified map of raw messages. +func UnmarshalDomainMappingPatch(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(DomainMappingPatch) + err = core.UnmarshalModel(m, "component", &obj.Component, UnmarshalComponentRef) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "tls_secret", &obj.TlsSecret) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// AsPatch returns a generic map representation of the DomainMappingPatch +func (domainMappingPatch *DomainMappingPatch) AsPatch() (_patch map[string]interface{}, err error) { + var jsonData []byte + jsonData, err = json.Marshal(domainMappingPatch) + if err == nil { + err = json.Unmarshal(jsonData, &_patch) + } + return +} + +// DomainMappingStatus : The detailed status of the domain mapping. +type DomainMappingStatus struct { + // Optional information to provide more context in case of a 'failed' or 'warning' status. + Reason *string `json:"reason,omitempty"` +} + +// Constants associated with the DomainMappingStatus.Reason property. +// Optional information to provide more context in case of a 'failed' or 'warning' status. +const ( + DomainMappingStatus_Reason_AppRefFailed = "app_ref_failed" + DomainMappingStatus_Reason_Deploying = "deploying" + DomainMappingStatus_Reason_DomainAlreadyClaimed = "domain_already_claimed" + DomainMappingStatus_Reason_Failed = "failed" + DomainMappingStatus_Reason_FailedReconcileIngress = "failed_reconcile_ingress" + DomainMappingStatus_Reason_Ready = "ready" +) + +// UnmarshalDomainMappingStatus unmarshals an instance of DomainMappingStatus from the specified map of raw messages. +func UnmarshalDomainMappingStatus(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(DomainMappingStatus) + err = core.UnmarshalPrimitive(m, "reason", &obj.Reason) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// EnvVar : Response model for environment variables. +type EnvVar struct { + // The key to reference as environment variable. + Key *string `json:"key,omitempty"` + + // The name of the environment variable. + Name *string `json:"name,omitempty"` + + // A prefix that can be added to all keys of a full secret or config map reference. + Prefix *string `json:"prefix,omitempty"` + + // The name of the secret or config map. + Reference *string `json:"reference,omitempty"` + + // Specify the type of the environment variable. + Type *string `json:"type" validate:"required"` + + // The literal value of the environment variable. + Value *string `json:"value,omitempty"` +} + +// Constants associated with the EnvVar.Type property. +// Specify the type of the environment variable. +const ( + EnvVar_Type_ConfigMapFullReference = "config_map_full_reference" + EnvVar_Type_ConfigMapKeyReference = "config_map_key_reference" + EnvVar_Type_Literal = "literal" + EnvVar_Type_SecretFullReference = "secret_full_reference" + EnvVar_Type_SecretKeyReference = "secret_key_reference" +) + +// UnmarshalEnvVar unmarshals an instance of EnvVar from the specified map of raw messages. +func UnmarshalEnvVar(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(EnvVar) + err = core.UnmarshalPrimitive(m, "key", &obj.Key) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "name", &obj.Name) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "prefix", &obj.Prefix) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "reference", &obj.Reference) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "type", &obj.Type) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "value", &obj.Value) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// EnvVarPrototype : Prototype model for environment variables. +type EnvVarPrototype struct { + // The key to reference as environment variable. + Key *string `json:"key,omitempty"` + + // The name of the environment variable. + Name *string `json:"name,omitempty"` + + // A prefix that can be added to all keys of a full secret or config map reference. + Prefix *string `json:"prefix,omitempty"` + + // The name of the secret or config map. + Reference *string `json:"reference,omitempty"` + + // Specify the type of the environment variable. + Type *string `json:"type,omitempty"` + + // The literal value of the environment variable. + Value *string `json:"value,omitempty"` +} + +// Constants associated with the EnvVarPrototype.Type property. +// Specify the type of the environment variable. +const ( + EnvVarPrototype_Type_ConfigMapFullReference = "config_map_full_reference" + EnvVarPrototype_Type_ConfigMapKeyReference = "config_map_key_reference" + EnvVarPrototype_Type_Literal = "literal" + EnvVarPrototype_Type_SecretFullReference = "secret_full_reference" + EnvVarPrototype_Type_SecretKeyReference = "secret_key_reference" +) + +// UnmarshalEnvVarPrototype unmarshals an instance of EnvVarPrototype from the specified map of raw messages. +func UnmarshalEnvVarPrototype(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(EnvVarPrototype) + err = core.UnmarshalPrimitive(m, "key", &obj.Key) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "name", &obj.Name) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "prefix", &obj.Prefix) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "reference", &obj.Reference) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "type", &obj.Type) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "value", &obj.Value) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// Function : Function is the response model for function resources. +type Function struct { + // Specifies whether the code is binary or not. Defaults to false when `code_reference` is set to a data URL. When + // `code_reference` is set to a code bundle URL, this field is always true. + CodeBinary *bool `json:"code_binary" validate:"required"` -// SetHeaders : Allow user to set Headers -func (options *DeleteSecretOptions) SetHeaders(param map[string]string) *DeleteSecretOptions { - options.Headers = param - return options -} + // Specifies the name of the function that should be invoked. + CodeMain *string `json:"code_main,omitempty"` -// DomainMapping : Response model for domain mapping definitions. -type DomainMapping struct { - // Exposes the value of the CNAME record that needs to be configured in the DNS settings of the domain, to route - // traffic properly to the target Code Engine region. - CnameTarget *string `json:"cname_target,omitempty"` + // Specifies either a reference to a code bundle or the source code itself. To specify the source code, use the data + // URL scheme and include the source code as base64 encoded. The data URL scheme is defined in [RFC + // 2397](https://tools.ietf.org/html/rfc2397). + CodeReference *string `json:"code_reference" validate:"required"` - // A reference to another component. - Component *ComponentRef `json:"component" validate:"required"` + // The name of the secret that is used to access the specified `code_reference`. The secret is used to authenticate + // with a non-public endpoint that is specified as`code_reference`. + CodeSecret *string `json:"code_secret,omitempty"` // The timestamp when the resource was created. CreatedAt *string `json:"created_at,omitempty"` - // The version of the domain mapping instance, which is used to achieve optimistic locking. + // URL to invoke the function. + Endpoint *string `json:"endpoint,omitempty"` + + // URL to function that is only visible within the project. + EndpointInternal *string `json:"endpoint_internal,omitempty"` + + // The version of the function instance, which is used to achieve optimistic locking. EntityTag *string `json:"entity_tag" validate:"required"` - // When you provision a new domain mapping, a URL is created identifying the location of the instance. + // When you provision a new function, a relative URL path is created identifying the location of the instance. Href *string `json:"href,omitempty"` // The identifier of the resource. ID *string `json:"id,omitempty"` - // The name of the domain mapping. + // Optional value controlling which of the system managed domain mappings will be setup for the function. Valid values + // are 'local_public', 'local_private' and 'local'. Visibility can only be 'local_private' if the project supports + // function private visibility. + ManagedDomainMappings *string `json:"managed_domain_mappings" validate:"required"` + + // The name of the function. Name *string `json:"name" validate:"required"` - // The ID of the project the resource is located in. + // The ID of the project in which the resource is located. ProjectID *string `json:"project_id,omitempty"` // The region of the project the resource is located in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', // 'eu-gb', 'jp-osa', 'jp-tok', 'us-east', 'us-south'. Region *string `json:"region,omitempty"` - // The type of the CE Resource. + // The type of the function. ResourceType *string `json:"resource_type,omitempty"` - // The current status of the domain mapping. - Status *string `json:"status,omitempty"` + // References to config maps, secrets or literal values, which are exposed as environment variables in the function. + RunEnvVariables []EnvVar `json:"run_env_variables" validate:"required"` - // The detailed status of the domain mapping. - StatusDetails *DomainMappingStatus `json:"status_details,omitempty"` + // The managed runtime used to execute the injected code. + Runtime *string `json:"runtime" validate:"required"` - // The name of the TLS secret that holds the certificate and private key of this domain mapping. - TlsSecret *string `json:"tls_secret" validate:"required"` + // Number of parallel requests handled by a single instance, supported only by Node.js, default is `1`. + ScaleConcurrency *int64 `json:"scale_concurrency" validate:"required"` - // Exposes whether the domain mapping is managed by the user or by Code Engine. - UserManaged *bool `json:"user_managed,omitempty"` + // Optional amount of CPU set for the instance of the function. For valid values see [Supported memory and CPU + // combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). + ScaleCpuLimit *string `json:"scale_cpu_limit" validate:"required"` - // Exposes whether the domain mapping is reachable through the public internet, or private IBM network, or only through - // other components within the same Code Engine project. - Visibility *string `json:"visibility,omitempty"` + // Optional amount of time in seconds that delays the scale down behavior for a function. + ScaleDownDelay *int64 `json:"scale_down_delay" validate:"required"` + + // Timeout in secs after which the function is terminated. + ScaleMaxExecutionTime *int64 `json:"scale_max_execution_time" validate:"required"` + + // Optional amount of memory set for the instance of the function. For valid values see [Supported memory and CPU + // combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). The units for specifying memory + // are Megabyte (M) or Gigabyte (G), whereas G and M are the shorthand expressions for GB and MB. For more information + // see [Units of measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). + ScaleMemoryLimit *string `json:"scale_memory_limit" validate:"required"` + + // The current status of the function. + Status *string `json:"status,omitempty"` + + // The detailed status of the function. + StatusDetails *FunctionStatus `json:"status_details" validate:"required"` } -// Constants associated with the DomainMapping.ResourceType property. -// The type of the CE Resource. +// Constants associated with the Function.ManagedDomainMappings property. +// Optional value controlling which of the system managed domain mappings will be setup for the function. Valid values +// are 'local_public', 'local_private' and 'local'. Visibility can only be 'local_private' if the project supports +// function private visibility. const ( - DomainMapping_ResourceType_DomainMappingV2 = "domain_mapping_v2" + Function_ManagedDomainMappings_Local = "local" + Function_ManagedDomainMappings_LocalPrivate = "local_private" + Function_ManagedDomainMappings_LocalPublic = "local_public" ) -// Constants associated with the DomainMapping.Status property. -// The current status of the domain mapping. +// Constants associated with the Function.ResourceType property. +// The type of the function. const ( - DomainMapping_Status_Deploying = "deploying" - DomainMapping_Status_Failed = "failed" - DomainMapping_Status_Ready = "ready" + Function_ResourceType_FunctionV2 = "function_v2" ) -// Constants associated with the DomainMapping.Visibility property. -// Exposes whether the domain mapping is reachable through the public internet, or private IBM network, or only through -// other components within the same Code Engine project. +// Constants associated with the Function.Status property. +// The current status of the function. const ( - DomainMapping_Visibility_Custom = "custom" - DomainMapping_Visibility_Private = "private" - DomainMapping_Visibility_Project = "project" - DomainMapping_Visibility_Public = "public" + Function_Status_Deploying = "deploying" + Function_Status_Failed = "failed" + Function_Status_Offline = "offline" + Function_Status_Ready = "ready" ) -// UnmarshalDomainMapping unmarshals an instance of DomainMapping from the specified map of raw messages. -func UnmarshalDomainMapping(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(DomainMapping) - err = core.UnmarshalPrimitive(m, "cname_target", &obj.CnameTarget) +// UnmarshalFunction unmarshals an instance of Function from the specified map of raw messages. +func UnmarshalFunction(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(Function) + err = core.UnmarshalPrimitive(m, "code_binary", &obj.CodeBinary) if err != nil { return } - err = core.UnmarshalModel(m, "component", &obj.Component, UnmarshalComponentRef) + err = core.UnmarshalPrimitive(m, "code_main", &obj.CodeMain) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "code_reference", &obj.CodeReference) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "code_secret", &obj.CodeSecret) if err != nil { return } @@ -7480,6 +8863,14 @@ func UnmarshalDomainMapping(m map[string]json.RawMessage, result interface{}) (e if err != nil { return } + err = core.UnmarshalPrimitive(m, "endpoint", &obj.Endpoint) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "endpoint_internal", &obj.EndpointInternal) + if err != nil { + return + } err = core.UnmarshalPrimitive(m, "entity_tag", &obj.EntityTag) if err != nil { return @@ -7492,6 +8883,10 @@ func UnmarshalDomainMapping(m map[string]json.RawMessage, result interface{}) (e if err != nil { return } + err = core.UnmarshalPrimitive(m, "managed_domain_mappings", &obj.ManagedDomainMappings) + if err != nil { + return + } err = core.UnmarshalPrimitive(m, "name", &obj.Name) if err != nil { return @@ -7508,23 +8903,39 @@ func UnmarshalDomainMapping(m map[string]json.RawMessage, result interface{}) (e if err != nil { return } - err = core.UnmarshalPrimitive(m, "status", &obj.Status) + err = core.UnmarshalModel(m, "run_env_variables", &obj.RunEnvVariables, UnmarshalEnvVar) if err != nil { return } - err = core.UnmarshalModel(m, "status_details", &obj.StatusDetails, UnmarshalDomainMappingStatus) + err = core.UnmarshalPrimitive(m, "runtime", &obj.Runtime) if err != nil { return } - err = core.UnmarshalPrimitive(m, "tls_secret", &obj.TlsSecret) + err = core.UnmarshalPrimitive(m, "scale_concurrency", &obj.ScaleConcurrency) if err != nil { return } - err = core.UnmarshalPrimitive(m, "user_managed", &obj.UserManaged) + err = core.UnmarshalPrimitive(m, "scale_cpu_limit", &obj.ScaleCpuLimit) if err != nil { return } - err = core.UnmarshalPrimitive(m, "visibility", &obj.Visibility) + err = core.UnmarshalPrimitive(m, "scale_down_delay", &obj.ScaleDownDelay) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "scale_max_execution_time", &obj.ScaleMaxExecutionTime) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "scale_memory_limit", &obj.ScaleMemoryLimit) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "status", &obj.Status) + if err != nil { + return + } + err = core.UnmarshalModel(m, "status_details", &obj.StatusDetails, UnmarshalFunctionStatus) if err != nil { return } @@ -7532,14 +8943,14 @@ func UnmarshalDomainMapping(m map[string]json.RawMessage, result interface{}) (e return } -// DomainMappingList : Contains a list of domain mappings and pagination information. -type DomainMappingList struct { - // List of all domain mappings. - DomainMappings []DomainMapping `json:"domain_mappings" validate:"required"` - +// FunctionList : Contains a list of functions and pagination information. +type FunctionList struct { // Describes properties needed to retrieve the first page of a result list. First *ListFirstMetadata `json:"first,omitempty"` + // List of all functions. + Functions []Function `json:"functions" validate:"required"` + // Maximum number of resources per page. Limit *int64 `json:"limit" validate:"required"` @@ -7547,14 +8958,14 @@ type DomainMappingList struct { Next *ListNextMetadata `json:"next,omitempty"` } -// UnmarshalDomainMappingList unmarshals an instance of DomainMappingList from the specified map of raw messages. -func UnmarshalDomainMappingList(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(DomainMappingList) - err = core.UnmarshalModel(m, "domain_mappings", &obj.DomainMappings, UnmarshalDomainMapping) +// UnmarshalFunctionList unmarshals an instance of FunctionList from the specified map of raw messages. +func UnmarshalFunctionList(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(FunctionList) + err = core.UnmarshalModel(m, "first", &obj.First, UnmarshalListFirstMetadata) if err != nil { return } - err = core.UnmarshalModel(m, "first", &obj.First, UnmarshalListFirstMetadata) + err = core.UnmarshalModel(m, "functions", &obj.Functions, UnmarshalFunction) if err != nil { return } @@ -7571,192 +8982,229 @@ func UnmarshalDomainMappingList(m map[string]json.RawMessage, result interface{} } // Retrieve the value to be passed to a request to access the next page of results -func (resp *DomainMappingList) GetNextStart() (*string, error) { +func (resp *FunctionList) GetNextStart() (*string, error) { if core.IsNil(resp.Next) { return nil, nil } return resp.Next.Start, nil } -// DomainMappingPatch : Patch a domain mappings object. -type DomainMappingPatch struct { - // A reference to another component. - Component *ComponentRef `json:"component,omitempty"` +// FunctionPatch : Request model for function update operations. +type FunctionPatch struct { + // Specifies whether the code is binary or not. Defaults to false when `code_reference` is set to a data URL. When + // `code_reference` is set to a code bundle URL, this field is always true. + CodeBinary *bool `json:"code_binary,omitempty"` - // The name of the TLS secret that holds the certificate and private key of this domain mapping. - TlsSecret *string `json:"tls_secret,omitempty"` -} - -// UnmarshalDomainMappingPatch unmarshals an instance of DomainMappingPatch from the specified map of raw messages. -func UnmarshalDomainMappingPatch(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(DomainMappingPatch) - err = core.UnmarshalModel(m, "component", &obj.Component, UnmarshalComponentRef) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "tls_secret", &obj.TlsSecret) - if err != nil { - return - } - reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) - return -} + // Specifies the name of the function that should be invoked. + CodeMain *string `json:"code_main,omitempty"` -// AsPatch returns a generic map representation of the DomainMappingPatch -func (domainMappingPatch *DomainMappingPatch) AsPatch() (_patch map[string]interface{}, err error) { - var jsonData []byte - jsonData, err = json.Marshal(domainMappingPatch) - if err == nil { - err = json.Unmarshal(jsonData, &_patch) - } - return -} + // Specifies either a reference to a code bundle or the source code itself. To specify the source code, use the data + // URL scheme and include the source code as base64 encoded. The data URL scheme is defined in [RFC + // 2397](https://tools.ietf.org/html/rfc2397). + CodeReference *string `json:"code_reference,omitempty"` -// DomainMappingStatus : The detailed status of the domain mapping. -type DomainMappingStatus struct { - // Optional information to provide more context in case of a 'failed' or 'warning' status. - Reason *string `json:"reason,omitempty"` -} + // The name of the secret that is used to access the specified `code_reference`. The secret is used to authenticate + // with a non-public endpoint that is specified as`code_reference`. + CodeSecret *string `json:"code_secret,omitempty"` -// Constants associated with the DomainMappingStatus.Reason property. -// Optional information to provide more context in case of a 'failed' or 'warning' status. -const ( - DomainMappingStatus_Reason_AppRefFailed = "app_ref_failed" - DomainMappingStatus_Reason_Deploying = "deploying" - DomainMappingStatus_Reason_DomainAlreadyClaimed = "domain_already_claimed" - DomainMappingStatus_Reason_Failed = "failed" - DomainMappingStatus_Reason_FailedReconcileIngress = "failed_reconcile_ingress" - DomainMappingStatus_Reason_Ready = "ready" -) + // Optional value controlling which of the system managed domain mappings will be setup for the function. Valid values + // are 'local_public', 'local_private' and 'local'. Visibility can only be 'local_private' if the project supports + // function private visibility. + ManagedDomainMappings *string `json:"managed_domain_mappings,omitempty"` -// UnmarshalDomainMappingStatus unmarshals an instance of DomainMappingStatus from the specified map of raw messages. -func UnmarshalDomainMappingStatus(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(DomainMappingStatus) - err = core.UnmarshalPrimitive(m, "reason", &obj.Reason) - if err != nil { - return - } - reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) - return -} + // Optional references to config maps, secrets or literal values. + RunEnvVariables []EnvVarPrototype `json:"run_env_variables,omitempty"` -// EnvVar : Response model for environment variables. -type EnvVar struct { - // The key to reference as environment variable. - Key *string `json:"key,omitempty"` + // The managed runtime used to execute the injected code. + Runtime *string `json:"runtime,omitempty"` - // The name of the environment variable. - Name *string `json:"name,omitempty"` + // Number of parallel requests handled by a single instance, supported only by Node.js, default is `1`. + ScaleConcurrency *int64 `json:"scale_concurrency,omitempty"` - // A prefix that can be added to all keys of a full secret or config map reference. - Prefix *string `json:"prefix,omitempty"` + // Optional amount of CPU set for the instance of the function. For valid values see [Supported memory and CPU + // combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). + ScaleCpuLimit *string `json:"scale_cpu_limit,omitempty"` - // The name of the secret or config map. - Reference *string `json:"reference,omitempty"` + // Optional amount of time in seconds that delays the scale down behavior for a function. + ScaleDownDelay *int64 `json:"scale_down_delay,omitempty"` - // Specify the type of the environment variable. - Type *string `json:"type" validate:"required"` + // Timeout in secs after which the function is terminated. + ScaleMaxExecutionTime *int64 `json:"scale_max_execution_time,omitempty"` - // The literal value of the environment variable. - Value *string `json:"value,omitempty"` + // Optional amount of memory set for the instance of the function. For valid values see [Supported memory and CPU + // combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). The units for specifying memory + // are Megabyte (M) or Gigabyte (G), whereas G and M are the shorthand expressions for GB and MB. For more information + // see [Units of measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). + ScaleMemoryLimit *string `json:"scale_memory_limit,omitempty"` } -// Constants associated with the EnvVar.Type property. -// Specify the type of the environment variable. +// Constants associated with the FunctionPatch.ManagedDomainMappings property. +// Optional value controlling which of the system managed domain mappings will be setup for the function. Valid values +// are 'local_public', 'local_private' and 'local'. Visibility can only be 'local_private' if the project supports +// function private visibility. const ( - EnvVar_Type_ConfigMapFullReference = "config_map_full_reference" - EnvVar_Type_ConfigMapKeyReference = "config_map_key_reference" - EnvVar_Type_Literal = "literal" - EnvVar_Type_SecretFullReference = "secret_full_reference" - EnvVar_Type_SecretKeyReference = "secret_key_reference" + FunctionPatch_ManagedDomainMappings_Local = "local" + FunctionPatch_ManagedDomainMappings_LocalPrivate = "local_private" + FunctionPatch_ManagedDomainMappings_LocalPublic = "local_public" ) -// UnmarshalEnvVar unmarshals an instance of EnvVar from the specified map of raw messages. -func UnmarshalEnvVar(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(EnvVar) - err = core.UnmarshalPrimitive(m, "key", &obj.Key) +// UnmarshalFunctionPatch unmarshals an instance of FunctionPatch from the specified map of raw messages. +func UnmarshalFunctionPatch(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(FunctionPatch) + err = core.UnmarshalPrimitive(m, "code_binary", &obj.CodeBinary) if err != nil { return } - err = core.UnmarshalPrimitive(m, "name", &obj.Name) + err = core.UnmarshalPrimitive(m, "code_main", &obj.CodeMain) if err != nil { return } - err = core.UnmarshalPrimitive(m, "prefix", &obj.Prefix) + err = core.UnmarshalPrimitive(m, "code_reference", &obj.CodeReference) if err != nil { return } - err = core.UnmarshalPrimitive(m, "reference", &obj.Reference) + err = core.UnmarshalPrimitive(m, "code_secret", &obj.CodeSecret) if err != nil { return } - err = core.UnmarshalPrimitive(m, "type", &obj.Type) + err = core.UnmarshalPrimitive(m, "managed_domain_mappings", &obj.ManagedDomainMappings) if err != nil { return } - err = core.UnmarshalPrimitive(m, "value", &obj.Value) + err = core.UnmarshalModel(m, "run_env_variables", &obj.RunEnvVariables, UnmarshalEnvVarPrototype) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "runtime", &obj.Runtime) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "scale_concurrency", &obj.ScaleConcurrency) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "scale_cpu_limit", &obj.ScaleCpuLimit) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "scale_down_delay", &obj.ScaleDownDelay) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "scale_max_execution_time", &obj.ScaleMaxExecutionTime) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "scale_memory_limit", &obj.ScaleMemoryLimit) if err != nil { return } - reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// AsPatch returns a generic map representation of the FunctionPatch +func (functionPatch *FunctionPatch) AsPatch() (_patch map[string]interface{}, err error) { + var jsonData []byte + jsonData, err = json.Marshal(functionPatch) + if err == nil { + err = json.Unmarshal(jsonData, &_patch) + } return } -// EnvVarPrototype : Prototype model for environment variables. -type EnvVarPrototype struct { - // The key to reference as environment variable. - Key *string `json:"key,omitempty"` +// FunctionRuntime : Response model for Function runtime objects. +type FunctionRuntime struct { + // Whether the function runtime is the default for the code bundle family. + Default *bool `json:"default,omitempty"` - // The name of the environment variable. - Name *string `json:"name,omitempty"` + // Whether the function runtime is deprecated. + Deprecated *bool `json:"deprecated,omitempty"` - // A prefix that can be added to all keys of a full secret or config map reference. - Prefix *string `json:"prefix,omitempty"` + // The code bundle family of the function runtime. + Family *string `json:"family,omitempty"` - // The name of the secret or config map. - Reference *string `json:"reference,omitempty"` + // The ID of the function runtime. + ID *string `json:"id,omitempty"` - // Specify the type of the environment variable. - Type *string `json:"type,omitempty"` + // The name of the function runtime. + Name *string `json:"name,omitempty"` - // The literal value of the environment variable. - Value *string `json:"value,omitempty"` + // Whether the function runtime is optimized. + Optimized *bool `json:"optimized,omitempty"` } -// Constants associated with the EnvVarPrototype.Type property. -// Specify the type of the environment variable. -const ( - EnvVarPrototype_Type_ConfigMapFullReference = "config_map_full_reference" - EnvVarPrototype_Type_ConfigMapKeyReference = "config_map_key_reference" - EnvVarPrototype_Type_Literal = "literal" - EnvVarPrototype_Type_SecretFullReference = "secret_full_reference" - EnvVarPrototype_Type_SecretKeyReference = "secret_key_reference" -) - -// UnmarshalEnvVarPrototype unmarshals an instance of EnvVarPrototype from the specified map of raw messages. -func UnmarshalEnvVarPrototype(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(EnvVarPrototype) - err = core.UnmarshalPrimitive(m, "key", &obj.Key) +// UnmarshalFunctionRuntime unmarshals an instance of FunctionRuntime from the specified map of raw messages. +func UnmarshalFunctionRuntime(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(FunctionRuntime) + err = core.UnmarshalPrimitive(m, "default", &obj.Default) if err != nil { return } - err = core.UnmarshalPrimitive(m, "name", &obj.Name) + err = core.UnmarshalPrimitive(m, "deprecated", &obj.Deprecated) if err != nil { return } - err = core.UnmarshalPrimitive(m, "prefix", &obj.Prefix) + err = core.UnmarshalPrimitive(m, "family", &obj.Family) if err != nil { return } - err = core.UnmarshalPrimitive(m, "reference", &obj.Reference) + err = core.UnmarshalPrimitive(m, "id", &obj.ID) if err != nil { return } - err = core.UnmarshalPrimitive(m, "type", &obj.Type) + err = core.UnmarshalPrimitive(m, "name", &obj.Name) if err != nil { return } - err = core.UnmarshalPrimitive(m, "value", &obj.Value) + err = core.UnmarshalPrimitive(m, "optimized", &obj.Optimized) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// FunctionRuntimeList : Contains a list of Function runtimes. +type FunctionRuntimeList struct { + // List of all Function runtimes. + FunctionRuntimes []FunctionRuntime `json:"function_runtimes,omitempty"` +} + +// UnmarshalFunctionRuntimeList unmarshals an instance of FunctionRuntimeList from the specified map of raw messages. +func UnmarshalFunctionRuntimeList(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(FunctionRuntimeList) + err = core.UnmarshalModel(m, "function_runtimes", &obj.FunctionRuntimes, UnmarshalFunctionRuntime) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// FunctionStatus : The detailed status of the function. +type FunctionStatus struct { + // Provides additional information about the status of the function. + Reason *string `json:"reason,omitempty"` +} + +// Constants associated with the FunctionStatus.Reason property. +// Provides additional information about the status of the function. +const ( + FunctionStatus_Reason_Deploying = "deploying" + FunctionStatus_Reason_DeployingConfiguringRoutes = "deploying_configuring_routes" + FunctionStatus_Reason_NoCodeBundle = "no_code_bundle" + FunctionStatus_Reason_Offline = "offline" + FunctionStatus_Reason_Ready = "ready" + FunctionStatus_Reason_ReadyLastUpdateFailed = "ready_last_update_failed" + FunctionStatus_Reason_ReadyUpdateInProgress = "ready_update_in_progress" + FunctionStatus_Reason_UnknownReason = "unknown_reason" +) + +// UnmarshalFunctionStatus unmarshals an instance of FunctionStatus from the specified map of raw messages. +func UnmarshalFunctionStatus(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(FunctionStatus) + err = core.UnmarshalPrimitive(m, "reason", &obj.Reason) if err != nil { return } @@ -8040,6 +9488,44 @@ func (options *GetDomainMappingOptions) SetHeaders(param map[string]string) *Get return options } +// GetFunctionOptions : The GetFunction options. +type GetFunctionOptions struct { + // The ID of the project. + ProjectID *string `json:"project_id" validate:"required,ne="` + + // The name of your function. + Name *string `json:"name" validate:"required,ne="` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewGetFunctionOptions : Instantiate GetFunctionOptions +func (*CodeEngineV2) NewGetFunctionOptions(projectID string, name string) *GetFunctionOptions { + return &GetFunctionOptions{ + ProjectID: core.StringPtr(projectID), + Name: core.StringPtr(name), + } +} + +// SetProjectID : Allow user to set ProjectID +func (_options *GetFunctionOptions) SetProjectID(projectID string) *GetFunctionOptions { + _options.ProjectID = core.StringPtr(projectID) + return _options +} + +// SetName : Allow user to set Name +func (_options *GetFunctionOptions) SetName(name string) *GetFunctionOptions { + _options.Name = core.StringPtr(name) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *GetFunctionOptions) SetHeaders(param map[string]string) *GetFunctionOptions { + options.Headers = param + return options +} + // GetJobOptions : The GetJob options. type GetJobOptions struct { // The ID of the project. @@ -8243,7 +9729,7 @@ type Job struct { // Reference to a build that is associated with the job. Build *string `json:"build,omitempty"` - // Reference to a buildrun that is associated with the job. + // Reference to a build run that is associated with the job. BuildRun *string `json:"build_run,omitempty"` // The timestamp when the resource was created. @@ -8273,7 +9759,7 @@ type Job struct { // The name of the job. Name *string `json:"name" validate:"required"` - // The ID of the project the resource is located in. + // The ID of the project in which the resource is located. ProjectID *string `json:"project_id,omitempty"` // The region of the project the resource is located in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', @@ -8287,7 +9773,7 @@ type Job struct { // be applied and the arguments specified by the container image, will be used to start the container. RunArguments []string `json:"run_arguments" validate:"required"` - // The user ID (UID) to run the job (e.g., 1001). + // The user ID (UID) to run the job. RunAsUser *int64 `json:"run_as_user,omitempty"` // Set commands for the job that are passed to start job run containers. If not specified an empty string array will be @@ -8306,12 +9792,12 @@ type Job struct { // `reader`, and `writer`. This property must not be set on a job run, which references a job template. RunServiceAccount *string `json:"run_service_account,omitempty"` - // Optional mounts of config maps or a secrets. + // Optional mounts of config maps or secrets. RunVolumeMounts []VolumeMount `json:"run_volume_mounts" validate:"required"` - // Define a custom set of array indices as comma-separated list containing single values and hyphen-separated ranges - // like `5,12-14,23,27`. Each instance can pick up its array index via environment variable `JOB_INDEX`. The number of - // unique array indices specified here determines the number of job instances to run. + // Define a custom set of array indices as a comma-separated list containing single values and hyphen-separated ranges, + // such as 5,12-14,23,27. Each instance gets its array index value from the environment variable JOB_INDEX. The number + // of unique array indices that you specify with this parameter determines the number of job instances to run. ScaleArraySpec *string `json:"scale_array_spec" validate:"required"` // Optional amount of CPU set for the instance of the job. For valid values see [Supported memory and CPU @@ -8536,7 +10022,7 @@ type JobPatch struct { // be applied and the arguments specified by the container image, will be used to start the container. RunArguments []string `json:"run_arguments,omitempty"` - // The user ID (UID) to run the job (e.g., 1001). + // The user ID (UID) to run the job. RunAsUser *int64 `json:"run_as_user,omitempty"` // Set commands for the job that are passed to start job run containers. If not specified an empty string array will be @@ -8559,9 +10045,9 @@ type JobPatch struct { // overwritten. RunVolumeMounts []VolumeMountPrototype `json:"run_volume_mounts,omitempty"` - // Define a custom set of array indices as comma-separated list containing single values and hyphen-separated ranges - // like `5,12-14,23,27`. Each instance can pick up its array index via environment variable `JOB_INDEX`. The number of - // unique array indices specified here determines the number of job instances to run. + // Define a custom set of array indices as a comma-separated list containing single values and hyphen-separated ranges, + // such as 5,12-14,23,27. Each instance gets its array index value from the environment variable JOB_INDEX. The number + // of unique array indices that you specify with this parameter determines the number of job instances to run. ScaleArraySpec *string `json:"scale_array_spec,omitempty"` // Optional amount of CPU set for the instance of the job. For valid values see [Supported memory and CPU @@ -8716,7 +10202,7 @@ type JobRun struct { // The name of the job run. Name *string `json:"name,omitempty"` - // The ID of the project the resource is located in. + // The ID of the project in which the resource is located. ProjectID *string `json:"project_id,omitempty"` // The region of the project the resource is located in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', @@ -8730,7 +10216,7 @@ type JobRun struct { // be applied and the arguments specified by the container image, will be used to start the container. RunArguments []string `json:"run_arguments" validate:"required"` - // The user ID (UID) to run the job (e.g., 1001). + // The user ID (UID) to run the job. RunAsUser *int64 `json:"run_as_user,omitempty"` // Set commands for the job that are passed to start job run containers. If not specified an empty string array will be @@ -8749,15 +10235,15 @@ type JobRun struct { // `reader`, and `writer`. This property must not be set on a job run, which references a job template. RunServiceAccount *string `json:"run_service_account,omitempty"` - // Optional mounts of config maps or a secrets. + // Optional mounts of config maps or secrets. RunVolumeMounts []VolumeMount `json:"run_volume_mounts" validate:"required"` // Optional value to override the JOB_ARRAY_SIZE environment variable for a job run. ScaleArraySizeVariableOverride *int64 `json:"scale_array_size_variable_override,omitempty"` - // Define a custom set of array indices as comma-separated list containing single values and hyphen-separated ranges - // like `5,12-14,23,27`. Each instance can pick up its array index via environment variable `JOB_INDEX`. The number of - // unique array indices specified here determines the number of job instances to run. + // Define a custom set of array indices as a comma-separated list containing single values and hyphen-separated ranges, + // such as 5,12-14,23,27. Each instance gets its array index value from the environment variable JOB_INDEX. The number + // of unique array indices that you specify with this parameter determines the number of job instances to run. ScaleArraySpec *string `json:"scale_array_spec,omitempty"` // Optional amount of CPU set for the instance of the job. For valid values see [Supported memory and CPU @@ -9049,6 +10535,64 @@ func UnmarshalJobRunStatus(m map[string]json.RawMessage, result interface{}) (er return } +// ListAppInstancesOptions : The ListAppInstances options. +type ListAppInstancesOptions struct { + // The ID of the project. + ProjectID *string `json:"project_id" validate:"required,ne="` + + // The name of your application. + AppName *string `json:"app_name" validate:"required,ne="` + + // Optional maximum number of apps per page. + Limit *int64 `json:"limit,omitempty"` + + // An optional token that indicates the beginning of the page of results to be returned. If omitted, the first page of + // results is returned. This value is obtained from the 'start' query parameter in the `next` object of the operation + // response. + Start *string `json:"start,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewListAppInstancesOptions : Instantiate ListAppInstancesOptions +func (*CodeEngineV2) NewListAppInstancesOptions(projectID string, appName string) *ListAppInstancesOptions { + return &ListAppInstancesOptions{ + ProjectID: core.StringPtr(projectID), + AppName: core.StringPtr(appName), + } +} + +// SetProjectID : Allow user to set ProjectID +func (_options *ListAppInstancesOptions) SetProjectID(projectID string) *ListAppInstancesOptions { + _options.ProjectID = core.StringPtr(projectID) + return _options +} + +// SetAppName : Allow user to set AppName +func (_options *ListAppInstancesOptions) SetAppName(appName string) *ListAppInstancesOptions { + _options.AppName = core.StringPtr(appName) + return _options +} + +// SetLimit : Allow user to set Limit +func (_options *ListAppInstancesOptions) SetLimit(limit int64) *ListAppInstancesOptions { + _options.Limit = core.Int64Ptr(limit) + return _options +} + +// SetStart : Allow user to set Start +func (_options *ListAppInstancesOptions) SetStart(start string) *ListAppInstancesOptions { + _options.Start = core.StringPtr(start) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *ListAppInstancesOptions) SetHeaders(param map[string]string) *ListAppInstancesOptions { + options.Headers = param + return options +} + // ListAppRevisionsOptions : The ListAppRevisions options. type ListAppRevisionsOptions struct { // The ID of the project. @@ -9268,7 +10812,9 @@ type ListBuildsOptions struct { // Optional maximum number of builds per page. Limit *int64 `json:"limit,omitempty"` - // The token to continue traversing paginated list of builds. + // An optional token that indicates the beginning of the page of results to be returned. If omitted, the first page of + // results is returned. This value is obtained from the 'start' query parameter in the `next` object of the operation + // response. Start *string `json:"start,omitempty"` // Allows users to set headers on API requests @@ -9362,7 +10908,9 @@ type ListDomainMappingsOptions struct { // Optional maximum number of domain mappings per page. Limit *int64 `json:"limit,omitempty"` - // The token to continue traversing paginated list of domain mappings. + // An optional token that indicates the beginning of the page of results to be returned. If omitted, the first page of + // results is returned. This value is obtained from the 'start' query parameter in the `next` object of the operation + // response. Start *string `json:"start,omitempty"` // Allows users to set headers on API requests @@ -9417,12 +10965,78 @@ func UnmarshalListFirstMetadata(m map[string]json.RawMessage, result interface{} return } +// ListFunctionRuntimesOptions : The ListFunctionRuntimes options. +type ListFunctionRuntimesOptions struct { + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewListFunctionRuntimesOptions : Instantiate ListFunctionRuntimesOptions +func (*CodeEngineV2) NewListFunctionRuntimesOptions() *ListFunctionRuntimesOptions { + return &ListFunctionRuntimesOptions{} +} + +// SetHeaders : Allow user to set Headers +func (options *ListFunctionRuntimesOptions) SetHeaders(param map[string]string) *ListFunctionRuntimesOptions { + options.Headers = param + return options +} + +// ListFunctionsOptions : The ListFunctions options. +type ListFunctionsOptions struct { + // The ID of the project. + ProjectID *string `json:"project_id" validate:"required,ne="` + + // Optional maximum number of functions per page. + Limit *int64 `json:"limit,omitempty"` + + // An optional token that indicates the beginning of the page of results to be returned. If omitted, the first page of + // results is returned. This value is obtained from the 'start' query parameter in the 'next_url' field of the + // operation response. + Start *string `json:"start,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewListFunctionsOptions : Instantiate ListFunctionsOptions +func (*CodeEngineV2) NewListFunctionsOptions(projectID string) *ListFunctionsOptions { + return &ListFunctionsOptions{ + ProjectID: core.StringPtr(projectID), + } +} + +// SetProjectID : Allow user to set ProjectID +func (_options *ListFunctionsOptions) SetProjectID(projectID string) *ListFunctionsOptions { + _options.ProjectID = core.StringPtr(projectID) + return _options +} + +// SetLimit : Allow user to set Limit +func (_options *ListFunctionsOptions) SetLimit(limit int64) *ListFunctionsOptions { + _options.Limit = core.Int64Ptr(limit) + return _options +} + +// SetStart : Allow user to set Start +func (_options *ListFunctionsOptions) SetStart(start string) *ListFunctionsOptions { + _options.Start = core.StringPtr(start) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *ListFunctionsOptions) SetHeaders(param map[string]string) *ListFunctionsOptions { + options.Headers = param + return options +} + // ListJobRunsOptions : The ListJobRuns options. type ListJobRunsOptions struct { // The ID of the project. ProjectID *string `json:"project_id" validate:"required,ne="` - // Optional name of the job that should be filtered for. + // Optional name of the job that you want to use to filter. JobName *string `json:"job_name,omitempty"` // Optional maximum number of job runs per page. @@ -9669,7 +11283,7 @@ func UnmarshalOperatorSecretProps(m map[string]json.RawMessage, result interface return } -// OperatorSecretPrototypeProps : Properties for the IBM Cloud Operator Secret Prototype. +// OperatorSecretPrototypeProps : Properties for the IBM Cloud Operator Secrets. type OperatorSecretPrototypeProps struct { // The list of resource groups (by ID) that the operator secret can bind services in. ResourceGroupIds []string `json:"resource_group_ids,omitempty"` @@ -9857,8 +11471,8 @@ type Project struct { // The type of the project. ResourceType *string `json:"resource_type,omitempty"` - // The current state of the project. For example, if the project is created and ready to get used, it will return - // active. + // The current state of the project. For example, when the project is created and is ready for use, the status of the + // project is active. Status *string `json:"status,omitempty"` } @@ -9869,8 +11483,8 @@ const ( ) // Constants associated with the Project.Status property. -// The current state of the project. For example, if the project is created and ready to get used, it will return -// active. +// The current state of the project. For example, when the project is created and is ready for use, the status of the +// project is active. const ( Project_Status_Active = "active" Project_Status_Creating = "creating" @@ -10293,7 +11907,7 @@ type Secret struct { // The name of the secret. Name *string `json:"name" validate:"required"` - // The ID of the project the resource is located in. + // The ID of the project in which the resource is located. ProjectID *string `json:"project_id,omitempty"` // The region of the project the resource is located in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', @@ -10556,7 +12170,7 @@ type SecretList struct { // Describes properties needed to retrieve the next page of a result list. Next *ListNextMetadata `json:"next,omitempty"` - // List of Secrets. + // List of secrets. Secrets []Secret `json:"secrets" validate:"required"` } @@ -10629,7 +12243,7 @@ func UnmarshalServiceAccessSecretProps(m map[string]json.RawMessage, result inte return } -// ServiceAccessSecretPrototypeProps : Properties for Service Access Secret Prototypes. +// ServiceAccessSecretPrototypeProps : Properties for Service Access Secrets. type ServiceAccessSecretPrototypeProps struct { // The service credential associated with the secret. ResourceKey *ResourceKeyRefPrototype `json:"resource_key" validate:"required"` @@ -10845,96 +12459,156 @@ func (*CodeEngineV2) NewUpdateBuildOptions(projectID string, name string, ifMatc ProjectID: core.StringPtr(projectID), Name: core.StringPtr(name), IfMatch: core.StringPtr(ifMatch), - Build: build, + Build: build, + } +} + +// SetProjectID : Allow user to set ProjectID +func (_options *UpdateBuildOptions) SetProjectID(projectID string) *UpdateBuildOptions { + _options.ProjectID = core.StringPtr(projectID) + return _options +} + +// SetName : Allow user to set Name +func (_options *UpdateBuildOptions) SetName(name string) *UpdateBuildOptions { + _options.Name = core.StringPtr(name) + return _options +} + +// SetIfMatch : Allow user to set IfMatch +func (_options *UpdateBuildOptions) SetIfMatch(ifMatch string) *UpdateBuildOptions { + _options.IfMatch = core.StringPtr(ifMatch) + return _options +} + +// SetBuild : Allow user to set Build +func (_options *UpdateBuildOptions) SetBuild(build map[string]interface{}) *UpdateBuildOptions { + _options.Build = build + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *UpdateBuildOptions) SetHeaders(param map[string]string) *UpdateBuildOptions { + options.Headers = param + return options +} + +// UpdateDomainMappingOptions : The UpdateDomainMapping options. +type UpdateDomainMappingOptions struct { + // The ID of the project. + ProjectID *string `json:"project_id" validate:"required,ne="` + + // The name of your domain mapping. + Name *string `json:"name" validate:"required,ne="` + + // Version of the domain mapping to be updated. Specify the version that you retrieved as entity_tag (ETag header) when + // reading the domain mapping. This value helps identify parallel usage of this API. Pass * to indicate to update any + // version available. This might result in stale updates. + IfMatch *string `json:"If-Match" validate:"required"` + + // DomainMapping patch. + DomainMapping map[string]interface{} `json:"domain_mapping" validate:"required"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewUpdateDomainMappingOptions : Instantiate UpdateDomainMappingOptions +func (*CodeEngineV2) NewUpdateDomainMappingOptions(projectID string, name string, ifMatch string, domainMapping map[string]interface{}) *UpdateDomainMappingOptions { + return &UpdateDomainMappingOptions{ + ProjectID: core.StringPtr(projectID), + Name: core.StringPtr(name), + IfMatch: core.StringPtr(ifMatch), + DomainMapping: domainMapping, } } // SetProjectID : Allow user to set ProjectID -func (_options *UpdateBuildOptions) SetProjectID(projectID string) *UpdateBuildOptions { +func (_options *UpdateDomainMappingOptions) SetProjectID(projectID string) *UpdateDomainMappingOptions { _options.ProjectID = core.StringPtr(projectID) return _options } // SetName : Allow user to set Name -func (_options *UpdateBuildOptions) SetName(name string) *UpdateBuildOptions { +func (_options *UpdateDomainMappingOptions) SetName(name string) *UpdateDomainMappingOptions { _options.Name = core.StringPtr(name) return _options } // SetIfMatch : Allow user to set IfMatch -func (_options *UpdateBuildOptions) SetIfMatch(ifMatch string) *UpdateBuildOptions { +func (_options *UpdateDomainMappingOptions) SetIfMatch(ifMatch string) *UpdateDomainMappingOptions { _options.IfMatch = core.StringPtr(ifMatch) return _options } -// SetBuild : Allow user to set Build -func (_options *UpdateBuildOptions) SetBuild(build map[string]interface{}) *UpdateBuildOptions { - _options.Build = build +// SetDomainMapping : Allow user to set DomainMapping +func (_options *UpdateDomainMappingOptions) SetDomainMapping(domainMapping map[string]interface{}) *UpdateDomainMappingOptions { + _options.DomainMapping = domainMapping return _options } // SetHeaders : Allow user to set Headers -func (options *UpdateBuildOptions) SetHeaders(param map[string]string) *UpdateBuildOptions { +func (options *UpdateDomainMappingOptions) SetHeaders(param map[string]string) *UpdateDomainMappingOptions { options.Headers = param return options } -// UpdateDomainMappingOptions : The UpdateDomainMapping options. -type UpdateDomainMappingOptions struct { +// UpdateFunctionOptions : The UpdateFunction options. +type UpdateFunctionOptions struct { // The ID of the project. ProjectID *string `json:"project_id" validate:"required,ne="` - // The name of your domain mapping. + // The name of your function. Name *string `json:"name" validate:"required,ne="` - // Version of the domain mapping to be updated. Specify the version that you retrieved as entity_tag (ETag header) when - // reading the domain mapping. This value helps identify parallel usage of this API. Pass * to indicate to update any + // Version of the function settings to be updated. Specify the version that you retrieved as entity_tag (ETag header) + // when reading the function. This value helps identifying parallel usage of this API. Pass * to indicate to update any // version available. This might result in stale updates. IfMatch *string `json:"If-Match" validate:"required"` - // DomainMapping patch. - DomainMapping map[string]interface{} `json:"domain_mapping" validate:"required"` + // Function patch. + Function map[string]interface{} `json:"function" validate:"required"` // Allows users to set headers on API requests Headers map[string]string } -// NewUpdateDomainMappingOptions : Instantiate UpdateDomainMappingOptions -func (*CodeEngineV2) NewUpdateDomainMappingOptions(projectID string, name string, ifMatch string, domainMapping map[string]interface{}) *UpdateDomainMappingOptions { - return &UpdateDomainMappingOptions{ +// NewUpdateFunctionOptions : Instantiate UpdateFunctionOptions +func (*CodeEngineV2) NewUpdateFunctionOptions(projectID string, name string, ifMatch string, function map[string]interface{}) *UpdateFunctionOptions { + return &UpdateFunctionOptions{ ProjectID: core.StringPtr(projectID), Name: core.StringPtr(name), IfMatch: core.StringPtr(ifMatch), - DomainMapping: domainMapping, + Function: function, } } // SetProjectID : Allow user to set ProjectID -func (_options *UpdateDomainMappingOptions) SetProjectID(projectID string) *UpdateDomainMappingOptions { +func (_options *UpdateFunctionOptions) SetProjectID(projectID string) *UpdateFunctionOptions { _options.ProjectID = core.StringPtr(projectID) return _options } // SetName : Allow user to set Name -func (_options *UpdateDomainMappingOptions) SetName(name string) *UpdateDomainMappingOptions { +func (_options *UpdateFunctionOptions) SetName(name string) *UpdateFunctionOptions { _options.Name = core.StringPtr(name) return _options } // SetIfMatch : Allow user to set IfMatch -func (_options *UpdateDomainMappingOptions) SetIfMatch(ifMatch string) *UpdateDomainMappingOptions { +func (_options *UpdateFunctionOptions) SetIfMatch(ifMatch string) *UpdateFunctionOptions { _options.IfMatch = core.StringPtr(ifMatch) return _options } -// SetDomainMapping : Allow user to set DomainMapping -func (_options *UpdateDomainMappingOptions) SetDomainMapping(domainMapping map[string]interface{}) *UpdateDomainMappingOptions { - _options.DomainMapping = domainMapping +// SetFunction : Allow user to set Function +func (_options *UpdateFunctionOptions) SetFunction(function map[string]interface{}) *UpdateFunctionOptions { + _options.Function = function return _options } // SetHeaders : Allow user to set Headers -func (options *UpdateDomainMappingOptions) SetHeaders(param map[string]string) *UpdateDomainMappingOptions { +func (options *UpdateFunctionOptions) SetHeaders(param map[string]string) *UpdateFunctionOptions { options.Headers = param return options } @@ -11823,6 +13497,87 @@ func (pager *AppRevisionsPager) GetAll() (allItems []AppRevision, err error) { return pager.GetAllWithContext(context.Background()) } +// +// AppInstancesPager can be used to simplify the use of the "ListAppInstances" method. +// +type AppInstancesPager struct { + hasNext bool + options *ListAppInstancesOptions + client *CodeEngineV2 + pageContext struct { + next *string + } +} + +// NewAppInstancesPager returns a new AppInstancesPager instance. +func (codeEngine *CodeEngineV2) NewAppInstancesPager(options *ListAppInstancesOptions) (pager *AppInstancesPager, err error) { + if options.Start != nil && *options.Start != "" { + err = fmt.Errorf("the 'options.Start' field should not be set") + return + } + + var optionsCopy ListAppInstancesOptions = *options + pager = &AppInstancesPager{ + hasNext: true, + options: &optionsCopy, + client: codeEngine, + } + return +} + +// HasNext returns true if there are potentially more results to be retrieved. +func (pager *AppInstancesPager) HasNext() bool { + return pager.hasNext +} + +// GetNextWithContext returns the next page of results using the specified Context. +func (pager *AppInstancesPager) GetNextWithContext(ctx context.Context) (page []AppInstance, err error) { + if !pager.HasNext() { + return nil, fmt.Errorf("no more results available") + } + + pager.options.Start = pager.pageContext.next + + result, _, err := pager.client.ListAppInstancesWithContext(ctx, pager.options) + if err != nil { + return + } + + var next *string + if result.Next != nil { + next = result.Next.Start + } + pager.pageContext.next = next + pager.hasNext = (pager.pageContext.next != nil) + page = result.Instances + + return +} + +// GetAllWithContext returns all results by invoking GetNextWithContext() repeatedly +// until all pages of results have been retrieved. +func (pager *AppInstancesPager) GetAllWithContext(ctx context.Context) (allItems []AppInstance, err error) { + for pager.HasNext() { + var nextPage []AppInstance + nextPage, err = pager.GetNextWithContext(ctx) + if err != nil { + return + } + allItems = append(allItems, nextPage...) + } + return +} + +// GetNext invokes GetNextWithContext() using context.Background() as the Context parameter. +func (pager *AppInstancesPager) GetNext() (page []AppInstance, err error) { + return pager.GetNextWithContext(context.Background()) +} + +// GetAll invokes GetAllWithContext() using context.Background() as the Context parameter. +func (pager *AppInstancesPager) GetAll() (allItems []AppInstance, err error) { + return pager.GetAllWithContext(context.Background()) +} + // // JobsPager can be used to simplify the use of the "ListJobs" method. // @@ -11985,6 +13740,87 @@ func (pager *JobRunsPager) GetAll() (allItems []JobRun, err error) { return pager.GetAllWithContext(context.Background()) } +// +// FunctionsPager can be used to simplify the use of the "ListFunctions" method. +// +type FunctionsPager struct { + hasNext bool + options *ListFunctionsOptions + client *CodeEngineV2 + pageContext struct { + next *string + } +} + +// NewFunctionsPager returns a new FunctionsPager instance. +func (codeEngine *CodeEngineV2) NewFunctionsPager(options *ListFunctionsOptions) (pager *FunctionsPager, err error) { + if options.Start != nil && *options.Start != "" { + err = fmt.Errorf("the 'options.Start' field should not be set") + return + } + + var optionsCopy ListFunctionsOptions = *options + pager = &FunctionsPager{ + hasNext: true, + options: &optionsCopy, + client: codeEngine, + } + return +} + +// HasNext returns true if there are potentially more results to be retrieved. +func (pager *FunctionsPager) HasNext() bool { + return pager.hasNext +} + +// GetNextWithContext returns the next page of results using the specified Context. +func (pager *FunctionsPager) GetNextWithContext(ctx context.Context) (page []Function, err error) { + if !pager.HasNext() { + return nil, fmt.Errorf("no more results available") + } + + pager.options.Start = pager.pageContext.next + + result, _, err := pager.client.ListFunctionsWithContext(ctx, pager.options) + if err != nil { + return + } + + var next *string + if result.Next != nil { + next = result.Next.Start + } + pager.pageContext.next = next + pager.hasNext = (pager.pageContext.next != nil) + page = result.Functions + + return +} + +// GetAllWithContext returns all results by invoking GetNextWithContext() repeatedly +// until all pages of results have been retrieved. +func (pager *FunctionsPager) GetAllWithContext(ctx context.Context) (allItems []Function, err error) { + for pager.HasNext() { + var nextPage []Function + nextPage, err = pager.GetNextWithContext(ctx) + if err != nil { + return + } + allItems = append(allItems, nextPage...) + } + return +} + +// GetNext invokes GetNextWithContext() using context.Background() as the Context parameter. +func (pager *FunctionsPager) GetNext() (page []Function, err error) { + return pager.GetNextWithContext(context.Background()) +} + +// GetAll invokes GetAllWithContext() using context.Background() as the Context parameter. +func (pager *FunctionsPager) GetAll() (allItems []Function, err error) { + return pager.GetAllWithContext(context.Background()) +} + // // BindingsPager can be used to simplify the use of the "ListBindings" method. // @@ -12229,26 +14065,26 @@ func (pager *BuildRunsPager) GetAll() (allItems []BuildRun, err error) { } // -// ConfigMapsPager can be used to simplify the use of the "ListConfigMaps" method. +// DomainMappingsPager can be used to simplify the use of the "ListDomainMappings" method. // -type ConfigMapsPager struct { +type DomainMappingsPager struct { hasNext bool - options *ListConfigMapsOptions + options *ListDomainMappingsOptions client *CodeEngineV2 pageContext struct { next *string } } -// NewConfigMapsPager returns a new ConfigMapsPager instance. -func (codeEngine *CodeEngineV2) NewConfigMapsPager(options *ListConfigMapsOptions) (pager *ConfigMapsPager, err error) { +// NewDomainMappingsPager returns a new DomainMappingsPager instance. +func (codeEngine *CodeEngineV2) NewDomainMappingsPager(options *ListDomainMappingsOptions) (pager *DomainMappingsPager, err error) { if options.Start != nil && *options.Start != "" { err = fmt.Errorf("the 'options.Start' field should not be set") return } - var optionsCopy ListConfigMapsOptions = *options - pager = &ConfigMapsPager{ + var optionsCopy ListDomainMappingsOptions = *options + pager = &DomainMappingsPager{ hasNext: true, options: &optionsCopy, client: codeEngine, @@ -12257,19 +14093,19 @@ func (codeEngine *CodeEngineV2) NewConfigMapsPager(options *ListConfigMapsOption } // HasNext returns true if there are potentially more results to be retrieved. -func (pager *ConfigMapsPager) HasNext() bool { +func (pager *DomainMappingsPager) HasNext() bool { return pager.hasNext } // GetNextWithContext returns the next page of results using the specified Context. -func (pager *ConfigMapsPager) GetNextWithContext(ctx context.Context) (page []ConfigMap, err error) { +func (pager *DomainMappingsPager) GetNextWithContext(ctx context.Context) (page []DomainMapping, err error) { if !pager.HasNext() { return nil, fmt.Errorf("no more results available") } pager.options.Start = pager.pageContext.next - result, _, err := pager.client.ListConfigMapsWithContext(ctx, pager.options) + result, _, err := pager.client.ListDomainMappingsWithContext(ctx, pager.options) if err != nil { return } @@ -12280,16 +14116,16 @@ func (pager *ConfigMapsPager) GetNextWithContext(ctx context.Context) (page []Co } pager.pageContext.next = next pager.hasNext = (pager.pageContext.next != nil) - page = result.ConfigMaps + page = result.DomainMappings return } // GetAllWithContext returns all results by invoking GetNextWithContext() repeatedly // until all pages of results have been retrieved. -func (pager *ConfigMapsPager) GetAllWithContext(ctx context.Context) (allItems []ConfigMap, err error) { +func (pager *DomainMappingsPager) GetAllWithContext(ctx context.Context) (allItems []DomainMapping, err error) { for pager.HasNext() { - var nextPage []ConfigMap + var nextPage []DomainMapping nextPage, err = pager.GetNextWithContext(ctx) if err != nil { return @@ -12300,36 +14136,36 @@ func (pager *ConfigMapsPager) GetAllWithContext(ctx context.Context) (allItems [ } // GetNext invokes GetNextWithContext() using context.Background() as the Context parameter. -func (pager *ConfigMapsPager) GetNext() (page []ConfigMap, err error) { +func (pager *DomainMappingsPager) GetNext() (page []DomainMapping, err error) { return pager.GetNextWithContext(context.Background()) } // GetAll invokes GetAllWithContext() using context.Background() as the Context parameter. -func (pager *ConfigMapsPager) GetAll() (allItems []ConfigMap, err error) { +func (pager *DomainMappingsPager) GetAll() (allItems []DomainMapping, err error) { return pager.GetAllWithContext(context.Background()) } // -// SecretsPager can be used to simplify the use of the "ListSecrets" method. +// ConfigMapsPager can be used to simplify the use of the "ListConfigMaps" method. // -type SecretsPager struct { +type ConfigMapsPager struct { hasNext bool - options *ListSecretsOptions + options *ListConfigMapsOptions client *CodeEngineV2 pageContext struct { next *string } } -// NewSecretsPager returns a new SecretsPager instance. -func (codeEngine *CodeEngineV2) NewSecretsPager(options *ListSecretsOptions) (pager *SecretsPager, err error) { +// NewConfigMapsPager returns a new ConfigMapsPager instance. +func (codeEngine *CodeEngineV2) NewConfigMapsPager(options *ListConfigMapsOptions) (pager *ConfigMapsPager, err error) { if options.Start != nil && *options.Start != "" { err = fmt.Errorf("the 'options.Start' field should not be set") return } - var optionsCopy ListSecretsOptions = *options - pager = &SecretsPager{ + var optionsCopy ListConfigMapsOptions = *options + pager = &ConfigMapsPager{ hasNext: true, options: &optionsCopy, client: codeEngine, @@ -12338,19 +14174,19 @@ func (codeEngine *CodeEngineV2) NewSecretsPager(options *ListSecretsOptions) (pa } // HasNext returns true if there are potentially more results to be retrieved. -func (pager *SecretsPager) HasNext() bool { +func (pager *ConfigMapsPager) HasNext() bool { return pager.hasNext } // GetNextWithContext returns the next page of results using the specified Context. -func (pager *SecretsPager) GetNextWithContext(ctx context.Context) (page []Secret, err error) { +func (pager *ConfigMapsPager) GetNextWithContext(ctx context.Context) (page []ConfigMap, err error) { if !pager.HasNext() { return nil, fmt.Errorf("no more results available") } pager.options.Start = pager.pageContext.next - result, _, err := pager.client.ListSecretsWithContext(ctx, pager.options) + result, _, err := pager.client.ListConfigMapsWithContext(ctx, pager.options) if err != nil { return } @@ -12361,16 +14197,16 @@ func (pager *SecretsPager) GetNextWithContext(ctx context.Context) (page []Secre } pager.pageContext.next = next pager.hasNext = (pager.pageContext.next != nil) - page = result.Secrets + page = result.ConfigMaps return } // GetAllWithContext returns all results by invoking GetNextWithContext() repeatedly // until all pages of results have been retrieved. -func (pager *SecretsPager) GetAllWithContext(ctx context.Context) (allItems []Secret, err error) { +func (pager *ConfigMapsPager) GetAllWithContext(ctx context.Context) (allItems []ConfigMap, err error) { for pager.HasNext() { - var nextPage []Secret + var nextPage []ConfigMap nextPage, err = pager.GetNextWithContext(ctx) if err != nil { return @@ -12381,36 +14217,36 @@ func (pager *SecretsPager) GetAllWithContext(ctx context.Context) (allItems []Se } // GetNext invokes GetNextWithContext() using context.Background() as the Context parameter. -func (pager *SecretsPager) GetNext() (page []Secret, err error) { +func (pager *ConfigMapsPager) GetNext() (page []ConfigMap, err error) { return pager.GetNextWithContext(context.Background()) } // GetAll invokes GetAllWithContext() using context.Background() as the Context parameter. -func (pager *SecretsPager) GetAll() (allItems []Secret, err error) { +func (pager *ConfigMapsPager) GetAll() (allItems []ConfigMap, err error) { return pager.GetAllWithContext(context.Background()) } // -// DomainMappingsPager can be used to simplify the use of the "ListDomainMappings" method. +// SecretsPager can be used to simplify the use of the "ListSecrets" method. // -type DomainMappingsPager struct { +type SecretsPager struct { hasNext bool - options *ListDomainMappingsOptions + options *ListSecretsOptions client *CodeEngineV2 pageContext struct { next *string } } -// NewDomainMappingsPager returns a new DomainMappingsPager instance. -func (codeEngine *CodeEngineV2) NewDomainMappingsPager(options *ListDomainMappingsOptions) (pager *DomainMappingsPager, err error) { +// NewSecretsPager returns a new SecretsPager instance. +func (codeEngine *CodeEngineV2) NewSecretsPager(options *ListSecretsOptions) (pager *SecretsPager, err error) { if options.Start != nil && *options.Start != "" { err = fmt.Errorf("the 'options.Start' field should not be set") return } - var optionsCopy ListDomainMappingsOptions = *options - pager = &DomainMappingsPager{ + var optionsCopy ListSecretsOptions = *options + pager = &SecretsPager{ hasNext: true, options: &optionsCopy, client: codeEngine, @@ -12419,19 +14255,19 @@ func (codeEngine *CodeEngineV2) NewDomainMappingsPager(options *ListDomainMappin } // HasNext returns true if there are potentially more results to be retrieved. -func (pager *DomainMappingsPager) HasNext() bool { +func (pager *SecretsPager) HasNext() bool { return pager.hasNext } // GetNextWithContext returns the next page of results using the specified Context. -func (pager *DomainMappingsPager) GetNextWithContext(ctx context.Context) (page []DomainMapping, err error) { +func (pager *SecretsPager) GetNextWithContext(ctx context.Context) (page []Secret, err error) { if !pager.HasNext() { return nil, fmt.Errorf("no more results available") } pager.options.Start = pager.pageContext.next - result, _, err := pager.client.ListDomainMappingsWithContext(ctx, pager.options) + result, _, err := pager.client.ListSecretsWithContext(ctx, pager.options) if err != nil { return } @@ -12442,16 +14278,16 @@ func (pager *DomainMappingsPager) GetNextWithContext(ctx context.Context) (page } pager.pageContext.next = next pager.hasNext = (pager.pageContext.next != nil) - page = result.DomainMappings + page = result.Secrets return } // GetAllWithContext returns all results by invoking GetNextWithContext() repeatedly // until all pages of results have been retrieved. -func (pager *DomainMappingsPager) GetAllWithContext(ctx context.Context) (allItems []DomainMapping, err error) { +func (pager *SecretsPager) GetAllWithContext(ctx context.Context) (allItems []Secret, err error) { for pager.HasNext() { - var nextPage []DomainMapping + var nextPage []Secret nextPage, err = pager.GetNextWithContext(ctx) if err != nil { return @@ -12462,11 +14298,11 @@ func (pager *DomainMappingsPager) GetAllWithContext(ctx context.Context) (allIte } // GetNext invokes GetNextWithContext() using context.Background() as the Context parameter. -func (pager *DomainMappingsPager) GetNext() (page []DomainMapping, err error) { +func (pager *SecretsPager) GetNext() (page []Secret, err error) { return pager.GetNextWithContext(context.Background()) } // GetAll invokes GetAllWithContext() using context.Background() as the Context parameter. -func (pager *DomainMappingsPager) GetAll() (allItems []DomainMapping, err error) { +func (pager *SecretsPager) GetAll() (allItems []Secret, err error) { return pager.GetAllWithContext(context.Background()) } diff --git a/codeenginev2/code_engine_v2_examples_test.go b/codeenginev2/code_engine_v2_examples_test.go index 9e4bda8..cc55bf5 100644 --- a/codeenginev2/code_engine_v2_examples_test.go +++ b/codeenginev2/code_engine_v2_examples_test.go @@ -1,7 +1,7 @@ -// +build examples +//go:build examples /** - * (C) Copyright IBM Corp. 2023. + * (C) Copyright IBM Corp. 2024. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -358,6 +358,32 @@ var _ = Describe(`CodeEngineV2 Examples Tests`, func() { Expect(response.StatusCode).To(Equal(200)) Expect(appRevision).ToNot(BeNil()) }) + It(`ListAppInstances request example`, func() { + fmt.Println("\nListAppInstances() result:") + // begin-list_app_instances + listAppInstancesOptions := &codeenginev2.ListAppInstancesOptions{ + ProjectID: core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"), + AppName: core.StringPtr("my-app"), + Limit: core.Int64Ptr(int64(100)), + } + + pager, err := codeEngineService.NewAppInstancesPager(listAppInstancesOptions) + if err != nil { + panic(err) + } + + var allResults []codeenginev2.AppInstance + for pager.HasNext() { + nextPage, err := pager.GetNext() + if err != nil { + panic(err) + } + allResults = append(allResults, nextPage...) + } + b, _ := json.MarshalIndent(allResults, "", " ") + fmt.Println(string(b)) + // end-list_app_instances + }) It(`ListJobs request example`, func() { fmt.Println("\nListJobs() result:") // begin-list_jobs @@ -526,6 +552,125 @@ var _ = Describe(`CodeEngineV2 Examples Tests`, func() { Expect(response.StatusCode).To(Equal(200)) Expect(jobRun).ToNot(BeNil()) }) + It(`ListFunctionRuntimes request example`, func() { + fmt.Println("\nListFunctionRuntimes() result:") + // begin-list_function_runtimes + + listFunctionRuntimesOptions := codeEngineService.NewListFunctionRuntimesOptions() + + functionRuntimeList, response, err := codeEngineService.ListFunctionRuntimes(listFunctionRuntimesOptions) + if err != nil { + panic(err) + } + b, _ := json.MarshalIndent(functionRuntimeList, "", " ") + fmt.Println(string(b)) + + // end-list_function_runtimes + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(functionRuntimeList).ToNot(BeNil()) + }) + It(`ListFunctions request example`, func() { + fmt.Println("\nListFunctions() result:") + // begin-list_functions + listFunctionsOptions := &codeenginev2.ListFunctionsOptions{ + ProjectID: core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"), + Limit: core.Int64Ptr(int64(100)), + } + + pager, err := codeEngineService.NewFunctionsPager(listFunctionsOptions) + if err != nil { + panic(err) + } + + var allResults []codeenginev2.Function + for pager.HasNext() { + nextPage, err := pager.GetNext() + if err != nil { + panic(err) + } + allResults = append(allResults, nextPage...) + } + b, _ := json.MarshalIndent(allResults, "", " ") + fmt.Println(string(b)) + // end-list_functions + }) + It(`CreateFunction request example`, func() { + fmt.Println("\nCreateFunction() result:") + // begin-create_function + + createFunctionOptions := codeEngineService.NewCreateFunctionOptions( + "15314cc3-85b4-4338-903f-c28cdee6d005", + "data:text/plain;base64,", + "my-function", + "nodejs-18", + ) + + function, response, err := codeEngineService.CreateFunction(createFunctionOptions) + if err != nil { + panic(err) + } + b, _ := json.MarshalIndent(function, "", " ") + fmt.Println(string(b)) + + // end-create_function + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(201)) + Expect(function).ToNot(BeNil()) + }) + It(`GetFunction request example`, func() { + fmt.Println("\nGetFunction() result:") + // begin-get_function + + getFunctionOptions := codeEngineService.NewGetFunctionOptions( + "15314cc3-85b4-4338-903f-c28cdee6d005", + "my-function", + ) + + function, response, err := codeEngineService.GetFunction(getFunctionOptions) + if err != nil { + panic(err) + } + b, _ := json.MarshalIndent(function, "", " ") + fmt.Println(string(b)) + + // end-get_function + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(function).ToNot(BeNil()) + }) + It(`UpdateFunction request example`, func() { + fmt.Println("\nUpdateFunction() result:") + // begin-update_function + + functionPatchModel := &codeenginev2.FunctionPatch{ + } + functionPatchModelAsPatch, asPatchErr := functionPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + updateFunctionOptions := codeEngineService.NewUpdateFunctionOptions( + "15314cc3-85b4-4338-903f-c28cdee6d005", + "my-function", + "testString", + functionPatchModelAsPatch, + ) + + function, response, err := codeEngineService.UpdateFunction(updateFunctionOptions) + if err != nil { + panic(err) + } + b, _ := json.MarshalIndent(function, "", " ") + fmt.Println(string(b)) + + // end-update_function + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(function).ToNot(BeNil()) + }) It(`ListBindings request example`, func() { fmt.Println("\nListBindings() result:") // begin-list_bindings @@ -772,6 +917,111 @@ var _ = Describe(`CodeEngineV2 Examples Tests`, func() { Expect(response.StatusCode).To(Equal(200)) Expect(buildRun).ToNot(BeNil()) }) + It(`ListDomainMappings request example`, func() { + fmt.Println("\nListDomainMappings() result:") + // begin-list_domain_mappings + listDomainMappingsOptions := &codeenginev2.ListDomainMappingsOptions{ + ProjectID: core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"), + Limit: core.Int64Ptr(int64(100)), + } + + pager, err := codeEngineService.NewDomainMappingsPager(listDomainMappingsOptions) + if err != nil { + panic(err) + } + + var allResults []codeenginev2.DomainMapping + for pager.HasNext() { + nextPage, err := pager.GetNext() + if err != nil { + panic(err) + } + allResults = append(allResults, nextPage...) + } + b, _ := json.MarshalIndent(allResults, "", " ") + fmt.Println(string(b)) + // end-list_domain_mappings + }) + It(`CreateDomainMapping request example`, func() { + fmt.Println("\nCreateDomainMapping() result:") + // begin-create_domain_mapping + + componentRefModel := &codeenginev2.ComponentRef{ + Name: core.StringPtr("my-app-1"), + ResourceType: core.StringPtr("app_v2"), + } + + createDomainMappingOptions := codeEngineService.NewCreateDomainMappingOptions( + "15314cc3-85b4-4338-903f-c28cdee6d005", + componentRefModel, + "www.example.com", + "my-tls-secret", + ) + + domainMapping, response, err := codeEngineService.CreateDomainMapping(createDomainMappingOptions) + if err != nil { + panic(err) + } + b, _ := json.MarshalIndent(domainMapping, "", " ") + fmt.Println(string(b)) + + // end-create_domain_mapping + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(201)) + Expect(domainMapping).ToNot(BeNil()) + }) + It(`GetDomainMapping request example`, func() { + fmt.Println("\nGetDomainMapping() result:") + // begin-get_domain_mapping + + getDomainMappingOptions := codeEngineService.NewGetDomainMappingOptions( + "15314cc3-85b4-4338-903f-c28cdee6d005", + "www.example.com", + ) + + domainMapping, response, err := codeEngineService.GetDomainMapping(getDomainMappingOptions) + if err != nil { + panic(err) + } + b, _ := json.MarshalIndent(domainMapping, "", " ") + fmt.Println(string(b)) + + // end-get_domain_mapping + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(domainMapping).ToNot(BeNil()) + }) + It(`UpdateDomainMapping request example`, func() { + fmt.Println("\nUpdateDomainMapping() result:") + // begin-update_domain_mapping + + domainMappingPatchModel := &codeenginev2.DomainMappingPatch{ + } + domainMappingPatchModelAsPatch, asPatchErr := domainMappingPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + updateDomainMappingOptions := codeEngineService.NewUpdateDomainMappingOptions( + "15314cc3-85b4-4338-903f-c28cdee6d005", + "www.example.com", + "testString", + domainMappingPatchModelAsPatch, + ) + + domainMapping, response, err := codeEngineService.UpdateDomainMapping(updateDomainMappingOptions) + if err != nil { + panic(err) + } + b, _ := json.MarshalIndent(domainMapping, "", " ") + fmt.Println(string(b)) + + // end-update_domain_mapping + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(domainMapping).ToNot(BeNil()) + }) It(`ListConfigMaps request example`, func() { fmt.Println("\nListConfigMaps() result:") // begin-list_config_maps @@ -958,111 +1208,6 @@ var _ = Describe(`CodeEngineV2 Examples Tests`, func() { Expect(response.StatusCode).To(Equal(200)) Expect(secret).ToNot(BeNil()) }) - It(`ListDomainMappings request example`, func() { - fmt.Println("\nListDomainMappings() result:") - // begin-list_domain_mappings - listDomainMappingsOptions := &codeenginev2.ListDomainMappingsOptions{ - ProjectID: core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"), - Limit: core.Int64Ptr(int64(100)), - } - - pager, err := codeEngineService.NewDomainMappingsPager(listDomainMappingsOptions) - if err != nil { - panic(err) - } - - var allResults []codeenginev2.DomainMapping - for pager.HasNext() { - nextPage, err := pager.GetNext() - if err != nil { - panic(err) - } - allResults = append(allResults, nextPage...) - } - b, _ := json.MarshalIndent(allResults, "", " ") - fmt.Println(string(b)) - // end-list_domain_mappings - }) - It(`CreateDomainMapping request example`, func() { - fmt.Println("\nCreateDomainMapping() result:") - // begin-create_domain_mapping - - componentRefModel := &codeenginev2.ComponentRef{ - Name: core.StringPtr("my-app-1"), - ResourceType: core.StringPtr("app_v2"), - } - - createDomainMappingOptions := codeEngineService.NewCreateDomainMappingOptions( - "15314cc3-85b4-4338-903f-c28cdee6d005", - componentRefModel, - "www.example.com", - "my-tls-secret", - ) - - domainMapping, response, err := codeEngineService.CreateDomainMapping(createDomainMappingOptions) - if err != nil { - panic(err) - } - b, _ := json.MarshalIndent(domainMapping, "", " ") - fmt.Println(string(b)) - - // end-create_domain_mapping - - Expect(err).To(BeNil()) - Expect(response.StatusCode).To(Equal(201)) - Expect(domainMapping).ToNot(BeNil()) - }) - It(`GetDomainMapping request example`, func() { - fmt.Println("\nGetDomainMapping() result:") - // begin-get_domain_mapping - - getDomainMappingOptions := codeEngineService.NewGetDomainMappingOptions( - "15314cc3-85b4-4338-903f-c28cdee6d005", - "www.example.com", - ) - - domainMapping, response, err := codeEngineService.GetDomainMapping(getDomainMappingOptions) - if err != nil { - panic(err) - } - b, _ := json.MarshalIndent(domainMapping, "", " ") - fmt.Println(string(b)) - - // end-get_domain_mapping - - Expect(err).To(BeNil()) - Expect(response.StatusCode).To(Equal(200)) - Expect(domainMapping).ToNot(BeNil()) - }) - It(`UpdateDomainMapping request example`, func() { - fmt.Println("\nUpdateDomainMapping() result:") - // begin-update_domain_mapping - - domainMappingPatchModel := &codeenginev2.DomainMappingPatch{ - } - domainMappingPatchModelAsPatch, asPatchErr := domainMappingPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - updateDomainMappingOptions := codeEngineService.NewUpdateDomainMappingOptions( - "15314cc3-85b4-4338-903f-c28cdee6d005", - "www.example.com", - "testString", - domainMappingPatchModelAsPatch, - ) - - domainMapping, response, err := codeEngineService.UpdateDomainMapping(updateDomainMappingOptions) - if err != nil { - panic(err) - } - b, _ := json.MarshalIndent(domainMapping, "", " ") - fmt.Println(string(b)) - - // end-update_domain_mapping - - Expect(err).To(BeNil()) - Expect(response.StatusCode).To(Equal(200)) - Expect(domainMapping).ToNot(BeNil()) - }) It(`DeleteProject request example`, func() { // begin-delete_project @@ -1168,6 +1313,27 @@ var _ = Describe(`CodeEngineV2 Examples Tests`, func() { Expect(err).To(BeNil()) Expect(response.StatusCode).To(Equal(202)) }) + It(`DeleteFunction request example`, func() { + // begin-delete_function + + deleteFunctionOptions := codeEngineService.NewDeleteFunctionOptions( + "15314cc3-85b4-4338-903f-c28cdee6d005", + "my-function", + ) + + response, err := codeEngineService.DeleteFunction(deleteFunctionOptions) + if err != nil { + panic(err) + } + if response.StatusCode != 202 { + fmt.Printf("\nUnexpected response status code received from DeleteFunction(): %d\n", response.StatusCode) + } + + // end-delete_function + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(202)) + }) It(`DeleteBinding request example`, func() { // begin-delete_binding @@ -1231,65 +1397,65 @@ var _ = Describe(`CodeEngineV2 Examples Tests`, func() { Expect(err).To(BeNil()) Expect(response.StatusCode).To(Equal(202)) }) - It(`DeleteConfigMap request example`, func() { - // begin-delete_config_map + It(`DeleteDomainMapping request example`, func() { + // begin-delete_domain_mapping - deleteConfigMapOptions := codeEngineService.NewDeleteConfigMapOptions( + deleteDomainMappingOptions := codeEngineService.NewDeleteDomainMappingOptions( "15314cc3-85b4-4338-903f-c28cdee6d005", - "my-config-map", + "www.example.com", ) - response, err := codeEngineService.DeleteConfigMap(deleteConfigMapOptions) + response, err := codeEngineService.DeleteDomainMapping(deleteDomainMappingOptions) if err != nil { panic(err) } if response.StatusCode != 202 { - fmt.Printf("\nUnexpected response status code received from DeleteConfigMap(): %d\n", response.StatusCode) + fmt.Printf("\nUnexpected response status code received from DeleteDomainMapping(): %d\n", response.StatusCode) } - // end-delete_config_map + // end-delete_domain_mapping Expect(err).To(BeNil()) Expect(response.StatusCode).To(Equal(202)) }) - It(`DeleteSecret request example`, func() { - // begin-delete_secret + It(`DeleteConfigMap request example`, func() { + // begin-delete_config_map - deleteSecretOptions := codeEngineService.NewDeleteSecretOptions( + deleteConfigMapOptions := codeEngineService.NewDeleteConfigMapOptions( "15314cc3-85b4-4338-903f-c28cdee6d005", - "my-secret", + "my-config-map", ) - response, err := codeEngineService.DeleteSecret(deleteSecretOptions) + response, err := codeEngineService.DeleteConfigMap(deleteConfigMapOptions) if err != nil { panic(err) } if response.StatusCode != 202 { - fmt.Printf("\nUnexpected response status code received from DeleteSecret(): %d\n", response.StatusCode) + fmt.Printf("\nUnexpected response status code received from DeleteConfigMap(): %d\n", response.StatusCode) } - // end-delete_secret + // end-delete_config_map Expect(err).To(BeNil()) Expect(response.StatusCode).To(Equal(202)) }) - It(`DeleteDomainMapping request example`, func() { - // begin-delete_domain_mapping + It(`DeleteSecret request example`, func() { + // begin-delete_secret - deleteDomainMappingOptions := codeEngineService.NewDeleteDomainMappingOptions( + deleteSecretOptions := codeEngineService.NewDeleteSecretOptions( "15314cc3-85b4-4338-903f-c28cdee6d005", - "www.example.com", + "my-secret", ) - response, err := codeEngineService.DeleteDomainMapping(deleteDomainMappingOptions) + response, err := codeEngineService.DeleteSecret(deleteSecretOptions) if err != nil { panic(err) } if response.StatusCode != 202 { - fmt.Printf("\nUnexpected response status code received from DeleteDomainMapping(): %d\n", response.StatusCode) + fmt.Printf("\nUnexpected response status code received from DeleteSecret(): %d\n", response.StatusCode) } - // end-delete_domain_mapping + // end-delete_secret Expect(err).To(BeNil()) Expect(response.StatusCode).To(Equal(202)) diff --git a/codeenginev2/code_engine_v2_integration_test.go b/codeenginev2/code_engine_v2_integration_test.go index c5f9ba6..7d6d2a5 100644 --- a/codeenginev2/code_engine_v2_integration_test.go +++ b/codeenginev2/code_engine_v2_integration_test.go @@ -521,6 +521,72 @@ var _ = Describe(`CodeEngineV2 Integration Tests`, func() { }) }) + Describe(`ListAppInstances - List application instances`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`ListAppInstances(listAppInstancesOptions *ListAppInstancesOptions) with pagination`, func(){ + listAppInstancesOptions := &codeenginev2.ListAppInstancesOptions{ + ProjectID: core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"), + AppName: core.StringPtr("my-app"), + Limit: core.Int64Ptr(int64(100)), + Start: core.StringPtr("testString"), + } + + listAppInstancesOptions.Start = nil + listAppInstancesOptions.Limit = core.Int64Ptr(1) + + var allResults []codeenginev2.AppInstance + for { + appInstanceList, response, err := codeEngineService.ListAppInstances(listAppInstancesOptions) + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(appInstanceList).ToNot(BeNil()) + allResults = append(allResults, appInstanceList.Instances...) + + listAppInstancesOptions.Start, err = appInstanceList.GetNextStart() + Expect(err).To(BeNil()) + + if listAppInstancesOptions.Start == nil { + break + } + } + fmt.Fprintf(GinkgoWriter, "Retrieved a total of %d item(s) with pagination.\n", len(allResults)) + }) + It(`ListAppInstances(listAppInstancesOptions *ListAppInstancesOptions) using AppInstancesPager`, func(){ + listAppInstancesOptions := &codeenginev2.ListAppInstancesOptions{ + ProjectID: core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"), + AppName: core.StringPtr("my-app"), + Limit: core.Int64Ptr(int64(100)), + } + + // Test GetNext(). + pager, err := codeEngineService.NewAppInstancesPager(listAppInstancesOptions) + Expect(err).To(BeNil()) + Expect(pager).ToNot(BeNil()) + + var allResults []codeenginev2.AppInstance + for pager.HasNext() { + nextPage, err := pager.GetNext() + Expect(err).To(BeNil()) + Expect(nextPage).ToNot(BeNil()) + allResults = append(allResults, nextPage...) + } + + // Test GetAll(). + pager, err = codeEngineService.NewAppInstancesPager(listAppInstancesOptions) + Expect(err).To(BeNil()) + Expect(pager).ToNot(BeNil()) + + allItems, err := pager.GetAll() + Expect(err).To(BeNil()) + Expect(allItems).ToNot(BeNil()) + + Expect(len(allItems)).To(Equal(len(allResults))) + fmt.Fprintf(GinkgoWriter, "ListAppInstances() returned a total of %d item(s) using AppInstancesPager.\n", len(allResults)) + }) + }) + Describe(`ListJobs - List jobs`, func() { BeforeEach(func() { shouldSkipTest() @@ -838,6 +904,185 @@ var _ = Describe(`CodeEngineV2 Integration Tests`, func() { }) }) + Describe(`ListFunctionRuntimes - List the function runtimes`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`ListFunctionRuntimes(listFunctionRuntimesOptions *ListFunctionRuntimesOptions)`, func() { + listFunctionRuntimesOptions := &codeenginev2.ListFunctionRuntimesOptions{ + } + + functionRuntimeList, response, err := codeEngineService.ListFunctionRuntimes(listFunctionRuntimesOptions) + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(functionRuntimeList).ToNot(BeNil()) + }) + }) + + Describe(`ListFunctions - List functions`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`ListFunctions(listFunctionsOptions *ListFunctionsOptions) with pagination`, func(){ + listFunctionsOptions := &codeenginev2.ListFunctionsOptions{ + ProjectID: core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"), + Limit: core.Int64Ptr(int64(100)), + Start: core.StringPtr("testString"), + } + + listFunctionsOptions.Start = nil + listFunctionsOptions.Limit = core.Int64Ptr(1) + + var allResults []codeenginev2.Function + for { + functionList, response, err := codeEngineService.ListFunctions(listFunctionsOptions) + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(functionList).ToNot(BeNil()) + allResults = append(allResults, functionList.Functions...) + + listFunctionsOptions.Start, err = functionList.GetNextStart() + Expect(err).To(BeNil()) + + if listFunctionsOptions.Start == nil { + break + } + } + fmt.Fprintf(GinkgoWriter, "Retrieved a total of %d item(s) with pagination.\n", len(allResults)) + }) + It(`ListFunctions(listFunctionsOptions *ListFunctionsOptions) using FunctionsPager`, func(){ + listFunctionsOptions := &codeenginev2.ListFunctionsOptions{ + ProjectID: core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"), + Limit: core.Int64Ptr(int64(100)), + } + + // Test GetNext(). + pager, err := codeEngineService.NewFunctionsPager(listFunctionsOptions) + Expect(err).To(BeNil()) + Expect(pager).ToNot(BeNil()) + + var allResults []codeenginev2.Function + for pager.HasNext() { + nextPage, err := pager.GetNext() + Expect(err).To(BeNil()) + Expect(nextPage).ToNot(BeNil()) + allResults = append(allResults, nextPage...) + } + + // Test GetAll(). + pager, err = codeEngineService.NewFunctionsPager(listFunctionsOptions) + Expect(err).To(BeNil()) + Expect(pager).ToNot(BeNil()) + + allItems, err := pager.GetAll() + Expect(err).To(BeNil()) + Expect(allItems).ToNot(BeNil()) + + Expect(len(allItems)).To(Equal(len(allResults))) + fmt.Fprintf(GinkgoWriter, "ListFunctions() returned a total of %d item(s) using FunctionsPager.\n", len(allResults)) + }) + }) + + Describe(`CreateFunction - Create a function`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`CreateFunction(createFunctionOptions *CreateFunctionOptions)`, func() { + envVarPrototypeModel := &codeenginev2.EnvVarPrototype{ + Key: core.StringPtr("MY_VARIABLE"), + Name: core.StringPtr("SOME"), + Prefix: core.StringPtr("PREFIX_"), + Reference: core.StringPtr("my-secret"), + Type: core.StringPtr("literal"), + Value: core.StringPtr("VALUE"), + } + + createFunctionOptions := &codeenginev2.CreateFunctionOptions{ + ProjectID: core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"), + CodeReference: core.StringPtr("data:text/plain;base64,"), + Name: core.StringPtr("my-function"), + Runtime: core.StringPtr("nodejs-18"), + CodeBinary: core.BoolPtr(false), + CodeMain: core.StringPtr("main"), + CodeSecret: core.StringPtr("my-secret"), + ManagedDomainMappings: core.StringPtr("local_public"), + RunEnvVariables: []codeenginev2.EnvVarPrototype{*envVarPrototypeModel}, + ScaleConcurrency: core.Int64Ptr(int64(1)), + ScaleCpuLimit: core.StringPtr("1"), + ScaleDownDelay: core.Int64Ptr(int64(300)), + ScaleMaxExecutionTime: core.Int64Ptr(int64(60)), + ScaleMemoryLimit: core.StringPtr("1G"), + } + + function, response, err := codeEngineService.CreateFunction(createFunctionOptions) + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(201)) + Expect(function).ToNot(BeNil()) + }) + }) + + Describe(`GetFunction - Get a function`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`GetFunction(getFunctionOptions *GetFunctionOptions)`, func() { + getFunctionOptions := &codeenginev2.GetFunctionOptions{ + ProjectID: core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"), + Name: core.StringPtr("my-function"), + } + + function, response, err := codeEngineService.GetFunction(getFunctionOptions) + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(function).ToNot(BeNil()) + }) + }) + + Describe(`UpdateFunction - Update a function`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`UpdateFunction(updateFunctionOptions *UpdateFunctionOptions)`, func() { + envVarPrototypeModel := &codeenginev2.EnvVarPrototype{ + Key: core.StringPtr("MY_VARIABLE"), + Name: core.StringPtr("SOME"), + Prefix: core.StringPtr("PREFIX_"), + Reference: core.StringPtr("my-secret"), + Type: core.StringPtr("literal"), + Value: core.StringPtr("VALUE"), + } + + functionPatchModel := &codeenginev2.FunctionPatch{ + CodeBinary: core.BoolPtr(false), + CodeMain: core.StringPtr("main"), + CodeReference: core.StringPtr("data:text/plain;base64,"), + CodeSecret: core.StringPtr("my-secret"), + ManagedDomainMappings: core.StringPtr("local_public"), + RunEnvVariables: []codeenginev2.EnvVarPrototype{*envVarPrototypeModel}, + Runtime: core.StringPtr("nodejs-18"), + ScaleConcurrency: core.Int64Ptr(int64(1)), + ScaleCpuLimit: core.StringPtr("1"), + ScaleDownDelay: core.Int64Ptr(int64(300)), + ScaleMaxExecutionTime: core.Int64Ptr(int64(60)), + ScaleMemoryLimit: core.StringPtr("1G"), + } + functionPatchModelAsPatch, asPatchErr := functionPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + updateFunctionOptions := &codeenginev2.UpdateFunctionOptions{ + ProjectID: core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"), + Name: core.StringPtr("my-function"), + IfMatch: core.StringPtr("testString"), + Function: functionPatchModelAsPatch, + } + + function, response, err := codeEngineService.UpdateFunction(updateFunctionOptions) + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(function).ToNot(BeNil()) + }) + }) + Describe(`ListBindings - List bindings`, func() { BeforeEach(func() { shouldSkipTest() @@ -1200,6 +1445,142 @@ var _ = Describe(`CodeEngineV2 Integration Tests`, func() { }) }) + Describe(`ListDomainMappings - List domain mappings`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`ListDomainMappings(listDomainMappingsOptions *ListDomainMappingsOptions) with pagination`, func(){ + listDomainMappingsOptions := &codeenginev2.ListDomainMappingsOptions{ + ProjectID: core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"), + Limit: core.Int64Ptr(int64(100)), + Start: core.StringPtr("testString"), + } + + listDomainMappingsOptions.Start = nil + listDomainMappingsOptions.Limit = core.Int64Ptr(1) + + var allResults []codeenginev2.DomainMapping + for { + domainMappingList, response, err := codeEngineService.ListDomainMappings(listDomainMappingsOptions) + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(domainMappingList).ToNot(BeNil()) + allResults = append(allResults, domainMappingList.DomainMappings...) + + listDomainMappingsOptions.Start, err = domainMappingList.GetNextStart() + Expect(err).To(BeNil()) + + if listDomainMappingsOptions.Start == nil { + break + } + } + fmt.Fprintf(GinkgoWriter, "Retrieved a total of %d item(s) with pagination.\n", len(allResults)) + }) + It(`ListDomainMappings(listDomainMappingsOptions *ListDomainMappingsOptions) using DomainMappingsPager`, func(){ + listDomainMappingsOptions := &codeenginev2.ListDomainMappingsOptions{ + ProjectID: core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"), + Limit: core.Int64Ptr(int64(100)), + } + + // Test GetNext(). + pager, err := codeEngineService.NewDomainMappingsPager(listDomainMappingsOptions) + Expect(err).To(BeNil()) + Expect(pager).ToNot(BeNil()) + + var allResults []codeenginev2.DomainMapping + for pager.HasNext() { + nextPage, err := pager.GetNext() + Expect(err).To(BeNil()) + Expect(nextPage).ToNot(BeNil()) + allResults = append(allResults, nextPage...) + } + + // Test GetAll(). + pager, err = codeEngineService.NewDomainMappingsPager(listDomainMappingsOptions) + Expect(err).To(BeNil()) + Expect(pager).ToNot(BeNil()) + + allItems, err := pager.GetAll() + Expect(err).To(BeNil()) + Expect(allItems).ToNot(BeNil()) + + Expect(len(allItems)).To(Equal(len(allResults))) + fmt.Fprintf(GinkgoWriter, "ListDomainMappings() returned a total of %d item(s) using DomainMappingsPager.\n", len(allResults)) + }) + }) + + Describe(`CreateDomainMapping - Create a domain mapping`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`CreateDomainMapping(createDomainMappingOptions *CreateDomainMappingOptions)`, func() { + componentRefModel := &codeenginev2.ComponentRef{ + Name: core.StringPtr("my-app-1"), + ResourceType: core.StringPtr("app_v2"), + } + + createDomainMappingOptions := &codeenginev2.CreateDomainMappingOptions{ + ProjectID: core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"), + Component: componentRefModel, + Name: core.StringPtr("www.example.com"), + TlsSecret: core.StringPtr("my-tls-secret"), + } + + domainMapping, response, err := codeEngineService.CreateDomainMapping(createDomainMappingOptions) + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(201)) + Expect(domainMapping).ToNot(BeNil()) + }) + }) + + Describe(`GetDomainMapping - Get a domain mapping`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`GetDomainMapping(getDomainMappingOptions *GetDomainMappingOptions)`, func() { + getDomainMappingOptions := &codeenginev2.GetDomainMappingOptions{ + ProjectID: core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"), + Name: core.StringPtr("www.example.com"), + } + + domainMapping, response, err := codeEngineService.GetDomainMapping(getDomainMappingOptions) + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(domainMapping).ToNot(BeNil()) + }) + }) + + Describe(`UpdateDomainMapping - Update a domain mapping`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`UpdateDomainMapping(updateDomainMappingOptions *UpdateDomainMappingOptions)`, func() { + componentRefModel := &codeenginev2.ComponentRef{ + Name: core.StringPtr("my-app-1"), + ResourceType: core.StringPtr("app_v2"), + } + + domainMappingPatchModel := &codeenginev2.DomainMappingPatch{ + Component: componentRefModel, + TlsSecret: core.StringPtr("my-tls-secret"), + } + domainMappingPatchModelAsPatch, asPatchErr := domainMappingPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + updateDomainMappingOptions := &codeenginev2.UpdateDomainMappingOptions{ + ProjectID: core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"), + Name: core.StringPtr("www.example.com"), + IfMatch: core.StringPtr("testString"), + DomainMapping: domainMappingPatchModelAsPatch, + } + + domainMapping, response, err := codeEngineService.UpdateDomainMapping(updateDomainMappingOptions) + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(domainMapping).ToNot(BeNil()) + }) + }) + Describe(`ListConfigMaps - List config maps`, func() { BeforeEach(func() { shouldSkipTest() @@ -1485,142 +1866,6 @@ var _ = Describe(`CodeEngineV2 Integration Tests`, func() { }) }) - Describe(`ListDomainMappings - List domain mappings`, func() { - BeforeEach(func() { - shouldSkipTest() - }) - It(`ListDomainMappings(listDomainMappingsOptions *ListDomainMappingsOptions) with pagination`, func(){ - listDomainMappingsOptions := &codeenginev2.ListDomainMappingsOptions{ - ProjectID: core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"), - Limit: core.Int64Ptr(int64(100)), - Start: core.StringPtr("testString"), - } - - listDomainMappingsOptions.Start = nil - listDomainMappingsOptions.Limit = core.Int64Ptr(1) - - var allResults []codeenginev2.DomainMapping - for { - domainMappingList, response, err := codeEngineService.ListDomainMappings(listDomainMappingsOptions) - Expect(err).To(BeNil()) - Expect(response.StatusCode).To(Equal(200)) - Expect(domainMappingList).ToNot(BeNil()) - allResults = append(allResults, domainMappingList.DomainMappings...) - - listDomainMappingsOptions.Start, err = domainMappingList.GetNextStart() - Expect(err).To(BeNil()) - - if listDomainMappingsOptions.Start == nil { - break - } - } - fmt.Fprintf(GinkgoWriter, "Retrieved a total of %d item(s) with pagination.\n", len(allResults)) - }) - It(`ListDomainMappings(listDomainMappingsOptions *ListDomainMappingsOptions) using DomainMappingsPager`, func(){ - listDomainMappingsOptions := &codeenginev2.ListDomainMappingsOptions{ - ProjectID: core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"), - Limit: core.Int64Ptr(int64(100)), - } - - // Test GetNext(). - pager, err := codeEngineService.NewDomainMappingsPager(listDomainMappingsOptions) - Expect(err).To(BeNil()) - Expect(pager).ToNot(BeNil()) - - var allResults []codeenginev2.DomainMapping - for pager.HasNext() { - nextPage, err := pager.GetNext() - Expect(err).To(BeNil()) - Expect(nextPage).ToNot(BeNil()) - allResults = append(allResults, nextPage...) - } - - // Test GetAll(). - pager, err = codeEngineService.NewDomainMappingsPager(listDomainMappingsOptions) - Expect(err).To(BeNil()) - Expect(pager).ToNot(BeNil()) - - allItems, err := pager.GetAll() - Expect(err).To(BeNil()) - Expect(allItems).ToNot(BeNil()) - - Expect(len(allItems)).To(Equal(len(allResults))) - fmt.Fprintf(GinkgoWriter, "ListDomainMappings() returned a total of %d item(s) using DomainMappingsPager.\n", len(allResults)) - }) - }) - - Describe(`CreateDomainMapping - Create a domain mapping`, func() { - BeforeEach(func() { - shouldSkipTest() - }) - It(`CreateDomainMapping(createDomainMappingOptions *CreateDomainMappingOptions)`, func() { - componentRefModel := &codeenginev2.ComponentRef{ - Name: core.StringPtr("my-app-1"), - ResourceType: core.StringPtr("app_v2"), - } - - createDomainMappingOptions := &codeenginev2.CreateDomainMappingOptions{ - ProjectID: core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"), - Component: componentRefModel, - Name: core.StringPtr("www.example.com"), - TlsSecret: core.StringPtr("my-tls-secret"), - } - - domainMapping, response, err := codeEngineService.CreateDomainMapping(createDomainMappingOptions) - Expect(err).To(BeNil()) - Expect(response.StatusCode).To(Equal(201)) - Expect(domainMapping).ToNot(BeNil()) - }) - }) - - Describe(`GetDomainMapping - Get a domain mapping`, func() { - BeforeEach(func() { - shouldSkipTest() - }) - It(`GetDomainMapping(getDomainMappingOptions *GetDomainMappingOptions)`, func() { - getDomainMappingOptions := &codeenginev2.GetDomainMappingOptions{ - ProjectID: core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"), - Name: core.StringPtr("www.example.com"), - } - - domainMapping, response, err := codeEngineService.GetDomainMapping(getDomainMappingOptions) - Expect(err).To(BeNil()) - Expect(response.StatusCode).To(Equal(200)) - Expect(domainMapping).ToNot(BeNil()) - }) - }) - - Describe(`UpdateDomainMapping - Update a domain mapping`, func() { - BeforeEach(func() { - shouldSkipTest() - }) - It(`UpdateDomainMapping(updateDomainMappingOptions *UpdateDomainMappingOptions)`, func() { - componentRefModel := &codeenginev2.ComponentRef{ - Name: core.StringPtr("my-app-1"), - ResourceType: core.StringPtr("app_v2"), - } - - domainMappingPatchModel := &codeenginev2.DomainMappingPatch{ - Component: componentRefModel, - TlsSecret: core.StringPtr("my-tls-secret"), - } - domainMappingPatchModelAsPatch, asPatchErr := domainMappingPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - updateDomainMappingOptions := &codeenginev2.UpdateDomainMappingOptions{ - ProjectID: core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"), - Name: core.StringPtr("www.example.com"), - IfMatch: core.StringPtr("testString"), - DomainMapping: domainMappingPatchModelAsPatch, - } - - domainMapping, response, err := codeEngineService.UpdateDomainMapping(updateDomainMappingOptions) - Expect(err).To(BeNil()) - Expect(response.StatusCode).To(Equal(200)) - Expect(domainMapping).ToNot(BeNil()) - }) - }) - Describe(`DeleteProject - Delete a project`, func() { BeforeEach(func() { shouldSkipTest() @@ -1701,6 +1946,22 @@ var _ = Describe(`CodeEngineV2 Integration Tests`, func() { }) }) + Describe(`DeleteFunction - Delete a function`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`DeleteFunction(deleteFunctionOptions *DeleteFunctionOptions)`, func() { + deleteFunctionOptions := &codeenginev2.DeleteFunctionOptions{ + ProjectID: core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"), + Name: core.StringPtr("my-function"), + } + + response, err := codeEngineService.DeleteFunction(deleteFunctionOptions) + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(202)) + }) + }) + Describe(`DeleteBinding - Delete a binding`, func() { BeforeEach(func() { shouldSkipTest() @@ -1749,49 +2010,49 @@ var _ = Describe(`CodeEngineV2 Integration Tests`, func() { }) }) - Describe(`DeleteConfigMap - Delete a config map`, func() { + Describe(`DeleteDomainMapping - Delete a domain mapping`, func() { BeforeEach(func() { shouldSkipTest() }) - It(`DeleteConfigMap(deleteConfigMapOptions *DeleteConfigMapOptions)`, func() { - deleteConfigMapOptions := &codeenginev2.DeleteConfigMapOptions{ + It(`DeleteDomainMapping(deleteDomainMappingOptions *DeleteDomainMappingOptions)`, func() { + deleteDomainMappingOptions := &codeenginev2.DeleteDomainMappingOptions{ ProjectID: core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"), - Name: core.StringPtr("my-config-map"), + Name: core.StringPtr("www.example.com"), } - response, err := codeEngineService.DeleteConfigMap(deleteConfigMapOptions) + response, err := codeEngineService.DeleteDomainMapping(deleteDomainMappingOptions) Expect(err).To(BeNil()) Expect(response.StatusCode).To(Equal(202)) }) }) - Describe(`DeleteSecret - Delete a secret`, func() { + Describe(`DeleteConfigMap - Delete a config map`, func() { BeforeEach(func() { shouldSkipTest() }) - It(`DeleteSecret(deleteSecretOptions *DeleteSecretOptions)`, func() { - deleteSecretOptions := &codeenginev2.DeleteSecretOptions{ + It(`DeleteConfigMap(deleteConfigMapOptions *DeleteConfigMapOptions)`, func() { + deleteConfigMapOptions := &codeenginev2.DeleteConfigMapOptions{ ProjectID: core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"), - Name: core.StringPtr("my-secret"), + Name: core.StringPtr("my-config-map"), } - response, err := codeEngineService.DeleteSecret(deleteSecretOptions) + response, err := codeEngineService.DeleteConfigMap(deleteConfigMapOptions) Expect(err).To(BeNil()) Expect(response.StatusCode).To(Equal(202)) }) }) - Describe(`DeleteDomainMapping - Delete a domain mapping`, func() { + Describe(`DeleteSecret - Delete a secret`, func() { BeforeEach(func() { shouldSkipTest() }) - It(`DeleteDomainMapping(deleteDomainMappingOptions *DeleteDomainMappingOptions)`, func() { - deleteDomainMappingOptions := &codeenginev2.DeleteDomainMappingOptions{ + It(`DeleteSecret(deleteSecretOptions *DeleteSecretOptions)`, func() { + deleteSecretOptions := &codeenginev2.DeleteSecretOptions{ ProjectID: core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"), - Name: core.StringPtr("www.example.com"), + Name: core.StringPtr("my-secret"), } - response, err := codeEngineService.DeleteDomainMapping(deleteDomainMappingOptions) + response, err := codeEngineService.DeleteSecret(deleteSecretOptions) Expect(err).To(BeNil()) Expect(response.StatusCode).To(Equal(202)) }) diff --git a/codeenginev2/code_engine_v2_test.go b/codeenginev2/code_engine_v2_test.go index 6f81559..b066dac 100644 --- a/codeenginev2/code_engine_v2_test.go +++ b/codeenginev2/code_engine_v2_test.go @@ -19,6 +19,7 @@ package codeenginev2_test import ( "bytes" "context" + "encoding/json" "fmt" "io" "net/http" @@ -3671,6 +3672,332 @@ var _ = Describe(`CodeEngineV2`, func() { }) }) }) + Describe(`ListAppInstances(listAppInstancesOptions *ListAppInstancesOptions) - Operation response error`, func() { + listAppInstancesPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/apps/my-app/instances" + Context(`Using mock server endpoint with invalid JSON response`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listAppInstancesPath)) + Expect(req.Method).To(Equal("GET")) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(100))})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke ListAppInstances with error: Operation response processing error`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + + // Construct an instance of the ListAppInstancesOptions model + listAppInstancesOptionsModel := new(codeenginev2.ListAppInstancesOptions) + listAppInstancesOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + listAppInstancesOptionsModel.AppName = core.StringPtr("my-app") + listAppInstancesOptionsModel.Limit = core.Int64Ptr(int64(100)) + listAppInstancesOptionsModel.Start = core.StringPtr("testString") + listAppInstancesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := codeEngineService.ListAppInstances(listAppInstancesOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + codeEngineService.EnableRetries(0, 0) + result, response, operationErr = codeEngineService.ListAppInstances(listAppInstancesOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`ListAppInstances(listAppInstancesOptions *ListAppInstancesOptions)`, func() { + listAppInstancesPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/apps/my-app/instances" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listAppInstancesPath)) + Expect(req.Method).To(Equal("GET")) + + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(100))})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"first": {"href": "Href"}, "instances": [{"app_name": "my-app", "created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app/instances", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-app-00001-deployment-6c9b5cf966-wjs44", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "app_instance_v2", "restarts": 4, "revision_name": "my-app", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_memory_limit": "4G", "status": "pending", "system_container": {"current_state": {"completed_at": "2022-09-22T17:40:00Z", "container_status": "ContainerStatus", "exit_code": 100, "reason": "ready", "started_at": "2022-09-22T17:34:00Z"}, "last_observed_state": {"completed_at": "2022-09-22T17:40:00Z", "container_status": "ContainerStatus", "exit_code": 100, "reason": "ready", "started_at": "2022-09-22T17:34:00Z"}}, "user_container": {"current_state": {"completed_at": "2022-09-22T17:40:00Z", "container_status": "ContainerStatus", "exit_code": 100, "reason": "ready", "started_at": "2022-09-22T17:34:00Z"}, "last_observed_state": {"completed_at": "2022-09-22T17:40:00Z", "container_status": "ContainerStatus", "exit_code": 100, "reason": "ready", "started_at": "2022-09-22T17:34:00Z"}}}], "limit": 100, "next": {"href": "Href", "start": "Start"}}`) + })) + }) + It(`Invoke ListAppInstances successfully with retries`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + codeEngineService.EnableRetries(0, 0) + + // Construct an instance of the ListAppInstancesOptions model + listAppInstancesOptionsModel := new(codeenginev2.ListAppInstancesOptions) + listAppInstancesOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + listAppInstancesOptionsModel.AppName = core.StringPtr("my-app") + listAppInstancesOptionsModel.Limit = core.Int64Ptr(int64(100)) + listAppInstancesOptionsModel.Start = core.StringPtr("testString") + listAppInstancesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := codeEngineService.ListAppInstancesWithContext(ctx, listAppInstancesOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + codeEngineService.DisableRetries() + result, response, operationErr := codeEngineService.ListAppInstances(listAppInstancesOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = codeEngineService.ListAppInstancesWithContext(ctx, listAppInstancesOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listAppInstancesPath)) + Expect(req.Method).To(Equal("GET")) + + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(100))})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"first": {"href": "Href"}, "instances": [{"app_name": "my-app", "created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app/instances", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-app-00001-deployment-6c9b5cf966-wjs44", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "app_instance_v2", "restarts": 4, "revision_name": "my-app", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_memory_limit": "4G", "status": "pending", "system_container": {"current_state": {"completed_at": "2022-09-22T17:40:00Z", "container_status": "ContainerStatus", "exit_code": 100, "reason": "ready", "started_at": "2022-09-22T17:34:00Z"}, "last_observed_state": {"completed_at": "2022-09-22T17:40:00Z", "container_status": "ContainerStatus", "exit_code": 100, "reason": "ready", "started_at": "2022-09-22T17:34:00Z"}}, "user_container": {"current_state": {"completed_at": "2022-09-22T17:40:00Z", "container_status": "ContainerStatus", "exit_code": 100, "reason": "ready", "started_at": "2022-09-22T17:34:00Z"}, "last_observed_state": {"completed_at": "2022-09-22T17:40:00Z", "container_status": "ContainerStatus", "exit_code": 100, "reason": "ready", "started_at": "2022-09-22T17:34:00Z"}}}], "limit": 100, "next": {"href": "Href", "start": "Start"}}`) + })) + }) + It(`Invoke ListAppInstances successfully`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := codeEngineService.ListAppInstances(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the ListAppInstancesOptions model + listAppInstancesOptionsModel := new(codeenginev2.ListAppInstancesOptions) + listAppInstancesOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + listAppInstancesOptionsModel.AppName = core.StringPtr("my-app") + listAppInstancesOptionsModel.Limit = core.Int64Ptr(int64(100)) + listAppInstancesOptionsModel.Start = core.StringPtr("testString") + listAppInstancesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = codeEngineService.ListAppInstances(listAppInstancesOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke ListAppInstances with error: Operation validation and request error`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + + // Construct an instance of the ListAppInstancesOptions model + listAppInstancesOptionsModel := new(codeenginev2.ListAppInstancesOptions) + listAppInstancesOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + listAppInstancesOptionsModel.AppName = core.StringPtr("my-app") + listAppInstancesOptionsModel.Limit = core.Int64Ptr(int64(100)) + listAppInstancesOptionsModel.Start = core.StringPtr("testString") + listAppInstancesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := codeEngineService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := codeEngineService.ListAppInstances(listAppInstancesOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + // Construct a second instance of the ListAppInstancesOptions model with no property values + listAppInstancesOptionsModelNew := new(codeenginev2.ListAppInstancesOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = codeEngineService.ListAppInstances(listAppInstancesOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(200) + })) + }) + It(`Invoke ListAppInstances successfully`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + + // Construct an instance of the ListAppInstancesOptions model + listAppInstancesOptionsModel := new(codeenginev2.ListAppInstancesOptions) + listAppInstancesOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + listAppInstancesOptionsModel.AppName = core.StringPtr("my-app") + listAppInstancesOptionsModel.Limit = core.Int64Ptr(int64(100)) + listAppInstancesOptionsModel.Start = core.StringPtr("testString") + listAppInstancesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := codeEngineService.ListAppInstances(listAppInstancesOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Test pagination helper method on response`, func() { + It(`Invoke GetNextStart successfully`, func() { + responseObject := new(codeenginev2.AppInstanceList) + nextObject := new(codeenginev2.ListNextMetadata) + nextObject.Start = core.StringPtr("abc-123") + responseObject.Next = nextObject + + value, err := responseObject.GetNextStart() + Expect(err).To(BeNil()) + Expect(value).To(Equal(core.StringPtr("abc-123"))) + }) + It(`Invoke GetNextStart without a "Next" property in the response`, func() { + responseObject := new(codeenginev2.AppInstanceList) + + value, err := responseObject.GetNextStart() + Expect(err).To(BeNil()) + Expect(value).To(BeNil()) + }) + }) + Context(`Using mock server endpoint - paginated response`, func() { + BeforeEach(func() { + var requestNumber int = 0 + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listAppInstancesPath)) + Expect(req.Method).To(Equal("GET")) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + requestNumber++ + if requestNumber == 1 { + fmt.Fprintf(res, "%s", `{"next":{"start":"1"},"instances":[{"app_name":"my-app","created_at":"2022-09-13T11:41:35+02:00","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app/instances","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-app-00001-deployment-6c9b5cf966-wjs44","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"app_instance_v2","restarts":4,"revision_name":"my-app","scale_cpu_limit":"1","scale_ephemeral_storage_limit":"4G","scale_memory_limit":"4G","status":"pending","system_container":{"current_state":{"completed_at":"2022-09-22T17:40:00Z","container_status":"ContainerStatus","exit_code":100,"reason":"ready","started_at":"2022-09-22T17:34:00Z"},"last_observed_state":{"completed_at":"2022-09-22T17:40:00Z","container_status":"ContainerStatus","exit_code":100,"reason":"ready","started_at":"2022-09-22T17:34:00Z"}},"user_container":{"current_state":{"completed_at":"2022-09-22T17:40:00Z","container_status":"ContainerStatus","exit_code":100,"reason":"ready","started_at":"2022-09-22T17:34:00Z"},"last_observed_state":{"completed_at":"2022-09-22T17:40:00Z","container_status":"ContainerStatus","exit_code":100,"reason":"ready","started_at":"2022-09-22T17:34:00Z"}}}],"total_count":2,"limit":1}`) + } else if requestNumber == 2 { + fmt.Fprintf(res, "%s", `{"instances":[{"app_name":"my-app","created_at":"2022-09-13T11:41:35+02:00","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app/instances","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-app-00001-deployment-6c9b5cf966-wjs44","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"app_instance_v2","restarts":4,"revision_name":"my-app","scale_cpu_limit":"1","scale_ephemeral_storage_limit":"4G","scale_memory_limit":"4G","status":"pending","system_container":{"current_state":{"completed_at":"2022-09-22T17:40:00Z","container_status":"ContainerStatus","exit_code":100,"reason":"ready","started_at":"2022-09-22T17:34:00Z"},"last_observed_state":{"completed_at":"2022-09-22T17:40:00Z","container_status":"ContainerStatus","exit_code":100,"reason":"ready","started_at":"2022-09-22T17:34:00Z"}},"user_container":{"current_state":{"completed_at":"2022-09-22T17:40:00Z","container_status":"ContainerStatus","exit_code":100,"reason":"ready","started_at":"2022-09-22T17:34:00Z"},"last_observed_state":{"completed_at":"2022-09-22T17:40:00Z","container_status":"ContainerStatus","exit_code":100,"reason":"ready","started_at":"2022-09-22T17:34:00Z"}}}],"total_count":2,"limit":1}`) + } else { + res.WriteHeader(400) + } + })) + }) + It(`Use AppInstancesPager.GetNext successfully`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + + listAppInstancesOptionsModel := &codeenginev2.ListAppInstancesOptions{ + ProjectID: core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"), + AppName: core.StringPtr("my-app"), + Limit: core.Int64Ptr(int64(100)), + } + + pager, err := codeEngineService.NewAppInstancesPager(listAppInstancesOptionsModel) + Expect(err).To(BeNil()) + Expect(pager).ToNot(BeNil()) + + var allResults []codeenginev2.AppInstance + for pager.HasNext() { + nextPage, err := pager.GetNext() + Expect(err).To(BeNil()) + Expect(nextPage).ToNot(BeNil()) + allResults = append(allResults, nextPage...) + } + Expect(len(allResults)).To(Equal(2)) + }) + It(`Use AppInstancesPager.GetAll successfully`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + + listAppInstancesOptionsModel := &codeenginev2.ListAppInstancesOptions{ + ProjectID: core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"), + AppName: core.StringPtr("my-app"), + Limit: core.Int64Ptr(int64(100)), + } + + pager, err := codeEngineService.NewAppInstancesPager(listAppInstancesOptionsModel) + Expect(err).To(BeNil()) + Expect(pager).ToNot(BeNil()) + + allResults, err := pager.GetAll() + Expect(err).To(BeNil()) + Expect(allResults).ToNot(BeNil()) + Expect(len(allResults)).To(Equal(2)) + }) + }) + }) Describe(`ListJobs(listJobsOptions *ListJobsOptions) - Operation response error`, func() { listJobsPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/jobs" Context(`Using mock server endpoint with invalid JSON response`, func() { @@ -6156,15 +6483,215 @@ var _ = Describe(`CodeEngineV2`, func() { }) }) }) - Describe(`ListBindings(listBindingsOptions *ListBindingsOptions) - Operation response error`, func() { - listBindingsPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/bindings" + Describe(`ListFunctionRuntimes(listFunctionRuntimesOptions *ListFunctionRuntimesOptions) - Operation response error`, func() { + listFunctionRuntimesPath := "/function_runtimes" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listBindingsPath)) + Expect(req.URL.EscapedPath()).To(Equal(listFunctionRuntimesPath)) + Expect(req.Method).To(Equal("GET")) + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke ListFunctionRuntimes with error: Operation response processing error`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + + // Construct an instance of the ListFunctionRuntimesOptions model + listFunctionRuntimesOptionsModel := new(codeenginev2.ListFunctionRuntimesOptions) + listFunctionRuntimesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := codeEngineService.ListFunctionRuntimes(listFunctionRuntimesOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + codeEngineService.EnableRetries(0, 0) + result, response, operationErr = codeEngineService.ListFunctionRuntimes(listFunctionRuntimesOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`ListFunctionRuntimes(listFunctionRuntimesOptions *ListFunctionRuntimesOptions)`, func() { + listFunctionRuntimesPath := "/function_runtimes" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listFunctionRuntimesPath)) + Expect(req.Method).To(Equal("GET")) + + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"function_runtimes": [{"default": true, "deprecated": false, "family": "nodejs", "id": "nodejs-18", "name": "Node.js 18", "optimized": true}]}`) + })) + }) + It(`Invoke ListFunctionRuntimes successfully with retries`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + codeEngineService.EnableRetries(0, 0) + + // Construct an instance of the ListFunctionRuntimesOptions model + listFunctionRuntimesOptionsModel := new(codeenginev2.ListFunctionRuntimesOptions) + listFunctionRuntimesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := codeEngineService.ListFunctionRuntimesWithContext(ctx, listFunctionRuntimesOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + codeEngineService.DisableRetries() + result, response, operationErr := codeEngineService.ListFunctionRuntimes(listFunctionRuntimesOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = codeEngineService.ListFunctionRuntimesWithContext(ctx, listFunctionRuntimesOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listFunctionRuntimesPath)) + Expect(req.Method).To(Equal("GET")) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"function_runtimes": [{"default": true, "deprecated": false, "family": "nodejs", "id": "nodejs-18", "name": "Node.js 18", "optimized": true}]}`) + })) + }) + It(`Invoke ListFunctionRuntimes successfully`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := codeEngineService.ListFunctionRuntimes(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the ListFunctionRuntimesOptions model + listFunctionRuntimesOptionsModel := new(codeenginev2.ListFunctionRuntimesOptions) + listFunctionRuntimesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = codeEngineService.ListFunctionRuntimes(listFunctionRuntimesOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke ListFunctionRuntimes with error: Operation request error`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + + // Construct an instance of the ListFunctionRuntimesOptions model + listFunctionRuntimesOptionsModel := new(codeenginev2.ListFunctionRuntimesOptions) + listFunctionRuntimesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := codeEngineService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := codeEngineService.ListFunctionRuntimes(listFunctionRuntimesOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(200) + })) + }) + It(`Invoke ListFunctionRuntimes successfully`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + + // Construct an instance of the ListFunctionRuntimesOptions model + listFunctionRuntimesOptionsModel := new(codeenginev2.ListFunctionRuntimesOptions) + listFunctionRuntimesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := codeEngineService.ListFunctionRuntimes(listFunctionRuntimesOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`ListFunctions(listFunctionsOptions *ListFunctionsOptions) - Operation response error`, func() { + listFunctionsPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/functions" + Context(`Using mock server endpoint with invalid JSON response`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listFunctionsPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(100))})) Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) @@ -6173,7 +6700,7 @@ var _ = Describe(`CodeEngineV2`, func() { fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke ListBindings with error: Operation response processing error`, func() { + It(`Invoke ListFunctions with error: Operation response processing error`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -6181,21 +6708,21 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the ListBindingsOptions model - listBindingsOptionsModel := new(codeenginev2.ListBindingsOptions) - listBindingsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - listBindingsOptionsModel.Limit = core.Int64Ptr(int64(100)) - listBindingsOptionsModel.Start = core.StringPtr("testString") - listBindingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListFunctionsOptions model + listFunctionsOptionsModel := new(codeenginev2.ListFunctionsOptions) + listFunctionsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + listFunctionsOptionsModel.Limit = core.Int64Ptr(int64(100)) + listFunctionsOptionsModel.Start = core.StringPtr("testString") + listFunctionsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := codeEngineService.ListBindings(listBindingsOptionsModel) + result, response, operationErr := codeEngineService.ListFunctions(listFunctionsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again codeEngineService.EnableRetries(0, 0) - result, response, operationErr = codeEngineService.ListBindings(listBindingsOptionsModel) + result, response, operationErr = codeEngineService.ListFunctions(listFunctionsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -6205,15 +6732,15 @@ var _ = Describe(`CodeEngineV2`, func() { }) }) }) - Describe(`ListBindings(listBindingsOptions *ListBindingsOptions)`, func() { - listBindingsPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/bindings" + Describe(`ListFunctions(listFunctionsOptions *ListFunctionsOptions)`, func() { + listFunctionsPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/functions" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listBindingsPath)) + Expect(req.URL.EscapedPath()).To(Equal(listFunctionsPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(100))})) @@ -6224,10 +6751,10 @@ var _ = Describe(`CodeEngineV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"bindings": [{"component": {"name": "my-app-1", "resource_type": "app_v2"}, "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/bindings/my-binding", "id": "a172ced-b5f21bc-71ba50c-1638604", "prefix": "MY_COS", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "binding_v2", "secret_name": "my-service-access", "status": "active"}], "first": {"href": "Href"}, "limit": 100, "next": {"href": "Href", "start": "Start"}}`) + fmt.Fprintf(res, "%s", `{"first": {"href": "Href"}, "functions": [{"code_binary": false, "code_main": "main", "code_reference": "data:text/plain;base64,", "code_secret": "my-secret", "created_at": "2022-09-13T11:41:35+02:00", "endpoint": "https://my-function.vg67hzldruk.eu-de.codeengine.appdomain.cloud", "endpoint_internal": "http://my-function.vg67hzldruk.svc.cluster.local", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/functions/my-function", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "managed_domain_mappings": "local_public", "name": "my-function", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "function_v2", "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "runtime": "nodejs-18", "scale_concurrency": 1, "scale_cpu_limit": "1", "scale_down_delay": 300, "scale_max_execution_time": 60, "scale_memory_limit": "1G", "status": "offline", "status_details": {"reason": "offline"}}], "limit": 100, "next": {"href": "Href", "start": "Start"}}`) })) }) - It(`Invoke ListBindings successfully with retries`, func() { + It(`Invoke ListFunctions successfully with retries`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -6236,23 +6763,23 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(codeEngineService).ToNot(BeNil()) codeEngineService.EnableRetries(0, 0) - // Construct an instance of the ListBindingsOptions model - listBindingsOptionsModel := new(codeenginev2.ListBindingsOptions) - listBindingsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - listBindingsOptionsModel.Limit = core.Int64Ptr(int64(100)) - listBindingsOptionsModel.Start = core.StringPtr("testString") - listBindingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListFunctionsOptions model + listFunctionsOptionsModel := new(codeenginev2.ListFunctionsOptions) + listFunctionsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + listFunctionsOptionsModel.Limit = core.Int64Ptr(int64(100)) + listFunctionsOptionsModel.Start = core.StringPtr("testString") + listFunctionsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := codeEngineService.ListBindingsWithContext(ctx, listBindingsOptionsModel) + _, _, operationErr := codeEngineService.ListFunctionsWithContext(ctx, listFunctionsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again codeEngineService.DisableRetries() - result, response, operationErr := codeEngineService.ListBindings(listBindingsOptionsModel) + result, response, operationErr := codeEngineService.ListFunctions(listFunctionsOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -6260,7 +6787,7 @@ var _ = Describe(`CodeEngineV2`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = codeEngineService.ListBindingsWithContext(ctx, listBindingsOptionsModel) + _, _, operationErr = codeEngineService.ListFunctionsWithContext(ctx, listFunctionsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -6274,7 +6801,7 @@ var _ = Describe(`CodeEngineV2`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listBindingsPath)) + Expect(req.URL.EscapedPath()).To(Equal(listFunctionsPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(100))})) @@ -6282,10 +6809,10 @@ var _ = Describe(`CodeEngineV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"bindings": [{"component": {"name": "my-app-1", "resource_type": "app_v2"}, "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/bindings/my-binding", "id": "a172ced-b5f21bc-71ba50c-1638604", "prefix": "MY_COS", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "binding_v2", "secret_name": "my-service-access", "status": "active"}], "first": {"href": "Href"}, "limit": 100, "next": {"href": "Href", "start": "Start"}}`) + fmt.Fprintf(res, "%s", `{"first": {"href": "Href"}, "functions": [{"code_binary": false, "code_main": "main", "code_reference": "data:text/plain;base64,", "code_secret": "my-secret", "created_at": "2022-09-13T11:41:35+02:00", "endpoint": "https://my-function.vg67hzldruk.eu-de.codeengine.appdomain.cloud", "endpoint_internal": "http://my-function.vg67hzldruk.svc.cluster.local", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/functions/my-function", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "managed_domain_mappings": "local_public", "name": "my-function", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "function_v2", "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "runtime": "nodejs-18", "scale_concurrency": 1, "scale_cpu_limit": "1", "scale_down_delay": 300, "scale_max_execution_time": 60, "scale_memory_limit": "1G", "status": "offline", "status_details": {"reason": "offline"}}], "limit": 100, "next": {"href": "Href", "start": "Start"}}`) })) }) - It(`Invoke ListBindings successfully`, func() { + It(`Invoke ListFunctions successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -6294,26 +6821,26 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(codeEngineService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := codeEngineService.ListBindings(nil) + result, response, operationErr := codeEngineService.ListFunctions(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the ListBindingsOptions model - listBindingsOptionsModel := new(codeenginev2.ListBindingsOptions) - listBindingsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - listBindingsOptionsModel.Limit = core.Int64Ptr(int64(100)) - listBindingsOptionsModel.Start = core.StringPtr("testString") - listBindingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListFunctionsOptions model + listFunctionsOptionsModel := new(codeenginev2.ListFunctionsOptions) + listFunctionsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + listFunctionsOptionsModel.Limit = core.Int64Ptr(int64(100)) + listFunctionsOptionsModel.Start = core.StringPtr("testString") + listFunctionsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = codeEngineService.ListBindings(listBindingsOptionsModel) + result, response, operationErr = codeEngineService.ListFunctions(listFunctionsOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke ListBindings with error: Operation validation and request error`, func() { + It(`Invoke ListFunctions with error: Operation validation and request error`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -6321,24 +6848,24 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the ListBindingsOptions model - listBindingsOptionsModel := new(codeenginev2.ListBindingsOptions) - listBindingsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - listBindingsOptionsModel.Limit = core.Int64Ptr(int64(100)) - listBindingsOptionsModel.Start = core.StringPtr("testString") - listBindingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListFunctionsOptions model + listFunctionsOptionsModel := new(codeenginev2.ListFunctionsOptions) + listFunctionsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + listFunctionsOptionsModel.Limit = core.Int64Ptr(int64(100)) + listFunctionsOptionsModel.Start = core.StringPtr("testString") + listFunctionsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := codeEngineService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := codeEngineService.ListBindings(listBindingsOptionsModel) + result, response, operationErr := codeEngineService.ListFunctions(listFunctionsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct a second instance of the ListBindingsOptions model with no property values - listBindingsOptionsModelNew := new(codeenginev2.ListBindingsOptions) + // Construct a second instance of the ListFunctionsOptions model with no property values + listFunctionsOptionsModelNew := new(codeenginev2.ListFunctionsOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = codeEngineService.ListBindings(listBindingsOptionsModelNew) + result, response, operationErr = codeEngineService.ListFunctions(listFunctionsOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -6356,7 +6883,7 @@ var _ = Describe(`CodeEngineV2`, func() { res.WriteHeader(200) })) }) - It(`Invoke ListBindings successfully`, func() { + It(`Invoke ListFunctions successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -6364,15 +6891,15 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the ListBindingsOptions model - listBindingsOptionsModel := new(codeenginev2.ListBindingsOptions) - listBindingsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - listBindingsOptionsModel.Limit = core.Int64Ptr(int64(100)) - listBindingsOptionsModel.Start = core.StringPtr("testString") - listBindingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListFunctionsOptions model + listFunctionsOptionsModel := new(codeenginev2.ListFunctionsOptions) + listFunctionsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + listFunctionsOptionsModel.Limit = core.Int64Ptr(int64(100)) + listFunctionsOptionsModel.Start = core.StringPtr("testString") + listFunctionsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := codeEngineService.ListBindings(listBindingsOptionsModel) + result, response, operationErr := codeEngineService.ListFunctions(listFunctionsOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -6385,7 +6912,7 @@ var _ = Describe(`CodeEngineV2`, func() { }) Context(`Test pagination helper method on response`, func() { It(`Invoke GetNextStart successfully`, func() { - responseObject := new(codeenginev2.BindingList) + responseObject := new(codeenginev2.FunctionList) nextObject := new(codeenginev2.ListNextMetadata) nextObject.Start = core.StringPtr("abc-123") responseObject.Next = nextObject @@ -6395,7 +6922,7 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(value).To(Equal(core.StringPtr("abc-123"))) }) It(`Invoke GetNextStart without a "Next" property in the response`, func() { - responseObject := new(codeenginev2.BindingList) + responseObject := new(codeenginev2.FunctionList) value, err := responseObject.GetNextStart() Expect(err).To(BeNil()) @@ -6409,7 +6936,7 @@ var _ = Describe(`CodeEngineV2`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listBindingsPath)) + Expect(req.URL.EscapedPath()).To(Equal(listFunctionsPath)) Expect(req.Method).To(Equal("GET")) // Set mock response @@ -6417,15 +6944,15 @@ var _ = Describe(`CodeEngineV2`, func() { res.WriteHeader(200) requestNumber++ if requestNumber == 1 { - fmt.Fprintf(res, "%s", `{"next":{"start":"1"},"total_count":2,"bindings":[{"component":{"name":"my-app-1","resource_type":"app_v2"},"href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/bindings/my-binding","id":"a172ced-b5f21bc-71ba50c-1638604","prefix":"MY_COS","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","resource_type":"binding_v2","secret_name":"my-service-access","status":"active"}],"limit":1}`) + fmt.Fprintf(res, "%s", `{"next":{"start":"1"},"functions":[{"code_binary":false,"code_main":"main","code_reference":"data:text/plain;base64,","code_secret":"my-secret","created_at":"2022-09-13T11:41:35+02:00","endpoint":"https://my-function.vg67hzldruk.eu-de.codeengine.appdomain.cloud","endpoint_internal":"http://my-function.vg67hzldruk.svc.cluster.local","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/functions/my-function","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","managed_domain_mappings":"local_public","name":"my-function","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"function_v2","run_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"runtime":"nodejs-18","scale_concurrency":1,"scale_cpu_limit":"1","scale_down_delay":300,"scale_max_execution_time":60,"scale_memory_limit":"1G","status":"offline","status_details":{"reason":"offline"}}],"total_count":2,"limit":1}`) } else if requestNumber == 2 { - fmt.Fprintf(res, "%s", `{"total_count":2,"bindings":[{"component":{"name":"my-app-1","resource_type":"app_v2"},"href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/bindings/my-binding","id":"a172ced-b5f21bc-71ba50c-1638604","prefix":"MY_COS","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","resource_type":"binding_v2","secret_name":"my-service-access","status":"active"}],"limit":1}`) + fmt.Fprintf(res, "%s", `{"functions":[{"code_binary":false,"code_main":"main","code_reference":"data:text/plain;base64,","code_secret":"my-secret","created_at":"2022-09-13T11:41:35+02:00","endpoint":"https://my-function.vg67hzldruk.eu-de.codeengine.appdomain.cloud","endpoint_internal":"http://my-function.vg67hzldruk.svc.cluster.local","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/functions/my-function","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","managed_domain_mappings":"local_public","name":"my-function","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"function_v2","run_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"runtime":"nodejs-18","scale_concurrency":1,"scale_cpu_limit":"1","scale_down_delay":300,"scale_max_execution_time":60,"scale_memory_limit":"1G","status":"offline","status_details":{"reason":"offline"}}],"total_count":2,"limit":1}`) } else { res.WriteHeader(400) } })) }) - It(`Use BindingsPager.GetNext successfully`, func() { + It(`Use FunctionsPager.GetNext successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -6433,16 +6960,16 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - listBindingsOptionsModel := &codeenginev2.ListBindingsOptions{ + listFunctionsOptionsModel := &codeenginev2.ListFunctionsOptions{ ProjectID: core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"), Limit: core.Int64Ptr(int64(100)), } - pager, err := codeEngineService.NewBindingsPager(listBindingsOptionsModel) + pager, err := codeEngineService.NewFunctionsPager(listFunctionsOptionsModel) Expect(err).To(BeNil()) Expect(pager).ToNot(BeNil()) - var allResults []codeenginev2.Binding + var allResults []codeenginev2.Function for pager.HasNext() { nextPage, err := pager.GetNext() Expect(err).To(BeNil()) @@ -6451,7 +6978,7 @@ var _ = Describe(`CodeEngineV2`, func() { } Expect(len(allResults)).To(Equal(2)) }) - It(`Use BindingsPager.GetAll successfully`, func() { + It(`Use FunctionsPager.GetAll successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -6459,12 +6986,12 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - listBindingsOptionsModel := &codeenginev2.ListBindingsOptions{ + listFunctionsOptionsModel := &codeenginev2.ListFunctionsOptions{ ProjectID: core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"), Limit: core.Int64Ptr(int64(100)), } - pager, err := codeEngineService.NewBindingsPager(listBindingsOptionsModel) + pager, err := codeEngineService.NewFunctionsPager(listFunctionsOptionsModel) Expect(err).To(BeNil()) Expect(pager).ToNot(BeNil()) @@ -6475,22 +7002,22 @@ var _ = Describe(`CodeEngineV2`, func() { }) }) }) - Describe(`CreateBinding(createBindingOptions *CreateBindingOptions) - Operation response error`, func() { - createBindingPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/bindings" + Describe(`CreateFunction(createFunctionOptions *CreateFunctionOptions) - Operation response error`, func() { + createFunctionPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/functions" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createBindingPath)) + Expect(req.URL.EscapedPath()).To(Equal(createFunctionPath)) Expect(req.Method).To(Equal("POST")) res.Header().Set("Content-type", "application/json") res.WriteHeader(201) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke CreateBinding with error: Operation response processing error`, func() { + It(`Invoke CreateFunction with error: Operation response processing error`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -6498,27 +7025,41 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the ComponentRef model - componentRefModel := new(codeenginev2.ComponentRef) - componentRefModel.Name = core.StringPtr("my-app-1") - componentRefModel.ResourceType = core.StringPtr("app_v2") + // Construct an instance of the EnvVarPrototype model + envVarPrototypeModel := new(codeenginev2.EnvVarPrototype) + envVarPrototypeModel.Key = core.StringPtr("MY_VARIABLE") + envVarPrototypeModel.Name = core.StringPtr("SOME") + envVarPrototypeModel.Prefix = core.StringPtr("PREFIX_") + envVarPrototypeModel.Reference = core.StringPtr("my-secret") + envVarPrototypeModel.Type = core.StringPtr("literal") + envVarPrototypeModel.Value = core.StringPtr("VALUE") - // Construct an instance of the CreateBindingOptions model - createBindingOptionsModel := new(codeenginev2.CreateBindingOptions) - createBindingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - createBindingOptionsModel.Component = componentRefModel - createBindingOptionsModel.Prefix = core.StringPtr("MY_COS") - createBindingOptionsModel.SecretName = core.StringPtr("my-service-access") - createBindingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the CreateFunctionOptions model + createFunctionOptionsModel := new(codeenginev2.CreateFunctionOptions) + createFunctionOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + createFunctionOptionsModel.CodeReference = core.StringPtr("data:text/plain;base64,") + createFunctionOptionsModel.Name = core.StringPtr("my-function") + createFunctionOptionsModel.Runtime = core.StringPtr("nodejs-18") + createFunctionOptionsModel.CodeBinary = core.BoolPtr(false) + createFunctionOptionsModel.CodeMain = core.StringPtr("main") + createFunctionOptionsModel.CodeSecret = core.StringPtr("my-secret") + createFunctionOptionsModel.ManagedDomainMappings = core.StringPtr("local_public") + createFunctionOptionsModel.RunEnvVariables = []codeenginev2.EnvVarPrototype{*envVarPrototypeModel} + createFunctionOptionsModel.ScaleConcurrency = core.Int64Ptr(int64(1)) + createFunctionOptionsModel.ScaleCpuLimit = core.StringPtr("1") + createFunctionOptionsModel.ScaleDownDelay = core.Int64Ptr(int64(300)) + createFunctionOptionsModel.ScaleMaxExecutionTime = core.Int64Ptr(int64(60)) + createFunctionOptionsModel.ScaleMemoryLimit = core.StringPtr("1G") + createFunctionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := codeEngineService.CreateBinding(createBindingOptionsModel) + result, response, operationErr := codeEngineService.CreateFunction(createFunctionOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again codeEngineService.EnableRetries(0, 0) - result, response, operationErr = codeEngineService.CreateBinding(createBindingOptionsModel) + result, response, operationErr = codeEngineService.CreateFunction(createFunctionOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -6528,15 +7069,15 @@ var _ = Describe(`CodeEngineV2`, func() { }) }) }) - Describe(`CreateBinding(createBindingOptions *CreateBindingOptions)`, func() { - createBindingPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/bindings" + Describe(`CreateFunction(createFunctionOptions *CreateFunctionOptions)`, func() { + createFunctionPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/functions" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createBindingPath)) + Expect(req.URL.EscapedPath()).To(Equal(createFunctionPath)) Expect(req.Method).To(Equal("POST")) // For gzip-disabled operation, verify Content-Encoding is not set. @@ -6561,10 +7102,10 @@ var _ = Describe(`CodeEngineV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"component": {"name": "my-app-1", "resource_type": "app_v2"}, "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/bindings/my-binding", "id": "a172ced-b5f21bc-71ba50c-1638604", "prefix": "MY_COS", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "binding_v2", "secret_name": "my-service-access", "status": "active"}`) + fmt.Fprintf(res, "%s", `{"code_binary": false, "code_main": "main", "code_reference": "data:text/plain;base64,", "code_secret": "my-secret", "created_at": "2022-09-13T11:41:35+02:00", "endpoint": "https://my-function.vg67hzldruk.eu-de.codeengine.appdomain.cloud", "endpoint_internal": "http://my-function.vg67hzldruk.svc.cluster.local", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/functions/my-function", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "managed_domain_mappings": "local_public", "name": "my-function", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "function_v2", "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "runtime": "nodejs-18", "scale_concurrency": 1, "scale_cpu_limit": "1", "scale_down_delay": 300, "scale_max_execution_time": 60, "scale_memory_limit": "1G", "status": "offline", "status_details": {"reason": "offline"}}`) })) }) - It(`Invoke CreateBinding successfully with retries`, func() { + It(`Invoke CreateFunction successfully with retries`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -6573,29 +7114,43 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(codeEngineService).ToNot(BeNil()) codeEngineService.EnableRetries(0, 0) - // Construct an instance of the ComponentRef model - componentRefModel := new(codeenginev2.ComponentRef) - componentRefModel.Name = core.StringPtr("my-app-1") - componentRefModel.ResourceType = core.StringPtr("app_v2") + // Construct an instance of the EnvVarPrototype model + envVarPrototypeModel := new(codeenginev2.EnvVarPrototype) + envVarPrototypeModel.Key = core.StringPtr("MY_VARIABLE") + envVarPrototypeModel.Name = core.StringPtr("SOME") + envVarPrototypeModel.Prefix = core.StringPtr("PREFIX_") + envVarPrototypeModel.Reference = core.StringPtr("my-secret") + envVarPrototypeModel.Type = core.StringPtr("literal") + envVarPrototypeModel.Value = core.StringPtr("VALUE") - // Construct an instance of the CreateBindingOptions model - createBindingOptionsModel := new(codeenginev2.CreateBindingOptions) - createBindingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - createBindingOptionsModel.Component = componentRefModel - createBindingOptionsModel.Prefix = core.StringPtr("MY_COS") - createBindingOptionsModel.SecretName = core.StringPtr("my-service-access") - createBindingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the CreateFunctionOptions model + createFunctionOptionsModel := new(codeenginev2.CreateFunctionOptions) + createFunctionOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + createFunctionOptionsModel.CodeReference = core.StringPtr("data:text/plain;base64,") + createFunctionOptionsModel.Name = core.StringPtr("my-function") + createFunctionOptionsModel.Runtime = core.StringPtr("nodejs-18") + createFunctionOptionsModel.CodeBinary = core.BoolPtr(false) + createFunctionOptionsModel.CodeMain = core.StringPtr("main") + createFunctionOptionsModel.CodeSecret = core.StringPtr("my-secret") + createFunctionOptionsModel.ManagedDomainMappings = core.StringPtr("local_public") + createFunctionOptionsModel.RunEnvVariables = []codeenginev2.EnvVarPrototype{*envVarPrototypeModel} + createFunctionOptionsModel.ScaleConcurrency = core.Int64Ptr(int64(1)) + createFunctionOptionsModel.ScaleCpuLimit = core.StringPtr("1") + createFunctionOptionsModel.ScaleDownDelay = core.Int64Ptr(int64(300)) + createFunctionOptionsModel.ScaleMaxExecutionTime = core.Int64Ptr(int64(60)) + createFunctionOptionsModel.ScaleMemoryLimit = core.StringPtr("1G") + createFunctionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := codeEngineService.CreateBindingWithContext(ctx, createBindingOptionsModel) + _, _, operationErr := codeEngineService.CreateFunctionWithContext(ctx, createFunctionOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again codeEngineService.DisableRetries() - result, response, operationErr := codeEngineService.CreateBinding(createBindingOptionsModel) + result, response, operationErr := codeEngineService.CreateFunction(createFunctionOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -6603,7 +7158,7 @@ var _ = Describe(`CodeEngineV2`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = codeEngineService.CreateBindingWithContext(ctx, createBindingOptionsModel) + _, _, operationErr = codeEngineService.CreateFunctionWithContext(ctx, createFunctionOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -6617,7 +7172,7 @@ var _ = Describe(`CodeEngineV2`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createBindingPath)) + Expect(req.URL.EscapedPath()).To(Equal(createFunctionPath)) Expect(req.Method).To(Equal("POST")) // For gzip-disabled operation, verify Content-Encoding is not set. @@ -6639,10 +7194,10 @@ var _ = Describe(`CodeEngineV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"component": {"name": "my-app-1", "resource_type": "app_v2"}, "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/bindings/my-binding", "id": "a172ced-b5f21bc-71ba50c-1638604", "prefix": "MY_COS", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "binding_v2", "secret_name": "my-service-access", "status": "active"}`) + fmt.Fprintf(res, "%s", `{"code_binary": false, "code_main": "main", "code_reference": "data:text/plain;base64,", "code_secret": "my-secret", "created_at": "2022-09-13T11:41:35+02:00", "endpoint": "https://my-function.vg67hzldruk.eu-de.codeengine.appdomain.cloud", "endpoint_internal": "http://my-function.vg67hzldruk.svc.cluster.local", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/functions/my-function", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "managed_domain_mappings": "local_public", "name": "my-function", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "function_v2", "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "runtime": "nodejs-18", "scale_concurrency": 1, "scale_cpu_limit": "1", "scale_down_delay": 300, "scale_max_execution_time": 60, "scale_memory_limit": "1G", "status": "offline", "status_details": {"reason": "offline"}}`) })) }) - It(`Invoke CreateBinding successfully`, func() { + It(`Invoke CreateFunction successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -6651,32 +7206,46 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(codeEngineService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := codeEngineService.CreateBinding(nil) + result, response, operationErr := codeEngineService.CreateFunction(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the ComponentRef model - componentRefModel := new(codeenginev2.ComponentRef) - componentRefModel.Name = core.StringPtr("my-app-1") - componentRefModel.ResourceType = core.StringPtr("app_v2") + // Construct an instance of the EnvVarPrototype model + envVarPrototypeModel := new(codeenginev2.EnvVarPrototype) + envVarPrototypeModel.Key = core.StringPtr("MY_VARIABLE") + envVarPrototypeModel.Name = core.StringPtr("SOME") + envVarPrototypeModel.Prefix = core.StringPtr("PREFIX_") + envVarPrototypeModel.Reference = core.StringPtr("my-secret") + envVarPrototypeModel.Type = core.StringPtr("literal") + envVarPrototypeModel.Value = core.StringPtr("VALUE") - // Construct an instance of the CreateBindingOptions model - createBindingOptionsModel := new(codeenginev2.CreateBindingOptions) - createBindingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - createBindingOptionsModel.Component = componentRefModel - createBindingOptionsModel.Prefix = core.StringPtr("MY_COS") - createBindingOptionsModel.SecretName = core.StringPtr("my-service-access") - createBindingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the CreateFunctionOptions model + createFunctionOptionsModel := new(codeenginev2.CreateFunctionOptions) + createFunctionOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + createFunctionOptionsModel.CodeReference = core.StringPtr("data:text/plain;base64,") + createFunctionOptionsModel.Name = core.StringPtr("my-function") + createFunctionOptionsModel.Runtime = core.StringPtr("nodejs-18") + createFunctionOptionsModel.CodeBinary = core.BoolPtr(false) + createFunctionOptionsModel.CodeMain = core.StringPtr("main") + createFunctionOptionsModel.CodeSecret = core.StringPtr("my-secret") + createFunctionOptionsModel.ManagedDomainMappings = core.StringPtr("local_public") + createFunctionOptionsModel.RunEnvVariables = []codeenginev2.EnvVarPrototype{*envVarPrototypeModel} + createFunctionOptionsModel.ScaleConcurrency = core.Int64Ptr(int64(1)) + createFunctionOptionsModel.ScaleCpuLimit = core.StringPtr("1") + createFunctionOptionsModel.ScaleDownDelay = core.Int64Ptr(int64(300)) + createFunctionOptionsModel.ScaleMaxExecutionTime = core.Int64Ptr(int64(60)) + createFunctionOptionsModel.ScaleMemoryLimit = core.StringPtr("1G") + createFunctionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = codeEngineService.CreateBinding(createBindingOptionsModel) + result, response, operationErr = codeEngineService.CreateFunction(createFunctionOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke CreateBinding with error: Operation validation and request error`, func() { + It(`Invoke CreateFunction with error: Operation validation and request error`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -6684,30 +7253,44 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the ComponentRef model - componentRefModel := new(codeenginev2.ComponentRef) - componentRefModel.Name = core.StringPtr("my-app-1") - componentRefModel.ResourceType = core.StringPtr("app_v2") + // Construct an instance of the EnvVarPrototype model + envVarPrototypeModel := new(codeenginev2.EnvVarPrototype) + envVarPrototypeModel.Key = core.StringPtr("MY_VARIABLE") + envVarPrototypeModel.Name = core.StringPtr("SOME") + envVarPrototypeModel.Prefix = core.StringPtr("PREFIX_") + envVarPrototypeModel.Reference = core.StringPtr("my-secret") + envVarPrototypeModel.Type = core.StringPtr("literal") + envVarPrototypeModel.Value = core.StringPtr("VALUE") - // Construct an instance of the CreateBindingOptions model - createBindingOptionsModel := new(codeenginev2.CreateBindingOptions) - createBindingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - createBindingOptionsModel.Component = componentRefModel - createBindingOptionsModel.Prefix = core.StringPtr("MY_COS") - createBindingOptionsModel.SecretName = core.StringPtr("my-service-access") - createBindingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the CreateFunctionOptions model + createFunctionOptionsModel := new(codeenginev2.CreateFunctionOptions) + createFunctionOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + createFunctionOptionsModel.CodeReference = core.StringPtr("data:text/plain;base64,") + createFunctionOptionsModel.Name = core.StringPtr("my-function") + createFunctionOptionsModel.Runtime = core.StringPtr("nodejs-18") + createFunctionOptionsModel.CodeBinary = core.BoolPtr(false) + createFunctionOptionsModel.CodeMain = core.StringPtr("main") + createFunctionOptionsModel.CodeSecret = core.StringPtr("my-secret") + createFunctionOptionsModel.ManagedDomainMappings = core.StringPtr("local_public") + createFunctionOptionsModel.RunEnvVariables = []codeenginev2.EnvVarPrototype{*envVarPrototypeModel} + createFunctionOptionsModel.ScaleConcurrency = core.Int64Ptr(int64(1)) + createFunctionOptionsModel.ScaleCpuLimit = core.StringPtr("1") + createFunctionOptionsModel.ScaleDownDelay = core.Int64Ptr(int64(300)) + createFunctionOptionsModel.ScaleMaxExecutionTime = core.Int64Ptr(int64(60)) + createFunctionOptionsModel.ScaleMemoryLimit = core.StringPtr("1G") + createFunctionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := codeEngineService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := codeEngineService.CreateBinding(createBindingOptionsModel) + result, response, operationErr := codeEngineService.CreateFunction(createFunctionOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct a second instance of the CreateBindingOptions model with no property values - createBindingOptionsModelNew := new(codeenginev2.CreateBindingOptions) + // Construct a second instance of the CreateFunctionOptions model with no property values + createFunctionOptionsModelNew := new(codeenginev2.CreateFunctionOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = codeEngineService.CreateBinding(createBindingOptionsModelNew) + result, response, operationErr = codeEngineService.CreateFunction(createFunctionOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -6725,7 +7308,7 @@ var _ = Describe(`CodeEngineV2`, func() { res.WriteHeader(201) })) }) - It(`Invoke CreateBinding successfully`, func() { + It(`Invoke CreateFunction successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -6733,21 +7316,35 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the ComponentRef model - componentRefModel := new(codeenginev2.ComponentRef) - componentRefModel.Name = core.StringPtr("my-app-1") - componentRefModel.ResourceType = core.StringPtr("app_v2") + // Construct an instance of the EnvVarPrototype model + envVarPrototypeModel := new(codeenginev2.EnvVarPrototype) + envVarPrototypeModel.Key = core.StringPtr("MY_VARIABLE") + envVarPrototypeModel.Name = core.StringPtr("SOME") + envVarPrototypeModel.Prefix = core.StringPtr("PREFIX_") + envVarPrototypeModel.Reference = core.StringPtr("my-secret") + envVarPrototypeModel.Type = core.StringPtr("literal") + envVarPrototypeModel.Value = core.StringPtr("VALUE") - // Construct an instance of the CreateBindingOptions model - createBindingOptionsModel := new(codeenginev2.CreateBindingOptions) - createBindingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - createBindingOptionsModel.Component = componentRefModel - createBindingOptionsModel.Prefix = core.StringPtr("MY_COS") - createBindingOptionsModel.SecretName = core.StringPtr("my-service-access") - createBindingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the CreateFunctionOptions model + createFunctionOptionsModel := new(codeenginev2.CreateFunctionOptions) + createFunctionOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + createFunctionOptionsModel.CodeReference = core.StringPtr("data:text/plain;base64,") + createFunctionOptionsModel.Name = core.StringPtr("my-function") + createFunctionOptionsModel.Runtime = core.StringPtr("nodejs-18") + createFunctionOptionsModel.CodeBinary = core.BoolPtr(false) + createFunctionOptionsModel.CodeMain = core.StringPtr("main") + createFunctionOptionsModel.CodeSecret = core.StringPtr("my-secret") + createFunctionOptionsModel.ManagedDomainMappings = core.StringPtr("local_public") + createFunctionOptionsModel.RunEnvVariables = []codeenginev2.EnvVarPrototype{*envVarPrototypeModel} + createFunctionOptionsModel.ScaleConcurrency = core.Int64Ptr(int64(1)) + createFunctionOptionsModel.ScaleCpuLimit = core.StringPtr("1") + createFunctionOptionsModel.ScaleDownDelay = core.Int64Ptr(int64(300)) + createFunctionOptionsModel.ScaleMaxExecutionTime = core.Int64Ptr(int64(60)) + createFunctionOptionsModel.ScaleMemoryLimit = core.StringPtr("1G") + createFunctionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := codeEngineService.CreateBinding(createBindingOptionsModel) + result, response, operationErr := codeEngineService.CreateFunction(createFunctionOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -6759,22 +7356,22 @@ var _ = Describe(`CodeEngineV2`, func() { }) }) }) - Describe(`GetBinding(getBindingOptions *GetBindingOptions) - Operation response error`, func() { - getBindingPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/bindings/a172ced-b5f21bc-71ba50c-1638604" + Describe(`GetFunction(getFunctionOptions *GetFunctionOptions) - Operation response error`, func() { + getFunctionPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/functions/my-function" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getBindingPath)) + Expect(req.URL.EscapedPath()).To(Equal(getFunctionPath)) Expect(req.Method).To(Equal("GET")) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke GetBinding with error: Operation response processing error`, func() { + It(`Invoke GetFunction with error: Operation response processing error`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -6782,20 +7379,20 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the GetBindingOptions model - getBindingOptionsModel := new(codeenginev2.GetBindingOptions) - getBindingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - getBindingOptionsModel.ID = core.StringPtr("a172ced-b5f21bc-71ba50c-1638604") - getBindingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetFunctionOptions model + getFunctionOptionsModel := new(codeenginev2.GetFunctionOptions) + getFunctionOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + getFunctionOptionsModel.Name = core.StringPtr("my-function") + getFunctionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := codeEngineService.GetBinding(getBindingOptionsModel) + result, response, operationErr := codeEngineService.GetFunction(getFunctionOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again codeEngineService.EnableRetries(0, 0) - result, response, operationErr = codeEngineService.GetBinding(getBindingOptionsModel) + result, response, operationErr = codeEngineService.GetFunction(getFunctionOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -6805,15 +7402,15 @@ var _ = Describe(`CodeEngineV2`, func() { }) }) }) - Describe(`GetBinding(getBindingOptions *GetBindingOptions)`, func() { - getBindingPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/bindings/a172ced-b5f21bc-71ba50c-1638604" + Describe(`GetFunction(getFunctionOptions *GetFunctionOptions)`, func() { + getFunctionPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/functions/my-function" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getBindingPath)) + Expect(req.URL.EscapedPath()).To(Equal(getFunctionPath)) Expect(req.Method).To(Equal("GET")) // Sleep a short time to support a timeout test @@ -6822,10 +7419,10 @@ var _ = Describe(`CodeEngineV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"component": {"name": "my-app-1", "resource_type": "app_v2"}, "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/bindings/my-binding", "id": "a172ced-b5f21bc-71ba50c-1638604", "prefix": "MY_COS", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "binding_v2", "secret_name": "my-service-access", "status": "active"}`) + fmt.Fprintf(res, "%s", `{"code_binary": false, "code_main": "main", "code_reference": "data:text/plain;base64,", "code_secret": "my-secret", "created_at": "2022-09-13T11:41:35+02:00", "endpoint": "https://my-function.vg67hzldruk.eu-de.codeengine.appdomain.cloud", "endpoint_internal": "http://my-function.vg67hzldruk.svc.cluster.local", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/functions/my-function", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "managed_domain_mappings": "local_public", "name": "my-function", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "function_v2", "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "runtime": "nodejs-18", "scale_concurrency": 1, "scale_cpu_limit": "1", "scale_down_delay": 300, "scale_max_execution_time": 60, "scale_memory_limit": "1G", "status": "offline", "status_details": {"reason": "offline"}}`) })) }) - It(`Invoke GetBinding successfully with retries`, func() { + It(`Invoke GetFunction successfully with retries`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -6834,22 +7431,22 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(codeEngineService).ToNot(BeNil()) codeEngineService.EnableRetries(0, 0) - // Construct an instance of the GetBindingOptions model - getBindingOptionsModel := new(codeenginev2.GetBindingOptions) - getBindingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - getBindingOptionsModel.ID = core.StringPtr("a172ced-b5f21bc-71ba50c-1638604") - getBindingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetFunctionOptions model + getFunctionOptionsModel := new(codeenginev2.GetFunctionOptions) + getFunctionOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + getFunctionOptionsModel.Name = core.StringPtr("my-function") + getFunctionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := codeEngineService.GetBindingWithContext(ctx, getBindingOptionsModel) + _, _, operationErr := codeEngineService.GetFunctionWithContext(ctx, getFunctionOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again codeEngineService.DisableRetries() - result, response, operationErr := codeEngineService.GetBinding(getBindingOptionsModel) + result, response, operationErr := codeEngineService.GetFunction(getFunctionOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -6857,7 +7454,7 @@ var _ = Describe(`CodeEngineV2`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = codeEngineService.GetBindingWithContext(ctx, getBindingOptionsModel) + _, _, operationErr = codeEngineService.GetFunctionWithContext(ctx, getFunctionOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -6871,16 +7468,16 @@ var _ = Describe(`CodeEngineV2`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getBindingPath)) + Expect(req.URL.EscapedPath()).To(Equal(getFunctionPath)) Expect(req.Method).To(Equal("GET")) // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"component": {"name": "my-app-1", "resource_type": "app_v2"}, "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/bindings/my-binding", "id": "a172ced-b5f21bc-71ba50c-1638604", "prefix": "MY_COS", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "binding_v2", "secret_name": "my-service-access", "status": "active"}`) + fmt.Fprintf(res, "%s", `{"code_binary": false, "code_main": "main", "code_reference": "data:text/plain;base64,", "code_secret": "my-secret", "created_at": "2022-09-13T11:41:35+02:00", "endpoint": "https://my-function.vg67hzldruk.eu-de.codeengine.appdomain.cloud", "endpoint_internal": "http://my-function.vg67hzldruk.svc.cluster.local", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/functions/my-function", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "managed_domain_mappings": "local_public", "name": "my-function", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "function_v2", "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "runtime": "nodejs-18", "scale_concurrency": 1, "scale_cpu_limit": "1", "scale_down_delay": 300, "scale_max_execution_time": 60, "scale_memory_limit": "1G", "status": "offline", "status_details": {"reason": "offline"}}`) })) }) - It(`Invoke GetBinding successfully`, func() { + It(`Invoke GetFunction successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -6889,25 +7486,25 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(codeEngineService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := codeEngineService.GetBinding(nil) + result, response, operationErr := codeEngineService.GetFunction(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the GetBindingOptions model - getBindingOptionsModel := new(codeenginev2.GetBindingOptions) - getBindingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - getBindingOptionsModel.ID = core.StringPtr("a172ced-b5f21bc-71ba50c-1638604") - getBindingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetFunctionOptions model + getFunctionOptionsModel := new(codeenginev2.GetFunctionOptions) + getFunctionOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + getFunctionOptionsModel.Name = core.StringPtr("my-function") + getFunctionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = codeEngineService.GetBinding(getBindingOptionsModel) + result, response, operationErr = codeEngineService.GetFunction(getFunctionOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke GetBinding with error: Operation validation and request error`, func() { + It(`Invoke GetFunction with error: Operation validation and request error`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -6915,23 +7512,23 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the GetBindingOptions model - getBindingOptionsModel := new(codeenginev2.GetBindingOptions) - getBindingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - getBindingOptionsModel.ID = core.StringPtr("a172ced-b5f21bc-71ba50c-1638604") - getBindingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetFunctionOptions model + getFunctionOptionsModel := new(codeenginev2.GetFunctionOptions) + getFunctionOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + getFunctionOptionsModel.Name = core.StringPtr("my-function") + getFunctionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := codeEngineService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := codeEngineService.GetBinding(getBindingOptionsModel) + result, response, operationErr := codeEngineService.GetFunction(getFunctionOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct a second instance of the GetBindingOptions model with no property values - getBindingOptionsModelNew := new(codeenginev2.GetBindingOptions) + // Construct a second instance of the GetFunctionOptions model with no property values + getFunctionOptionsModelNew := new(codeenginev2.GetFunctionOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = codeEngineService.GetBinding(getBindingOptionsModelNew) + result, response, operationErr = codeEngineService.GetFunction(getFunctionOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -6949,7 +7546,7 @@ var _ = Describe(`CodeEngineV2`, func() { res.WriteHeader(200) })) }) - It(`Invoke GetBinding successfully`, func() { + It(`Invoke GetFunction successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -6957,14 +7554,14 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the GetBindingOptions model - getBindingOptionsModel := new(codeenginev2.GetBindingOptions) - getBindingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - getBindingOptionsModel.ID = core.StringPtr("a172ced-b5f21bc-71ba50c-1638604") - getBindingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetFunctionOptions model + getFunctionOptionsModel := new(codeenginev2.GetFunctionOptions) + getFunctionOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + getFunctionOptionsModel.Name = core.StringPtr("my-function") + getFunctionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := codeEngineService.GetBinding(getBindingOptionsModel) + result, response, operationErr := codeEngineService.GetFunction(getFunctionOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -6976,21 +7573,21 @@ var _ = Describe(`CodeEngineV2`, func() { }) }) }) - Describe(`DeleteBinding(deleteBindingOptions *DeleteBindingOptions)`, func() { - deleteBindingPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/bindings/a172ced-b5f21bc-71ba50c-1638604" + Describe(`DeleteFunction(deleteFunctionOptions *DeleteFunctionOptions)`, func() { + deleteFunctionPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/functions/my-function" Context(`Using mock server endpoint`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(deleteBindingPath)) + Expect(req.URL.EscapedPath()).To(Equal(deleteFunctionPath)) Expect(req.Method).To(Equal("DELETE")) res.WriteHeader(202) })) }) - It(`Invoke DeleteBinding successfully`, func() { + It(`Invoke DeleteFunction successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -6999,22 +7596,22 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(codeEngineService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - response, operationErr := codeEngineService.DeleteBinding(nil) + response, operationErr := codeEngineService.DeleteFunction(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) - // Construct an instance of the DeleteBindingOptions model - deleteBindingOptionsModel := new(codeenginev2.DeleteBindingOptions) - deleteBindingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - deleteBindingOptionsModel.ID = core.StringPtr("a172ced-b5f21bc-71ba50c-1638604") - deleteBindingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the DeleteFunctionOptions model + deleteFunctionOptionsModel := new(codeenginev2.DeleteFunctionOptions) + deleteFunctionOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + deleteFunctionOptionsModel.Name = core.StringPtr("my-function") + deleteFunctionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - response, operationErr = codeEngineService.DeleteBinding(deleteBindingOptionsModel) + response, operationErr = codeEngineService.DeleteFunction(deleteFunctionOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) }) - It(`Invoke DeleteBinding with error: Operation validation and request error`, func() { + It(`Invoke DeleteFunction with error: Operation validation and request error`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -7022,22 +7619,22 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the DeleteBindingOptions model - deleteBindingOptionsModel := new(codeenginev2.DeleteBindingOptions) - deleteBindingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - deleteBindingOptionsModel.ID = core.StringPtr("a172ced-b5f21bc-71ba50c-1638604") - deleteBindingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the DeleteFunctionOptions model + deleteFunctionOptionsModel := new(codeenginev2.DeleteFunctionOptions) + deleteFunctionOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + deleteFunctionOptionsModel.Name = core.StringPtr("my-function") + deleteFunctionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := codeEngineService.SetServiceURL("") Expect(err).To(BeNil()) - response, operationErr := codeEngineService.DeleteBinding(deleteBindingOptionsModel) + response, operationErr := codeEngineService.DeleteFunction(deleteFunctionOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) - // Construct a second instance of the DeleteBindingOptions model with no property values - deleteBindingOptionsModelNew := new(codeenginev2.DeleteBindingOptions) + // Construct a second instance of the DeleteFunctionOptions model with no property values + deleteFunctionOptionsModelNew := new(codeenginev2.DeleteFunctionOptions) // Invoke operation with invalid model (negative test) - response, operationErr = codeEngineService.DeleteBinding(deleteBindingOptionsModelNew) + response, operationErr = codeEngineService.DeleteFunction(deleteFunctionOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) }) @@ -7046,24 +7643,24 @@ var _ = Describe(`CodeEngineV2`, func() { }) }) }) - Describe(`ListBuilds(listBuildsOptions *ListBuildsOptions) - Operation response error`, func() { - listBuildsPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/builds" + Describe(`UpdateFunction(updateFunctionOptions *UpdateFunctionOptions) - Operation response error`, func() { + updateFunctionPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/functions/my-function" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listBuildsPath)) - Expect(req.Method).To(Equal("GET")) - Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(100))})) - Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + Expect(req.URL.EscapedPath()).To(Equal(updateFunctionPath)) + Expect(req.Method).To(Equal("PATCH")) + Expect(req.Header["If-Match"]).ToNot(BeNil()) + Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke ListBuilds with error: Operation response processing error`, func() { + It(`Invoke UpdateFunction with error: Operation response processing error`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -7071,21 +7668,48 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the ListBuildsOptions model - listBuildsOptionsModel := new(codeenginev2.ListBuildsOptions) - listBuildsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - listBuildsOptionsModel.Limit = core.Int64Ptr(int64(100)) - listBuildsOptionsModel.Start = core.StringPtr("testString") - listBuildsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the EnvVarPrototype model + envVarPrototypeModel := new(codeenginev2.EnvVarPrototype) + envVarPrototypeModel.Key = core.StringPtr("MY_VARIABLE") + envVarPrototypeModel.Name = core.StringPtr("SOME") + envVarPrototypeModel.Prefix = core.StringPtr("PREFIX_") + envVarPrototypeModel.Reference = core.StringPtr("my-secret") + envVarPrototypeModel.Type = core.StringPtr("literal") + envVarPrototypeModel.Value = core.StringPtr("VALUE") + + // Construct an instance of the FunctionPatch model + functionPatchModel := new(codeenginev2.FunctionPatch) + functionPatchModel.CodeBinary = core.BoolPtr(false) + functionPatchModel.CodeMain = core.StringPtr("main") + functionPatchModel.CodeReference = core.StringPtr("data:text/plain;base64,") + functionPatchModel.CodeSecret = core.StringPtr("my-secret") + functionPatchModel.ManagedDomainMappings = core.StringPtr("local_public") + functionPatchModel.RunEnvVariables = []codeenginev2.EnvVarPrototype{*envVarPrototypeModel} + functionPatchModel.Runtime = core.StringPtr("nodejs-18") + functionPatchModel.ScaleConcurrency = core.Int64Ptr(int64(1)) + functionPatchModel.ScaleCpuLimit = core.StringPtr("1") + functionPatchModel.ScaleDownDelay = core.Int64Ptr(int64(300)) + functionPatchModel.ScaleMaxExecutionTime = core.Int64Ptr(int64(60)) + functionPatchModel.ScaleMemoryLimit = core.StringPtr("1G") + functionPatchModelAsPatch, asPatchErr := functionPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateFunctionOptions model + updateFunctionOptionsModel := new(codeenginev2.UpdateFunctionOptions) + updateFunctionOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + updateFunctionOptionsModel.Name = core.StringPtr("my-function") + updateFunctionOptionsModel.IfMatch = core.StringPtr("testString") + updateFunctionOptionsModel.Function = functionPatchModelAsPatch + updateFunctionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := codeEngineService.ListBuilds(listBuildsOptionsModel) + result, response, operationErr := codeEngineService.UpdateFunction(updateFunctionOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again codeEngineService.EnableRetries(0, 0) - result, response, operationErr = codeEngineService.ListBuilds(listBuildsOptionsModel) + result, response, operationErr = codeEngineService.UpdateFunction(updateFunctionOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -7095,29 +7719,45 @@ var _ = Describe(`CodeEngineV2`, func() { }) }) }) - Describe(`ListBuilds(listBuildsOptions *ListBuildsOptions)`, func() { - listBuildsPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/builds" + Describe(`UpdateFunction(updateFunctionOptions *UpdateFunctionOptions)`, func() { + updateFunctionPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/functions/my-function" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listBuildsPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(updateFunctionPath)) + Expect(req.Method).To(Equal("PATCH")) - Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(100))})) - Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + + Expect(req.Header["If-Match"]).ToNot(BeNil()) + Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) // Sleep a short time to support a timeout test time.Sleep(100 * time.Millisecond) // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"builds": [{"created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "build_v2", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "SourceSecret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "ready", "status_details": {"reason": "registered"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}], "first": {"href": "Href"}, "limit": 100, "next": {"href": "Href", "start": "Start"}}`) + fmt.Fprintf(res, "%s", `{"code_binary": false, "code_main": "main", "code_reference": "data:text/plain;base64,", "code_secret": "my-secret", "created_at": "2022-09-13T11:41:35+02:00", "endpoint": "https://my-function.vg67hzldruk.eu-de.codeengine.appdomain.cloud", "endpoint_internal": "http://my-function.vg67hzldruk.svc.cluster.local", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/functions/my-function", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "managed_domain_mappings": "local_public", "name": "my-function", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "function_v2", "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "runtime": "nodejs-18", "scale_concurrency": 1, "scale_cpu_limit": "1", "scale_down_delay": 300, "scale_max_execution_time": 60, "scale_memory_limit": "1G", "status": "offline", "status_details": {"reason": "offline"}}`) })) }) - It(`Invoke ListBuilds successfully with retries`, func() { + It(`Invoke UpdateFunction successfully with retries`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -7126,23 +7766,50 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(codeEngineService).ToNot(BeNil()) codeEngineService.EnableRetries(0, 0) - // Construct an instance of the ListBuildsOptions model - listBuildsOptionsModel := new(codeenginev2.ListBuildsOptions) - listBuildsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - listBuildsOptionsModel.Limit = core.Int64Ptr(int64(100)) - listBuildsOptionsModel.Start = core.StringPtr("testString") - listBuildsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the EnvVarPrototype model + envVarPrototypeModel := new(codeenginev2.EnvVarPrototype) + envVarPrototypeModel.Key = core.StringPtr("MY_VARIABLE") + envVarPrototypeModel.Name = core.StringPtr("SOME") + envVarPrototypeModel.Prefix = core.StringPtr("PREFIX_") + envVarPrototypeModel.Reference = core.StringPtr("my-secret") + envVarPrototypeModel.Type = core.StringPtr("literal") + envVarPrototypeModel.Value = core.StringPtr("VALUE") + + // Construct an instance of the FunctionPatch model + functionPatchModel := new(codeenginev2.FunctionPatch) + functionPatchModel.CodeBinary = core.BoolPtr(false) + functionPatchModel.CodeMain = core.StringPtr("main") + functionPatchModel.CodeReference = core.StringPtr("data:text/plain;base64,") + functionPatchModel.CodeSecret = core.StringPtr("my-secret") + functionPatchModel.ManagedDomainMappings = core.StringPtr("local_public") + functionPatchModel.RunEnvVariables = []codeenginev2.EnvVarPrototype{*envVarPrototypeModel} + functionPatchModel.Runtime = core.StringPtr("nodejs-18") + functionPatchModel.ScaleConcurrency = core.Int64Ptr(int64(1)) + functionPatchModel.ScaleCpuLimit = core.StringPtr("1") + functionPatchModel.ScaleDownDelay = core.Int64Ptr(int64(300)) + functionPatchModel.ScaleMaxExecutionTime = core.Int64Ptr(int64(60)) + functionPatchModel.ScaleMemoryLimit = core.StringPtr("1G") + functionPatchModelAsPatch, asPatchErr := functionPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateFunctionOptions model + updateFunctionOptionsModel := new(codeenginev2.UpdateFunctionOptions) + updateFunctionOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + updateFunctionOptionsModel.Name = core.StringPtr("my-function") + updateFunctionOptionsModel.IfMatch = core.StringPtr("testString") + updateFunctionOptionsModel.Function = functionPatchModelAsPatch + updateFunctionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := codeEngineService.ListBuildsWithContext(ctx, listBuildsOptionsModel) + _, _, operationErr := codeEngineService.UpdateFunctionWithContext(ctx, updateFunctionOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again codeEngineService.DisableRetries() - result, response, operationErr := codeEngineService.ListBuilds(listBuildsOptionsModel) + result, response, operationErr := codeEngineService.UpdateFunction(updateFunctionOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -7150,7 +7817,7 @@ var _ = Describe(`CodeEngineV2`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = codeEngineService.ListBuildsWithContext(ctx, listBuildsOptionsModel) + _, _, operationErr = codeEngineService.UpdateFunctionWithContext(ctx, updateFunctionOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -7164,46 +7831,89 @@ var _ = Describe(`CodeEngineV2`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listBuildsPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(updateFunctionPath)) + Expect(req.Method).To(Equal("PATCH")) - Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(100))})) - Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) - // Set mock response - res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"builds": [{"created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "build_v2", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "SourceSecret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "ready", "status_details": {"reason": "registered"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}], "first": {"href": "Href"}, "limit": 100, "next": {"href": "Href", "start": "Start"}}`) - })) - }) - It(`Invoke ListBuilds successfully`, func() { - codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - }) + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + + Expect(req.Header["If-Match"]).ToNot(BeNil()) + Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"code_binary": false, "code_main": "main", "code_reference": "data:text/plain;base64,", "code_secret": "my-secret", "created_at": "2022-09-13T11:41:35+02:00", "endpoint": "https://my-function.vg67hzldruk.eu-de.codeengine.appdomain.cloud", "endpoint_internal": "http://my-function.vg67hzldruk.svc.cluster.local", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/functions/my-function", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "managed_domain_mappings": "local_public", "name": "my-function", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "function_v2", "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "runtime": "nodejs-18", "scale_concurrency": 1, "scale_cpu_limit": "1", "scale_down_delay": 300, "scale_max_execution_time": 60, "scale_memory_limit": "1G", "status": "offline", "status_details": {"reason": "offline"}}`) + })) + }) + It(`Invoke UpdateFunction successfully`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := codeEngineService.ListBuilds(nil) + result, response, operationErr := codeEngineService.UpdateFunction(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the ListBuildsOptions model - listBuildsOptionsModel := new(codeenginev2.ListBuildsOptions) - listBuildsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - listBuildsOptionsModel.Limit = core.Int64Ptr(int64(100)) - listBuildsOptionsModel.Start = core.StringPtr("testString") - listBuildsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the EnvVarPrototype model + envVarPrototypeModel := new(codeenginev2.EnvVarPrototype) + envVarPrototypeModel.Key = core.StringPtr("MY_VARIABLE") + envVarPrototypeModel.Name = core.StringPtr("SOME") + envVarPrototypeModel.Prefix = core.StringPtr("PREFIX_") + envVarPrototypeModel.Reference = core.StringPtr("my-secret") + envVarPrototypeModel.Type = core.StringPtr("literal") + envVarPrototypeModel.Value = core.StringPtr("VALUE") + + // Construct an instance of the FunctionPatch model + functionPatchModel := new(codeenginev2.FunctionPatch) + functionPatchModel.CodeBinary = core.BoolPtr(false) + functionPatchModel.CodeMain = core.StringPtr("main") + functionPatchModel.CodeReference = core.StringPtr("data:text/plain;base64,") + functionPatchModel.CodeSecret = core.StringPtr("my-secret") + functionPatchModel.ManagedDomainMappings = core.StringPtr("local_public") + functionPatchModel.RunEnvVariables = []codeenginev2.EnvVarPrototype{*envVarPrototypeModel} + functionPatchModel.Runtime = core.StringPtr("nodejs-18") + functionPatchModel.ScaleConcurrency = core.Int64Ptr(int64(1)) + functionPatchModel.ScaleCpuLimit = core.StringPtr("1") + functionPatchModel.ScaleDownDelay = core.Int64Ptr(int64(300)) + functionPatchModel.ScaleMaxExecutionTime = core.Int64Ptr(int64(60)) + functionPatchModel.ScaleMemoryLimit = core.StringPtr("1G") + functionPatchModelAsPatch, asPatchErr := functionPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateFunctionOptions model + updateFunctionOptionsModel := new(codeenginev2.UpdateFunctionOptions) + updateFunctionOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + updateFunctionOptionsModel.Name = core.StringPtr("my-function") + updateFunctionOptionsModel.IfMatch = core.StringPtr("testString") + updateFunctionOptionsModel.Function = functionPatchModelAsPatch + updateFunctionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = codeEngineService.ListBuilds(listBuildsOptionsModel) + result, response, operationErr = codeEngineService.UpdateFunction(updateFunctionOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke ListBuilds with error: Operation validation and request error`, func() { + It(`Invoke UpdateFunction with error: Operation validation and request error`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -7211,24 +7921,51 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the ListBuildsOptions model - listBuildsOptionsModel := new(codeenginev2.ListBuildsOptions) - listBuildsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - listBuildsOptionsModel.Limit = core.Int64Ptr(int64(100)) - listBuildsOptionsModel.Start = core.StringPtr("testString") - listBuildsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the EnvVarPrototype model + envVarPrototypeModel := new(codeenginev2.EnvVarPrototype) + envVarPrototypeModel.Key = core.StringPtr("MY_VARIABLE") + envVarPrototypeModel.Name = core.StringPtr("SOME") + envVarPrototypeModel.Prefix = core.StringPtr("PREFIX_") + envVarPrototypeModel.Reference = core.StringPtr("my-secret") + envVarPrototypeModel.Type = core.StringPtr("literal") + envVarPrototypeModel.Value = core.StringPtr("VALUE") + + // Construct an instance of the FunctionPatch model + functionPatchModel := new(codeenginev2.FunctionPatch) + functionPatchModel.CodeBinary = core.BoolPtr(false) + functionPatchModel.CodeMain = core.StringPtr("main") + functionPatchModel.CodeReference = core.StringPtr("data:text/plain;base64,") + functionPatchModel.CodeSecret = core.StringPtr("my-secret") + functionPatchModel.ManagedDomainMappings = core.StringPtr("local_public") + functionPatchModel.RunEnvVariables = []codeenginev2.EnvVarPrototype{*envVarPrototypeModel} + functionPatchModel.Runtime = core.StringPtr("nodejs-18") + functionPatchModel.ScaleConcurrency = core.Int64Ptr(int64(1)) + functionPatchModel.ScaleCpuLimit = core.StringPtr("1") + functionPatchModel.ScaleDownDelay = core.Int64Ptr(int64(300)) + functionPatchModel.ScaleMaxExecutionTime = core.Int64Ptr(int64(60)) + functionPatchModel.ScaleMemoryLimit = core.StringPtr("1G") + functionPatchModelAsPatch, asPatchErr := functionPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateFunctionOptions model + updateFunctionOptionsModel := new(codeenginev2.UpdateFunctionOptions) + updateFunctionOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + updateFunctionOptionsModel.Name = core.StringPtr("my-function") + updateFunctionOptionsModel.IfMatch = core.StringPtr("testString") + updateFunctionOptionsModel.Function = functionPatchModelAsPatch + updateFunctionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := codeEngineService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := codeEngineService.ListBuilds(listBuildsOptionsModel) + result, response, operationErr := codeEngineService.UpdateFunction(updateFunctionOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct a second instance of the ListBuildsOptions model with no property values - listBuildsOptionsModelNew := new(codeenginev2.ListBuildsOptions) + // Construct a second instance of the UpdateFunctionOptions model with no property values + updateFunctionOptionsModelNew := new(codeenginev2.UpdateFunctionOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = codeEngineService.ListBuilds(listBuildsOptionsModelNew) + result, response, operationErr = codeEngineService.UpdateFunction(updateFunctionOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -7246,7 +7983,7 @@ var _ = Describe(`CodeEngineV2`, func() { res.WriteHeader(200) })) }) - It(`Invoke ListBuilds successfully`, func() { + It(`Invoke UpdateFunction successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -7254,15 +7991,42 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the ListBuildsOptions model - listBuildsOptionsModel := new(codeenginev2.ListBuildsOptions) - listBuildsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - listBuildsOptionsModel.Limit = core.Int64Ptr(int64(100)) - listBuildsOptionsModel.Start = core.StringPtr("testString") - listBuildsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the EnvVarPrototype model + envVarPrototypeModel := new(codeenginev2.EnvVarPrototype) + envVarPrototypeModel.Key = core.StringPtr("MY_VARIABLE") + envVarPrototypeModel.Name = core.StringPtr("SOME") + envVarPrototypeModel.Prefix = core.StringPtr("PREFIX_") + envVarPrototypeModel.Reference = core.StringPtr("my-secret") + envVarPrototypeModel.Type = core.StringPtr("literal") + envVarPrototypeModel.Value = core.StringPtr("VALUE") + + // Construct an instance of the FunctionPatch model + functionPatchModel := new(codeenginev2.FunctionPatch) + functionPatchModel.CodeBinary = core.BoolPtr(false) + functionPatchModel.CodeMain = core.StringPtr("main") + functionPatchModel.CodeReference = core.StringPtr("data:text/plain;base64,") + functionPatchModel.CodeSecret = core.StringPtr("my-secret") + functionPatchModel.ManagedDomainMappings = core.StringPtr("local_public") + functionPatchModel.RunEnvVariables = []codeenginev2.EnvVarPrototype{*envVarPrototypeModel} + functionPatchModel.Runtime = core.StringPtr("nodejs-18") + functionPatchModel.ScaleConcurrency = core.Int64Ptr(int64(1)) + functionPatchModel.ScaleCpuLimit = core.StringPtr("1") + functionPatchModel.ScaleDownDelay = core.Int64Ptr(int64(300)) + functionPatchModel.ScaleMaxExecutionTime = core.Int64Ptr(int64(60)) + functionPatchModel.ScaleMemoryLimit = core.StringPtr("1G") + functionPatchModelAsPatch, asPatchErr := functionPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateFunctionOptions model + updateFunctionOptionsModel := new(codeenginev2.UpdateFunctionOptions) + updateFunctionOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + updateFunctionOptionsModel.Name = core.StringPtr("my-function") + updateFunctionOptionsModel.IfMatch = core.StringPtr("testString") + updateFunctionOptionsModel.Function = functionPatchModelAsPatch + updateFunctionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := codeEngineService.ListBuilds(listBuildsOptionsModel) + result, response, operationErr := codeEngineService.UpdateFunction(updateFunctionOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -7273,114 +8037,25 @@ var _ = Describe(`CodeEngineV2`, func() { testServer.Close() }) }) - Context(`Test pagination helper method on response`, func() { - It(`Invoke GetNextStart successfully`, func() { - responseObject := new(codeenginev2.BuildList) - nextObject := new(codeenginev2.ListNextMetadata) - nextObject.Start = core.StringPtr("abc-123") - responseObject.Next = nextObject - - value, err := responseObject.GetNextStart() - Expect(err).To(BeNil()) - Expect(value).To(Equal(core.StringPtr("abc-123"))) - }) - It(`Invoke GetNextStart without a "Next" property in the response`, func() { - responseObject := new(codeenginev2.BuildList) - - value, err := responseObject.GetNextStart() - Expect(err).To(BeNil()) - Expect(value).To(BeNil()) - }) - }) - Context(`Using mock server endpoint - paginated response`, func() { - BeforeEach(func() { - var requestNumber int = 0 - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listBuildsPath)) - Expect(req.Method).To(Equal("GET")) - - // Set mock response - res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - requestNumber++ - if requestNumber == 1 { - fmt.Fprintf(res, "%s", `{"next":{"start":"1"},"total_count":2,"limit":1,"builds":[{"created_at":"2022-09-13T11:41:35+02:00","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-build","output_image":"private.de.icr.io/icr_namespace/image-name","output_secret":"ce-auto-icr-private-eu-de","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"build_v2","source_context_dir":"some/subfolder","source_revision":"main","source_secret":"SourceSecret","source_type":"git","source_url":"https://github.com/IBM/CodeEngine","status":"ready","status_details":{"reason":"registered"},"strategy_size":"medium","strategy_spec_file":"Dockerfile","strategy_type":"dockerfile","timeout":600}]}`) - } else if requestNumber == 2 { - fmt.Fprintf(res, "%s", `{"total_count":2,"limit":1,"builds":[{"created_at":"2022-09-13T11:41:35+02:00","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-build","output_image":"private.de.icr.io/icr_namespace/image-name","output_secret":"ce-auto-icr-private-eu-de","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"build_v2","source_context_dir":"some/subfolder","source_revision":"main","source_secret":"SourceSecret","source_type":"git","source_url":"https://github.com/IBM/CodeEngine","status":"ready","status_details":{"reason":"registered"},"strategy_size":"medium","strategy_spec_file":"Dockerfile","strategy_type":"dockerfile","timeout":600}]}`) - } else { - res.WriteHeader(400) - } - })) - }) - It(`Use BuildsPager.GetNext successfully`, func() { - codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - }) - Expect(serviceErr).To(BeNil()) - Expect(codeEngineService).ToNot(BeNil()) - - listBuildsOptionsModel := &codeenginev2.ListBuildsOptions{ - ProjectID: core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"), - Limit: core.Int64Ptr(int64(100)), - } - - pager, err := codeEngineService.NewBuildsPager(listBuildsOptionsModel) - Expect(err).To(BeNil()) - Expect(pager).ToNot(BeNil()) - - var allResults []codeenginev2.Build - for pager.HasNext() { - nextPage, err := pager.GetNext() - Expect(err).To(BeNil()) - Expect(nextPage).ToNot(BeNil()) - allResults = append(allResults, nextPage...) - } - Expect(len(allResults)).To(Equal(2)) - }) - It(`Use BuildsPager.GetAll successfully`, func() { - codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - }) - Expect(serviceErr).To(BeNil()) - Expect(codeEngineService).ToNot(BeNil()) - - listBuildsOptionsModel := &codeenginev2.ListBuildsOptions{ - ProjectID: core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"), - Limit: core.Int64Ptr(int64(100)), - } - - pager, err := codeEngineService.NewBuildsPager(listBuildsOptionsModel) - Expect(err).To(BeNil()) - Expect(pager).ToNot(BeNil()) - - allResults, err := pager.GetAll() - Expect(err).To(BeNil()) - Expect(allResults).ToNot(BeNil()) - Expect(len(allResults)).To(Equal(2)) - }) - }) }) - Describe(`CreateBuild(createBuildOptions *CreateBuildOptions) - Operation response error`, func() { - createBuildPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/builds" + Describe(`ListBindings(listBindingsOptions *ListBindingsOptions) - Operation response error`, func() { + listBindingsPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/bindings" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createBuildPath)) - Expect(req.Method).To(Equal("POST")) + Expect(req.URL.EscapedPath()).To(Equal(listBindingsPath)) + Expect(req.Method).To(Equal("GET")) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(100))})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) res.Header().Set("Content-type", "application/json") - res.WriteHeader(201) + res.WriteHeader(200) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke CreateBuild with error: Operation response processing error`, func() { + It(`Invoke ListBindings with error: Operation response processing error`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -7388,31 +8063,21 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the CreateBuildOptions model - createBuildOptionsModel := new(codeenginev2.CreateBuildOptions) - createBuildOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - createBuildOptionsModel.Name = core.StringPtr("my-build") - createBuildOptionsModel.OutputImage = core.StringPtr("private.de.icr.io/icr_namespace/image-name") - createBuildOptionsModel.OutputSecret = core.StringPtr("ce-auto-icr-private-eu-de") - createBuildOptionsModel.StrategyType = core.StringPtr("dockerfile") - createBuildOptionsModel.SourceContextDir = core.StringPtr("some/subfolder") - createBuildOptionsModel.SourceRevision = core.StringPtr("main") - createBuildOptionsModel.SourceSecret = core.StringPtr("testString") - createBuildOptionsModel.SourceType = core.StringPtr("git") - createBuildOptionsModel.SourceURL = core.StringPtr("https://github.com/IBM/CodeEngine") - createBuildOptionsModel.StrategySize = core.StringPtr("medium") - createBuildOptionsModel.StrategySpecFile = core.StringPtr("Dockerfile") - createBuildOptionsModel.Timeout = core.Int64Ptr(int64(600)) - createBuildOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListBindingsOptions model + listBindingsOptionsModel := new(codeenginev2.ListBindingsOptions) + listBindingsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + listBindingsOptionsModel.Limit = core.Int64Ptr(int64(100)) + listBindingsOptionsModel.Start = core.StringPtr("testString") + listBindingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := codeEngineService.CreateBuild(createBuildOptionsModel) + result, response, operationErr := codeEngineService.ListBindings(listBindingsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again codeEngineService.EnableRetries(0, 0) - result, response, operationErr = codeEngineService.CreateBuild(createBuildOptionsModel) + result, response, operationErr = codeEngineService.ListBindings(listBindingsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -7422,43 +8087,29 @@ var _ = Describe(`CodeEngineV2`, func() { }) }) }) - Describe(`CreateBuild(createBuildOptions *CreateBuildOptions)`, func() { - createBuildPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/builds" + Describe(`ListBindings(listBindingsOptions *ListBindingsOptions)`, func() { + listBindingsPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/bindings" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createBuildPath)) - Expect(req.Method).To(Equal("POST")) - - // For gzip-disabled operation, verify Content-Encoding is not set. - Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) - - // If there is a body, then make sure we can read it - bodyBuf := new(bytes.Buffer) - if req.Header.Get("Content-Encoding") == "gzip" { - body, err := core.NewGzipDecompressionReader(req.Body) - Expect(err).To(BeNil()) - _, err = bodyBuf.ReadFrom(body) - Expect(err).To(BeNil()) - } else { - _, err := bodyBuf.ReadFrom(req.Body) - Expect(err).To(BeNil()) - } - fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + Expect(req.URL.EscapedPath()).To(Equal(listBindingsPath)) + Expect(req.Method).To(Equal("GET")) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(100))})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) // Sleep a short time to support a timeout test time.Sleep(100 * time.Millisecond) // Set mock response res.Header().Set("Content-type", "application/json") - res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "build_v2", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "SourceSecret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "ready", "status_details": {"reason": "registered"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}`) + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"bindings": [{"component": {"name": "my-app-1", "resource_type": "app_v2"}, "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/bindings/my-binding", "id": "a172ced-b5f21bc-71ba50c-1638604", "prefix": "MY_COS", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "binding_v2", "secret_name": "my-service-access", "status": "active"}], "first": {"href": "Href"}, "limit": 100, "next": {"href": "Href", "start": "Start"}}`) })) }) - It(`Invoke CreateBuild successfully with retries`, func() { + It(`Invoke ListBindings successfully with retries`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -7467,33 +8118,23 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(codeEngineService).ToNot(BeNil()) codeEngineService.EnableRetries(0, 0) - // Construct an instance of the CreateBuildOptions model - createBuildOptionsModel := new(codeenginev2.CreateBuildOptions) - createBuildOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - createBuildOptionsModel.Name = core.StringPtr("my-build") - createBuildOptionsModel.OutputImage = core.StringPtr("private.de.icr.io/icr_namespace/image-name") - createBuildOptionsModel.OutputSecret = core.StringPtr("ce-auto-icr-private-eu-de") - createBuildOptionsModel.StrategyType = core.StringPtr("dockerfile") - createBuildOptionsModel.SourceContextDir = core.StringPtr("some/subfolder") - createBuildOptionsModel.SourceRevision = core.StringPtr("main") - createBuildOptionsModel.SourceSecret = core.StringPtr("testString") - createBuildOptionsModel.SourceType = core.StringPtr("git") - createBuildOptionsModel.SourceURL = core.StringPtr("https://github.com/IBM/CodeEngine") - createBuildOptionsModel.StrategySize = core.StringPtr("medium") - createBuildOptionsModel.StrategySpecFile = core.StringPtr("Dockerfile") - createBuildOptionsModel.Timeout = core.Int64Ptr(int64(600)) - createBuildOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListBindingsOptions model + listBindingsOptionsModel := new(codeenginev2.ListBindingsOptions) + listBindingsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + listBindingsOptionsModel.Limit = core.Int64Ptr(int64(100)) + listBindingsOptionsModel.Start = core.StringPtr("testString") + listBindingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := codeEngineService.CreateBuildWithContext(ctx, createBuildOptionsModel) + _, _, operationErr := codeEngineService.ListBindingsWithContext(ctx, listBindingsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again codeEngineService.DisableRetries() - result, response, operationErr := codeEngineService.CreateBuild(createBuildOptionsModel) + result, response, operationErr := codeEngineService.ListBindings(listBindingsOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -7501,7 +8142,7 @@ var _ = Describe(`CodeEngineV2`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = codeEngineService.CreateBuildWithContext(ctx, createBuildOptionsModel) + _, _, operationErr = codeEngineService.ListBindingsWithContext(ctx, listBindingsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -7515,32 +8156,18 @@ var _ = Describe(`CodeEngineV2`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createBuildPath)) - Expect(req.Method).To(Equal("POST")) - - // For gzip-disabled operation, verify Content-Encoding is not set. - Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) - - // If there is a body, then make sure we can read it - bodyBuf := new(bytes.Buffer) - if req.Header.Get("Content-Encoding") == "gzip" { - body, err := core.NewGzipDecompressionReader(req.Body) - Expect(err).To(BeNil()) - _, err = bodyBuf.ReadFrom(body) - Expect(err).To(BeNil()) - } else { - _, err := bodyBuf.ReadFrom(req.Body) - Expect(err).To(BeNil()) - } - fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + Expect(req.URL.EscapedPath()).To(Equal(listBindingsPath)) + Expect(req.Method).To(Equal("GET")) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(100))})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) // Set mock response res.Header().Set("Content-type", "application/json") - res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "build_v2", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "SourceSecret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "ready", "status_details": {"reason": "registered"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}`) + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"bindings": [{"component": {"name": "my-app-1", "resource_type": "app_v2"}, "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/bindings/my-binding", "id": "a172ced-b5f21bc-71ba50c-1638604", "prefix": "MY_COS", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "binding_v2", "secret_name": "my-service-access", "status": "active"}], "first": {"href": "Href"}, "limit": 100, "next": {"href": "Href", "start": "Start"}}`) })) }) - It(`Invoke CreateBuild successfully`, func() { + It(`Invoke ListBindings successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -7549,36 +8176,26 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(codeEngineService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := codeEngineService.CreateBuild(nil) + result, response, operationErr := codeEngineService.ListBindings(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the CreateBuildOptions model - createBuildOptionsModel := new(codeenginev2.CreateBuildOptions) - createBuildOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - createBuildOptionsModel.Name = core.StringPtr("my-build") - createBuildOptionsModel.OutputImage = core.StringPtr("private.de.icr.io/icr_namespace/image-name") - createBuildOptionsModel.OutputSecret = core.StringPtr("ce-auto-icr-private-eu-de") - createBuildOptionsModel.StrategyType = core.StringPtr("dockerfile") - createBuildOptionsModel.SourceContextDir = core.StringPtr("some/subfolder") - createBuildOptionsModel.SourceRevision = core.StringPtr("main") - createBuildOptionsModel.SourceSecret = core.StringPtr("testString") - createBuildOptionsModel.SourceType = core.StringPtr("git") - createBuildOptionsModel.SourceURL = core.StringPtr("https://github.com/IBM/CodeEngine") - createBuildOptionsModel.StrategySize = core.StringPtr("medium") - createBuildOptionsModel.StrategySpecFile = core.StringPtr("Dockerfile") - createBuildOptionsModel.Timeout = core.Int64Ptr(int64(600)) - createBuildOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListBindingsOptions model + listBindingsOptionsModel := new(codeenginev2.ListBindingsOptions) + listBindingsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + listBindingsOptionsModel.Limit = core.Int64Ptr(int64(100)) + listBindingsOptionsModel.Start = core.StringPtr("testString") + listBindingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = codeEngineService.CreateBuild(createBuildOptionsModel) + result, response, operationErr = codeEngineService.ListBindings(listBindingsOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke CreateBuild with error: Operation validation and request error`, func() { + It(`Invoke ListBindings with error: Operation validation and request error`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -7586,34 +8203,24 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the CreateBuildOptions model - createBuildOptionsModel := new(codeenginev2.CreateBuildOptions) - createBuildOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - createBuildOptionsModel.Name = core.StringPtr("my-build") - createBuildOptionsModel.OutputImage = core.StringPtr("private.de.icr.io/icr_namespace/image-name") - createBuildOptionsModel.OutputSecret = core.StringPtr("ce-auto-icr-private-eu-de") - createBuildOptionsModel.StrategyType = core.StringPtr("dockerfile") - createBuildOptionsModel.SourceContextDir = core.StringPtr("some/subfolder") - createBuildOptionsModel.SourceRevision = core.StringPtr("main") - createBuildOptionsModel.SourceSecret = core.StringPtr("testString") - createBuildOptionsModel.SourceType = core.StringPtr("git") - createBuildOptionsModel.SourceURL = core.StringPtr("https://github.com/IBM/CodeEngine") - createBuildOptionsModel.StrategySize = core.StringPtr("medium") - createBuildOptionsModel.StrategySpecFile = core.StringPtr("Dockerfile") - createBuildOptionsModel.Timeout = core.Int64Ptr(int64(600)) - createBuildOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListBindingsOptions model + listBindingsOptionsModel := new(codeenginev2.ListBindingsOptions) + listBindingsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + listBindingsOptionsModel.Limit = core.Int64Ptr(int64(100)) + listBindingsOptionsModel.Start = core.StringPtr("testString") + listBindingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := codeEngineService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := codeEngineService.CreateBuild(createBuildOptionsModel) + result, response, operationErr := codeEngineService.ListBindings(listBindingsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct a second instance of the CreateBuildOptions model with no property values - createBuildOptionsModelNew := new(codeenginev2.CreateBuildOptions) + // Construct a second instance of the ListBindingsOptions model with no property values + listBindingsOptionsModelNew := new(codeenginev2.ListBindingsOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = codeEngineService.CreateBuild(createBuildOptionsModelNew) + result, response, operationErr = codeEngineService.ListBindings(listBindingsOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -7628,10 +8235,10 @@ var _ = Describe(`CodeEngineV2`, func() { defer GinkgoRecover() // Set success status code with no respoonse body - res.WriteHeader(201) + res.WriteHeader(200) })) }) - It(`Invoke CreateBuild successfully`, func() { + It(`Invoke ListBindings successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -7639,25 +8246,15 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the CreateBuildOptions model - createBuildOptionsModel := new(codeenginev2.CreateBuildOptions) - createBuildOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - createBuildOptionsModel.Name = core.StringPtr("my-build") - createBuildOptionsModel.OutputImage = core.StringPtr("private.de.icr.io/icr_namespace/image-name") - createBuildOptionsModel.OutputSecret = core.StringPtr("ce-auto-icr-private-eu-de") - createBuildOptionsModel.StrategyType = core.StringPtr("dockerfile") - createBuildOptionsModel.SourceContextDir = core.StringPtr("some/subfolder") - createBuildOptionsModel.SourceRevision = core.StringPtr("main") - createBuildOptionsModel.SourceSecret = core.StringPtr("testString") - createBuildOptionsModel.SourceType = core.StringPtr("git") - createBuildOptionsModel.SourceURL = core.StringPtr("https://github.com/IBM/CodeEngine") - createBuildOptionsModel.StrategySize = core.StringPtr("medium") - createBuildOptionsModel.StrategySpecFile = core.StringPtr("Dockerfile") - createBuildOptionsModel.Timeout = core.Int64Ptr(int64(600)) - createBuildOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListBindingsOptions model + listBindingsOptionsModel := new(codeenginev2.ListBindingsOptions) + listBindingsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + listBindingsOptionsModel.Limit = core.Int64Ptr(int64(100)) + listBindingsOptionsModel.Start = core.StringPtr("testString") + listBindingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := codeEngineService.CreateBuild(createBuildOptionsModel) + result, response, operationErr := codeEngineService.ListBindings(listBindingsOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -7668,23 +8265,49 @@ var _ = Describe(`CodeEngineV2`, func() { testServer.Close() }) }) - }) - Describe(`GetBuild(getBuildOptions *GetBuildOptions) - Operation response error`, func() { - getBuildPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/builds/my-build" - Context(`Using mock server endpoint with invalid JSON response`, func() { + Context(`Test pagination helper method on response`, func() { + It(`Invoke GetNextStart successfully`, func() { + responseObject := new(codeenginev2.BindingList) + nextObject := new(codeenginev2.ListNextMetadata) + nextObject.Start = core.StringPtr("abc-123") + responseObject.Next = nextObject + + value, err := responseObject.GetNextStart() + Expect(err).To(BeNil()) + Expect(value).To(Equal(core.StringPtr("abc-123"))) + }) + It(`Invoke GetNextStart without a "Next" property in the response`, func() { + responseObject := new(codeenginev2.BindingList) + + value, err := responseObject.GetNextStart() + Expect(err).To(BeNil()) + Expect(value).To(BeNil()) + }) + }) + Context(`Using mock server endpoint - paginated response`, func() { BeforeEach(func() { + var requestNumber int = 0 testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getBuildPath)) + Expect(req.URL.EscapedPath()).To(Equal(listBindingsPath)) Expect(req.Method).To(Equal("GET")) + + // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprint(res, `} this is not valid json {`) + requestNumber++ + if requestNumber == 1 { + fmt.Fprintf(res, "%s", `{"next":{"start":"1"},"total_count":2,"bindings":[{"component":{"name":"my-app-1","resource_type":"app_v2"},"href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/bindings/my-binding","id":"a172ced-b5f21bc-71ba50c-1638604","prefix":"MY_COS","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","resource_type":"binding_v2","secret_name":"my-service-access","status":"active"}],"limit":1}`) + } else if requestNumber == 2 { + fmt.Fprintf(res, "%s", `{"total_count":2,"bindings":[{"component":{"name":"my-app-1","resource_type":"app_v2"},"href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/bindings/my-binding","id":"a172ced-b5f21bc-71ba50c-1638604","prefix":"MY_COS","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","resource_type":"binding_v2","secret_name":"my-service-access","status":"active"}],"limit":1}`) + } else { + res.WriteHeader(400) + } })) }) - It(`Invoke GetBuild with error: Operation response processing error`, func() { + It(`Use BindingsPager.GetNext successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -7692,74 +8315,169 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the GetBuildOptions model - getBuildOptionsModel := new(codeenginev2.GetBuildOptions) - getBuildOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - getBuildOptionsModel.Name = core.StringPtr("my-build") - getBuildOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := codeEngineService.GetBuild(getBuildOptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(response).ToNot(BeNil()) - Expect(result).To(BeNil()) + listBindingsOptionsModel := &codeenginev2.ListBindingsOptions{ + ProjectID: core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"), + Limit: core.Int64Ptr(int64(100)), + } - // Enable retries and test again - codeEngineService.EnableRetries(0, 0) - result, response, operationErr = codeEngineService.GetBuild(getBuildOptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(response).ToNot(BeNil()) - Expect(result).To(BeNil()) + pager, err := codeEngineService.NewBindingsPager(listBindingsOptionsModel) + Expect(err).To(BeNil()) + Expect(pager).ToNot(BeNil()) + + var allResults []codeenginev2.Binding + for pager.HasNext() { + nextPage, err := pager.GetNext() + Expect(err).To(BeNil()) + Expect(nextPage).ToNot(BeNil()) + allResults = append(allResults, nextPage...) + } + Expect(len(allResults)).To(Equal(2)) }) - AfterEach(func() { - testServer.Close() + It(`Use BindingsPager.GetAll successfully`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + + listBindingsOptionsModel := &codeenginev2.ListBindingsOptions{ + ProjectID: core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"), + Limit: core.Int64Ptr(int64(100)), + } + + pager, err := codeEngineService.NewBindingsPager(listBindingsOptionsModel) + Expect(err).To(BeNil()) + Expect(pager).ToNot(BeNil()) + + allResults, err := pager.GetAll() + Expect(err).To(BeNil()) + Expect(allResults).ToNot(BeNil()) + Expect(len(allResults)).To(Equal(2)) }) }) }) - Describe(`GetBuild(getBuildOptions *GetBuildOptions)`, func() { - getBuildPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/builds/my-build" - Context(`Using mock server endpoint with timeout`, func() { + Describe(`CreateBinding(createBindingOptions *CreateBindingOptions) - Operation response error`, func() { + createBindingPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/bindings" + Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getBuildPath)) - Expect(req.Method).To(Equal("GET")) - - // Sleep a short time to support a timeout test - time.Sleep(100 * time.Millisecond) - - // Set mock response + Expect(req.URL.EscapedPath()).To(Equal(createBindingPath)) + Expect(req.Method).To(Equal("POST")) res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "build_v2", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "SourceSecret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "ready", "status_details": {"reason": "registered"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}`) + res.WriteHeader(201) + fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke GetBuild successfully with retries`, func() { + It(`Invoke CreateBinding with error: Operation response processing error`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, }) Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - codeEngineService.EnableRetries(0, 0) - // Construct an instance of the GetBuildOptions model - getBuildOptionsModel := new(codeenginev2.GetBuildOptions) - getBuildOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - getBuildOptionsModel.Name = core.StringPtr("my-build") - getBuildOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ComponentRef model + componentRefModel := new(codeenginev2.ComponentRef) + componentRefModel.Name = core.StringPtr("my-app-1") + componentRefModel.ResourceType = core.StringPtr("app_v2") + + // Construct an instance of the CreateBindingOptions model + createBindingOptionsModel := new(codeenginev2.CreateBindingOptions) + createBindingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + createBindingOptionsModel.Component = componentRefModel + createBindingOptionsModel.Prefix = core.StringPtr("MY_COS") + createBindingOptionsModel.SecretName = core.StringPtr("my-service-access") + createBindingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := codeEngineService.CreateBinding(createBindingOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + codeEngineService.EnableRetries(0, 0) + result, response, operationErr = codeEngineService.CreateBinding(createBindingOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`CreateBinding(createBindingOptions *CreateBindingOptions)`, func() { + createBindingPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/bindings" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(createBindingPath)) + Expect(req.Method).To(Equal("POST")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(201) + fmt.Fprintf(res, "%s", `{"component": {"name": "my-app-1", "resource_type": "app_v2"}, "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/bindings/my-binding", "id": "a172ced-b5f21bc-71ba50c-1638604", "prefix": "MY_COS", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "binding_v2", "secret_name": "my-service-access", "status": "active"}`) + })) + }) + It(`Invoke CreateBinding successfully with retries`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + codeEngineService.EnableRetries(0, 0) + + // Construct an instance of the ComponentRef model + componentRefModel := new(codeenginev2.ComponentRef) + componentRefModel.Name = core.StringPtr("my-app-1") + componentRefModel.ResourceType = core.StringPtr("app_v2") + + // Construct an instance of the CreateBindingOptions model + createBindingOptionsModel := new(codeenginev2.CreateBindingOptions) + createBindingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + createBindingOptionsModel.Component = componentRefModel + createBindingOptionsModel.Prefix = core.StringPtr("MY_COS") + createBindingOptionsModel.SecretName = core.StringPtr("my-service-access") + createBindingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := codeEngineService.GetBuildWithContext(ctx, getBuildOptionsModel) + _, _, operationErr := codeEngineService.CreateBindingWithContext(ctx, createBindingOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again codeEngineService.DisableRetries() - result, response, operationErr := codeEngineService.GetBuild(getBuildOptionsModel) + result, response, operationErr := codeEngineService.CreateBinding(createBindingOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -7767,7 +8485,7 @@ var _ = Describe(`CodeEngineV2`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = codeEngineService.GetBuildWithContext(ctx, getBuildOptionsModel) + _, _, operationErr = codeEngineService.CreateBindingWithContext(ctx, createBindingOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -7781,16 +8499,32 @@ var _ = Describe(`CodeEngineV2`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getBuildPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(createBindingPath)) + Expect(req.Method).To(Equal("POST")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) // Set mock response res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "build_v2", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "SourceSecret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "ready", "status_details": {"reason": "registered"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}`) + res.WriteHeader(201) + fmt.Fprintf(res, "%s", `{"component": {"name": "my-app-1", "resource_type": "app_v2"}, "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/bindings/my-binding", "id": "a172ced-b5f21bc-71ba50c-1638604", "prefix": "MY_COS", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "binding_v2", "secret_name": "my-service-access", "status": "active"}`) })) }) - It(`Invoke GetBuild successfully`, func() { + It(`Invoke CreateBinding successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -7799,25 +8533,32 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(codeEngineService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := codeEngineService.GetBuild(nil) + result, response, operationErr := codeEngineService.CreateBinding(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the GetBuildOptions model - getBuildOptionsModel := new(codeenginev2.GetBuildOptions) - getBuildOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - getBuildOptionsModel.Name = core.StringPtr("my-build") - getBuildOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ComponentRef model + componentRefModel := new(codeenginev2.ComponentRef) + componentRefModel.Name = core.StringPtr("my-app-1") + componentRefModel.ResourceType = core.StringPtr("app_v2") + + // Construct an instance of the CreateBindingOptions model + createBindingOptionsModel := new(codeenginev2.CreateBindingOptions) + createBindingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + createBindingOptionsModel.Component = componentRefModel + createBindingOptionsModel.Prefix = core.StringPtr("MY_COS") + createBindingOptionsModel.SecretName = core.StringPtr("my-service-access") + createBindingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = codeEngineService.GetBuild(getBuildOptionsModel) + result, response, operationErr = codeEngineService.CreateBinding(createBindingOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke GetBuild with error: Operation validation and request error`, func() { + It(`Invoke CreateBinding with error: Operation validation and request error`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -7825,23 +8566,30 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the GetBuildOptions model - getBuildOptionsModel := new(codeenginev2.GetBuildOptions) - getBuildOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - getBuildOptionsModel.Name = core.StringPtr("my-build") - getBuildOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ComponentRef model + componentRefModel := new(codeenginev2.ComponentRef) + componentRefModel.Name = core.StringPtr("my-app-1") + componentRefModel.ResourceType = core.StringPtr("app_v2") + + // Construct an instance of the CreateBindingOptions model + createBindingOptionsModel := new(codeenginev2.CreateBindingOptions) + createBindingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + createBindingOptionsModel.Component = componentRefModel + createBindingOptionsModel.Prefix = core.StringPtr("MY_COS") + createBindingOptionsModel.SecretName = core.StringPtr("my-service-access") + createBindingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := codeEngineService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := codeEngineService.GetBuild(getBuildOptionsModel) + result, response, operationErr := codeEngineService.CreateBinding(createBindingOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct a second instance of the GetBuildOptions model with no property values - getBuildOptionsModelNew := new(codeenginev2.GetBuildOptions) + // Construct a second instance of the CreateBindingOptions model with no property values + createBindingOptionsModelNew := new(codeenginev2.CreateBindingOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = codeEngineService.GetBuild(getBuildOptionsModelNew) + result, response, operationErr = codeEngineService.CreateBinding(createBindingOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -7856,10 +8604,10 @@ var _ = Describe(`CodeEngineV2`, func() { defer GinkgoRecover() // Set success status code with no respoonse body - res.WriteHeader(200) + res.WriteHeader(201) })) }) - It(`Invoke GetBuild successfully`, func() { + It(`Invoke CreateBinding successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -7867,14 +8615,21 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the GetBuildOptions model - getBuildOptionsModel := new(codeenginev2.GetBuildOptions) - getBuildOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - getBuildOptionsModel.Name = core.StringPtr("my-build") - getBuildOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ComponentRef model + componentRefModel := new(codeenginev2.ComponentRef) + componentRefModel.Name = core.StringPtr("my-app-1") + componentRefModel.ResourceType = core.StringPtr("app_v2") + + // Construct an instance of the CreateBindingOptions model + createBindingOptionsModel := new(codeenginev2.CreateBindingOptions) + createBindingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + createBindingOptionsModel.Component = componentRefModel + createBindingOptionsModel.Prefix = core.StringPtr("MY_COS") + createBindingOptionsModel.SecretName = core.StringPtr("my-service-access") + createBindingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := codeEngineService.GetBuild(getBuildOptionsModel) + result, response, operationErr := codeEngineService.CreateBinding(createBindingOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -7886,21 +8641,22 @@ var _ = Describe(`CodeEngineV2`, func() { }) }) }) - Describe(`DeleteBuild(deleteBuildOptions *DeleteBuildOptions)`, func() { - deleteBuildPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/builds/my-build" - Context(`Using mock server endpoint`, func() { + Describe(`GetBinding(getBindingOptions *GetBindingOptions) - Operation response error`, func() { + getBindingPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/bindings/a172ced-b5f21bc-71ba50c-1638604" + Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(deleteBuildPath)) - Expect(req.Method).To(Equal("DELETE")) - - res.WriteHeader(202) + Expect(req.URL.EscapedPath()).To(Equal(getBindingPath)) + Expect(req.Method).To(Equal("GET")) + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke DeleteBuild successfully`, func() { + It(`Invoke GetBinding with error: Operation response processing error`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -7908,31 +8664,1157 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Invoke operation with nil options model (negative test) - response, operationErr := codeEngineService.DeleteBuild(nil) - Expect(operationErr).NotTo(BeNil()) - Expect(response).To(BeNil()) - - // Construct an instance of the DeleteBuildOptions model - deleteBuildOptionsModel := new(codeenginev2.DeleteBuildOptions) - deleteBuildOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - deleteBuildOptionsModel.Name = core.StringPtr("my-build") - deleteBuildOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetBindingOptions model + getBindingOptionsModel := new(codeenginev2.GetBindingOptions) + getBindingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + getBindingOptionsModel.ID = core.StringPtr("a172ced-b5f21bc-71ba50c-1638604") + getBindingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := codeEngineService.GetBinding(getBindingOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) - // Invoke operation with valid options model (positive test) - response, operationErr = codeEngineService.DeleteBuild(deleteBuildOptionsModel) - Expect(operationErr).To(BeNil()) + // Enable retries and test again + codeEngineService.EnableRetries(0, 0) + result, response, operationErr = codeEngineService.GetBinding(getBindingOptionsModel) + Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) }) - It(`Invoke DeleteBuild with error: Operation validation and request error`, func() { - codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - }) - Expect(serviceErr).To(BeNil()) - Expect(codeEngineService).ToNot(BeNil()) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetBinding(getBindingOptions *GetBindingOptions)`, func() { + getBindingPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/bindings/a172ced-b5f21bc-71ba50c-1638604" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() - // Construct an instance of the DeleteBuildOptions model + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getBindingPath)) + Expect(req.Method).To(Equal("GET")) + + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"component": {"name": "my-app-1", "resource_type": "app_v2"}, "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/bindings/my-binding", "id": "a172ced-b5f21bc-71ba50c-1638604", "prefix": "MY_COS", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "binding_v2", "secret_name": "my-service-access", "status": "active"}`) + })) + }) + It(`Invoke GetBinding successfully with retries`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + codeEngineService.EnableRetries(0, 0) + + // Construct an instance of the GetBindingOptions model + getBindingOptionsModel := new(codeenginev2.GetBindingOptions) + getBindingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + getBindingOptionsModel.ID = core.StringPtr("a172ced-b5f21bc-71ba50c-1638604") + getBindingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := codeEngineService.GetBindingWithContext(ctx, getBindingOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + codeEngineService.DisableRetries() + result, response, operationErr := codeEngineService.GetBinding(getBindingOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = codeEngineService.GetBindingWithContext(ctx, getBindingOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getBindingPath)) + Expect(req.Method).To(Equal("GET")) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"component": {"name": "my-app-1", "resource_type": "app_v2"}, "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/bindings/my-binding", "id": "a172ced-b5f21bc-71ba50c-1638604", "prefix": "MY_COS", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "binding_v2", "secret_name": "my-service-access", "status": "active"}`) + })) + }) + It(`Invoke GetBinding successfully`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := codeEngineService.GetBinding(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the GetBindingOptions model + getBindingOptionsModel := new(codeenginev2.GetBindingOptions) + getBindingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + getBindingOptionsModel.ID = core.StringPtr("a172ced-b5f21bc-71ba50c-1638604") + getBindingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = codeEngineService.GetBinding(getBindingOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke GetBinding with error: Operation validation and request error`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + + // Construct an instance of the GetBindingOptions model + getBindingOptionsModel := new(codeenginev2.GetBindingOptions) + getBindingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + getBindingOptionsModel.ID = core.StringPtr("a172ced-b5f21bc-71ba50c-1638604") + getBindingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := codeEngineService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := codeEngineService.GetBinding(getBindingOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + // Construct a second instance of the GetBindingOptions model with no property values + getBindingOptionsModelNew := new(codeenginev2.GetBindingOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = codeEngineService.GetBinding(getBindingOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(200) + })) + }) + It(`Invoke GetBinding successfully`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + + // Construct an instance of the GetBindingOptions model + getBindingOptionsModel := new(codeenginev2.GetBindingOptions) + getBindingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + getBindingOptionsModel.ID = core.StringPtr("a172ced-b5f21bc-71ba50c-1638604") + getBindingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := codeEngineService.GetBinding(getBindingOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`DeleteBinding(deleteBindingOptions *DeleteBindingOptions)`, func() { + deleteBindingPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/bindings/a172ced-b5f21bc-71ba50c-1638604" + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(deleteBindingPath)) + Expect(req.Method).To(Equal("DELETE")) + + res.WriteHeader(202) + })) + }) + It(`Invoke DeleteBinding successfully`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + response, operationErr := codeEngineService.DeleteBinding(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + + // Construct an instance of the DeleteBindingOptions model + deleteBindingOptionsModel := new(codeenginev2.DeleteBindingOptions) + deleteBindingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + deleteBindingOptionsModel.ID = core.StringPtr("a172ced-b5f21bc-71ba50c-1638604") + deleteBindingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + response, operationErr = codeEngineService.DeleteBinding(deleteBindingOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + }) + It(`Invoke DeleteBinding with error: Operation validation and request error`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + + // Construct an instance of the DeleteBindingOptions model + deleteBindingOptionsModel := new(codeenginev2.DeleteBindingOptions) + deleteBindingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + deleteBindingOptionsModel.ID = core.StringPtr("a172ced-b5f21bc-71ba50c-1638604") + deleteBindingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := codeEngineService.SetServiceURL("") + Expect(err).To(BeNil()) + response, operationErr := codeEngineService.DeleteBinding(deleteBindingOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + // Construct a second instance of the DeleteBindingOptions model with no property values + deleteBindingOptionsModelNew := new(codeenginev2.DeleteBindingOptions) + // Invoke operation with invalid model (negative test) + response, operationErr = codeEngineService.DeleteBinding(deleteBindingOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`ListBuilds(listBuildsOptions *ListBuildsOptions) - Operation response error`, func() { + listBuildsPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/builds" + Context(`Using mock server endpoint with invalid JSON response`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listBuildsPath)) + Expect(req.Method).To(Equal("GET")) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(100))})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke ListBuilds with error: Operation response processing error`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + + // Construct an instance of the ListBuildsOptions model + listBuildsOptionsModel := new(codeenginev2.ListBuildsOptions) + listBuildsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + listBuildsOptionsModel.Limit = core.Int64Ptr(int64(100)) + listBuildsOptionsModel.Start = core.StringPtr("testString") + listBuildsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := codeEngineService.ListBuilds(listBuildsOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + codeEngineService.EnableRetries(0, 0) + result, response, operationErr = codeEngineService.ListBuilds(listBuildsOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`ListBuilds(listBuildsOptions *ListBuildsOptions)`, func() { + listBuildsPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/builds" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listBuildsPath)) + Expect(req.Method).To(Equal("GET")) + + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(100))})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"builds": [{"created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "build_v2", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "SourceSecret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "ready", "status_details": {"reason": "registered"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}], "first": {"href": "Href"}, "limit": 100, "next": {"href": "Href", "start": "Start"}}`) + })) + }) + It(`Invoke ListBuilds successfully with retries`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + codeEngineService.EnableRetries(0, 0) + + // Construct an instance of the ListBuildsOptions model + listBuildsOptionsModel := new(codeenginev2.ListBuildsOptions) + listBuildsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + listBuildsOptionsModel.Limit = core.Int64Ptr(int64(100)) + listBuildsOptionsModel.Start = core.StringPtr("testString") + listBuildsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := codeEngineService.ListBuildsWithContext(ctx, listBuildsOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + codeEngineService.DisableRetries() + result, response, operationErr := codeEngineService.ListBuilds(listBuildsOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = codeEngineService.ListBuildsWithContext(ctx, listBuildsOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listBuildsPath)) + Expect(req.Method).To(Equal("GET")) + + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(100))})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"builds": [{"created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "build_v2", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "SourceSecret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "ready", "status_details": {"reason": "registered"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}], "first": {"href": "Href"}, "limit": 100, "next": {"href": "Href", "start": "Start"}}`) + })) + }) + It(`Invoke ListBuilds successfully`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := codeEngineService.ListBuilds(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the ListBuildsOptions model + listBuildsOptionsModel := new(codeenginev2.ListBuildsOptions) + listBuildsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + listBuildsOptionsModel.Limit = core.Int64Ptr(int64(100)) + listBuildsOptionsModel.Start = core.StringPtr("testString") + listBuildsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = codeEngineService.ListBuilds(listBuildsOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke ListBuilds with error: Operation validation and request error`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + + // Construct an instance of the ListBuildsOptions model + listBuildsOptionsModel := new(codeenginev2.ListBuildsOptions) + listBuildsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + listBuildsOptionsModel.Limit = core.Int64Ptr(int64(100)) + listBuildsOptionsModel.Start = core.StringPtr("testString") + listBuildsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := codeEngineService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := codeEngineService.ListBuilds(listBuildsOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + // Construct a second instance of the ListBuildsOptions model with no property values + listBuildsOptionsModelNew := new(codeenginev2.ListBuildsOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = codeEngineService.ListBuilds(listBuildsOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(200) + })) + }) + It(`Invoke ListBuilds successfully`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + + // Construct an instance of the ListBuildsOptions model + listBuildsOptionsModel := new(codeenginev2.ListBuildsOptions) + listBuildsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + listBuildsOptionsModel.Limit = core.Int64Ptr(int64(100)) + listBuildsOptionsModel.Start = core.StringPtr("testString") + listBuildsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := codeEngineService.ListBuilds(listBuildsOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Test pagination helper method on response`, func() { + It(`Invoke GetNextStart successfully`, func() { + responseObject := new(codeenginev2.BuildList) + nextObject := new(codeenginev2.ListNextMetadata) + nextObject.Start = core.StringPtr("abc-123") + responseObject.Next = nextObject + + value, err := responseObject.GetNextStart() + Expect(err).To(BeNil()) + Expect(value).To(Equal(core.StringPtr("abc-123"))) + }) + It(`Invoke GetNextStart without a "Next" property in the response`, func() { + responseObject := new(codeenginev2.BuildList) + + value, err := responseObject.GetNextStart() + Expect(err).To(BeNil()) + Expect(value).To(BeNil()) + }) + }) + Context(`Using mock server endpoint - paginated response`, func() { + BeforeEach(func() { + var requestNumber int = 0 + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listBuildsPath)) + Expect(req.Method).To(Equal("GET")) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + requestNumber++ + if requestNumber == 1 { + fmt.Fprintf(res, "%s", `{"next":{"start":"1"},"total_count":2,"limit":1,"builds":[{"created_at":"2022-09-13T11:41:35+02:00","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-build","output_image":"private.de.icr.io/icr_namespace/image-name","output_secret":"ce-auto-icr-private-eu-de","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"build_v2","source_context_dir":"some/subfolder","source_revision":"main","source_secret":"SourceSecret","source_type":"git","source_url":"https://github.com/IBM/CodeEngine","status":"ready","status_details":{"reason":"registered"},"strategy_size":"medium","strategy_spec_file":"Dockerfile","strategy_type":"dockerfile","timeout":600}]}`) + } else if requestNumber == 2 { + fmt.Fprintf(res, "%s", `{"total_count":2,"limit":1,"builds":[{"created_at":"2022-09-13T11:41:35+02:00","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-build","output_image":"private.de.icr.io/icr_namespace/image-name","output_secret":"ce-auto-icr-private-eu-de","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"build_v2","source_context_dir":"some/subfolder","source_revision":"main","source_secret":"SourceSecret","source_type":"git","source_url":"https://github.com/IBM/CodeEngine","status":"ready","status_details":{"reason":"registered"},"strategy_size":"medium","strategy_spec_file":"Dockerfile","strategy_type":"dockerfile","timeout":600}]}`) + } else { + res.WriteHeader(400) + } + })) + }) + It(`Use BuildsPager.GetNext successfully`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + + listBuildsOptionsModel := &codeenginev2.ListBuildsOptions{ + ProjectID: core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"), + Limit: core.Int64Ptr(int64(100)), + } + + pager, err := codeEngineService.NewBuildsPager(listBuildsOptionsModel) + Expect(err).To(BeNil()) + Expect(pager).ToNot(BeNil()) + + var allResults []codeenginev2.Build + for pager.HasNext() { + nextPage, err := pager.GetNext() + Expect(err).To(BeNil()) + Expect(nextPage).ToNot(BeNil()) + allResults = append(allResults, nextPage...) + } + Expect(len(allResults)).To(Equal(2)) + }) + It(`Use BuildsPager.GetAll successfully`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + + listBuildsOptionsModel := &codeenginev2.ListBuildsOptions{ + ProjectID: core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"), + Limit: core.Int64Ptr(int64(100)), + } + + pager, err := codeEngineService.NewBuildsPager(listBuildsOptionsModel) + Expect(err).To(BeNil()) + Expect(pager).ToNot(BeNil()) + + allResults, err := pager.GetAll() + Expect(err).To(BeNil()) + Expect(allResults).ToNot(BeNil()) + Expect(len(allResults)).To(Equal(2)) + }) + }) + }) + Describe(`CreateBuild(createBuildOptions *CreateBuildOptions) - Operation response error`, func() { + createBuildPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/builds" + Context(`Using mock server endpoint with invalid JSON response`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(createBuildPath)) + Expect(req.Method).To(Equal("POST")) + res.Header().Set("Content-type", "application/json") + res.WriteHeader(201) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke CreateBuild with error: Operation response processing error`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + + // Construct an instance of the CreateBuildOptions model + createBuildOptionsModel := new(codeenginev2.CreateBuildOptions) + createBuildOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + createBuildOptionsModel.Name = core.StringPtr("my-build") + createBuildOptionsModel.OutputImage = core.StringPtr("private.de.icr.io/icr_namespace/image-name") + createBuildOptionsModel.OutputSecret = core.StringPtr("ce-auto-icr-private-eu-de") + createBuildOptionsModel.StrategyType = core.StringPtr("dockerfile") + createBuildOptionsModel.SourceContextDir = core.StringPtr("some/subfolder") + createBuildOptionsModel.SourceRevision = core.StringPtr("main") + createBuildOptionsModel.SourceSecret = core.StringPtr("testString") + createBuildOptionsModel.SourceType = core.StringPtr("git") + createBuildOptionsModel.SourceURL = core.StringPtr("https://github.com/IBM/CodeEngine") + createBuildOptionsModel.StrategySize = core.StringPtr("medium") + createBuildOptionsModel.StrategySpecFile = core.StringPtr("Dockerfile") + createBuildOptionsModel.Timeout = core.Int64Ptr(int64(600)) + createBuildOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := codeEngineService.CreateBuild(createBuildOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + codeEngineService.EnableRetries(0, 0) + result, response, operationErr = codeEngineService.CreateBuild(createBuildOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`CreateBuild(createBuildOptions *CreateBuildOptions)`, func() { + createBuildPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/builds" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(createBuildPath)) + Expect(req.Method).To(Equal("POST")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(201) + fmt.Fprintf(res, "%s", `{"created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "build_v2", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "SourceSecret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "ready", "status_details": {"reason": "registered"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}`) + })) + }) + It(`Invoke CreateBuild successfully with retries`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + codeEngineService.EnableRetries(0, 0) + + // Construct an instance of the CreateBuildOptions model + createBuildOptionsModel := new(codeenginev2.CreateBuildOptions) + createBuildOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + createBuildOptionsModel.Name = core.StringPtr("my-build") + createBuildOptionsModel.OutputImage = core.StringPtr("private.de.icr.io/icr_namespace/image-name") + createBuildOptionsModel.OutputSecret = core.StringPtr("ce-auto-icr-private-eu-de") + createBuildOptionsModel.StrategyType = core.StringPtr("dockerfile") + createBuildOptionsModel.SourceContextDir = core.StringPtr("some/subfolder") + createBuildOptionsModel.SourceRevision = core.StringPtr("main") + createBuildOptionsModel.SourceSecret = core.StringPtr("testString") + createBuildOptionsModel.SourceType = core.StringPtr("git") + createBuildOptionsModel.SourceURL = core.StringPtr("https://github.com/IBM/CodeEngine") + createBuildOptionsModel.StrategySize = core.StringPtr("medium") + createBuildOptionsModel.StrategySpecFile = core.StringPtr("Dockerfile") + createBuildOptionsModel.Timeout = core.Int64Ptr(int64(600)) + createBuildOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := codeEngineService.CreateBuildWithContext(ctx, createBuildOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + codeEngineService.DisableRetries() + result, response, operationErr := codeEngineService.CreateBuild(createBuildOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = codeEngineService.CreateBuildWithContext(ctx, createBuildOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(createBuildPath)) + Expect(req.Method).To(Equal("POST")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(201) + fmt.Fprintf(res, "%s", `{"created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "build_v2", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "SourceSecret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "ready", "status_details": {"reason": "registered"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}`) + })) + }) + It(`Invoke CreateBuild successfully`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := codeEngineService.CreateBuild(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the CreateBuildOptions model + createBuildOptionsModel := new(codeenginev2.CreateBuildOptions) + createBuildOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + createBuildOptionsModel.Name = core.StringPtr("my-build") + createBuildOptionsModel.OutputImage = core.StringPtr("private.de.icr.io/icr_namespace/image-name") + createBuildOptionsModel.OutputSecret = core.StringPtr("ce-auto-icr-private-eu-de") + createBuildOptionsModel.StrategyType = core.StringPtr("dockerfile") + createBuildOptionsModel.SourceContextDir = core.StringPtr("some/subfolder") + createBuildOptionsModel.SourceRevision = core.StringPtr("main") + createBuildOptionsModel.SourceSecret = core.StringPtr("testString") + createBuildOptionsModel.SourceType = core.StringPtr("git") + createBuildOptionsModel.SourceURL = core.StringPtr("https://github.com/IBM/CodeEngine") + createBuildOptionsModel.StrategySize = core.StringPtr("medium") + createBuildOptionsModel.StrategySpecFile = core.StringPtr("Dockerfile") + createBuildOptionsModel.Timeout = core.Int64Ptr(int64(600)) + createBuildOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = codeEngineService.CreateBuild(createBuildOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke CreateBuild with error: Operation validation and request error`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + + // Construct an instance of the CreateBuildOptions model + createBuildOptionsModel := new(codeenginev2.CreateBuildOptions) + createBuildOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + createBuildOptionsModel.Name = core.StringPtr("my-build") + createBuildOptionsModel.OutputImage = core.StringPtr("private.de.icr.io/icr_namespace/image-name") + createBuildOptionsModel.OutputSecret = core.StringPtr("ce-auto-icr-private-eu-de") + createBuildOptionsModel.StrategyType = core.StringPtr("dockerfile") + createBuildOptionsModel.SourceContextDir = core.StringPtr("some/subfolder") + createBuildOptionsModel.SourceRevision = core.StringPtr("main") + createBuildOptionsModel.SourceSecret = core.StringPtr("testString") + createBuildOptionsModel.SourceType = core.StringPtr("git") + createBuildOptionsModel.SourceURL = core.StringPtr("https://github.com/IBM/CodeEngine") + createBuildOptionsModel.StrategySize = core.StringPtr("medium") + createBuildOptionsModel.StrategySpecFile = core.StringPtr("Dockerfile") + createBuildOptionsModel.Timeout = core.Int64Ptr(int64(600)) + createBuildOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := codeEngineService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := codeEngineService.CreateBuild(createBuildOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + // Construct a second instance of the CreateBuildOptions model with no property values + createBuildOptionsModelNew := new(codeenginev2.CreateBuildOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = codeEngineService.CreateBuild(createBuildOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(201) + })) + }) + It(`Invoke CreateBuild successfully`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + + // Construct an instance of the CreateBuildOptions model + createBuildOptionsModel := new(codeenginev2.CreateBuildOptions) + createBuildOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + createBuildOptionsModel.Name = core.StringPtr("my-build") + createBuildOptionsModel.OutputImage = core.StringPtr("private.de.icr.io/icr_namespace/image-name") + createBuildOptionsModel.OutputSecret = core.StringPtr("ce-auto-icr-private-eu-de") + createBuildOptionsModel.StrategyType = core.StringPtr("dockerfile") + createBuildOptionsModel.SourceContextDir = core.StringPtr("some/subfolder") + createBuildOptionsModel.SourceRevision = core.StringPtr("main") + createBuildOptionsModel.SourceSecret = core.StringPtr("testString") + createBuildOptionsModel.SourceType = core.StringPtr("git") + createBuildOptionsModel.SourceURL = core.StringPtr("https://github.com/IBM/CodeEngine") + createBuildOptionsModel.StrategySize = core.StringPtr("medium") + createBuildOptionsModel.StrategySpecFile = core.StringPtr("Dockerfile") + createBuildOptionsModel.Timeout = core.Int64Ptr(int64(600)) + createBuildOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := codeEngineService.CreateBuild(createBuildOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetBuild(getBuildOptions *GetBuildOptions) - Operation response error`, func() { + getBuildPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/builds/my-build" + Context(`Using mock server endpoint with invalid JSON response`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getBuildPath)) + Expect(req.Method).To(Equal("GET")) + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke GetBuild with error: Operation response processing error`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + + // Construct an instance of the GetBuildOptions model + getBuildOptionsModel := new(codeenginev2.GetBuildOptions) + getBuildOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + getBuildOptionsModel.Name = core.StringPtr("my-build") + getBuildOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := codeEngineService.GetBuild(getBuildOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + codeEngineService.EnableRetries(0, 0) + result, response, operationErr = codeEngineService.GetBuild(getBuildOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetBuild(getBuildOptions *GetBuildOptions)`, func() { + getBuildPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/builds/my-build" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getBuildPath)) + Expect(req.Method).To(Equal("GET")) + + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "build_v2", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "SourceSecret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "ready", "status_details": {"reason": "registered"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}`) + })) + }) + It(`Invoke GetBuild successfully with retries`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + codeEngineService.EnableRetries(0, 0) + + // Construct an instance of the GetBuildOptions model + getBuildOptionsModel := new(codeenginev2.GetBuildOptions) + getBuildOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + getBuildOptionsModel.Name = core.StringPtr("my-build") + getBuildOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := codeEngineService.GetBuildWithContext(ctx, getBuildOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + codeEngineService.DisableRetries() + result, response, operationErr := codeEngineService.GetBuild(getBuildOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = codeEngineService.GetBuildWithContext(ctx, getBuildOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getBuildPath)) + Expect(req.Method).To(Equal("GET")) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "build_v2", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "SourceSecret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "ready", "status_details": {"reason": "registered"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}`) + })) + }) + It(`Invoke GetBuild successfully`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := codeEngineService.GetBuild(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the GetBuildOptions model + getBuildOptionsModel := new(codeenginev2.GetBuildOptions) + getBuildOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + getBuildOptionsModel.Name = core.StringPtr("my-build") + getBuildOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = codeEngineService.GetBuild(getBuildOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke GetBuild with error: Operation validation and request error`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + + // Construct an instance of the GetBuildOptions model + getBuildOptionsModel := new(codeenginev2.GetBuildOptions) + getBuildOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + getBuildOptionsModel.Name = core.StringPtr("my-build") + getBuildOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := codeEngineService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := codeEngineService.GetBuild(getBuildOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + // Construct a second instance of the GetBuildOptions model with no property values + getBuildOptionsModelNew := new(codeenginev2.GetBuildOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = codeEngineService.GetBuild(getBuildOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(200) + })) + }) + It(`Invoke GetBuild successfully`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + + // Construct an instance of the GetBuildOptions model + getBuildOptionsModel := new(codeenginev2.GetBuildOptions) + getBuildOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + getBuildOptionsModel.Name = core.StringPtr("my-build") + getBuildOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := codeEngineService.GetBuild(getBuildOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`DeleteBuild(deleteBuildOptions *DeleteBuildOptions)`, func() { + deleteBuildPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/builds/my-build" + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(deleteBuildPath)) + Expect(req.Method).To(Equal("DELETE")) + + res.WriteHeader(202) + })) + }) + It(`Invoke DeleteBuild successfully`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + response, operationErr := codeEngineService.DeleteBuild(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + + // Construct an instance of the DeleteBuildOptions model + deleteBuildOptionsModel := new(codeenginev2.DeleteBuildOptions) + deleteBuildOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + deleteBuildOptionsModel.Name = core.StringPtr("my-build") + deleteBuildOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + response, operationErr = codeEngineService.DeleteBuild(deleteBuildOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + }) + It(`Invoke DeleteBuild with error: Operation validation and request error`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + + // Construct an instance of the DeleteBuildOptions model deleteBuildOptionsModel := new(codeenginev2.DeleteBuildOptions) deleteBuildOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") deleteBuildOptionsModel.Name = core.StringPtr("my-build") @@ -9231,15 +11113,15 @@ var _ = Describe(`CodeEngineV2`, func() { }) }) }) - Describe(`ListConfigMaps(listConfigMapsOptions *ListConfigMapsOptions) - Operation response error`, func() { - listConfigMapsPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/config_maps" + Describe(`ListDomainMappings(listDomainMappingsOptions *ListDomainMappingsOptions) - Operation response error`, func() { + listDomainMappingsPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/domain_mappings" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listConfigMapsPath)) + Expect(req.URL.EscapedPath()).To(Equal(listDomainMappingsPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(100))})) Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) @@ -9248,7 +11130,7 @@ var _ = Describe(`CodeEngineV2`, func() { fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke ListConfigMaps with error: Operation response processing error`, func() { + It(`Invoke ListDomainMappings with error: Operation response processing error`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -9256,21 +11138,21 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the ListConfigMapsOptions model - listConfigMapsOptionsModel := new(codeenginev2.ListConfigMapsOptions) - listConfigMapsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - listConfigMapsOptionsModel.Limit = core.Int64Ptr(int64(100)) - listConfigMapsOptionsModel.Start = core.StringPtr("testString") - listConfigMapsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListDomainMappingsOptions model + listDomainMappingsOptionsModel := new(codeenginev2.ListDomainMappingsOptions) + listDomainMappingsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + listDomainMappingsOptionsModel.Limit = core.Int64Ptr(int64(100)) + listDomainMappingsOptionsModel.Start = core.StringPtr("testString") + listDomainMappingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := codeEngineService.ListConfigMaps(listConfigMapsOptionsModel) + result, response, operationErr := codeEngineService.ListDomainMappings(listDomainMappingsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again codeEngineService.EnableRetries(0, 0) - result, response, operationErr = codeEngineService.ListConfigMaps(listConfigMapsOptionsModel) + result, response, operationErr = codeEngineService.ListDomainMappings(listDomainMappingsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -9280,15 +11162,15 @@ var _ = Describe(`CodeEngineV2`, func() { }) }) }) - Describe(`ListConfigMaps(listConfigMapsOptions *ListConfigMapsOptions)`, func() { - listConfigMapsPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/config_maps" + Describe(`ListDomainMappings(listDomainMappingsOptions *ListDomainMappingsOptions)`, func() { + listDomainMappingsPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/domain_mappings" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listConfigMapsPath)) + Expect(req.URL.EscapedPath()).To(Equal(listDomainMappingsPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(100))})) @@ -9299,10 +11181,10 @@ var _ = Describe(`CodeEngineV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"config_maps": [{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "Inner"}, "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-config-map", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "config_map_v2"}], "first": {"href": "Href"}, "limit": 100, "next": {"href": "Href", "start": "Start"}}`) + fmt.Fprintf(res, "%s", `{"domain_mappings": [{"cname_target": "custom.abcdabcdabc.us-east.codeengine.appdomain.cloud", "component": {"name": "my-app-1", "resource_type": "app_v2"}, "created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/domain_mappings/www.example.com", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "www.example.com", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "domain_mapping_v2", "status": "ready", "status_details": {"reason": "ready"}, "tls_secret": "my-tls-secret", "user_managed": false, "visibility": "public"}], "first": {"href": "Href"}, "limit": 100, "next": {"href": "Href", "start": "Start"}}`) })) }) - It(`Invoke ListConfigMaps successfully with retries`, func() { + It(`Invoke ListDomainMappings successfully with retries`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -9311,23 +11193,23 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(codeEngineService).ToNot(BeNil()) codeEngineService.EnableRetries(0, 0) - // Construct an instance of the ListConfigMapsOptions model - listConfigMapsOptionsModel := new(codeenginev2.ListConfigMapsOptions) - listConfigMapsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - listConfigMapsOptionsModel.Limit = core.Int64Ptr(int64(100)) - listConfigMapsOptionsModel.Start = core.StringPtr("testString") - listConfigMapsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListDomainMappingsOptions model + listDomainMappingsOptionsModel := new(codeenginev2.ListDomainMappingsOptions) + listDomainMappingsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + listDomainMappingsOptionsModel.Limit = core.Int64Ptr(int64(100)) + listDomainMappingsOptionsModel.Start = core.StringPtr("testString") + listDomainMappingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := codeEngineService.ListConfigMapsWithContext(ctx, listConfigMapsOptionsModel) + _, _, operationErr := codeEngineService.ListDomainMappingsWithContext(ctx, listDomainMappingsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again codeEngineService.DisableRetries() - result, response, operationErr := codeEngineService.ListConfigMaps(listConfigMapsOptionsModel) + result, response, operationErr := codeEngineService.ListDomainMappings(listDomainMappingsOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -9335,7 +11217,7 @@ var _ = Describe(`CodeEngineV2`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = codeEngineService.ListConfigMapsWithContext(ctx, listConfigMapsOptionsModel) + _, _, operationErr = codeEngineService.ListDomainMappingsWithContext(ctx, listDomainMappingsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -9349,7 +11231,7 @@ var _ = Describe(`CodeEngineV2`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listConfigMapsPath)) + Expect(req.URL.EscapedPath()).To(Equal(listDomainMappingsPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(100))})) @@ -9357,10 +11239,10 @@ var _ = Describe(`CodeEngineV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"config_maps": [{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "Inner"}, "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-config-map", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "config_map_v2"}], "first": {"href": "Href"}, "limit": 100, "next": {"href": "Href", "start": "Start"}}`) + fmt.Fprintf(res, "%s", `{"domain_mappings": [{"cname_target": "custom.abcdabcdabc.us-east.codeengine.appdomain.cloud", "component": {"name": "my-app-1", "resource_type": "app_v2"}, "created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/domain_mappings/www.example.com", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "www.example.com", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "domain_mapping_v2", "status": "ready", "status_details": {"reason": "ready"}, "tls_secret": "my-tls-secret", "user_managed": false, "visibility": "public"}], "first": {"href": "Href"}, "limit": 100, "next": {"href": "Href", "start": "Start"}}`) })) }) - It(`Invoke ListConfigMaps successfully`, func() { + It(`Invoke ListDomainMappings successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -9369,26 +11251,26 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(codeEngineService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := codeEngineService.ListConfigMaps(nil) + result, response, operationErr := codeEngineService.ListDomainMappings(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the ListConfigMapsOptions model - listConfigMapsOptionsModel := new(codeenginev2.ListConfigMapsOptions) - listConfigMapsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - listConfigMapsOptionsModel.Limit = core.Int64Ptr(int64(100)) - listConfigMapsOptionsModel.Start = core.StringPtr("testString") - listConfigMapsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListDomainMappingsOptions model + listDomainMappingsOptionsModel := new(codeenginev2.ListDomainMappingsOptions) + listDomainMappingsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + listDomainMappingsOptionsModel.Limit = core.Int64Ptr(int64(100)) + listDomainMappingsOptionsModel.Start = core.StringPtr("testString") + listDomainMappingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = codeEngineService.ListConfigMaps(listConfigMapsOptionsModel) + result, response, operationErr = codeEngineService.ListDomainMappings(listDomainMappingsOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke ListConfigMaps with error: Operation validation and request error`, func() { + It(`Invoke ListDomainMappings with error: Operation validation and request error`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -9396,24 +11278,24 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the ListConfigMapsOptions model - listConfigMapsOptionsModel := new(codeenginev2.ListConfigMapsOptions) - listConfigMapsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - listConfigMapsOptionsModel.Limit = core.Int64Ptr(int64(100)) - listConfigMapsOptionsModel.Start = core.StringPtr("testString") - listConfigMapsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListDomainMappingsOptions model + listDomainMappingsOptionsModel := new(codeenginev2.ListDomainMappingsOptions) + listDomainMappingsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + listDomainMappingsOptionsModel.Limit = core.Int64Ptr(int64(100)) + listDomainMappingsOptionsModel.Start = core.StringPtr("testString") + listDomainMappingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := codeEngineService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := codeEngineService.ListConfigMaps(listConfigMapsOptionsModel) + result, response, operationErr := codeEngineService.ListDomainMappings(listDomainMappingsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct a second instance of the ListConfigMapsOptions model with no property values - listConfigMapsOptionsModelNew := new(codeenginev2.ListConfigMapsOptions) + // Construct a second instance of the ListDomainMappingsOptions model with no property values + listDomainMappingsOptionsModelNew := new(codeenginev2.ListDomainMappingsOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = codeEngineService.ListConfigMaps(listConfigMapsOptionsModelNew) + result, response, operationErr = codeEngineService.ListDomainMappings(listDomainMappingsOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -9431,7 +11313,7 @@ var _ = Describe(`CodeEngineV2`, func() { res.WriteHeader(200) })) }) - It(`Invoke ListConfigMaps successfully`, func() { + It(`Invoke ListDomainMappings successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -9439,15 +11321,15 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the ListConfigMapsOptions model - listConfigMapsOptionsModel := new(codeenginev2.ListConfigMapsOptions) - listConfigMapsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - listConfigMapsOptionsModel.Limit = core.Int64Ptr(int64(100)) - listConfigMapsOptionsModel.Start = core.StringPtr("testString") - listConfigMapsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListDomainMappingsOptions model + listDomainMappingsOptionsModel := new(codeenginev2.ListDomainMappingsOptions) + listDomainMappingsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + listDomainMappingsOptionsModel.Limit = core.Int64Ptr(int64(100)) + listDomainMappingsOptionsModel.Start = core.StringPtr("testString") + listDomainMappingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := codeEngineService.ListConfigMaps(listConfigMapsOptionsModel) + result, response, operationErr := codeEngineService.ListDomainMappings(listDomainMappingsOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -9460,7 +11342,7 @@ var _ = Describe(`CodeEngineV2`, func() { }) Context(`Test pagination helper method on response`, func() { It(`Invoke GetNextStart successfully`, func() { - responseObject := new(codeenginev2.ConfigMapList) + responseObject := new(codeenginev2.DomainMappingList) nextObject := new(codeenginev2.ListNextMetadata) nextObject.Start = core.StringPtr("abc-123") responseObject.Next = nextObject @@ -9470,7 +11352,7 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(value).To(Equal(core.StringPtr("abc-123"))) }) It(`Invoke GetNextStart without a "Next" property in the response`, func() { - responseObject := new(codeenginev2.ConfigMapList) + responseObject := new(codeenginev2.DomainMappingList) value, err := responseObject.GetNextStart() Expect(err).To(BeNil()) @@ -9484,7 +11366,7 @@ var _ = Describe(`CodeEngineV2`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listConfigMapsPath)) + Expect(req.URL.EscapedPath()).To(Equal(listDomainMappingsPath)) Expect(req.Method).To(Equal("GET")) // Set mock response @@ -9492,15 +11374,15 @@ var _ = Describe(`CodeEngineV2`, func() { res.WriteHeader(200) requestNumber++ if requestNumber == 1 { - fmt.Fprintf(res, "%s", `{"next":{"start":"1"},"config_maps":[{"created_at":"2022-09-13T11:41:35+02:00","data":{"mapKey":"Inner"},"entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-config-map","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"config_map_v2"}],"total_count":2,"limit":1}`) + fmt.Fprintf(res, "%s", `{"next":{"start":"1"},"domain_mappings":[{"cname_target":"custom.abcdabcdabc.us-east.codeengine.appdomain.cloud","component":{"name":"my-app-1","resource_type":"app_v2"},"created_at":"2022-09-13T11:41:35+02:00","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/domain_mappings/www.example.com","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"www.example.com","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"domain_mapping_v2","status":"ready","status_details":{"reason":"ready"},"tls_secret":"my-tls-secret","user_managed":false,"visibility":"public"}],"total_count":2,"limit":1}`) } else if requestNumber == 2 { - fmt.Fprintf(res, "%s", `{"config_maps":[{"created_at":"2022-09-13T11:41:35+02:00","data":{"mapKey":"Inner"},"entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-config-map","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"config_map_v2"}],"total_count":2,"limit":1}`) + fmt.Fprintf(res, "%s", `{"domain_mappings":[{"cname_target":"custom.abcdabcdabc.us-east.codeengine.appdomain.cloud","component":{"name":"my-app-1","resource_type":"app_v2"},"created_at":"2022-09-13T11:41:35+02:00","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/domain_mappings/www.example.com","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"www.example.com","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"domain_mapping_v2","status":"ready","status_details":{"reason":"ready"},"tls_secret":"my-tls-secret","user_managed":false,"visibility":"public"}],"total_count":2,"limit":1}`) } else { res.WriteHeader(400) } })) }) - It(`Use ConfigMapsPager.GetNext successfully`, func() { + It(`Use DomainMappingsPager.GetNext successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -9508,16 +11390,16 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - listConfigMapsOptionsModel := &codeenginev2.ListConfigMapsOptions{ + listDomainMappingsOptionsModel := &codeenginev2.ListDomainMappingsOptions{ ProjectID: core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"), Limit: core.Int64Ptr(int64(100)), } - pager, err := codeEngineService.NewConfigMapsPager(listConfigMapsOptionsModel) + pager, err := codeEngineService.NewDomainMappingsPager(listDomainMappingsOptionsModel) Expect(err).To(BeNil()) Expect(pager).ToNot(BeNil()) - var allResults []codeenginev2.ConfigMap + var allResults []codeenginev2.DomainMapping for pager.HasNext() { nextPage, err := pager.GetNext() Expect(err).To(BeNil()) @@ -9526,7 +11408,7 @@ var _ = Describe(`CodeEngineV2`, func() { } Expect(len(allResults)).To(Equal(2)) }) - It(`Use ConfigMapsPager.GetAll successfully`, func() { + It(`Use DomainMappingsPager.GetAll successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -9534,12 +11416,12 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - listConfigMapsOptionsModel := &codeenginev2.ListConfigMapsOptions{ + listDomainMappingsOptionsModel := &codeenginev2.ListDomainMappingsOptions{ ProjectID: core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"), Limit: core.Int64Ptr(int64(100)), } - pager, err := codeEngineService.NewConfigMapsPager(listConfigMapsOptionsModel) + pager, err := codeEngineService.NewDomainMappingsPager(listDomainMappingsOptionsModel) Expect(err).To(BeNil()) Expect(pager).ToNot(BeNil()) @@ -9550,22 +11432,22 @@ var _ = Describe(`CodeEngineV2`, func() { }) }) }) - Describe(`CreateConfigMap(createConfigMapOptions *CreateConfigMapOptions) - Operation response error`, func() { - createConfigMapPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/config_maps" + Describe(`CreateDomainMapping(createDomainMappingOptions *CreateDomainMappingOptions) - Operation response error`, func() { + createDomainMappingPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/domain_mappings" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createConfigMapPath)) + Expect(req.URL.EscapedPath()).To(Equal(createDomainMappingPath)) Expect(req.Method).To(Equal("POST")) res.Header().Set("Content-type", "application/json") res.WriteHeader(201) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke CreateConfigMap with error: Operation response processing error`, func() { + It(`Invoke CreateDomainMapping with error: Operation response processing error`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -9573,21 +11455,27 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the CreateConfigMapOptions model - createConfigMapOptionsModel := new(codeenginev2.CreateConfigMapOptions) - createConfigMapOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - createConfigMapOptionsModel.Name = core.StringPtr("my-config-map") - createConfigMapOptionsModel.Data = map[string]string{"key1": "testString"} - createConfigMapOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ComponentRef model + componentRefModel := new(codeenginev2.ComponentRef) + componentRefModel.Name = core.StringPtr("my-app-1") + componentRefModel.ResourceType = core.StringPtr("app_v2") + + // Construct an instance of the CreateDomainMappingOptions model + createDomainMappingOptionsModel := new(codeenginev2.CreateDomainMappingOptions) + createDomainMappingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + createDomainMappingOptionsModel.Component = componentRefModel + createDomainMappingOptionsModel.Name = core.StringPtr("www.example.com") + createDomainMappingOptionsModel.TlsSecret = core.StringPtr("my-tls-secret") + createDomainMappingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := codeEngineService.CreateConfigMap(createConfigMapOptionsModel) + result, response, operationErr := codeEngineService.CreateDomainMapping(createDomainMappingOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again codeEngineService.EnableRetries(0, 0) - result, response, operationErr = codeEngineService.CreateConfigMap(createConfigMapOptionsModel) + result, response, operationErr = codeEngineService.CreateDomainMapping(createDomainMappingOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -9597,15 +11485,15 @@ var _ = Describe(`CodeEngineV2`, func() { }) }) }) - Describe(`CreateConfigMap(createConfigMapOptions *CreateConfigMapOptions)`, func() { - createConfigMapPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/config_maps" + Describe(`CreateDomainMapping(createDomainMappingOptions *CreateDomainMappingOptions)`, func() { + createDomainMappingPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/domain_mappings" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createConfigMapPath)) + Expect(req.URL.EscapedPath()).To(Equal(createDomainMappingPath)) Expect(req.Method).To(Equal("POST")) // For gzip-disabled operation, verify Content-Encoding is not set. @@ -9630,10 +11518,10 @@ var _ = Describe(`CodeEngineV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "Inner"}, "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-config-map", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "config_map_v2"}`) + fmt.Fprintf(res, "%s", `{"cname_target": "custom.abcdabcdabc.us-east.codeengine.appdomain.cloud", "component": {"name": "my-app-1", "resource_type": "app_v2"}, "created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/domain_mappings/www.example.com", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "www.example.com", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "domain_mapping_v2", "status": "ready", "status_details": {"reason": "ready"}, "tls_secret": "my-tls-secret", "user_managed": false, "visibility": "public"}`) })) }) - It(`Invoke CreateConfigMap successfully with retries`, func() { + It(`Invoke CreateDomainMapping successfully with retries`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -9642,23 +11530,29 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(codeEngineService).ToNot(BeNil()) codeEngineService.EnableRetries(0, 0) - // Construct an instance of the CreateConfigMapOptions model - createConfigMapOptionsModel := new(codeenginev2.CreateConfigMapOptions) - createConfigMapOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - createConfigMapOptionsModel.Name = core.StringPtr("my-config-map") - createConfigMapOptionsModel.Data = map[string]string{"key1": "testString"} - createConfigMapOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ComponentRef model + componentRefModel := new(codeenginev2.ComponentRef) + componentRefModel.Name = core.StringPtr("my-app-1") + componentRefModel.ResourceType = core.StringPtr("app_v2") + + // Construct an instance of the CreateDomainMappingOptions model + createDomainMappingOptionsModel := new(codeenginev2.CreateDomainMappingOptions) + createDomainMappingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + createDomainMappingOptionsModel.Component = componentRefModel + createDomainMappingOptionsModel.Name = core.StringPtr("www.example.com") + createDomainMappingOptionsModel.TlsSecret = core.StringPtr("my-tls-secret") + createDomainMappingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := codeEngineService.CreateConfigMapWithContext(ctx, createConfigMapOptionsModel) + _, _, operationErr := codeEngineService.CreateDomainMappingWithContext(ctx, createDomainMappingOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again codeEngineService.DisableRetries() - result, response, operationErr := codeEngineService.CreateConfigMap(createConfigMapOptionsModel) + result, response, operationErr := codeEngineService.CreateDomainMapping(createDomainMappingOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -9666,7 +11560,7 @@ var _ = Describe(`CodeEngineV2`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = codeEngineService.CreateConfigMapWithContext(ctx, createConfigMapOptionsModel) + _, _, operationErr = codeEngineService.CreateDomainMappingWithContext(ctx, createDomainMappingOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -9680,7 +11574,7 @@ var _ = Describe(`CodeEngineV2`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createConfigMapPath)) + Expect(req.URL.EscapedPath()).To(Equal(createDomainMappingPath)) Expect(req.Method).To(Equal("POST")) // For gzip-disabled operation, verify Content-Encoding is not set. @@ -9702,10 +11596,10 @@ var _ = Describe(`CodeEngineV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "Inner"}, "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-config-map", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "config_map_v2"}`) + fmt.Fprintf(res, "%s", `{"cname_target": "custom.abcdabcdabc.us-east.codeengine.appdomain.cloud", "component": {"name": "my-app-1", "resource_type": "app_v2"}, "created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/domain_mappings/www.example.com", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "www.example.com", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "domain_mapping_v2", "status": "ready", "status_details": {"reason": "ready"}, "tls_secret": "my-tls-secret", "user_managed": false, "visibility": "public"}`) })) }) - It(`Invoke CreateConfigMap successfully`, func() { + It(`Invoke CreateDomainMapping successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -9714,26 +11608,32 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(codeEngineService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := codeEngineService.CreateConfigMap(nil) + result, response, operationErr := codeEngineService.CreateDomainMapping(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the CreateConfigMapOptions model - createConfigMapOptionsModel := new(codeenginev2.CreateConfigMapOptions) - createConfigMapOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - createConfigMapOptionsModel.Name = core.StringPtr("my-config-map") - createConfigMapOptionsModel.Data = map[string]string{"key1": "testString"} - createConfigMapOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ComponentRef model + componentRefModel := new(codeenginev2.ComponentRef) + componentRefModel.Name = core.StringPtr("my-app-1") + componentRefModel.ResourceType = core.StringPtr("app_v2") + + // Construct an instance of the CreateDomainMappingOptions model + createDomainMappingOptionsModel := new(codeenginev2.CreateDomainMappingOptions) + createDomainMappingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + createDomainMappingOptionsModel.Component = componentRefModel + createDomainMappingOptionsModel.Name = core.StringPtr("www.example.com") + createDomainMappingOptionsModel.TlsSecret = core.StringPtr("my-tls-secret") + createDomainMappingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = codeEngineService.CreateConfigMap(createConfigMapOptionsModel) + result, response, operationErr = codeEngineService.CreateDomainMapping(createDomainMappingOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke CreateConfigMap with error: Operation validation and request error`, func() { + It(`Invoke CreateDomainMapping with error: Operation validation and request error`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -9741,24 +11641,30 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the CreateConfigMapOptions model - createConfigMapOptionsModel := new(codeenginev2.CreateConfigMapOptions) - createConfigMapOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - createConfigMapOptionsModel.Name = core.StringPtr("my-config-map") - createConfigMapOptionsModel.Data = map[string]string{"key1": "testString"} - createConfigMapOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ComponentRef model + componentRefModel := new(codeenginev2.ComponentRef) + componentRefModel.Name = core.StringPtr("my-app-1") + componentRefModel.ResourceType = core.StringPtr("app_v2") + + // Construct an instance of the CreateDomainMappingOptions model + createDomainMappingOptionsModel := new(codeenginev2.CreateDomainMappingOptions) + createDomainMappingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + createDomainMappingOptionsModel.Component = componentRefModel + createDomainMappingOptionsModel.Name = core.StringPtr("www.example.com") + createDomainMappingOptionsModel.TlsSecret = core.StringPtr("my-tls-secret") + createDomainMappingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := codeEngineService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := codeEngineService.CreateConfigMap(createConfigMapOptionsModel) + result, response, operationErr := codeEngineService.CreateDomainMapping(createDomainMappingOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct a second instance of the CreateConfigMapOptions model with no property values - createConfigMapOptionsModelNew := new(codeenginev2.CreateConfigMapOptions) + // Construct a second instance of the CreateDomainMappingOptions model with no property values + createDomainMappingOptionsModelNew := new(codeenginev2.CreateDomainMappingOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = codeEngineService.CreateConfigMap(createConfigMapOptionsModelNew) + result, response, operationErr = codeEngineService.CreateDomainMapping(createDomainMappingOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -9776,7 +11682,7 @@ var _ = Describe(`CodeEngineV2`, func() { res.WriteHeader(201) })) }) - It(`Invoke CreateConfigMap successfully`, func() { + It(`Invoke CreateDomainMapping successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -9784,15 +11690,21 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the CreateConfigMapOptions model - createConfigMapOptionsModel := new(codeenginev2.CreateConfigMapOptions) - createConfigMapOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - createConfigMapOptionsModel.Name = core.StringPtr("my-config-map") - createConfigMapOptionsModel.Data = map[string]string{"key1": "testString"} - createConfigMapOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ComponentRef model + componentRefModel := new(codeenginev2.ComponentRef) + componentRefModel.Name = core.StringPtr("my-app-1") + componentRefModel.ResourceType = core.StringPtr("app_v2") + + // Construct an instance of the CreateDomainMappingOptions model + createDomainMappingOptionsModel := new(codeenginev2.CreateDomainMappingOptions) + createDomainMappingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + createDomainMappingOptionsModel.Component = componentRefModel + createDomainMappingOptionsModel.Name = core.StringPtr("www.example.com") + createDomainMappingOptionsModel.TlsSecret = core.StringPtr("my-tls-secret") + createDomainMappingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := codeEngineService.CreateConfigMap(createConfigMapOptionsModel) + result, response, operationErr := codeEngineService.CreateDomainMapping(createDomainMappingOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -9804,22 +11716,22 @@ var _ = Describe(`CodeEngineV2`, func() { }) }) }) - Describe(`GetConfigMap(getConfigMapOptions *GetConfigMapOptions) - Operation response error`, func() { - getConfigMapPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/config_maps/my-config-map" + Describe(`GetDomainMapping(getDomainMappingOptions *GetDomainMappingOptions) - Operation response error`, func() { + getDomainMappingPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/domain_mappings/www.example.com" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getConfigMapPath)) + Expect(req.URL.EscapedPath()).To(Equal(getDomainMappingPath)) Expect(req.Method).To(Equal("GET")) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke GetConfigMap with error: Operation response processing error`, func() { + It(`Invoke GetDomainMapping with error: Operation response processing error`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -9827,20 +11739,20 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the GetConfigMapOptions model - getConfigMapOptionsModel := new(codeenginev2.GetConfigMapOptions) - getConfigMapOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - getConfigMapOptionsModel.Name = core.StringPtr("my-config-map") - getConfigMapOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetDomainMappingOptions model + getDomainMappingOptionsModel := new(codeenginev2.GetDomainMappingOptions) + getDomainMappingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + getDomainMappingOptionsModel.Name = core.StringPtr("www.example.com") + getDomainMappingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := codeEngineService.GetConfigMap(getConfigMapOptionsModel) + result, response, operationErr := codeEngineService.GetDomainMapping(getDomainMappingOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again codeEngineService.EnableRetries(0, 0) - result, response, operationErr = codeEngineService.GetConfigMap(getConfigMapOptionsModel) + result, response, operationErr = codeEngineService.GetDomainMapping(getDomainMappingOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -9850,15 +11762,15 @@ var _ = Describe(`CodeEngineV2`, func() { }) }) }) - Describe(`GetConfigMap(getConfigMapOptions *GetConfigMapOptions)`, func() { - getConfigMapPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/config_maps/my-config-map" + Describe(`GetDomainMapping(getDomainMappingOptions *GetDomainMappingOptions)`, func() { + getDomainMappingPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/domain_mappings/www.example.com" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getConfigMapPath)) + Expect(req.URL.EscapedPath()).To(Equal(getDomainMappingPath)) Expect(req.Method).To(Equal("GET")) // Sleep a short time to support a timeout test @@ -9867,10 +11779,10 @@ var _ = Describe(`CodeEngineV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "Inner"}, "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-config-map", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "config_map_v2"}`) + fmt.Fprintf(res, "%s", `{"cname_target": "custom.abcdabcdabc.us-east.codeengine.appdomain.cloud", "component": {"name": "my-app-1", "resource_type": "app_v2"}, "created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/domain_mappings/www.example.com", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "www.example.com", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "domain_mapping_v2", "status": "ready", "status_details": {"reason": "ready"}, "tls_secret": "my-tls-secret", "user_managed": false, "visibility": "public"}`) })) }) - It(`Invoke GetConfigMap successfully with retries`, func() { + It(`Invoke GetDomainMapping successfully with retries`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -9879,22 +11791,22 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(codeEngineService).ToNot(BeNil()) codeEngineService.EnableRetries(0, 0) - // Construct an instance of the GetConfigMapOptions model - getConfigMapOptionsModel := new(codeenginev2.GetConfigMapOptions) - getConfigMapOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - getConfigMapOptionsModel.Name = core.StringPtr("my-config-map") - getConfigMapOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetDomainMappingOptions model + getDomainMappingOptionsModel := new(codeenginev2.GetDomainMappingOptions) + getDomainMappingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + getDomainMappingOptionsModel.Name = core.StringPtr("www.example.com") + getDomainMappingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := codeEngineService.GetConfigMapWithContext(ctx, getConfigMapOptionsModel) + _, _, operationErr := codeEngineService.GetDomainMappingWithContext(ctx, getDomainMappingOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again codeEngineService.DisableRetries() - result, response, operationErr := codeEngineService.GetConfigMap(getConfigMapOptionsModel) + result, response, operationErr := codeEngineService.GetDomainMapping(getDomainMappingOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -9902,7 +11814,7 @@ var _ = Describe(`CodeEngineV2`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = codeEngineService.GetConfigMapWithContext(ctx, getConfigMapOptionsModel) + _, _, operationErr = codeEngineService.GetDomainMappingWithContext(ctx, getDomainMappingOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -9916,16 +11828,16 @@ var _ = Describe(`CodeEngineV2`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getConfigMapPath)) + Expect(req.URL.EscapedPath()).To(Equal(getDomainMappingPath)) Expect(req.Method).To(Equal("GET")) // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "Inner"}, "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-config-map", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "config_map_v2"}`) + fmt.Fprintf(res, "%s", `{"cname_target": "custom.abcdabcdabc.us-east.codeengine.appdomain.cloud", "component": {"name": "my-app-1", "resource_type": "app_v2"}, "created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/domain_mappings/www.example.com", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "www.example.com", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "domain_mapping_v2", "status": "ready", "status_details": {"reason": "ready"}, "tls_secret": "my-tls-secret", "user_managed": false, "visibility": "public"}`) })) }) - It(`Invoke GetConfigMap successfully`, func() { + It(`Invoke GetDomainMapping successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -9934,25 +11846,25 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(codeEngineService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := codeEngineService.GetConfigMap(nil) + result, response, operationErr := codeEngineService.GetDomainMapping(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the GetConfigMapOptions model - getConfigMapOptionsModel := new(codeenginev2.GetConfigMapOptions) - getConfigMapOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - getConfigMapOptionsModel.Name = core.StringPtr("my-config-map") - getConfigMapOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetDomainMappingOptions model + getDomainMappingOptionsModel := new(codeenginev2.GetDomainMappingOptions) + getDomainMappingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + getDomainMappingOptionsModel.Name = core.StringPtr("www.example.com") + getDomainMappingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = codeEngineService.GetConfigMap(getConfigMapOptionsModel) + result, response, operationErr = codeEngineService.GetDomainMapping(getDomainMappingOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke GetConfigMap with error: Operation validation and request error`, func() { + It(`Invoke GetDomainMapping with error: Operation validation and request error`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -9960,23 +11872,23 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the GetConfigMapOptions model - getConfigMapOptionsModel := new(codeenginev2.GetConfigMapOptions) - getConfigMapOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - getConfigMapOptionsModel.Name = core.StringPtr("my-config-map") - getConfigMapOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetDomainMappingOptions model + getDomainMappingOptionsModel := new(codeenginev2.GetDomainMappingOptions) + getDomainMappingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + getDomainMappingOptionsModel.Name = core.StringPtr("www.example.com") + getDomainMappingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := codeEngineService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := codeEngineService.GetConfigMap(getConfigMapOptionsModel) + result, response, operationErr := codeEngineService.GetDomainMapping(getDomainMappingOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct a second instance of the GetConfigMapOptions model with no property values - getConfigMapOptionsModelNew := new(codeenginev2.GetConfigMapOptions) + // Construct a second instance of the GetDomainMappingOptions model with no property values + getDomainMappingOptionsModelNew := new(codeenginev2.GetDomainMappingOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = codeEngineService.GetConfigMap(getConfigMapOptionsModelNew) + result, response, operationErr = codeEngineService.GetDomainMapping(getDomainMappingOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -9994,7 +11906,7 @@ var _ = Describe(`CodeEngineV2`, func() { res.WriteHeader(200) })) }) - It(`Invoke GetConfigMap successfully`, func() { + It(`Invoke GetDomainMapping successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -10002,14 +11914,14 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the GetConfigMapOptions model - getConfigMapOptionsModel := new(codeenginev2.GetConfigMapOptions) - getConfigMapOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - getConfigMapOptionsModel.Name = core.StringPtr("my-config-map") - getConfigMapOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetDomainMappingOptions model + getDomainMappingOptionsModel := new(codeenginev2.GetDomainMappingOptions) + getDomainMappingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + getDomainMappingOptionsModel.Name = core.StringPtr("www.example.com") + getDomainMappingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := codeEngineService.GetConfigMap(getConfigMapOptionsModel) + result, response, operationErr := codeEngineService.GetDomainMapping(getDomainMappingOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -10021,16 +11933,86 @@ var _ = Describe(`CodeEngineV2`, func() { }) }) }) - Describe(`ReplaceConfigMap(replaceConfigMapOptions *ReplaceConfigMapOptions) - Operation response error`, func() { - replaceConfigMapPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/config_maps/my-config-map" - Context(`Using mock server endpoint with invalid JSON response`, func() { + Describe(`DeleteDomainMapping(deleteDomainMappingOptions *DeleteDomainMappingOptions)`, func() { + deleteDomainMappingPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/domain_mappings/www.example.com" + Context(`Using mock server endpoint`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(replaceConfigMapPath)) - Expect(req.Method).To(Equal("PUT")) + Expect(req.URL.EscapedPath()).To(Equal(deleteDomainMappingPath)) + Expect(req.Method).To(Equal("DELETE")) + + res.WriteHeader(202) + })) + }) + It(`Invoke DeleteDomainMapping successfully`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + response, operationErr := codeEngineService.DeleteDomainMapping(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + + // Construct an instance of the DeleteDomainMappingOptions model + deleteDomainMappingOptionsModel := new(codeenginev2.DeleteDomainMappingOptions) + deleteDomainMappingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + deleteDomainMappingOptionsModel.Name = core.StringPtr("www.example.com") + deleteDomainMappingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + response, operationErr = codeEngineService.DeleteDomainMapping(deleteDomainMappingOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + }) + It(`Invoke DeleteDomainMapping with error: Operation validation and request error`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + + // Construct an instance of the DeleteDomainMappingOptions model + deleteDomainMappingOptionsModel := new(codeenginev2.DeleteDomainMappingOptions) + deleteDomainMappingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + deleteDomainMappingOptionsModel.Name = core.StringPtr("www.example.com") + deleteDomainMappingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := codeEngineService.SetServiceURL("") + Expect(err).To(BeNil()) + response, operationErr := codeEngineService.DeleteDomainMapping(deleteDomainMappingOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + // Construct a second instance of the DeleteDomainMappingOptions model with no property values + deleteDomainMappingOptionsModelNew := new(codeenginev2.DeleteDomainMappingOptions) + // Invoke operation with invalid model (negative test) + response, operationErr = codeEngineService.DeleteDomainMapping(deleteDomainMappingOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`UpdateDomainMapping(updateDomainMappingOptions *UpdateDomainMappingOptions) - Operation response error`, func() { + updateDomainMappingPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/domain_mappings/www.example.com" + Context(`Using mock server endpoint with invalid JSON response`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(updateDomainMappingPath)) + Expect(req.Method).To(Equal("PATCH")) Expect(req.Header["If-Match"]).ToNot(BeNil()) Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) res.Header().Set("Content-type", "application/json") @@ -10038,7 +12020,7 @@ var _ = Describe(`CodeEngineV2`, func() { fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke ReplaceConfigMap with error: Operation response processing error`, func() { + It(`Invoke UpdateDomainMapping with error: Operation response processing error`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -10046,22 +12028,34 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the ReplaceConfigMapOptions model - replaceConfigMapOptionsModel := new(codeenginev2.ReplaceConfigMapOptions) - replaceConfigMapOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - replaceConfigMapOptionsModel.Name = core.StringPtr("my-config-map") - replaceConfigMapOptionsModel.IfMatch = core.StringPtr("testString") - replaceConfigMapOptionsModel.Data = map[string]string{"key1": "testString"} - replaceConfigMapOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ComponentRef model + componentRefModel := new(codeenginev2.ComponentRef) + componentRefModel.Name = core.StringPtr("my-app-1") + componentRefModel.ResourceType = core.StringPtr("app_v2") + + // Construct an instance of the DomainMappingPatch model + domainMappingPatchModel := new(codeenginev2.DomainMappingPatch) + domainMappingPatchModel.Component = componentRefModel + domainMappingPatchModel.TlsSecret = core.StringPtr("my-tls-secret") + domainMappingPatchModelAsPatch, asPatchErr := domainMappingPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateDomainMappingOptions model + updateDomainMappingOptionsModel := new(codeenginev2.UpdateDomainMappingOptions) + updateDomainMappingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + updateDomainMappingOptionsModel.Name = core.StringPtr("www.example.com") + updateDomainMappingOptionsModel.IfMatch = core.StringPtr("testString") + updateDomainMappingOptionsModel.DomainMapping = domainMappingPatchModelAsPatch + updateDomainMappingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := codeEngineService.ReplaceConfigMap(replaceConfigMapOptionsModel) + result, response, operationErr := codeEngineService.UpdateDomainMapping(updateDomainMappingOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again codeEngineService.EnableRetries(0, 0) - result, response, operationErr = codeEngineService.ReplaceConfigMap(replaceConfigMapOptionsModel) + result, response, operationErr = codeEngineService.UpdateDomainMapping(updateDomainMappingOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -10071,16 +12065,16 @@ var _ = Describe(`CodeEngineV2`, func() { }) }) }) - Describe(`ReplaceConfigMap(replaceConfigMapOptions *ReplaceConfigMapOptions)`, func() { - replaceConfigMapPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/config_maps/my-config-map" + Describe(`UpdateDomainMapping(updateDomainMappingOptions *UpdateDomainMappingOptions)`, func() { + updateDomainMappingPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/domain_mappings/www.example.com" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(replaceConfigMapPath)) - Expect(req.Method).To(Equal("PUT")) + Expect(req.URL.EscapedPath()).To(Equal(updateDomainMappingPath)) + Expect(req.Method).To(Equal("PATCH")) // For gzip-disabled operation, verify Content-Encoding is not set. Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) @@ -10106,10 +12100,10 @@ var _ = Describe(`CodeEngineV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "Inner"}, "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-config-map", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "config_map_v2"}`) + fmt.Fprintf(res, "%s", `{"cname_target": "custom.abcdabcdabc.us-east.codeengine.appdomain.cloud", "component": {"name": "my-app-1", "resource_type": "app_v2"}, "created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/domain_mappings/www.example.com", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "www.example.com", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "domain_mapping_v2", "status": "ready", "status_details": {"reason": "ready"}, "tls_secret": "my-tls-secret", "user_managed": false, "visibility": "public"}`) })) }) - It(`Invoke ReplaceConfigMap successfully with retries`, func() { + It(`Invoke UpdateDomainMapping successfully with retries`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -10118,24 +12112,36 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(codeEngineService).ToNot(BeNil()) codeEngineService.EnableRetries(0, 0) - // Construct an instance of the ReplaceConfigMapOptions model - replaceConfigMapOptionsModel := new(codeenginev2.ReplaceConfigMapOptions) - replaceConfigMapOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - replaceConfigMapOptionsModel.Name = core.StringPtr("my-config-map") - replaceConfigMapOptionsModel.IfMatch = core.StringPtr("testString") - replaceConfigMapOptionsModel.Data = map[string]string{"key1": "testString"} - replaceConfigMapOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ComponentRef model + componentRefModel := new(codeenginev2.ComponentRef) + componentRefModel.Name = core.StringPtr("my-app-1") + componentRefModel.ResourceType = core.StringPtr("app_v2") + + // Construct an instance of the DomainMappingPatch model + domainMappingPatchModel := new(codeenginev2.DomainMappingPatch) + domainMappingPatchModel.Component = componentRefModel + domainMappingPatchModel.TlsSecret = core.StringPtr("my-tls-secret") + domainMappingPatchModelAsPatch, asPatchErr := domainMappingPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateDomainMappingOptions model + updateDomainMappingOptionsModel := new(codeenginev2.UpdateDomainMappingOptions) + updateDomainMappingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + updateDomainMappingOptionsModel.Name = core.StringPtr("www.example.com") + updateDomainMappingOptionsModel.IfMatch = core.StringPtr("testString") + updateDomainMappingOptionsModel.DomainMapping = domainMappingPatchModelAsPatch + updateDomainMappingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := codeEngineService.ReplaceConfigMapWithContext(ctx, replaceConfigMapOptionsModel) + _, _, operationErr := codeEngineService.UpdateDomainMappingWithContext(ctx, updateDomainMappingOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again codeEngineService.DisableRetries() - result, response, operationErr := codeEngineService.ReplaceConfigMap(replaceConfigMapOptionsModel) + result, response, operationErr := codeEngineService.UpdateDomainMapping(updateDomainMappingOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -10143,7 +12149,7 @@ var _ = Describe(`CodeEngineV2`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = codeEngineService.ReplaceConfigMapWithContext(ctx, replaceConfigMapOptionsModel) + _, _, operationErr = codeEngineService.UpdateDomainMappingWithContext(ctx, updateDomainMappingOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -10157,8 +12163,8 @@ var _ = Describe(`CodeEngineV2`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(replaceConfigMapPath)) - Expect(req.Method).To(Equal("PUT")) + Expect(req.URL.EscapedPath()).To(Equal(updateDomainMappingPath)) + Expect(req.Method).To(Equal("PATCH")) // For gzip-disabled operation, verify Content-Encoding is not set. Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) @@ -10181,10 +12187,10 @@ var _ = Describe(`CodeEngineV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "Inner"}, "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-config-map", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "config_map_v2"}`) + fmt.Fprintf(res, "%s", `{"cname_target": "custom.abcdabcdabc.us-east.codeengine.appdomain.cloud", "component": {"name": "my-app-1", "resource_type": "app_v2"}, "created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/domain_mappings/www.example.com", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "www.example.com", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "domain_mapping_v2", "status": "ready", "status_details": {"reason": "ready"}, "tls_secret": "my-tls-secret", "user_managed": false, "visibility": "public"}`) })) }) - It(`Invoke ReplaceConfigMap successfully`, func() { + It(`Invoke UpdateDomainMapping successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -10193,27 +12199,39 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(codeEngineService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := codeEngineService.ReplaceConfigMap(nil) + result, response, operationErr := codeEngineService.UpdateDomainMapping(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the ReplaceConfigMapOptions model - replaceConfigMapOptionsModel := new(codeenginev2.ReplaceConfigMapOptions) - replaceConfigMapOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - replaceConfigMapOptionsModel.Name = core.StringPtr("my-config-map") - replaceConfigMapOptionsModel.IfMatch = core.StringPtr("testString") - replaceConfigMapOptionsModel.Data = map[string]string{"key1": "testString"} - replaceConfigMapOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ComponentRef model + componentRefModel := new(codeenginev2.ComponentRef) + componentRefModel.Name = core.StringPtr("my-app-1") + componentRefModel.ResourceType = core.StringPtr("app_v2") + + // Construct an instance of the DomainMappingPatch model + domainMappingPatchModel := new(codeenginev2.DomainMappingPatch) + domainMappingPatchModel.Component = componentRefModel + domainMappingPatchModel.TlsSecret = core.StringPtr("my-tls-secret") + domainMappingPatchModelAsPatch, asPatchErr := domainMappingPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateDomainMappingOptions model + updateDomainMappingOptionsModel := new(codeenginev2.UpdateDomainMappingOptions) + updateDomainMappingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + updateDomainMappingOptionsModel.Name = core.StringPtr("www.example.com") + updateDomainMappingOptionsModel.IfMatch = core.StringPtr("testString") + updateDomainMappingOptionsModel.DomainMapping = domainMappingPatchModelAsPatch + updateDomainMappingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = codeEngineService.ReplaceConfigMap(replaceConfigMapOptionsModel) + result, response, operationErr = codeEngineService.UpdateDomainMapping(updateDomainMappingOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke ReplaceConfigMap with error: Operation validation and request error`, func() { + It(`Invoke UpdateDomainMapping with error: Operation validation and request error`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -10221,25 +12239,37 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the ReplaceConfigMapOptions model - replaceConfigMapOptionsModel := new(codeenginev2.ReplaceConfigMapOptions) - replaceConfigMapOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - replaceConfigMapOptionsModel.Name = core.StringPtr("my-config-map") - replaceConfigMapOptionsModel.IfMatch = core.StringPtr("testString") - replaceConfigMapOptionsModel.Data = map[string]string{"key1": "testString"} - replaceConfigMapOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ComponentRef model + componentRefModel := new(codeenginev2.ComponentRef) + componentRefModel.Name = core.StringPtr("my-app-1") + componentRefModel.ResourceType = core.StringPtr("app_v2") + + // Construct an instance of the DomainMappingPatch model + domainMappingPatchModel := new(codeenginev2.DomainMappingPatch) + domainMappingPatchModel.Component = componentRefModel + domainMappingPatchModel.TlsSecret = core.StringPtr("my-tls-secret") + domainMappingPatchModelAsPatch, asPatchErr := domainMappingPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateDomainMappingOptions model + updateDomainMappingOptionsModel := new(codeenginev2.UpdateDomainMappingOptions) + updateDomainMappingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + updateDomainMappingOptionsModel.Name = core.StringPtr("www.example.com") + updateDomainMappingOptionsModel.IfMatch = core.StringPtr("testString") + updateDomainMappingOptionsModel.DomainMapping = domainMappingPatchModelAsPatch + updateDomainMappingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := codeEngineService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := codeEngineService.ReplaceConfigMap(replaceConfigMapOptionsModel) + result, response, operationErr := codeEngineService.UpdateDomainMapping(updateDomainMappingOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct a second instance of the ReplaceConfigMapOptions model with no property values - replaceConfigMapOptionsModelNew := new(codeenginev2.ReplaceConfigMapOptions) + // Construct a second instance of the UpdateDomainMappingOptions model with no property values + updateDomainMappingOptionsModelNew := new(codeenginev2.UpdateDomainMappingOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = codeEngineService.ReplaceConfigMap(replaceConfigMapOptionsModelNew) + result, response, operationErr = codeEngineService.UpdateDomainMapping(updateDomainMappingOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -10257,7 +12287,7 @@ var _ = Describe(`CodeEngineV2`, func() { res.WriteHeader(200) })) }) - It(`Invoke ReplaceConfigMap successfully`, func() { + It(`Invoke UpdateDomainMapping successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -10265,16 +12295,28 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the ReplaceConfigMapOptions model - replaceConfigMapOptionsModel := new(codeenginev2.ReplaceConfigMapOptions) - replaceConfigMapOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - replaceConfigMapOptionsModel.Name = core.StringPtr("my-config-map") - replaceConfigMapOptionsModel.IfMatch = core.StringPtr("testString") - replaceConfigMapOptionsModel.Data = map[string]string{"key1": "testString"} - replaceConfigMapOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ComponentRef model + componentRefModel := new(codeenginev2.ComponentRef) + componentRefModel.Name = core.StringPtr("my-app-1") + componentRefModel.ResourceType = core.StringPtr("app_v2") + + // Construct an instance of the DomainMappingPatch model + domainMappingPatchModel := new(codeenginev2.DomainMappingPatch) + domainMappingPatchModel.Component = componentRefModel + domainMappingPatchModel.TlsSecret = core.StringPtr("my-tls-secret") + domainMappingPatchModelAsPatch, asPatchErr := domainMappingPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateDomainMappingOptions model + updateDomainMappingOptionsModel := new(codeenginev2.UpdateDomainMappingOptions) + updateDomainMappingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + updateDomainMappingOptionsModel.Name = core.StringPtr("www.example.com") + updateDomainMappingOptionsModel.IfMatch = core.StringPtr("testString") + updateDomainMappingOptionsModel.DomainMapping = domainMappingPatchModelAsPatch + updateDomainMappingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := codeEngineService.ReplaceConfigMap(replaceConfigMapOptionsModel) + result, response, operationErr := codeEngineService.UpdateDomainMapping(updateDomainMappingOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -10286,85 +12328,15 @@ var _ = Describe(`CodeEngineV2`, func() { }) }) }) - Describe(`DeleteConfigMap(deleteConfigMapOptions *DeleteConfigMapOptions)`, func() { - deleteConfigMapPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/config_maps/my-config-map" - Context(`Using mock server endpoint`, func() { - BeforeEach(func() { - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(deleteConfigMapPath)) - Expect(req.Method).To(Equal("DELETE")) - - res.WriteHeader(202) - })) - }) - It(`Invoke DeleteConfigMap successfully`, func() { - codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - }) - Expect(serviceErr).To(BeNil()) - Expect(codeEngineService).ToNot(BeNil()) - - // Invoke operation with nil options model (negative test) - response, operationErr := codeEngineService.DeleteConfigMap(nil) - Expect(operationErr).NotTo(BeNil()) - Expect(response).To(BeNil()) - - // Construct an instance of the DeleteConfigMapOptions model - deleteConfigMapOptionsModel := new(codeenginev2.DeleteConfigMapOptions) - deleteConfigMapOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - deleteConfigMapOptionsModel.Name = core.StringPtr("my-config-map") - deleteConfigMapOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - - // Invoke operation with valid options model (positive test) - response, operationErr = codeEngineService.DeleteConfigMap(deleteConfigMapOptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) - }) - It(`Invoke DeleteConfigMap with error: Operation validation and request error`, func() { - codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - }) - Expect(serviceErr).To(BeNil()) - Expect(codeEngineService).ToNot(BeNil()) - - // Construct an instance of the DeleteConfigMapOptions model - deleteConfigMapOptionsModel := new(codeenginev2.DeleteConfigMapOptions) - deleteConfigMapOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - deleteConfigMapOptionsModel.Name = core.StringPtr("my-config-map") - deleteConfigMapOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - // Invoke operation with empty URL (negative test) - err := codeEngineService.SetServiceURL("") - Expect(err).To(BeNil()) - response, operationErr := codeEngineService.DeleteConfigMap(deleteConfigMapOptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) - Expect(response).To(BeNil()) - // Construct a second instance of the DeleteConfigMapOptions model with no property values - deleteConfigMapOptionsModelNew := new(codeenginev2.DeleteConfigMapOptions) - // Invoke operation with invalid model (negative test) - response, operationErr = codeEngineService.DeleteConfigMap(deleteConfigMapOptionsModelNew) - Expect(operationErr).ToNot(BeNil()) - Expect(response).To(BeNil()) - }) - AfterEach(func() { - testServer.Close() - }) - }) - }) - Describe(`ListSecrets(listSecretsOptions *ListSecretsOptions) - Operation response error`, func() { - listSecretsPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/secrets" + Describe(`ListConfigMaps(listConfigMapsOptions *ListConfigMapsOptions) - Operation response error`, func() { + listConfigMapsPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/config_maps" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listSecretsPath)) + Expect(req.URL.EscapedPath()).To(Equal(listConfigMapsPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(100))})) Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) @@ -10373,7 +12345,7 @@ var _ = Describe(`CodeEngineV2`, func() { fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke ListSecrets with error: Operation response processing error`, func() { + It(`Invoke ListConfigMaps with error: Operation response processing error`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -10381,21 +12353,21 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the ListSecretsOptions model - listSecretsOptionsModel := new(codeenginev2.ListSecretsOptions) - listSecretsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - listSecretsOptionsModel.Limit = core.Int64Ptr(int64(100)) - listSecretsOptionsModel.Start = core.StringPtr("testString") - listSecretsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListConfigMapsOptions model + listConfigMapsOptionsModel := new(codeenginev2.ListConfigMapsOptions) + listConfigMapsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + listConfigMapsOptionsModel.Limit = core.Int64Ptr(int64(100)) + listConfigMapsOptionsModel.Start = core.StringPtr("testString") + listConfigMapsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := codeEngineService.ListSecrets(listSecretsOptionsModel) + result, response, operationErr := codeEngineService.ListConfigMaps(listConfigMapsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again codeEngineService.EnableRetries(0, 0) - result, response, operationErr = codeEngineService.ListSecrets(listSecretsOptionsModel) + result, response, operationErr = codeEngineService.ListConfigMaps(listConfigMapsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -10405,15 +12377,15 @@ var _ = Describe(`CodeEngineV2`, func() { }) }) }) - Describe(`ListSecrets(listSecretsOptions *ListSecretsOptions)`, func() { - listSecretsPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/secrets" + Describe(`ListConfigMaps(listConfigMapsOptions *ListConfigMapsOptions)`, func() { + listConfigMapsPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/config_maps" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listSecretsPath)) + Expect(req.URL.EscapedPath()).To(Equal(listConfigMapsPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(100))})) @@ -10424,10 +12396,10 @@ var _ = Describe(`CodeEngineV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"first": {"href": "Href"}, "limit": 100, "next": {"href": "Href", "start": "Start"}, "secrets": [{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "Inner"}, "entity_tag": "2385407409", "format": "generic", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-secret", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "ResourceType", "service_access": {"resource_key": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "name": "Name"}, "role": {"crn": "crn:v1:bluemix:public:iam::::serviceRole:Writer", "name": "Manager"}, "service_instance": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "type": "Type"}, "serviceid": {"crn": "Crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}}, "service_operator": {"apikey_id": "ApiKey-17041d26-55e4-40a8-8ab5-5a69b68e204b", "resource_group_ids": ["ResourceGroupIds"], "serviceid": {"crn": "Crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}, "user_managed": false}}]}`) + fmt.Fprintf(res, "%s", `{"config_maps": [{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "Inner"}, "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-config-map", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "config_map_v2"}], "first": {"href": "Href"}, "limit": 100, "next": {"href": "Href", "start": "Start"}}`) })) }) - It(`Invoke ListSecrets successfully with retries`, func() { + It(`Invoke ListConfigMaps successfully with retries`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -10436,23 +12408,23 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(codeEngineService).ToNot(BeNil()) codeEngineService.EnableRetries(0, 0) - // Construct an instance of the ListSecretsOptions model - listSecretsOptionsModel := new(codeenginev2.ListSecretsOptions) - listSecretsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - listSecretsOptionsModel.Limit = core.Int64Ptr(int64(100)) - listSecretsOptionsModel.Start = core.StringPtr("testString") - listSecretsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListConfigMapsOptions model + listConfigMapsOptionsModel := new(codeenginev2.ListConfigMapsOptions) + listConfigMapsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + listConfigMapsOptionsModel.Limit = core.Int64Ptr(int64(100)) + listConfigMapsOptionsModel.Start = core.StringPtr("testString") + listConfigMapsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := codeEngineService.ListSecretsWithContext(ctx, listSecretsOptionsModel) + _, _, operationErr := codeEngineService.ListConfigMapsWithContext(ctx, listConfigMapsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again codeEngineService.DisableRetries() - result, response, operationErr := codeEngineService.ListSecrets(listSecretsOptionsModel) + result, response, operationErr := codeEngineService.ListConfigMaps(listConfigMapsOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -10460,7 +12432,7 @@ var _ = Describe(`CodeEngineV2`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = codeEngineService.ListSecretsWithContext(ctx, listSecretsOptionsModel) + _, _, operationErr = codeEngineService.ListConfigMapsWithContext(ctx, listConfigMapsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -10474,7 +12446,7 @@ var _ = Describe(`CodeEngineV2`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listSecretsPath)) + Expect(req.URL.EscapedPath()).To(Equal(listConfigMapsPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(100))})) @@ -10482,10 +12454,10 @@ var _ = Describe(`CodeEngineV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"first": {"href": "Href"}, "limit": 100, "next": {"href": "Href", "start": "Start"}, "secrets": [{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "Inner"}, "entity_tag": "2385407409", "format": "generic", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-secret", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "ResourceType", "service_access": {"resource_key": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "name": "Name"}, "role": {"crn": "crn:v1:bluemix:public:iam::::serviceRole:Writer", "name": "Manager"}, "service_instance": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "type": "Type"}, "serviceid": {"crn": "Crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}}, "service_operator": {"apikey_id": "ApiKey-17041d26-55e4-40a8-8ab5-5a69b68e204b", "resource_group_ids": ["ResourceGroupIds"], "serviceid": {"crn": "Crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}, "user_managed": false}}]}`) + fmt.Fprintf(res, "%s", `{"config_maps": [{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "Inner"}, "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-config-map", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "config_map_v2"}], "first": {"href": "Href"}, "limit": 100, "next": {"href": "Href", "start": "Start"}}`) })) }) - It(`Invoke ListSecrets successfully`, func() { + It(`Invoke ListConfigMaps successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -10494,26 +12466,26 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(codeEngineService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := codeEngineService.ListSecrets(nil) + result, response, operationErr := codeEngineService.ListConfigMaps(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the ListSecretsOptions model - listSecretsOptionsModel := new(codeenginev2.ListSecretsOptions) - listSecretsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - listSecretsOptionsModel.Limit = core.Int64Ptr(int64(100)) - listSecretsOptionsModel.Start = core.StringPtr("testString") - listSecretsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListConfigMapsOptions model + listConfigMapsOptionsModel := new(codeenginev2.ListConfigMapsOptions) + listConfigMapsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + listConfigMapsOptionsModel.Limit = core.Int64Ptr(int64(100)) + listConfigMapsOptionsModel.Start = core.StringPtr("testString") + listConfigMapsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = codeEngineService.ListSecrets(listSecretsOptionsModel) + result, response, operationErr = codeEngineService.ListConfigMaps(listConfigMapsOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke ListSecrets with error: Operation validation and request error`, func() { + It(`Invoke ListConfigMaps with error: Operation validation and request error`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -10521,24 +12493,24 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the ListSecretsOptions model - listSecretsOptionsModel := new(codeenginev2.ListSecretsOptions) - listSecretsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - listSecretsOptionsModel.Limit = core.Int64Ptr(int64(100)) - listSecretsOptionsModel.Start = core.StringPtr("testString") - listSecretsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListConfigMapsOptions model + listConfigMapsOptionsModel := new(codeenginev2.ListConfigMapsOptions) + listConfigMapsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + listConfigMapsOptionsModel.Limit = core.Int64Ptr(int64(100)) + listConfigMapsOptionsModel.Start = core.StringPtr("testString") + listConfigMapsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := codeEngineService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := codeEngineService.ListSecrets(listSecretsOptionsModel) + result, response, operationErr := codeEngineService.ListConfigMaps(listConfigMapsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct a second instance of the ListSecretsOptions model with no property values - listSecretsOptionsModelNew := new(codeenginev2.ListSecretsOptions) + // Construct a second instance of the ListConfigMapsOptions model with no property values + listConfigMapsOptionsModelNew := new(codeenginev2.ListConfigMapsOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = codeEngineService.ListSecrets(listSecretsOptionsModelNew) + result, response, operationErr = codeEngineService.ListConfigMaps(listConfigMapsOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -10556,7 +12528,7 @@ var _ = Describe(`CodeEngineV2`, func() { res.WriteHeader(200) })) }) - It(`Invoke ListSecrets successfully`, func() { + It(`Invoke ListConfigMaps successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -10564,15 +12536,15 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the ListSecretsOptions model - listSecretsOptionsModel := new(codeenginev2.ListSecretsOptions) - listSecretsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - listSecretsOptionsModel.Limit = core.Int64Ptr(int64(100)) - listSecretsOptionsModel.Start = core.StringPtr("testString") - listSecretsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListConfigMapsOptions model + listConfigMapsOptionsModel := new(codeenginev2.ListConfigMapsOptions) + listConfigMapsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + listConfigMapsOptionsModel.Limit = core.Int64Ptr(int64(100)) + listConfigMapsOptionsModel.Start = core.StringPtr("testString") + listConfigMapsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := codeEngineService.ListSecrets(listSecretsOptionsModel) + result, response, operationErr := codeEngineService.ListConfigMaps(listConfigMapsOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -10585,7 +12557,7 @@ var _ = Describe(`CodeEngineV2`, func() { }) Context(`Test pagination helper method on response`, func() { It(`Invoke GetNextStart successfully`, func() { - responseObject := new(codeenginev2.SecretList) + responseObject := new(codeenginev2.ConfigMapList) nextObject := new(codeenginev2.ListNextMetadata) nextObject.Start = core.StringPtr("abc-123") responseObject.Next = nextObject @@ -10595,7 +12567,7 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(value).To(Equal(core.StringPtr("abc-123"))) }) It(`Invoke GetNextStart without a "Next" property in the response`, func() { - responseObject := new(codeenginev2.SecretList) + responseObject := new(codeenginev2.ConfigMapList) value, err := responseObject.GetNextStart() Expect(err).To(BeNil()) @@ -10609,7 +12581,7 @@ var _ = Describe(`CodeEngineV2`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listSecretsPath)) + Expect(req.URL.EscapedPath()).To(Equal(listConfigMapsPath)) Expect(req.Method).To(Equal("GET")) // Set mock response @@ -10617,15 +12589,15 @@ var _ = Describe(`CodeEngineV2`, func() { res.WriteHeader(200) requestNumber++ if requestNumber == 1 { - fmt.Fprintf(res, "%s", `{"next":{"start":"1"},"total_count":2,"limit":1,"secrets":[{"created_at":"2022-09-13T11:41:35+02:00","data":{"mapKey":"Inner"},"entity_tag":"2385407409","format":"generic","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-secret","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"ResourceType","service_access":{"resource_key":{"id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","name":"Name"},"role":{"crn":"crn:v1:bluemix:public:iam::::serviceRole:Writer","name":"Manager"},"service_instance":{"id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","type":"Type"},"serviceid":{"crn":"Crn","id":"ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}},"service_operator":{"apikey_id":"ApiKey-17041d26-55e4-40a8-8ab5-5a69b68e204b","resource_group_ids":["ResourceGroupIds"],"serviceid":{"crn":"Crn","id":"ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"},"user_managed":false}}]}`) + fmt.Fprintf(res, "%s", `{"next":{"start":"1"},"config_maps":[{"created_at":"2022-09-13T11:41:35+02:00","data":{"mapKey":"Inner"},"entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-config-map","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"config_map_v2"}],"total_count":2,"limit":1}`) } else if requestNumber == 2 { - fmt.Fprintf(res, "%s", `{"total_count":2,"limit":1,"secrets":[{"created_at":"2022-09-13T11:41:35+02:00","data":{"mapKey":"Inner"},"entity_tag":"2385407409","format":"generic","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-secret","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"ResourceType","service_access":{"resource_key":{"id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","name":"Name"},"role":{"crn":"crn:v1:bluemix:public:iam::::serviceRole:Writer","name":"Manager"},"service_instance":{"id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","type":"Type"},"serviceid":{"crn":"Crn","id":"ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}},"service_operator":{"apikey_id":"ApiKey-17041d26-55e4-40a8-8ab5-5a69b68e204b","resource_group_ids":["ResourceGroupIds"],"serviceid":{"crn":"Crn","id":"ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"},"user_managed":false}}]}`) + fmt.Fprintf(res, "%s", `{"config_maps":[{"created_at":"2022-09-13T11:41:35+02:00","data":{"mapKey":"Inner"},"entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-config-map","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"config_map_v2"}],"total_count":2,"limit":1}`) } else { res.WriteHeader(400) } })) }) - It(`Use SecretsPager.GetNext successfully`, func() { + It(`Use ConfigMapsPager.GetNext successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -10633,16 +12605,16 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - listSecretsOptionsModel := &codeenginev2.ListSecretsOptions{ + listConfigMapsOptionsModel := &codeenginev2.ListConfigMapsOptions{ ProjectID: core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"), Limit: core.Int64Ptr(int64(100)), } - pager, err := codeEngineService.NewSecretsPager(listSecretsOptionsModel) + pager, err := codeEngineService.NewConfigMapsPager(listConfigMapsOptionsModel) Expect(err).To(BeNil()) Expect(pager).ToNot(BeNil()) - var allResults []codeenginev2.Secret + var allResults []codeenginev2.ConfigMap for pager.HasNext() { nextPage, err := pager.GetNext() Expect(err).To(BeNil()) @@ -10651,7 +12623,7 @@ var _ = Describe(`CodeEngineV2`, func() { } Expect(len(allResults)).To(Equal(2)) }) - It(`Use SecretsPager.GetAll successfully`, func() { + It(`Use ConfigMapsPager.GetAll successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -10659,12 +12631,12 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - listSecretsOptionsModel := &codeenginev2.ListSecretsOptions{ + listConfigMapsOptionsModel := &codeenginev2.ListConfigMapsOptions{ ProjectID: core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"), Limit: core.Int64Ptr(int64(100)), } - pager, err := codeEngineService.NewSecretsPager(listSecretsOptionsModel) + pager, err := codeEngineService.NewConfigMapsPager(listConfigMapsOptionsModel) Expect(err).To(BeNil()) Expect(pager).ToNot(BeNil()) @@ -10675,22 +12647,22 @@ var _ = Describe(`CodeEngineV2`, func() { }) }) }) - Describe(`CreateSecret(createSecretOptions *CreateSecretOptions) - Operation response error`, func() { - createSecretPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/secrets" + Describe(`CreateConfigMap(createConfigMapOptions *CreateConfigMapOptions) - Operation response error`, func() { + createConfigMapPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/config_maps" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createSecretPath)) + Expect(req.URL.EscapedPath()).To(Equal(createConfigMapPath)) Expect(req.Method).To(Equal("POST")) res.Header().Set("Content-type", "application/json") res.WriteHeader(201) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke CreateSecret with error: Operation response processing error`, func() { + It(`Invoke CreateConfigMap with error: Operation response processing error`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -10698,63 +12670,21 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the SecretDataSSHSecretData model - secretDataModel := new(codeenginev2.SecretDataSSHSecretData) - secretDataModel.SshKey = core.StringPtr("testString") - secretDataModel.KnownHosts = core.StringPtr("testString") - secretDataModel.SetProperty("foo", core.StringPtr("testString")) - - // Construct an instance of the ResourceKeyRefPrototype model - resourceKeyRefPrototypeModel := new(codeenginev2.ResourceKeyRefPrototype) - resourceKeyRefPrototypeModel.ID = core.StringPtr("4e49b3e0-27a8-48d2-a784-c7ee48bb863b") - - // Construct an instance of the RoleRefPrototype model - roleRefPrototypeModel := new(codeenginev2.RoleRefPrototype) - roleRefPrototypeModel.Crn = core.StringPtr("crn:v1:bluemix:public:iam::::serviceRole:Writer") - - // Construct an instance of the ServiceInstanceRefPrototype model - serviceInstanceRefPrototypeModel := new(codeenginev2.ServiceInstanceRefPrototype) - serviceInstanceRefPrototypeModel.ID = core.StringPtr("4e49b3e0-27a8-48d2-a784-c7ee48bb863b") - - // Construct an instance of the ServiceIDRef model - serviceIdRefModel := new(codeenginev2.ServiceIDRef) - serviceIdRefModel.Crn = core.StringPtr("testString") - serviceIdRefModel.ID = core.StringPtr("ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637") - - // Construct an instance of the ServiceAccessSecretPrototypeProps model - serviceAccessSecretPrototypePropsModel := new(codeenginev2.ServiceAccessSecretPrototypeProps) - serviceAccessSecretPrototypePropsModel.ResourceKey = resourceKeyRefPrototypeModel - serviceAccessSecretPrototypePropsModel.Role = roleRefPrototypeModel - serviceAccessSecretPrototypePropsModel.ServiceInstance = serviceInstanceRefPrototypeModel - serviceAccessSecretPrototypePropsModel.Serviceid = serviceIdRefModel - - // Construct an instance of the ServiceIDRefPrototype model - serviceIdRefPrototypeModel := new(codeenginev2.ServiceIDRefPrototype) - serviceIdRefPrototypeModel.ID = core.StringPtr("ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637") - - // Construct an instance of the OperatorSecretPrototypeProps model - operatorSecretPrototypePropsModel := new(codeenginev2.OperatorSecretPrototypeProps) - operatorSecretPrototypePropsModel.ResourceGroupIds = []string{"testString"} - operatorSecretPrototypePropsModel.Serviceid = serviceIdRefPrototypeModel - - // Construct an instance of the CreateSecretOptions model - createSecretOptionsModel := new(codeenginev2.CreateSecretOptions) - createSecretOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - createSecretOptionsModel.Format = core.StringPtr("generic") - createSecretOptionsModel.Name = core.StringPtr("my-secret") - createSecretOptionsModel.Data = secretDataModel - createSecretOptionsModel.ServiceAccess = serviceAccessSecretPrototypePropsModel - createSecretOptionsModel.ServiceOperator = operatorSecretPrototypePropsModel - createSecretOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the CreateConfigMapOptions model + createConfigMapOptionsModel := new(codeenginev2.CreateConfigMapOptions) + createConfigMapOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + createConfigMapOptionsModel.Name = core.StringPtr("my-config-map") + createConfigMapOptionsModel.Data = map[string]string{"key1": "testString"} + createConfigMapOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := codeEngineService.CreateSecret(createSecretOptionsModel) + result, response, operationErr := codeEngineService.CreateConfigMap(createConfigMapOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again codeEngineService.EnableRetries(0, 0) - result, response, operationErr = codeEngineService.CreateSecret(createSecretOptionsModel) + result, response, operationErr = codeEngineService.CreateConfigMap(createConfigMapOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -10764,15 +12694,15 @@ var _ = Describe(`CodeEngineV2`, func() { }) }) }) - Describe(`CreateSecret(createSecretOptions *CreateSecretOptions)`, func() { - createSecretPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/secrets" + Describe(`CreateConfigMap(createConfigMapOptions *CreateConfigMapOptions)`, func() { + createConfigMapPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/config_maps" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createSecretPath)) + Expect(req.URL.EscapedPath()).To(Equal(createConfigMapPath)) Expect(req.Method).To(Equal("POST")) // For gzip-disabled operation, verify Content-Encoding is not set. @@ -10796,78 +12726,36 @@ var _ = Describe(`CodeEngineV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") - res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "Inner"}, "entity_tag": "2385407409", "format": "generic", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-secret", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "ResourceType", "service_access": {"resource_key": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "name": "Name"}, "role": {"crn": "crn:v1:bluemix:public:iam::::serviceRole:Writer", "name": "Manager"}, "service_instance": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "type": "Type"}, "serviceid": {"crn": "Crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}}, "service_operator": {"apikey_id": "ApiKey-17041d26-55e4-40a8-8ab5-5a69b68e204b", "resource_group_ids": ["ResourceGroupIds"], "serviceid": {"crn": "Crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}, "user_managed": false}}`) - })) - }) - It(`Invoke CreateSecret successfully with retries`, func() { - codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - }) - Expect(serviceErr).To(BeNil()) - Expect(codeEngineService).ToNot(BeNil()) - codeEngineService.EnableRetries(0, 0) - - // Construct an instance of the SecretDataSSHSecretData model - secretDataModel := new(codeenginev2.SecretDataSSHSecretData) - secretDataModel.SshKey = core.StringPtr("testString") - secretDataModel.KnownHosts = core.StringPtr("testString") - secretDataModel.SetProperty("foo", core.StringPtr("testString")) - - // Construct an instance of the ResourceKeyRefPrototype model - resourceKeyRefPrototypeModel := new(codeenginev2.ResourceKeyRefPrototype) - resourceKeyRefPrototypeModel.ID = core.StringPtr("4e49b3e0-27a8-48d2-a784-c7ee48bb863b") - - // Construct an instance of the RoleRefPrototype model - roleRefPrototypeModel := new(codeenginev2.RoleRefPrototype) - roleRefPrototypeModel.Crn = core.StringPtr("crn:v1:bluemix:public:iam::::serviceRole:Writer") - - // Construct an instance of the ServiceInstanceRefPrototype model - serviceInstanceRefPrototypeModel := new(codeenginev2.ServiceInstanceRefPrototype) - serviceInstanceRefPrototypeModel.ID = core.StringPtr("4e49b3e0-27a8-48d2-a784-c7ee48bb863b") - - // Construct an instance of the ServiceIDRef model - serviceIdRefModel := new(codeenginev2.ServiceIDRef) - serviceIdRefModel.Crn = core.StringPtr("testString") - serviceIdRefModel.ID = core.StringPtr("ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637") - - // Construct an instance of the ServiceAccessSecretPrototypeProps model - serviceAccessSecretPrototypePropsModel := new(codeenginev2.ServiceAccessSecretPrototypeProps) - serviceAccessSecretPrototypePropsModel.ResourceKey = resourceKeyRefPrototypeModel - serviceAccessSecretPrototypePropsModel.Role = roleRefPrototypeModel - serviceAccessSecretPrototypePropsModel.ServiceInstance = serviceInstanceRefPrototypeModel - serviceAccessSecretPrototypePropsModel.Serviceid = serviceIdRefModel - - // Construct an instance of the ServiceIDRefPrototype model - serviceIdRefPrototypeModel := new(codeenginev2.ServiceIDRefPrototype) - serviceIdRefPrototypeModel.ID = core.StringPtr("ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637") - - // Construct an instance of the OperatorSecretPrototypeProps model - operatorSecretPrototypePropsModel := new(codeenginev2.OperatorSecretPrototypeProps) - operatorSecretPrototypePropsModel.ResourceGroupIds = []string{"testString"} - operatorSecretPrototypePropsModel.Serviceid = serviceIdRefPrototypeModel + res.WriteHeader(201) + fmt.Fprintf(res, "%s", `{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "Inner"}, "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-config-map", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "config_map_v2"}`) + })) + }) + It(`Invoke CreateConfigMap successfully with retries`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + codeEngineService.EnableRetries(0, 0) - // Construct an instance of the CreateSecretOptions model - createSecretOptionsModel := new(codeenginev2.CreateSecretOptions) - createSecretOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - createSecretOptionsModel.Format = core.StringPtr("generic") - createSecretOptionsModel.Name = core.StringPtr("my-secret") - createSecretOptionsModel.Data = secretDataModel - createSecretOptionsModel.ServiceAccess = serviceAccessSecretPrototypePropsModel - createSecretOptionsModel.ServiceOperator = operatorSecretPrototypePropsModel - createSecretOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the CreateConfigMapOptions model + createConfigMapOptionsModel := new(codeenginev2.CreateConfigMapOptions) + createConfigMapOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + createConfigMapOptionsModel.Name = core.StringPtr("my-config-map") + createConfigMapOptionsModel.Data = map[string]string{"key1": "testString"} + createConfigMapOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := codeEngineService.CreateSecretWithContext(ctx, createSecretOptionsModel) + _, _, operationErr := codeEngineService.CreateConfigMapWithContext(ctx, createConfigMapOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again codeEngineService.DisableRetries() - result, response, operationErr := codeEngineService.CreateSecret(createSecretOptionsModel) + result, response, operationErr := codeEngineService.CreateConfigMap(createConfigMapOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -10875,7 +12763,7 @@ var _ = Describe(`CodeEngineV2`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = codeEngineService.CreateSecretWithContext(ctx, createSecretOptionsModel) + _, _, operationErr = codeEngineService.CreateConfigMapWithContext(ctx, createConfigMapOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -10889,7 +12777,7 @@ var _ = Describe(`CodeEngineV2`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createSecretPath)) + Expect(req.URL.EscapedPath()).To(Equal(createConfigMapPath)) Expect(req.Method).To(Equal("POST")) // For gzip-disabled operation, verify Content-Encoding is not set. @@ -10911,10 +12799,10 @@ var _ = Describe(`CodeEngineV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "Inner"}, "entity_tag": "2385407409", "format": "generic", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-secret", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "ResourceType", "service_access": {"resource_key": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "name": "Name"}, "role": {"crn": "crn:v1:bluemix:public:iam::::serviceRole:Writer", "name": "Manager"}, "service_instance": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "type": "Type"}, "serviceid": {"crn": "Crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}}, "service_operator": {"apikey_id": "ApiKey-17041d26-55e4-40a8-8ab5-5a69b68e204b", "resource_group_ids": ["ResourceGroupIds"], "serviceid": {"crn": "Crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}, "user_managed": false}}`) + fmt.Fprintf(res, "%s", `{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "Inner"}, "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-config-map", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "config_map_v2"}`) })) }) - It(`Invoke CreateSecret successfully`, func() { + It(`Invoke CreateConfigMap successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -10923,68 +12811,26 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(codeEngineService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := codeEngineService.CreateSecret(nil) + result, response, operationErr := codeEngineService.CreateConfigMap(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the SecretDataSSHSecretData model - secretDataModel := new(codeenginev2.SecretDataSSHSecretData) - secretDataModel.SshKey = core.StringPtr("testString") - secretDataModel.KnownHosts = core.StringPtr("testString") - secretDataModel.SetProperty("foo", core.StringPtr("testString")) - - // Construct an instance of the ResourceKeyRefPrototype model - resourceKeyRefPrototypeModel := new(codeenginev2.ResourceKeyRefPrototype) - resourceKeyRefPrototypeModel.ID = core.StringPtr("4e49b3e0-27a8-48d2-a784-c7ee48bb863b") - - // Construct an instance of the RoleRefPrototype model - roleRefPrototypeModel := new(codeenginev2.RoleRefPrototype) - roleRefPrototypeModel.Crn = core.StringPtr("crn:v1:bluemix:public:iam::::serviceRole:Writer") - - // Construct an instance of the ServiceInstanceRefPrototype model - serviceInstanceRefPrototypeModel := new(codeenginev2.ServiceInstanceRefPrototype) - serviceInstanceRefPrototypeModel.ID = core.StringPtr("4e49b3e0-27a8-48d2-a784-c7ee48bb863b") - - // Construct an instance of the ServiceIDRef model - serviceIdRefModel := new(codeenginev2.ServiceIDRef) - serviceIdRefModel.Crn = core.StringPtr("testString") - serviceIdRefModel.ID = core.StringPtr("ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637") - - // Construct an instance of the ServiceAccessSecretPrototypeProps model - serviceAccessSecretPrototypePropsModel := new(codeenginev2.ServiceAccessSecretPrototypeProps) - serviceAccessSecretPrototypePropsModel.ResourceKey = resourceKeyRefPrototypeModel - serviceAccessSecretPrototypePropsModel.Role = roleRefPrototypeModel - serviceAccessSecretPrototypePropsModel.ServiceInstance = serviceInstanceRefPrototypeModel - serviceAccessSecretPrototypePropsModel.Serviceid = serviceIdRefModel - - // Construct an instance of the ServiceIDRefPrototype model - serviceIdRefPrototypeModel := new(codeenginev2.ServiceIDRefPrototype) - serviceIdRefPrototypeModel.ID = core.StringPtr("ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637") - - // Construct an instance of the OperatorSecretPrototypeProps model - operatorSecretPrototypePropsModel := new(codeenginev2.OperatorSecretPrototypeProps) - operatorSecretPrototypePropsModel.ResourceGroupIds = []string{"testString"} - operatorSecretPrototypePropsModel.Serviceid = serviceIdRefPrototypeModel - - // Construct an instance of the CreateSecretOptions model - createSecretOptionsModel := new(codeenginev2.CreateSecretOptions) - createSecretOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - createSecretOptionsModel.Format = core.StringPtr("generic") - createSecretOptionsModel.Name = core.StringPtr("my-secret") - createSecretOptionsModel.Data = secretDataModel - createSecretOptionsModel.ServiceAccess = serviceAccessSecretPrototypePropsModel - createSecretOptionsModel.ServiceOperator = operatorSecretPrototypePropsModel - createSecretOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the CreateConfigMapOptions model + createConfigMapOptionsModel := new(codeenginev2.CreateConfigMapOptions) + createConfigMapOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + createConfigMapOptionsModel.Name = core.StringPtr("my-config-map") + createConfigMapOptionsModel.Data = map[string]string{"key1": "testString"} + createConfigMapOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = codeEngineService.CreateSecret(createSecretOptionsModel) + result, response, operationErr = codeEngineService.CreateConfigMap(createConfigMapOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke CreateSecret with error: Operation validation and request error`, func() { + It(`Invoke CreateConfigMap with error: Operation validation and request error`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -10992,66 +12838,24 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the SecretDataSSHSecretData model - secretDataModel := new(codeenginev2.SecretDataSSHSecretData) - secretDataModel.SshKey = core.StringPtr("testString") - secretDataModel.KnownHosts = core.StringPtr("testString") - secretDataModel.SetProperty("foo", core.StringPtr("testString")) - - // Construct an instance of the ResourceKeyRefPrototype model - resourceKeyRefPrototypeModel := new(codeenginev2.ResourceKeyRefPrototype) - resourceKeyRefPrototypeModel.ID = core.StringPtr("4e49b3e0-27a8-48d2-a784-c7ee48bb863b") - - // Construct an instance of the RoleRefPrototype model - roleRefPrototypeModel := new(codeenginev2.RoleRefPrototype) - roleRefPrototypeModel.Crn = core.StringPtr("crn:v1:bluemix:public:iam::::serviceRole:Writer") - - // Construct an instance of the ServiceInstanceRefPrototype model - serviceInstanceRefPrototypeModel := new(codeenginev2.ServiceInstanceRefPrototype) - serviceInstanceRefPrototypeModel.ID = core.StringPtr("4e49b3e0-27a8-48d2-a784-c7ee48bb863b") - - // Construct an instance of the ServiceIDRef model - serviceIdRefModel := new(codeenginev2.ServiceIDRef) - serviceIdRefModel.Crn = core.StringPtr("testString") - serviceIdRefModel.ID = core.StringPtr("ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637") - - // Construct an instance of the ServiceAccessSecretPrototypeProps model - serviceAccessSecretPrototypePropsModel := new(codeenginev2.ServiceAccessSecretPrototypeProps) - serviceAccessSecretPrototypePropsModel.ResourceKey = resourceKeyRefPrototypeModel - serviceAccessSecretPrototypePropsModel.Role = roleRefPrototypeModel - serviceAccessSecretPrototypePropsModel.ServiceInstance = serviceInstanceRefPrototypeModel - serviceAccessSecretPrototypePropsModel.Serviceid = serviceIdRefModel - - // Construct an instance of the ServiceIDRefPrototype model - serviceIdRefPrototypeModel := new(codeenginev2.ServiceIDRefPrototype) - serviceIdRefPrototypeModel.ID = core.StringPtr("ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637") - - // Construct an instance of the OperatorSecretPrototypeProps model - operatorSecretPrototypePropsModel := new(codeenginev2.OperatorSecretPrototypeProps) - operatorSecretPrototypePropsModel.ResourceGroupIds = []string{"testString"} - operatorSecretPrototypePropsModel.Serviceid = serviceIdRefPrototypeModel - - // Construct an instance of the CreateSecretOptions model - createSecretOptionsModel := new(codeenginev2.CreateSecretOptions) - createSecretOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - createSecretOptionsModel.Format = core.StringPtr("generic") - createSecretOptionsModel.Name = core.StringPtr("my-secret") - createSecretOptionsModel.Data = secretDataModel - createSecretOptionsModel.ServiceAccess = serviceAccessSecretPrototypePropsModel - createSecretOptionsModel.ServiceOperator = operatorSecretPrototypePropsModel - createSecretOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the CreateConfigMapOptions model + createConfigMapOptionsModel := new(codeenginev2.CreateConfigMapOptions) + createConfigMapOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + createConfigMapOptionsModel.Name = core.StringPtr("my-config-map") + createConfigMapOptionsModel.Data = map[string]string{"key1": "testString"} + createConfigMapOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := codeEngineService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := codeEngineService.CreateSecret(createSecretOptionsModel) + result, response, operationErr := codeEngineService.CreateConfigMap(createConfigMapOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct a second instance of the CreateSecretOptions model with no property values - createSecretOptionsModelNew := new(codeenginev2.CreateSecretOptions) + // Construct a second instance of the CreateConfigMapOptions model with no property values + createConfigMapOptionsModelNew := new(codeenginev2.CreateConfigMapOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = codeEngineService.CreateSecret(createSecretOptionsModelNew) + result, response, operationErr = codeEngineService.CreateConfigMap(createConfigMapOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -11069,7 +12873,7 @@ var _ = Describe(`CodeEngineV2`, func() { res.WriteHeader(201) })) }) - It(`Invoke CreateSecret successfully`, func() { + It(`Invoke CreateConfigMap successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -11077,57 +12881,15 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the SecretDataSSHSecretData model - secretDataModel := new(codeenginev2.SecretDataSSHSecretData) - secretDataModel.SshKey = core.StringPtr("testString") - secretDataModel.KnownHosts = core.StringPtr("testString") - secretDataModel.SetProperty("foo", core.StringPtr("testString")) - - // Construct an instance of the ResourceKeyRefPrototype model - resourceKeyRefPrototypeModel := new(codeenginev2.ResourceKeyRefPrototype) - resourceKeyRefPrototypeModel.ID = core.StringPtr("4e49b3e0-27a8-48d2-a784-c7ee48bb863b") - - // Construct an instance of the RoleRefPrototype model - roleRefPrototypeModel := new(codeenginev2.RoleRefPrototype) - roleRefPrototypeModel.Crn = core.StringPtr("crn:v1:bluemix:public:iam::::serviceRole:Writer") - - // Construct an instance of the ServiceInstanceRefPrototype model - serviceInstanceRefPrototypeModel := new(codeenginev2.ServiceInstanceRefPrototype) - serviceInstanceRefPrototypeModel.ID = core.StringPtr("4e49b3e0-27a8-48d2-a784-c7ee48bb863b") - - // Construct an instance of the ServiceIDRef model - serviceIdRefModel := new(codeenginev2.ServiceIDRef) - serviceIdRefModel.Crn = core.StringPtr("testString") - serviceIdRefModel.ID = core.StringPtr("ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637") - - // Construct an instance of the ServiceAccessSecretPrototypeProps model - serviceAccessSecretPrototypePropsModel := new(codeenginev2.ServiceAccessSecretPrototypeProps) - serviceAccessSecretPrototypePropsModel.ResourceKey = resourceKeyRefPrototypeModel - serviceAccessSecretPrototypePropsModel.Role = roleRefPrototypeModel - serviceAccessSecretPrototypePropsModel.ServiceInstance = serviceInstanceRefPrototypeModel - serviceAccessSecretPrototypePropsModel.Serviceid = serviceIdRefModel - - // Construct an instance of the ServiceIDRefPrototype model - serviceIdRefPrototypeModel := new(codeenginev2.ServiceIDRefPrototype) - serviceIdRefPrototypeModel.ID = core.StringPtr("ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637") - - // Construct an instance of the OperatorSecretPrototypeProps model - operatorSecretPrototypePropsModel := new(codeenginev2.OperatorSecretPrototypeProps) - operatorSecretPrototypePropsModel.ResourceGroupIds = []string{"testString"} - operatorSecretPrototypePropsModel.Serviceid = serviceIdRefPrototypeModel - - // Construct an instance of the CreateSecretOptions model - createSecretOptionsModel := new(codeenginev2.CreateSecretOptions) - createSecretOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - createSecretOptionsModel.Format = core.StringPtr("generic") - createSecretOptionsModel.Name = core.StringPtr("my-secret") - createSecretOptionsModel.Data = secretDataModel - createSecretOptionsModel.ServiceAccess = serviceAccessSecretPrototypePropsModel - createSecretOptionsModel.ServiceOperator = operatorSecretPrototypePropsModel - createSecretOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the CreateConfigMapOptions model + createConfigMapOptionsModel := new(codeenginev2.CreateConfigMapOptions) + createConfigMapOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + createConfigMapOptionsModel.Name = core.StringPtr("my-config-map") + createConfigMapOptionsModel.Data = map[string]string{"key1": "testString"} + createConfigMapOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := codeEngineService.CreateSecret(createSecretOptionsModel) + result, response, operationErr := codeEngineService.CreateConfigMap(createConfigMapOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -11139,22 +12901,22 @@ var _ = Describe(`CodeEngineV2`, func() { }) }) }) - Describe(`GetSecret(getSecretOptions *GetSecretOptions) - Operation response error`, func() { - getSecretPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/secrets/my-secret" + Describe(`GetConfigMap(getConfigMapOptions *GetConfigMapOptions) - Operation response error`, func() { + getConfigMapPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/config_maps/my-config-map" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getSecretPath)) + Expect(req.URL.EscapedPath()).To(Equal(getConfigMapPath)) Expect(req.Method).To(Equal("GET")) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke GetSecret with error: Operation response processing error`, func() { + It(`Invoke GetConfigMap with error: Operation response processing error`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -11162,20 +12924,20 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the GetSecretOptions model - getSecretOptionsModel := new(codeenginev2.GetSecretOptions) - getSecretOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - getSecretOptionsModel.Name = core.StringPtr("my-secret") - getSecretOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetConfigMapOptions model + getConfigMapOptionsModel := new(codeenginev2.GetConfigMapOptions) + getConfigMapOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + getConfigMapOptionsModel.Name = core.StringPtr("my-config-map") + getConfigMapOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := codeEngineService.GetSecret(getSecretOptionsModel) + result, response, operationErr := codeEngineService.GetConfigMap(getConfigMapOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again codeEngineService.EnableRetries(0, 0) - result, response, operationErr = codeEngineService.GetSecret(getSecretOptionsModel) + result, response, operationErr = codeEngineService.GetConfigMap(getConfigMapOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -11185,15 +12947,15 @@ var _ = Describe(`CodeEngineV2`, func() { }) }) }) - Describe(`GetSecret(getSecretOptions *GetSecretOptions)`, func() { - getSecretPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/secrets/my-secret" + Describe(`GetConfigMap(getConfigMapOptions *GetConfigMapOptions)`, func() { + getConfigMapPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/config_maps/my-config-map" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getSecretPath)) + Expect(req.URL.EscapedPath()).To(Equal(getConfigMapPath)) Expect(req.Method).To(Equal("GET")) // Sleep a short time to support a timeout test @@ -11202,10 +12964,10 @@ var _ = Describe(`CodeEngineV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "Inner"}, "entity_tag": "2385407409", "format": "generic", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-secret", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "ResourceType", "service_access": {"resource_key": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "name": "Name"}, "role": {"crn": "crn:v1:bluemix:public:iam::::serviceRole:Writer", "name": "Manager"}, "service_instance": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "type": "Type"}, "serviceid": {"crn": "Crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}}, "service_operator": {"apikey_id": "ApiKey-17041d26-55e4-40a8-8ab5-5a69b68e204b", "resource_group_ids": ["ResourceGroupIds"], "serviceid": {"crn": "Crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}, "user_managed": false}}`) + fmt.Fprintf(res, "%s", `{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "Inner"}, "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-config-map", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "config_map_v2"}`) })) }) - It(`Invoke GetSecret successfully with retries`, func() { + It(`Invoke GetConfigMap successfully with retries`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -11214,22 +12976,22 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(codeEngineService).ToNot(BeNil()) codeEngineService.EnableRetries(0, 0) - // Construct an instance of the GetSecretOptions model - getSecretOptionsModel := new(codeenginev2.GetSecretOptions) - getSecretOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - getSecretOptionsModel.Name = core.StringPtr("my-secret") - getSecretOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetConfigMapOptions model + getConfigMapOptionsModel := new(codeenginev2.GetConfigMapOptions) + getConfigMapOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + getConfigMapOptionsModel.Name = core.StringPtr("my-config-map") + getConfigMapOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := codeEngineService.GetSecretWithContext(ctx, getSecretOptionsModel) + _, _, operationErr := codeEngineService.GetConfigMapWithContext(ctx, getConfigMapOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again codeEngineService.DisableRetries() - result, response, operationErr := codeEngineService.GetSecret(getSecretOptionsModel) + result, response, operationErr := codeEngineService.GetConfigMap(getConfigMapOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -11237,7 +12999,7 @@ var _ = Describe(`CodeEngineV2`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = codeEngineService.GetSecretWithContext(ctx, getSecretOptionsModel) + _, _, operationErr = codeEngineService.GetConfigMapWithContext(ctx, getConfigMapOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -11251,16 +13013,16 @@ var _ = Describe(`CodeEngineV2`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getSecretPath)) + Expect(req.URL.EscapedPath()).To(Equal(getConfigMapPath)) Expect(req.Method).To(Equal("GET")) // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "Inner"}, "entity_tag": "2385407409", "format": "generic", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-secret", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "ResourceType", "service_access": {"resource_key": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "name": "Name"}, "role": {"crn": "crn:v1:bluemix:public:iam::::serviceRole:Writer", "name": "Manager"}, "service_instance": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "type": "Type"}, "serviceid": {"crn": "Crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}}, "service_operator": {"apikey_id": "ApiKey-17041d26-55e4-40a8-8ab5-5a69b68e204b", "resource_group_ids": ["ResourceGroupIds"], "serviceid": {"crn": "Crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}, "user_managed": false}}`) + fmt.Fprintf(res, "%s", `{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "Inner"}, "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-config-map", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "config_map_v2"}`) })) }) - It(`Invoke GetSecret successfully`, func() { + It(`Invoke GetConfigMap successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -11269,25 +13031,25 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(codeEngineService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := codeEngineService.GetSecret(nil) + result, response, operationErr := codeEngineService.GetConfigMap(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the GetSecretOptions model - getSecretOptionsModel := new(codeenginev2.GetSecretOptions) - getSecretOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - getSecretOptionsModel.Name = core.StringPtr("my-secret") - getSecretOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetConfigMapOptions model + getConfigMapOptionsModel := new(codeenginev2.GetConfigMapOptions) + getConfigMapOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + getConfigMapOptionsModel.Name = core.StringPtr("my-config-map") + getConfigMapOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = codeEngineService.GetSecret(getSecretOptionsModel) + result, response, operationErr = codeEngineService.GetConfigMap(getConfigMapOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke GetSecret with error: Operation validation and request error`, func() { + It(`Invoke GetConfigMap with error: Operation validation and request error`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -11295,23 +13057,23 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the GetSecretOptions model - getSecretOptionsModel := new(codeenginev2.GetSecretOptions) - getSecretOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - getSecretOptionsModel.Name = core.StringPtr("my-secret") - getSecretOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetConfigMapOptions model + getConfigMapOptionsModel := new(codeenginev2.GetConfigMapOptions) + getConfigMapOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + getConfigMapOptionsModel.Name = core.StringPtr("my-config-map") + getConfigMapOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := codeEngineService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := codeEngineService.GetSecret(getSecretOptionsModel) + result, response, operationErr := codeEngineService.GetConfigMap(getConfigMapOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct a second instance of the GetSecretOptions model with no property values - getSecretOptionsModelNew := new(codeenginev2.GetSecretOptions) + // Construct a second instance of the GetConfigMapOptions model with no property values + getConfigMapOptionsModelNew := new(codeenginev2.GetConfigMapOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = codeEngineService.GetSecret(getSecretOptionsModelNew) + result, response, operationErr = codeEngineService.GetConfigMap(getConfigMapOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -11329,7 +13091,7 @@ var _ = Describe(`CodeEngineV2`, func() { res.WriteHeader(200) })) }) - It(`Invoke GetSecret successfully`, func() { + It(`Invoke GetConfigMap successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -11337,14 +13099,14 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the GetSecretOptions model - getSecretOptionsModel := new(codeenginev2.GetSecretOptions) - getSecretOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - getSecretOptionsModel.Name = core.StringPtr("my-secret") - getSecretOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetConfigMapOptions model + getConfigMapOptionsModel := new(codeenginev2.GetConfigMapOptions) + getConfigMapOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + getConfigMapOptionsModel.Name = core.StringPtr("my-config-map") + getConfigMapOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := codeEngineService.GetSecret(getSecretOptionsModel) + result, response, operationErr := codeEngineService.GetConfigMap(getConfigMapOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -11356,15 +13118,15 @@ var _ = Describe(`CodeEngineV2`, func() { }) }) }) - Describe(`ReplaceSecret(replaceSecretOptions *ReplaceSecretOptions) - Operation response error`, func() { - replaceSecretPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/secrets/my-secret" + Describe(`ReplaceConfigMap(replaceConfigMapOptions *ReplaceConfigMapOptions) - Operation response error`, func() { + replaceConfigMapPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/config_maps/my-config-map" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(replaceSecretPath)) + Expect(req.URL.EscapedPath()).To(Equal(replaceConfigMapPath)) Expect(req.Method).To(Equal("PUT")) Expect(req.Header["If-Match"]).ToNot(BeNil()) Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) @@ -11373,7 +13135,7 @@ var _ = Describe(`CodeEngineV2`, func() { fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke ReplaceSecret with error: Operation response processing error`, func() { + It(`Invoke ReplaceConfigMap with error: Operation response processing error`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -11381,29 +13143,22 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the SecretDataSSHSecretData model - secretDataModel := new(codeenginev2.SecretDataSSHSecretData) - secretDataModel.SshKey = core.StringPtr("testString") - secretDataModel.KnownHosts = core.StringPtr("testString") - secretDataModel.SetProperty("foo", core.StringPtr("testString")) - - // Construct an instance of the ReplaceSecretOptions model - replaceSecretOptionsModel := new(codeenginev2.ReplaceSecretOptions) - replaceSecretOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - replaceSecretOptionsModel.Name = core.StringPtr("my-secret") - replaceSecretOptionsModel.IfMatch = core.StringPtr("testString") - replaceSecretOptionsModel.Format = core.StringPtr("generic") - replaceSecretOptionsModel.Data = secretDataModel - replaceSecretOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ReplaceConfigMapOptions model + replaceConfigMapOptionsModel := new(codeenginev2.ReplaceConfigMapOptions) + replaceConfigMapOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + replaceConfigMapOptionsModel.Name = core.StringPtr("my-config-map") + replaceConfigMapOptionsModel.IfMatch = core.StringPtr("testString") + replaceConfigMapOptionsModel.Data = map[string]string{"key1": "testString"} + replaceConfigMapOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := codeEngineService.ReplaceSecret(replaceSecretOptionsModel) + result, response, operationErr := codeEngineService.ReplaceConfigMap(replaceConfigMapOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again codeEngineService.EnableRetries(0, 0) - result, response, operationErr = codeEngineService.ReplaceSecret(replaceSecretOptionsModel) + result, response, operationErr = codeEngineService.ReplaceConfigMap(replaceConfigMapOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -11413,15 +13168,15 @@ var _ = Describe(`CodeEngineV2`, func() { }) }) }) - Describe(`ReplaceSecret(replaceSecretOptions *ReplaceSecretOptions)`, func() { - replaceSecretPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/secrets/my-secret" + Describe(`ReplaceConfigMap(replaceConfigMapOptions *ReplaceConfigMapOptions)`, func() { + replaceConfigMapPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/config_maps/my-config-map" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(replaceSecretPath)) + Expect(req.URL.EscapedPath()).To(Equal(replaceConfigMapPath)) Expect(req.Method).To(Equal("PUT")) // For gzip-disabled operation, verify Content-Encoding is not set. @@ -11448,10 +13203,10 @@ var _ = Describe(`CodeEngineV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "Inner"}, "entity_tag": "2385407409", "format": "generic", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-secret", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "ResourceType", "service_access": {"resource_key": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "name": "Name"}, "role": {"crn": "crn:v1:bluemix:public:iam::::serviceRole:Writer", "name": "Manager"}, "service_instance": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "type": "Type"}, "serviceid": {"crn": "Crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}}, "service_operator": {"apikey_id": "ApiKey-17041d26-55e4-40a8-8ab5-5a69b68e204b", "resource_group_ids": ["ResourceGroupIds"], "serviceid": {"crn": "Crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}, "user_managed": false}}`) + fmt.Fprintf(res, "%s", `{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "Inner"}, "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-config-map", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "config_map_v2"}`) })) }) - It(`Invoke ReplaceSecret successfully with retries`, func() { + It(`Invoke ReplaceConfigMap successfully with retries`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -11460,31 +13215,24 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(codeEngineService).ToNot(BeNil()) codeEngineService.EnableRetries(0, 0) - // Construct an instance of the SecretDataSSHSecretData model - secretDataModel := new(codeenginev2.SecretDataSSHSecretData) - secretDataModel.SshKey = core.StringPtr("testString") - secretDataModel.KnownHosts = core.StringPtr("testString") - secretDataModel.SetProperty("foo", core.StringPtr("testString")) - - // Construct an instance of the ReplaceSecretOptions model - replaceSecretOptionsModel := new(codeenginev2.ReplaceSecretOptions) - replaceSecretOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - replaceSecretOptionsModel.Name = core.StringPtr("my-secret") - replaceSecretOptionsModel.IfMatch = core.StringPtr("testString") - replaceSecretOptionsModel.Format = core.StringPtr("generic") - replaceSecretOptionsModel.Data = secretDataModel - replaceSecretOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ReplaceConfigMapOptions model + replaceConfigMapOptionsModel := new(codeenginev2.ReplaceConfigMapOptions) + replaceConfigMapOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + replaceConfigMapOptionsModel.Name = core.StringPtr("my-config-map") + replaceConfigMapOptionsModel.IfMatch = core.StringPtr("testString") + replaceConfigMapOptionsModel.Data = map[string]string{"key1": "testString"} + replaceConfigMapOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := codeEngineService.ReplaceSecretWithContext(ctx, replaceSecretOptionsModel) + _, _, operationErr := codeEngineService.ReplaceConfigMapWithContext(ctx, replaceConfigMapOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again codeEngineService.DisableRetries() - result, response, operationErr := codeEngineService.ReplaceSecret(replaceSecretOptionsModel) + result, response, operationErr := codeEngineService.ReplaceConfigMap(replaceConfigMapOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -11492,7 +13240,7 @@ var _ = Describe(`CodeEngineV2`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = codeEngineService.ReplaceSecretWithContext(ctx, replaceSecretOptionsModel) + _, _, operationErr = codeEngineService.ReplaceConfigMapWithContext(ctx, replaceConfigMapOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -11506,7 +13254,7 @@ var _ = Describe(`CodeEngineV2`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(replaceSecretPath)) + Expect(req.URL.EscapedPath()).To(Equal(replaceConfigMapPath)) Expect(req.Method).To(Equal("PUT")) // For gzip-disabled operation, verify Content-Encoding is not set. @@ -11530,10 +13278,10 @@ var _ = Describe(`CodeEngineV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "Inner"}, "entity_tag": "2385407409", "format": "generic", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-secret", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "ResourceType", "service_access": {"resource_key": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "name": "Name"}, "role": {"crn": "crn:v1:bluemix:public:iam::::serviceRole:Writer", "name": "Manager"}, "service_instance": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "type": "Type"}, "serviceid": {"crn": "Crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}}, "service_operator": {"apikey_id": "ApiKey-17041d26-55e4-40a8-8ab5-5a69b68e204b", "resource_group_ids": ["ResourceGroupIds"], "serviceid": {"crn": "Crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}, "user_managed": false}}`) + fmt.Fprintf(res, "%s", `{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "Inner"}, "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-config-map", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "config_map_v2"}`) })) }) - It(`Invoke ReplaceSecret successfully`, func() { + It(`Invoke ReplaceConfigMap successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -11542,34 +13290,27 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(codeEngineService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := codeEngineService.ReplaceSecret(nil) + result, response, operationErr := codeEngineService.ReplaceConfigMap(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the SecretDataSSHSecretData model - secretDataModel := new(codeenginev2.SecretDataSSHSecretData) - secretDataModel.SshKey = core.StringPtr("testString") - secretDataModel.KnownHosts = core.StringPtr("testString") - secretDataModel.SetProperty("foo", core.StringPtr("testString")) - - // Construct an instance of the ReplaceSecretOptions model - replaceSecretOptionsModel := new(codeenginev2.ReplaceSecretOptions) - replaceSecretOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - replaceSecretOptionsModel.Name = core.StringPtr("my-secret") - replaceSecretOptionsModel.IfMatch = core.StringPtr("testString") - replaceSecretOptionsModel.Format = core.StringPtr("generic") - replaceSecretOptionsModel.Data = secretDataModel - replaceSecretOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ReplaceConfigMapOptions model + replaceConfigMapOptionsModel := new(codeenginev2.ReplaceConfigMapOptions) + replaceConfigMapOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + replaceConfigMapOptionsModel.Name = core.StringPtr("my-config-map") + replaceConfigMapOptionsModel.IfMatch = core.StringPtr("testString") + replaceConfigMapOptionsModel.Data = map[string]string{"key1": "testString"} + replaceConfigMapOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = codeEngineService.ReplaceSecret(replaceSecretOptionsModel) + result, response, operationErr = codeEngineService.ReplaceConfigMap(replaceConfigMapOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke ReplaceSecret with error: Operation validation and request error`, func() { + It(`Invoke ReplaceConfigMap with error: Operation validation and request error`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -11577,32 +13318,25 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the SecretDataSSHSecretData model - secretDataModel := new(codeenginev2.SecretDataSSHSecretData) - secretDataModel.SshKey = core.StringPtr("testString") - secretDataModel.KnownHosts = core.StringPtr("testString") - secretDataModel.SetProperty("foo", core.StringPtr("testString")) - - // Construct an instance of the ReplaceSecretOptions model - replaceSecretOptionsModel := new(codeenginev2.ReplaceSecretOptions) - replaceSecretOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - replaceSecretOptionsModel.Name = core.StringPtr("my-secret") - replaceSecretOptionsModel.IfMatch = core.StringPtr("testString") - replaceSecretOptionsModel.Format = core.StringPtr("generic") - replaceSecretOptionsModel.Data = secretDataModel - replaceSecretOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ReplaceConfigMapOptions model + replaceConfigMapOptionsModel := new(codeenginev2.ReplaceConfigMapOptions) + replaceConfigMapOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + replaceConfigMapOptionsModel.Name = core.StringPtr("my-config-map") + replaceConfigMapOptionsModel.IfMatch = core.StringPtr("testString") + replaceConfigMapOptionsModel.Data = map[string]string{"key1": "testString"} + replaceConfigMapOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := codeEngineService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := codeEngineService.ReplaceSecret(replaceSecretOptionsModel) + result, response, operationErr := codeEngineService.ReplaceConfigMap(replaceConfigMapOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct a second instance of the ReplaceSecretOptions model with no property values - replaceSecretOptionsModelNew := new(codeenginev2.ReplaceSecretOptions) + // Construct a second instance of the ReplaceConfigMapOptions model with no property values + replaceConfigMapOptionsModelNew := new(codeenginev2.ReplaceConfigMapOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = codeEngineService.ReplaceSecret(replaceSecretOptionsModelNew) + result, response, operationErr = codeEngineService.ReplaceConfigMap(replaceConfigMapOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -11620,7 +13354,7 @@ var _ = Describe(`CodeEngineV2`, func() { res.WriteHeader(200) })) }) - It(`Invoke ReplaceSecret successfully`, func() { + It(`Invoke ReplaceConfigMap successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -11628,23 +13362,16 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the SecretDataSSHSecretData model - secretDataModel := new(codeenginev2.SecretDataSSHSecretData) - secretDataModel.SshKey = core.StringPtr("testString") - secretDataModel.KnownHosts = core.StringPtr("testString") - secretDataModel.SetProperty("foo", core.StringPtr("testString")) - - // Construct an instance of the ReplaceSecretOptions model - replaceSecretOptionsModel := new(codeenginev2.ReplaceSecretOptions) - replaceSecretOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - replaceSecretOptionsModel.Name = core.StringPtr("my-secret") - replaceSecretOptionsModel.IfMatch = core.StringPtr("testString") - replaceSecretOptionsModel.Format = core.StringPtr("generic") - replaceSecretOptionsModel.Data = secretDataModel - replaceSecretOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ReplaceConfigMapOptions model + replaceConfigMapOptionsModel := new(codeenginev2.ReplaceConfigMapOptions) + replaceConfigMapOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + replaceConfigMapOptionsModel.Name = core.StringPtr("my-config-map") + replaceConfigMapOptionsModel.IfMatch = core.StringPtr("testString") + replaceConfigMapOptionsModel.Data = map[string]string{"key1": "testString"} + replaceConfigMapOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := codeEngineService.ReplaceSecret(replaceSecretOptionsModel) + result, response, operationErr := codeEngineService.ReplaceConfigMap(replaceConfigMapOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -11656,21 +13383,21 @@ var _ = Describe(`CodeEngineV2`, func() { }) }) }) - Describe(`DeleteSecret(deleteSecretOptions *DeleteSecretOptions)`, func() { - deleteSecretPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/secrets/my-secret" + Describe(`DeleteConfigMap(deleteConfigMapOptions *DeleteConfigMapOptions)`, func() { + deleteConfigMapPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/config_maps/my-config-map" Context(`Using mock server endpoint`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(deleteSecretPath)) + Expect(req.URL.EscapedPath()).To(Equal(deleteConfigMapPath)) Expect(req.Method).To(Equal("DELETE")) res.WriteHeader(202) })) }) - It(`Invoke DeleteSecret successfully`, func() { + It(`Invoke DeleteConfigMap successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -11679,22 +13406,22 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(codeEngineService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - response, operationErr := codeEngineService.DeleteSecret(nil) + response, operationErr := codeEngineService.DeleteConfigMap(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) - // Construct an instance of the DeleteSecretOptions model - deleteSecretOptionsModel := new(codeenginev2.DeleteSecretOptions) - deleteSecretOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - deleteSecretOptionsModel.Name = core.StringPtr("my-secret") - deleteSecretOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the DeleteConfigMapOptions model + deleteConfigMapOptionsModel := new(codeenginev2.DeleteConfigMapOptions) + deleteConfigMapOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + deleteConfigMapOptionsModel.Name = core.StringPtr("my-config-map") + deleteConfigMapOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - response, operationErr = codeEngineService.DeleteSecret(deleteSecretOptionsModel) + response, operationErr = codeEngineService.DeleteConfigMap(deleteConfigMapOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) }) - It(`Invoke DeleteSecret with error: Operation validation and request error`, func() { + It(`Invoke DeleteConfigMap with error: Operation validation and request error`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -11702,22 +13429,22 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the DeleteSecretOptions model - deleteSecretOptionsModel := new(codeenginev2.DeleteSecretOptions) - deleteSecretOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - deleteSecretOptionsModel.Name = core.StringPtr("my-secret") - deleteSecretOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the DeleteConfigMapOptions model + deleteConfigMapOptionsModel := new(codeenginev2.DeleteConfigMapOptions) + deleteConfigMapOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + deleteConfigMapOptionsModel.Name = core.StringPtr("my-config-map") + deleteConfigMapOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := codeEngineService.SetServiceURL("") Expect(err).To(BeNil()) - response, operationErr := codeEngineService.DeleteSecret(deleteSecretOptionsModel) + response, operationErr := codeEngineService.DeleteConfigMap(deleteConfigMapOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) - // Construct a second instance of the DeleteSecretOptions model with no property values - deleteSecretOptionsModelNew := new(codeenginev2.DeleteSecretOptions) + // Construct a second instance of the DeleteConfigMapOptions model with no property values + deleteConfigMapOptionsModelNew := new(codeenginev2.DeleteConfigMapOptions) // Invoke operation with invalid model (negative test) - response, operationErr = codeEngineService.DeleteSecret(deleteSecretOptionsModelNew) + response, operationErr = codeEngineService.DeleteConfigMap(deleteConfigMapOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) }) @@ -11726,15 +13453,15 @@ var _ = Describe(`CodeEngineV2`, func() { }) }) }) - Describe(`ListDomainMappings(listDomainMappingsOptions *ListDomainMappingsOptions) - Operation response error`, func() { - listDomainMappingsPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/domain_mappings" + Describe(`ListSecrets(listSecretsOptions *ListSecretsOptions) - Operation response error`, func() { + listSecretsPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/secrets" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listDomainMappingsPath)) + Expect(req.URL.EscapedPath()).To(Equal(listSecretsPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(100))})) Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) @@ -11743,7 +13470,7 @@ var _ = Describe(`CodeEngineV2`, func() { fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke ListDomainMappings with error: Operation response processing error`, func() { + It(`Invoke ListSecrets with error: Operation response processing error`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -11751,21 +13478,21 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the ListDomainMappingsOptions model - listDomainMappingsOptionsModel := new(codeenginev2.ListDomainMappingsOptions) - listDomainMappingsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - listDomainMappingsOptionsModel.Limit = core.Int64Ptr(int64(100)) - listDomainMappingsOptionsModel.Start = core.StringPtr("testString") - listDomainMappingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListSecretsOptions model + listSecretsOptionsModel := new(codeenginev2.ListSecretsOptions) + listSecretsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + listSecretsOptionsModel.Limit = core.Int64Ptr(int64(100)) + listSecretsOptionsModel.Start = core.StringPtr("testString") + listSecretsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := codeEngineService.ListDomainMappings(listDomainMappingsOptionsModel) + result, response, operationErr := codeEngineService.ListSecrets(listSecretsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again codeEngineService.EnableRetries(0, 0) - result, response, operationErr = codeEngineService.ListDomainMappings(listDomainMappingsOptionsModel) + result, response, operationErr = codeEngineService.ListSecrets(listSecretsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -11775,15 +13502,15 @@ var _ = Describe(`CodeEngineV2`, func() { }) }) }) - Describe(`ListDomainMappings(listDomainMappingsOptions *ListDomainMappingsOptions)`, func() { - listDomainMappingsPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/domain_mappings" + Describe(`ListSecrets(listSecretsOptions *ListSecretsOptions)`, func() { + listSecretsPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/secrets" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listDomainMappingsPath)) + Expect(req.URL.EscapedPath()).To(Equal(listSecretsPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(100))})) @@ -11794,10 +13521,10 @@ var _ = Describe(`CodeEngineV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"domain_mappings": [{"cname_target": "custom.abcdabcdabc.us-east.codeengine.appdomain.cloud", "component": {"name": "my-app-1", "resource_type": "app_v2"}, "created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/domain_mappings/www.example.com", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "www.example.com", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "domain_mapping_v2", "status": "ready", "status_details": {"reason": "ready"}, "tls_secret": "my-tls-secret", "user_managed": false, "visibility": "public"}], "first": {"href": "Href"}, "limit": 100, "next": {"href": "Href", "start": "Start"}}`) + fmt.Fprintf(res, "%s", `{"first": {"href": "Href"}, "limit": 100, "next": {"href": "Href", "start": "Start"}, "secrets": [{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "Inner"}, "entity_tag": "2385407409", "format": "generic", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-secret", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "ResourceType", "service_access": {"resource_key": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "name": "Name"}, "role": {"crn": "crn:v1:bluemix:public:iam::::serviceRole:Writer", "name": "Manager"}, "service_instance": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "type": "Type"}, "serviceid": {"crn": "Crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}}, "service_operator": {"apikey_id": "ApiKey-17041d26-55e4-40a8-8ab5-5a69b68e204b", "resource_group_ids": ["ResourceGroupIds"], "serviceid": {"crn": "Crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}, "user_managed": false}}]}`) })) }) - It(`Invoke ListDomainMappings successfully with retries`, func() { + It(`Invoke ListSecrets successfully with retries`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -11806,23 +13533,23 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(codeEngineService).ToNot(BeNil()) codeEngineService.EnableRetries(0, 0) - // Construct an instance of the ListDomainMappingsOptions model - listDomainMappingsOptionsModel := new(codeenginev2.ListDomainMappingsOptions) - listDomainMappingsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - listDomainMappingsOptionsModel.Limit = core.Int64Ptr(int64(100)) - listDomainMappingsOptionsModel.Start = core.StringPtr("testString") - listDomainMappingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListSecretsOptions model + listSecretsOptionsModel := new(codeenginev2.ListSecretsOptions) + listSecretsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + listSecretsOptionsModel.Limit = core.Int64Ptr(int64(100)) + listSecretsOptionsModel.Start = core.StringPtr("testString") + listSecretsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := codeEngineService.ListDomainMappingsWithContext(ctx, listDomainMappingsOptionsModel) + _, _, operationErr := codeEngineService.ListSecretsWithContext(ctx, listSecretsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again codeEngineService.DisableRetries() - result, response, operationErr := codeEngineService.ListDomainMappings(listDomainMappingsOptionsModel) + result, response, operationErr := codeEngineService.ListSecrets(listSecretsOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -11830,7 +13557,7 @@ var _ = Describe(`CodeEngineV2`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = codeEngineService.ListDomainMappingsWithContext(ctx, listDomainMappingsOptionsModel) + _, _, operationErr = codeEngineService.ListSecretsWithContext(ctx, listSecretsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -11844,7 +13571,7 @@ var _ = Describe(`CodeEngineV2`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listDomainMappingsPath)) + Expect(req.URL.EscapedPath()).To(Equal(listSecretsPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(100))})) @@ -11852,10 +13579,10 @@ var _ = Describe(`CodeEngineV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"domain_mappings": [{"cname_target": "custom.abcdabcdabc.us-east.codeengine.appdomain.cloud", "component": {"name": "my-app-1", "resource_type": "app_v2"}, "created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/domain_mappings/www.example.com", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "www.example.com", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "domain_mapping_v2", "status": "ready", "status_details": {"reason": "ready"}, "tls_secret": "my-tls-secret", "user_managed": false, "visibility": "public"}], "first": {"href": "Href"}, "limit": 100, "next": {"href": "Href", "start": "Start"}}`) + fmt.Fprintf(res, "%s", `{"first": {"href": "Href"}, "limit": 100, "next": {"href": "Href", "start": "Start"}, "secrets": [{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "Inner"}, "entity_tag": "2385407409", "format": "generic", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-secret", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "ResourceType", "service_access": {"resource_key": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "name": "Name"}, "role": {"crn": "crn:v1:bluemix:public:iam::::serviceRole:Writer", "name": "Manager"}, "service_instance": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "type": "Type"}, "serviceid": {"crn": "Crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}}, "service_operator": {"apikey_id": "ApiKey-17041d26-55e4-40a8-8ab5-5a69b68e204b", "resource_group_ids": ["ResourceGroupIds"], "serviceid": {"crn": "Crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}, "user_managed": false}}]}`) })) }) - It(`Invoke ListDomainMappings successfully`, func() { + It(`Invoke ListSecrets successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -11864,26 +13591,26 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(codeEngineService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := codeEngineService.ListDomainMappings(nil) + result, response, operationErr := codeEngineService.ListSecrets(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the ListDomainMappingsOptions model - listDomainMappingsOptionsModel := new(codeenginev2.ListDomainMappingsOptions) - listDomainMappingsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - listDomainMappingsOptionsModel.Limit = core.Int64Ptr(int64(100)) - listDomainMappingsOptionsModel.Start = core.StringPtr("testString") - listDomainMappingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListSecretsOptions model + listSecretsOptionsModel := new(codeenginev2.ListSecretsOptions) + listSecretsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + listSecretsOptionsModel.Limit = core.Int64Ptr(int64(100)) + listSecretsOptionsModel.Start = core.StringPtr("testString") + listSecretsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = codeEngineService.ListDomainMappings(listDomainMappingsOptionsModel) + result, response, operationErr = codeEngineService.ListSecrets(listSecretsOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke ListDomainMappings with error: Operation validation and request error`, func() { + It(`Invoke ListSecrets with error: Operation validation and request error`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -11891,24 +13618,24 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the ListDomainMappingsOptions model - listDomainMappingsOptionsModel := new(codeenginev2.ListDomainMappingsOptions) - listDomainMappingsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - listDomainMappingsOptionsModel.Limit = core.Int64Ptr(int64(100)) - listDomainMappingsOptionsModel.Start = core.StringPtr("testString") - listDomainMappingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListSecretsOptions model + listSecretsOptionsModel := new(codeenginev2.ListSecretsOptions) + listSecretsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + listSecretsOptionsModel.Limit = core.Int64Ptr(int64(100)) + listSecretsOptionsModel.Start = core.StringPtr("testString") + listSecretsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := codeEngineService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := codeEngineService.ListDomainMappings(listDomainMappingsOptionsModel) + result, response, operationErr := codeEngineService.ListSecrets(listSecretsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct a second instance of the ListDomainMappingsOptions model with no property values - listDomainMappingsOptionsModelNew := new(codeenginev2.ListDomainMappingsOptions) + // Construct a second instance of the ListSecretsOptions model with no property values + listSecretsOptionsModelNew := new(codeenginev2.ListSecretsOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = codeEngineService.ListDomainMappings(listDomainMappingsOptionsModelNew) + result, response, operationErr = codeEngineService.ListSecrets(listSecretsOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -11926,7 +13653,7 @@ var _ = Describe(`CodeEngineV2`, func() { res.WriteHeader(200) })) }) - It(`Invoke ListDomainMappings successfully`, func() { + It(`Invoke ListSecrets successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -11934,15 +13661,15 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the ListDomainMappingsOptions model - listDomainMappingsOptionsModel := new(codeenginev2.ListDomainMappingsOptions) - listDomainMappingsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - listDomainMappingsOptionsModel.Limit = core.Int64Ptr(int64(100)) - listDomainMappingsOptionsModel.Start = core.StringPtr("testString") - listDomainMappingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListSecretsOptions model + listSecretsOptionsModel := new(codeenginev2.ListSecretsOptions) + listSecretsOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + listSecretsOptionsModel.Limit = core.Int64Ptr(int64(100)) + listSecretsOptionsModel.Start = core.StringPtr("testString") + listSecretsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := codeEngineService.ListDomainMappings(listDomainMappingsOptionsModel) + result, response, operationErr := codeEngineService.ListSecrets(listSecretsOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -11955,7 +13682,7 @@ var _ = Describe(`CodeEngineV2`, func() { }) Context(`Test pagination helper method on response`, func() { It(`Invoke GetNextStart successfully`, func() { - responseObject := new(codeenginev2.DomainMappingList) + responseObject := new(codeenginev2.SecretList) nextObject := new(codeenginev2.ListNextMetadata) nextObject.Start = core.StringPtr("abc-123") responseObject.Next = nextObject @@ -11965,7 +13692,7 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(value).To(Equal(core.StringPtr("abc-123"))) }) It(`Invoke GetNextStart without a "Next" property in the response`, func() { - responseObject := new(codeenginev2.DomainMappingList) + responseObject := new(codeenginev2.SecretList) value, err := responseObject.GetNextStart() Expect(err).To(BeNil()) @@ -11979,7 +13706,7 @@ var _ = Describe(`CodeEngineV2`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listDomainMappingsPath)) + Expect(req.URL.EscapedPath()).To(Equal(listSecretsPath)) Expect(req.Method).To(Equal("GET")) // Set mock response @@ -11987,15 +13714,15 @@ var _ = Describe(`CodeEngineV2`, func() { res.WriteHeader(200) requestNumber++ if requestNumber == 1 { - fmt.Fprintf(res, "%s", `{"next":{"start":"1"},"domain_mappings":[{"cname_target":"custom.abcdabcdabc.us-east.codeengine.appdomain.cloud","component":{"name":"my-app-1","resource_type":"app_v2"},"created_at":"2022-09-13T11:41:35+02:00","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/domain_mappings/www.example.com","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"www.example.com","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"domain_mapping_v2","status":"ready","status_details":{"reason":"ready"},"tls_secret":"my-tls-secret","user_managed":false,"visibility":"public"}],"total_count":2,"limit":1}`) + fmt.Fprintf(res, "%s", `{"next":{"start":"1"},"total_count":2,"limit":1,"secrets":[{"created_at":"2022-09-13T11:41:35+02:00","data":{"mapKey":"Inner"},"entity_tag":"2385407409","format":"generic","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-secret","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"ResourceType","service_access":{"resource_key":{"id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","name":"Name"},"role":{"crn":"crn:v1:bluemix:public:iam::::serviceRole:Writer","name":"Manager"},"service_instance":{"id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","type":"Type"},"serviceid":{"crn":"Crn","id":"ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}},"service_operator":{"apikey_id":"ApiKey-17041d26-55e4-40a8-8ab5-5a69b68e204b","resource_group_ids":["ResourceGroupIds"],"serviceid":{"crn":"Crn","id":"ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"},"user_managed":false}}]}`) } else if requestNumber == 2 { - fmt.Fprintf(res, "%s", `{"domain_mappings":[{"cname_target":"custom.abcdabcdabc.us-east.codeengine.appdomain.cloud","component":{"name":"my-app-1","resource_type":"app_v2"},"created_at":"2022-09-13T11:41:35+02:00","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/domain_mappings/www.example.com","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"www.example.com","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"domain_mapping_v2","status":"ready","status_details":{"reason":"ready"},"tls_secret":"my-tls-secret","user_managed":false,"visibility":"public"}],"total_count":2,"limit":1}`) + fmt.Fprintf(res, "%s", `{"total_count":2,"limit":1,"secrets":[{"created_at":"2022-09-13T11:41:35+02:00","data":{"mapKey":"Inner"},"entity_tag":"2385407409","format":"generic","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-secret","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"ResourceType","service_access":{"resource_key":{"id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","name":"Name"},"role":{"crn":"crn:v1:bluemix:public:iam::::serviceRole:Writer","name":"Manager"},"service_instance":{"id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","type":"Type"},"serviceid":{"crn":"Crn","id":"ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}},"service_operator":{"apikey_id":"ApiKey-17041d26-55e4-40a8-8ab5-5a69b68e204b","resource_group_ids":["ResourceGroupIds"],"serviceid":{"crn":"Crn","id":"ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"},"user_managed":false}}]}`) } else { res.WriteHeader(400) } })) }) - It(`Use DomainMappingsPager.GetNext successfully`, func() { + It(`Use SecretsPager.GetNext successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -12003,16 +13730,16 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - listDomainMappingsOptionsModel := &codeenginev2.ListDomainMappingsOptions{ + listSecretsOptionsModel := &codeenginev2.ListSecretsOptions{ ProjectID: core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"), Limit: core.Int64Ptr(int64(100)), } - pager, err := codeEngineService.NewDomainMappingsPager(listDomainMappingsOptionsModel) + pager, err := codeEngineService.NewSecretsPager(listSecretsOptionsModel) Expect(err).To(BeNil()) Expect(pager).ToNot(BeNil()) - var allResults []codeenginev2.DomainMapping + var allResults []codeenginev2.Secret for pager.HasNext() { nextPage, err := pager.GetNext() Expect(err).To(BeNil()) @@ -12021,7 +13748,7 @@ var _ = Describe(`CodeEngineV2`, func() { } Expect(len(allResults)).To(Equal(2)) }) - It(`Use DomainMappingsPager.GetAll successfully`, func() { + It(`Use SecretsPager.GetAll successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -12029,12 +13756,12 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - listDomainMappingsOptionsModel := &codeenginev2.ListDomainMappingsOptions{ + listSecretsOptionsModel := &codeenginev2.ListSecretsOptions{ ProjectID: core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"), Limit: core.Int64Ptr(int64(100)), } - pager, err := codeEngineService.NewDomainMappingsPager(listDomainMappingsOptionsModel) + pager, err := codeEngineService.NewSecretsPager(listSecretsOptionsModel) Expect(err).To(BeNil()) Expect(pager).ToNot(BeNil()) @@ -12045,22 +13772,22 @@ var _ = Describe(`CodeEngineV2`, func() { }) }) }) - Describe(`CreateDomainMapping(createDomainMappingOptions *CreateDomainMappingOptions) - Operation response error`, func() { - createDomainMappingPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/domain_mappings" + Describe(`CreateSecret(createSecretOptions *CreateSecretOptions) - Operation response error`, func() { + createSecretPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/secrets" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createDomainMappingPath)) + Expect(req.URL.EscapedPath()).To(Equal(createSecretPath)) Expect(req.Method).To(Equal("POST")) res.Header().Set("Content-type", "application/json") res.WriteHeader(201) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke CreateDomainMapping with error: Operation response processing error`, func() { + It(`Invoke CreateSecret with error: Operation response processing error`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -12068,27 +13795,63 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the ComponentRef model - componentRefModel := new(codeenginev2.ComponentRef) - componentRefModel.Name = core.StringPtr("my-app-1") - componentRefModel.ResourceType = core.StringPtr("app_v2") + // Construct an instance of the SecretDataSSHSecretData model + secretDataModel := new(codeenginev2.SecretDataSSHSecretData) + secretDataModel.SshKey = core.StringPtr("testString") + secretDataModel.KnownHosts = core.StringPtr("testString") + secretDataModel.SetProperty("foo", core.StringPtr("testString")) - // Construct an instance of the CreateDomainMappingOptions model - createDomainMappingOptionsModel := new(codeenginev2.CreateDomainMappingOptions) - createDomainMappingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - createDomainMappingOptionsModel.Component = componentRefModel - createDomainMappingOptionsModel.Name = core.StringPtr("www.example.com") - createDomainMappingOptionsModel.TlsSecret = core.StringPtr("my-tls-secret") - createDomainMappingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ResourceKeyRefPrototype model + resourceKeyRefPrototypeModel := new(codeenginev2.ResourceKeyRefPrototype) + resourceKeyRefPrototypeModel.ID = core.StringPtr("4e49b3e0-27a8-48d2-a784-c7ee48bb863b") + + // Construct an instance of the RoleRefPrototype model + roleRefPrototypeModel := new(codeenginev2.RoleRefPrototype) + roleRefPrototypeModel.Crn = core.StringPtr("crn:v1:bluemix:public:iam::::serviceRole:Writer") + + // Construct an instance of the ServiceInstanceRefPrototype model + serviceInstanceRefPrototypeModel := new(codeenginev2.ServiceInstanceRefPrototype) + serviceInstanceRefPrototypeModel.ID = core.StringPtr("4e49b3e0-27a8-48d2-a784-c7ee48bb863b") + + // Construct an instance of the ServiceIDRef model + serviceIdRefModel := new(codeenginev2.ServiceIDRef) + serviceIdRefModel.Crn = core.StringPtr("testString") + serviceIdRefModel.ID = core.StringPtr("ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637") + + // Construct an instance of the ServiceAccessSecretPrototypeProps model + serviceAccessSecretPrototypePropsModel := new(codeenginev2.ServiceAccessSecretPrototypeProps) + serviceAccessSecretPrototypePropsModel.ResourceKey = resourceKeyRefPrototypeModel + serviceAccessSecretPrototypePropsModel.Role = roleRefPrototypeModel + serviceAccessSecretPrototypePropsModel.ServiceInstance = serviceInstanceRefPrototypeModel + serviceAccessSecretPrototypePropsModel.Serviceid = serviceIdRefModel + + // Construct an instance of the ServiceIDRefPrototype model + serviceIdRefPrototypeModel := new(codeenginev2.ServiceIDRefPrototype) + serviceIdRefPrototypeModel.ID = core.StringPtr("ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637") + + // Construct an instance of the OperatorSecretPrototypeProps model + operatorSecretPrototypePropsModel := new(codeenginev2.OperatorSecretPrototypeProps) + operatorSecretPrototypePropsModel.ResourceGroupIds = []string{"testString"} + operatorSecretPrototypePropsModel.Serviceid = serviceIdRefPrototypeModel + + // Construct an instance of the CreateSecretOptions model + createSecretOptionsModel := new(codeenginev2.CreateSecretOptions) + createSecretOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + createSecretOptionsModel.Format = core.StringPtr("generic") + createSecretOptionsModel.Name = core.StringPtr("my-secret") + createSecretOptionsModel.Data = secretDataModel + createSecretOptionsModel.ServiceAccess = serviceAccessSecretPrototypePropsModel + createSecretOptionsModel.ServiceOperator = operatorSecretPrototypePropsModel + createSecretOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := codeEngineService.CreateDomainMapping(createDomainMappingOptionsModel) + result, response, operationErr := codeEngineService.CreateSecret(createSecretOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again codeEngineService.EnableRetries(0, 0) - result, response, operationErr = codeEngineService.CreateDomainMapping(createDomainMappingOptionsModel) + result, response, operationErr = codeEngineService.CreateSecret(createSecretOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -12098,15 +13861,15 @@ var _ = Describe(`CodeEngineV2`, func() { }) }) }) - Describe(`CreateDomainMapping(createDomainMappingOptions *CreateDomainMappingOptions)`, func() { - createDomainMappingPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/domain_mappings" + Describe(`CreateSecret(createSecretOptions *CreateSecretOptions)`, func() { + createSecretPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/secrets" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createDomainMappingPath)) + Expect(req.URL.EscapedPath()).To(Equal(createSecretPath)) Expect(req.Method).To(Equal("POST")) // For gzip-disabled operation, verify Content-Encoding is not set. @@ -12125,47 +13888,83 @@ var _ = Describe(`CodeEngineV2`, func() { } fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) - // Sleep a short time to support a timeout test - time.Sleep(100 * time.Millisecond) + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(201) + fmt.Fprintf(res, "%s", `{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "Inner"}, "entity_tag": "2385407409", "format": "generic", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-secret", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "ResourceType", "service_access": {"resource_key": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "name": "Name"}, "role": {"crn": "crn:v1:bluemix:public:iam::::serviceRole:Writer", "name": "Manager"}, "service_instance": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "type": "Type"}, "serviceid": {"crn": "Crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}}, "service_operator": {"apikey_id": "ApiKey-17041d26-55e4-40a8-8ab5-5a69b68e204b", "resource_group_ids": ["ResourceGroupIds"], "serviceid": {"crn": "Crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}, "user_managed": false}}`) + })) + }) + It(`Invoke CreateSecret successfully with retries`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + codeEngineService.EnableRetries(0, 0) + + // Construct an instance of the SecretDataSSHSecretData model + secretDataModel := new(codeenginev2.SecretDataSSHSecretData) + secretDataModel.SshKey = core.StringPtr("testString") + secretDataModel.KnownHosts = core.StringPtr("testString") + secretDataModel.SetProperty("foo", core.StringPtr("testString")) + + // Construct an instance of the ResourceKeyRefPrototype model + resourceKeyRefPrototypeModel := new(codeenginev2.ResourceKeyRefPrototype) + resourceKeyRefPrototypeModel.ID = core.StringPtr("4e49b3e0-27a8-48d2-a784-c7ee48bb863b") + + // Construct an instance of the RoleRefPrototype model + roleRefPrototypeModel := new(codeenginev2.RoleRefPrototype) + roleRefPrototypeModel.Crn = core.StringPtr("crn:v1:bluemix:public:iam::::serviceRole:Writer") + + // Construct an instance of the ServiceInstanceRefPrototype model + serviceInstanceRefPrototypeModel := new(codeenginev2.ServiceInstanceRefPrototype) + serviceInstanceRefPrototypeModel.ID = core.StringPtr("4e49b3e0-27a8-48d2-a784-c7ee48bb863b") + + // Construct an instance of the ServiceIDRef model + serviceIdRefModel := new(codeenginev2.ServiceIDRef) + serviceIdRefModel.Crn = core.StringPtr("testString") + serviceIdRefModel.ID = core.StringPtr("ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637") - // Set mock response - res.Header().Set("Content-type", "application/json") - res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"cname_target": "custom.abcdabcdabc.us-east.codeengine.appdomain.cloud", "component": {"name": "my-app-1", "resource_type": "app_v2"}, "created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/domain_mappings/www.example.com", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "www.example.com", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "domain_mapping_v2", "status": "ready", "status_details": {"reason": "ready"}, "tls_secret": "my-tls-secret", "user_managed": false, "visibility": "public"}`) - })) - }) - It(`Invoke CreateDomainMapping successfully with retries`, func() { - codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - }) - Expect(serviceErr).To(BeNil()) - Expect(codeEngineService).ToNot(BeNil()) - codeEngineService.EnableRetries(0, 0) + // Construct an instance of the ServiceAccessSecretPrototypeProps model + serviceAccessSecretPrototypePropsModel := new(codeenginev2.ServiceAccessSecretPrototypeProps) + serviceAccessSecretPrototypePropsModel.ResourceKey = resourceKeyRefPrototypeModel + serviceAccessSecretPrototypePropsModel.Role = roleRefPrototypeModel + serviceAccessSecretPrototypePropsModel.ServiceInstance = serviceInstanceRefPrototypeModel + serviceAccessSecretPrototypePropsModel.Serviceid = serviceIdRefModel - // Construct an instance of the ComponentRef model - componentRefModel := new(codeenginev2.ComponentRef) - componentRefModel.Name = core.StringPtr("my-app-1") - componentRefModel.ResourceType = core.StringPtr("app_v2") + // Construct an instance of the ServiceIDRefPrototype model + serviceIdRefPrototypeModel := new(codeenginev2.ServiceIDRefPrototype) + serviceIdRefPrototypeModel.ID = core.StringPtr("ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637") - // Construct an instance of the CreateDomainMappingOptions model - createDomainMappingOptionsModel := new(codeenginev2.CreateDomainMappingOptions) - createDomainMappingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - createDomainMappingOptionsModel.Component = componentRefModel - createDomainMappingOptionsModel.Name = core.StringPtr("www.example.com") - createDomainMappingOptionsModel.TlsSecret = core.StringPtr("my-tls-secret") - createDomainMappingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the OperatorSecretPrototypeProps model + operatorSecretPrototypePropsModel := new(codeenginev2.OperatorSecretPrototypeProps) + operatorSecretPrototypePropsModel.ResourceGroupIds = []string{"testString"} + operatorSecretPrototypePropsModel.Serviceid = serviceIdRefPrototypeModel + + // Construct an instance of the CreateSecretOptions model + createSecretOptionsModel := new(codeenginev2.CreateSecretOptions) + createSecretOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + createSecretOptionsModel.Format = core.StringPtr("generic") + createSecretOptionsModel.Name = core.StringPtr("my-secret") + createSecretOptionsModel.Data = secretDataModel + createSecretOptionsModel.ServiceAccess = serviceAccessSecretPrototypePropsModel + createSecretOptionsModel.ServiceOperator = operatorSecretPrototypePropsModel + createSecretOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := codeEngineService.CreateDomainMappingWithContext(ctx, createDomainMappingOptionsModel) + _, _, operationErr := codeEngineService.CreateSecretWithContext(ctx, createSecretOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again codeEngineService.DisableRetries() - result, response, operationErr := codeEngineService.CreateDomainMapping(createDomainMappingOptionsModel) + result, response, operationErr := codeEngineService.CreateSecret(createSecretOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -12173,7 +13972,7 @@ var _ = Describe(`CodeEngineV2`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = codeEngineService.CreateDomainMappingWithContext(ctx, createDomainMappingOptionsModel) + _, _, operationErr = codeEngineService.CreateSecretWithContext(ctx, createSecretOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -12187,7 +13986,7 @@ var _ = Describe(`CodeEngineV2`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createDomainMappingPath)) + Expect(req.URL.EscapedPath()).To(Equal(createSecretPath)) Expect(req.Method).To(Equal("POST")) // For gzip-disabled operation, verify Content-Encoding is not set. @@ -12209,10 +14008,10 @@ var _ = Describe(`CodeEngineV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"cname_target": "custom.abcdabcdabc.us-east.codeengine.appdomain.cloud", "component": {"name": "my-app-1", "resource_type": "app_v2"}, "created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/domain_mappings/www.example.com", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "www.example.com", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "domain_mapping_v2", "status": "ready", "status_details": {"reason": "ready"}, "tls_secret": "my-tls-secret", "user_managed": false, "visibility": "public"}`) + fmt.Fprintf(res, "%s", `{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "Inner"}, "entity_tag": "2385407409", "format": "generic", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-secret", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "ResourceType", "service_access": {"resource_key": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "name": "Name"}, "role": {"crn": "crn:v1:bluemix:public:iam::::serviceRole:Writer", "name": "Manager"}, "service_instance": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "type": "Type"}, "serviceid": {"crn": "Crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}}, "service_operator": {"apikey_id": "ApiKey-17041d26-55e4-40a8-8ab5-5a69b68e204b", "resource_group_ids": ["ResourceGroupIds"], "serviceid": {"crn": "Crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}, "user_managed": false}}`) })) }) - It(`Invoke CreateDomainMapping successfully`, func() { + It(`Invoke CreateSecret successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -12221,32 +14020,68 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(codeEngineService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := codeEngineService.CreateDomainMapping(nil) + result, response, operationErr := codeEngineService.CreateSecret(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the ComponentRef model - componentRefModel := new(codeenginev2.ComponentRef) - componentRefModel.Name = core.StringPtr("my-app-1") - componentRefModel.ResourceType = core.StringPtr("app_v2") + // Construct an instance of the SecretDataSSHSecretData model + secretDataModel := new(codeenginev2.SecretDataSSHSecretData) + secretDataModel.SshKey = core.StringPtr("testString") + secretDataModel.KnownHosts = core.StringPtr("testString") + secretDataModel.SetProperty("foo", core.StringPtr("testString")) - // Construct an instance of the CreateDomainMappingOptions model - createDomainMappingOptionsModel := new(codeenginev2.CreateDomainMappingOptions) - createDomainMappingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - createDomainMappingOptionsModel.Component = componentRefModel - createDomainMappingOptionsModel.Name = core.StringPtr("www.example.com") - createDomainMappingOptionsModel.TlsSecret = core.StringPtr("my-tls-secret") - createDomainMappingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ResourceKeyRefPrototype model + resourceKeyRefPrototypeModel := new(codeenginev2.ResourceKeyRefPrototype) + resourceKeyRefPrototypeModel.ID = core.StringPtr("4e49b3e0-27a8-48d2-a784-c7ee48bb863b") + + // Construct an instance of the RoleRefPrototype model + roleRefPrototypeModel := new(codeenginev2.RoleRefPrototype) + roleRefPrototypeModel.Crn = core.StringPtr("crn:v1:bluemix:public:iam::::serviceRole:Writer") + + // Construct an instance of the ServiceInstanceRefPrototype model + serviceInstanceRefPrototypeModel := new(codeenginev2.ServiceInstanceRefPrototype) + serviceInstanceRefPrototypeModel.ID = core.StringPtr("4e49b3e0-27a8-48d2-a784-c7ee48bb863b") + + // Construct an instance of the ServiceIDRef model + serviceIdRefModel := new(codeenginev2.ServiceIDRef) + serviceIdRefModel.Crn = core.StringPtr("testString") + serviceIdRefModel.ID = core.StringPtr("ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637") + + // Construct an instance of the ServiceAccessSecretPrototypeProps model + serviceAccessSecretPrototypePropsModel := new(codeenginev2.ServiceAccessSecretPrototypeProps) + serviceAccessSecretPrototypePropsModel.ResourceKey = resourceKeyRefPrototypeModel + serviceAccessSecretPrototypePropsModel.Role = roleRefPrototypeModel + serviceAccessSecretPrototypePropsModel.ServiceInstance = serviceInstanceRefPrototypeModel + serviceAccessSecretPrototypePropsModel.Serviceid = serviceIdRefModel + + // Construct an instance of the ServiceIDRefPrototype model + serviceIdRefPrototypeModel := new(codeenginev2.ServiceIDRefPrototype) + serviceIdRefPrototypeModel.ID = core.StringPtr("ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637") + + // Construct an instance of the OperatorSecretPrototypeProps model + operatorSecretPrototypePropsModel := new(codeenginev2.OperatorSecretPrototypeProps) + operatorSecretPrototypePropsModel.ResourceGroupIds = []string{"testString"} + operatorSecretPrototypePropsModel.Serviceid = serviceIdRefPrototypeModel + + // Construct an instance of the CreateSecretOptions model + createSecretOptionsModel := new(codeenginev2.CreateSecretOptions) + createSecretOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + createSecretOptionsModel.Format = core.StringPtr("generic") + createSecretOptionsModel.Name = core.StringPtr("my-secret") + createSecretOptionsModel.Data = secretDataModel + createSecretOptionsModel.ServiceAccess = serviceAccessSecretPrototypePropsModel + createSecretOptionsModel.ServiceOperator = operatorSecretPrototypePropsModel + createSecretOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = codeEngineService.CreateDomainMapping(createDomainMappingOptionsModel) + result, response, operationErr = codeEngineService.CreateSecret(createSecretOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke CreateDomainMapping with error: Operation validation and request error`, func() { + It(`Invoke CreateSecret with error: Operation validation and request error`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -12254,30 +14089,66 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the ComponentRef model - componentRefModel := new(codeenginev2.ComponentRef) - componentRefModel.Name = core.StringPtr("my-app-1") - componentRefModel.ResourceType = core.StringPtr("app_v2") + // Construct an instance of the SecretDataSSHSecretData model + secretDataModel := new(codeenginev2.SecretDataSSHSecretData) + secretDataModel.SshKey = core.StringPtr("testString") + secretDataModel.KnownHosts = core.StringPtr("testString") + secretDataModel.SetProperty("foo", core.StringPtr("testString")) - // Construct an instance of the CreateDomainMappingOptions model - createDomainMappingOptionsModel := new(codeenginev2.CreateDomainMappingOptions) - createDomainMappingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - createDomainMappingOptionsModel.Component = componentRefModel - createDomainMappingOptionsModel.Name = core.StringPtr("www.example.com") - createDomainMappingOptionsModel.TlsSecret = core.StringPtr("my-tls-secret") - createDomainMappingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ResourceKeyRefPrototype model + resourceKeyRefPrototypeModel := new(codeenginev2.ResourceKeyRefPrototype) + resourceKeyRefPrototypeModel.ID = core.StringPtr("4e49b3e0-27a8-48d2-a784-c7ee48bb863b") + + // Construct an instance of the RoleRefPrototype model + roleRefPrototypeModel := new(codeenginev2.RoleRefPrototype) + roleRefPrototypeModel.Crn = core.StringPtr("crn:v1:bluemix:public:iam::::serviceRole:Writer") + + // Construct an instance of the ServiceInstanceRefPrototype model + serviceInstanceRefPrototypeModel := new(codeenginev2.ServiceInstanceRefPrototype) + serviceInstanceRefPrototypeModel.ID = core.StringPtr("4e49b3e0-27a8-48d2-a784-c7ee48bb863b") + + // Construct an instance of the ServiceIDRef model + serviceIdRefModel := new(codeenginev2.ServiceIDRef) + serviceIdRefModel.Crn = core.StringPtr("testString") + serviceIdRefModel.ID = core.StringPtr("ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637") + + // Construct an instance of the ServiceAccessSecretPrototypeProps model + serviceAccessSecretPrototypePropsModel := new(codeenginev2.ServiceAccessSecretPrototypeProps) + serviceAccessSecretPrototypePropsModel.ResourceKey = resourceKeyRefPrototypeModel + serviceAccessSecretPrototypePropsModel.Role = roleRefPrototypeModel + serviceAccessSecretPrototypePropsModel.ServiceInstance = serviceInstanceRefPrototypeModel + serviceAccessSecretPrototypePropsModel.Serviceid = serviceIdRefModel + + // Construct an instance of the ServiceIDRefPrototype model + serviceIdRefPrototypeModel := new(codeenginev2.ServiceIDRefPrototype) + serviceIdRefPrototypeModel.ID = core.StringPtr("ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637") + + // Construct an instance of the OperatorSecretPrototypeProps model + operatorSecretPrototypePropsModel := new(codeenginev2.OperatorSecretPrototypeProps) + operatorSecretPrototypePropsModel.ResourceGroupIds = []string{"testString"} + operatorSecretPrototypePropsModel.Serviceid = serviceIdRefPrototypeModel + + // Construct an instance of the CreateSecretOptions model + createSecretOptionsModel := new(codeenginev2.CreateSecretOptions) + createSecretOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + createSecretOptionsModel.Format = core.StringPtr("generic") + createSecretOptionsModel.Name = core.StringPtr("my-secret") + createSecretOptionsModel.Data = secretDataModel + createSecretOptionsModel.ServiceAccess = serviceAccessSecretPrototypePropsModel + createSecretOptionsModel.ServiceOperator = operatorSecretPrototypePropsModel + createSecretOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := codeEngineService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := codeEngineService.CreateDomainMapping(createDomainMappingOptionsModel) + result, response, operationErr := codeEngineService.CreateSecret(createSecretOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct a second instance of the CreateDomainMappingOptions model with no property values - createDomainMappingOptionsModelNew := new(codeenginev2.CreateDomainMappingOptions) + // Construct a second instance of the CreateSecretOptions model with no property values + createSecretOptionsModelNew := new(codeenginev2.CreateSecretOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = codeEngineService.CreateDomainMapping(createDomainMappingOptionsModelNew) + result, response, operationErr = codeEngineService.CreateSecret(createSecretOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -12295,7 +14166,7 @@ var _ = Describe(`CodeEngineV2`, func() { res.WriteHeader(201) })) }) - It(`Invoke CreateDomainMapping successfully`, func() { + It(`Invoke CreateSecret successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -12303,21 +14174,57 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the ComponentRef model - componentRefModel := new(codeenginev2.ComponentRef) - componentRefModel.Name = core.StringPtr("my-app-1") - componentRefModel.ResourceType = core.StringPtr("app_v2") + // Construct an instance of the SecretDataSSHSecretData model + secretDataModel := new(codeenginev2.SecretDataSSHSecretData) + secretDataModel.SshKey = core.StringPtr("testString") + secretDataModel.KnownHosts = core.StringPtr("testString") + secretDataModel.SetProperty("foo", core.StringPtr("testString")) - // Construct an instance of the CreateDomainMappingOptions model - createDomainMappingOptionsModel := new(codeenginev2.CreateDomainMappingOptions) - createDomainMappingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - createDomainMappingOptionsModel.Component = componentRefModel - createDomainMappingOptionsModel.Name = core.StringPtr("www.example.com") - createDomainMappingOptionsModel.TlsSecret = core.StringPtr("my-tls-secret") - createDomainMappingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ResourceKeyRefPrototype model + resourceKeyRefPrototypeModel := new(codeenginev2.ResourceKeyRefPrototype) + resourceKeyRefPrototypeModel.ID = core.StringPtr("4e49b3e0-27a8-48d2-a784-c7ee48bb863b") + + // Construct an instance of the RoleRefPrototype model + roleRefPrototypeModel := new(codeenginev2.RoleRefPrototype) + roleRefPrototypeModel.Crn = core.StringPtr("crn:v1:bluemix:public:iam::::serviceRole:Writer") + + // Construct an instance of the ServiceInstanceRefPrototype model + serviceInstanceRefPrototypeModel := new(codeenginev2.ServiceInstanceRefPrototype) + serviceInstanceRefPrototypeModel.ID = core.StringPtr("4e49b3e0-27a8-48d2-a784-c7ee48bb863b") + + // Construct an instance of the ServiceIDRef model + serviceIdRefModel := new(codeenginev2.ServiceIDRef) + serviceIdRefModel.Crn = core.StringPtr("testString") + serviceIdRefModel.ID = core.StringPtr("ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637") + + // Construct an instance of the ServiceAccessSecretPrototypeProps model + serviceAccessSecretPrototypePropsModel := new(codeenginev2.ServiceAccessSecretPrototypeProps) + serviceAccessSecretPrototypePropsModel.ResourceKey = resourceKeyRefPrototypeModel + serviceAccessSecretPrototypePropsModel.Role = roleRefPrototypeModel + serviceAccessSecretPrototypePropsModel.ServiceInstance = serviceInstanceRefPrototypeModel + serviceAccessSecretPrototypePropsModel.Serviceid = serviceIdRefModel + + // Construct an instance of the ServiceIDRefPrototype model + serviceIdRefPrototypeModel := new(codeenginev2.ServiceIDRefPrototype) + serviceIdRefPrototypeModel.ID = core.StringPtr("ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637") + + // Construct an instance of the OperatorSecretPrototypeProps model + operatorSecretPrototypePropsModel := new(codeenginev2.OperatorSecretPrototypeProps) + operatorSecretPrototypePropsModel.ResourceGroupIds = []string{"testString"} + operatorSecretPrototypePropsModel.Serviceid = serviceIdRefPrototypeModel + + // Construct an instance of the CreateSecretOptions model + createSecretOptionsModel := new(codeenginev2.CreateSecretOptions) + createSecretOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + createSecretOptionsModel.Format = core.StringPtr("generic") + createSecretOptionsModel.Name = core.StringPtr("my-secret") + createSecretOptionsModel.Data = secretDataModel + createSecretOptionsModel.ServiceAccess = serviceAccessSecretPrototypePropsModel + createSecretOptionsModel.ServiceOperator = operatorSecretPrototypePropsModel + createSecretOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := codeEngineService.CreateDomainMapping(createDomainMappingOptionsModel) + result, response, operationErr := codeEngineService.CreateSecret(createSecretOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -12329,22 +14236,22 @@ var _ = Describe(`CodeEngineV2`, func() { }) }) }) - Describe(`GetDomainMapping(getDomainMappingOptions *GetDomainMappingOptions) - Operation response error`, func() { - getDomainMappingPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/domain_mappings/www.example.com" + Describe(`GetSecret(getSecretOptions *GetSecretOptions) - Operation response error`, func() { + getSecretPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/secrets/my-secret" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getDomainMappingPath)) + Expect(req.URL.EscapedPath()).To(Equal(getSecretPath)) Expect(req.Method).To(Equal("GET")) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke GetDomainMapping with error: Operation response processing error`, func() { + It(`Invoke GetSecret with error: Operation response processing error`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -12352,20 +14259,20 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the GetDomainMappingOptions model - getDomainMappingOptionsModel := new(codeenginev2.GetDomainMappingOptions) - getDomainMappingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - getDomainMappingOptionsModel.Name = core.StringPtr("www.example.com") - getDomainMappingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetSecretOptions model + getSecretOptionsModel := new(codeenginev2.GetSecretOptions) + getSecretOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + getSecretOptionsModel.Name = core.StringPtr("my-secret") + getSecretOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := codeEngineService.GetDomainMapping(getDomainMappingOptionsModel) + result, response, operationErr := codeEngineService.GetSecret(getSecretOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again codeEngineService.EnableRetries(0, 0) - result, response, operationErr = codeEngineService.GetDomainMapping(getDomainMappingOptionsModel) + result, response, operationErr = codeEngineService.GetSecret(getSecretOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -12375,15 +14282,15 @@ var _ = Describe(`CodeEngineV2`, func() { }) }) }) - Describe(`GetDomainMapping(getDomainMappingOptions *GetDomainMappingOptions)`, func() { - getDomainMappingPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/domain_mappings/www.example.com" + Describe(`GetSecret(getSecretOptions *GetSecretOptions)`, func() { + getSecretPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/secrets/my-secret" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getDomainMappingPath)) + Expect(req.URL.EscapedPath()).To(Equal(getSecretPath)) Expect(req.Method).To(Equal("GET")) // Sleep a short time to support a timeout test @@ -12392,10 +14299,10 @@ var _ = Describe(`CodeEngineV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"cname_target": "custom.abcdabcdabc.us-east.codeengine.appdomain.cloud", "component": {"name": "my-app-1", "resource_type": "app_v2"}, "created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/domain_mappings/www.example.com", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "www.example.com", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "domain_mapping_v2", "status": "ready", "status_details": {"reason": "ready"}, "tls_secret": "my-tls-secret", "user_managed": false, "visibility": "public"}`) + fmt.Fprintf(res, "%s", `{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "Inner"}, "entity_tag": "2385407409", "format": "generic", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-secret", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "ResourceType", "service_access": {"resource_key": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "name": "Name"}, "role": {"crn": "crn:v1:bluemix:public:iam::::serviceRole:Writer", "name": "Manager"}, "service_instance": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "type": "Type"}, "serviceid": {"crn": "Crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}}, "service_operator": {"apikey_id": "ApiKey-17041d26-55e4-40a8-8ab5-5a69b68e204b", "resource_group_ids": ["ResourceGroupIds"], "serviceid": {"crn": "Crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}, "user_managed": false}}`) })) }) - It(`Invoke GetDomainMapping successfully with retries`, func() { + It(`Invoke GetSecret successfully with retries`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -12404,22 +14311,22 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(codeEngineService).ToNot(BeNil()) codeEngineService.EnableRetries(0, 0) - // Construct an instance of the GetDomainMappingOptions model - getDomainMappingOptionsModel := new(codeenginev2.GetDomainMappingOptions) - getDomainMappingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - getDomainMappingOptionsModel.Name = core.StringPtr("www.example.com") - getDomainMappingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetSecretOptions model + getSecretOptionsModel := new(codeenginev2.GetSecretOptions) + getSecretOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + getSecretOptionsModel.Name = core.StringPtr("my-secret") + getSecretOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := codeEngineService.GetDomainMappingWithContext(ctx, getDomainMappingOptionsModel) + _, _, operationErr := codeEngineService.GetSecretWithContext(ctx, getSecretOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again codeEngineService.DisableRetries() - result, response, operationErr := codeEngineService.GetDomainMapping(getDomainMappingOptionsModel) + result, response, operationErr := codeEngineService.GetSecret(getSecretOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -12427,7 +14334,7 @@ var _ = Describe(`CodeEngineV2`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = codeEngineService.GetDomainMappingWithContext(ctx, getDomainMappingOptionsModel) + _, _, operationErr = codeEngineService.GetSecretWithContext(ctx, getSecretOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -12441,16 +14348,16 @@ var _ = Describe(`CodeEngineV2`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getDomainMappingPath)) + Expect(req.URL.EscapedPath()).To(Equal(getSecretPath)) Expect(req.Method).To(Equal("GET")) // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"cname_target": "custom.abcdabcdabc.us-east.codeengine.appdomain.cloud", "component": {"name": "my-app-1", "resource_type": "app_v2"}, "created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/domain_mappings/www.example.com", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "www.example.com", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "domain_mapping_v2", "status": "ready", "status_details": {"reason": "ready"}, "tls_secret": "my-tls-secret", "user_managed": false, "visibility": "public"}`) + fmt.Fprintf(res, "%s", `{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "Inner"}, "entity_tag": "2385407409", "format": "generic", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-secret", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "ResourceType", "service_access": {"resource_key": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "name": "Name"}, "role": {"crn": "crn:v1:bluemix:public:iam::::serviceRole:Writer", "name": "Manager"}, "service_instance": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "type": "Type"}, "serviceid": {"crn": "Crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}}, "service_operator": {"apikey_id": "ApiKey-17041d26-55e4-40a8-8ab5-5a69b68e204b", "resource_group_ids": ["ResourceGroupIds"], "serviceid": {"crn": "Crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}, "user_managed": false}}`) })) }) - It(`Invoke GetDomainMapping successfully`, func() { + It(`Invoke GetSecret successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -12459,25 +14366,25 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(codeEngineService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := codeEngineService.GetDomainMapping(nil) + result, response, operationErr := codeEngineService.GetSecret(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the GetDomainMappingOptions model - getDomainMappingOptionsModel := new(codeenginev2.GetDomainMappingOptions) - getDomainMappingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - getDomainMappingOptionsModel.Name = core.StringPtr("www.example.com") - getDomainMappingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetSecretOptions model + getSecretOptionsModel := new(codeenginev2.GetSecretOptions) + getSecretOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + getSecretOptionsModel.Name = core.StringPtr("my-secret") + getSecretOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = codeEngineService.GetDomainMapping(getDomainMappingOptionsModel) + result, response, operationErr = codeEngineService.GetSecret(getSecretOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke GetDomainMapping with error: Operation validation and request error`, func() { + It(`Invoke GetSecret with error: Operation validation and request error`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -12485,23 +14392,23 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the GetDomainMappingOptions model - getDomainMappingOptionsModel := new(codeenginev2.GetDomainMappingOptions) - getDomainMappingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - getDomainMappingOptionsModel.Name = core.StringPtr("www.example.com") - getDomainMappingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetSecretOptions model + getSecretOptionsModel := new(codeenginev2.GetSecretOptions) + getSecretOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + getSecretOptionsModel.Name = core.StringPtr("my-secret") + getSecretOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := codeEngineService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := codeEngineService.GetDomainMapping(getDomainMappingOptionsModel) + result, response, operationErr := codeEngineService.GetSecret(getSecretOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct a second instance of the GetDomainMappingOptions model with no property values - getDomainMappingOptionsModelNew := new(codeenginev2.GetDomainMappingOptions) + // Construct a second instance of the GetSecretOptions model with no property values + getSecretOptionsModelNew := new(codeenginev2.GetSecretOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = codeEngineService.GetDomainMapping(getDomainMappingOptionsModelNew) + result, response, operationErr = codeEngineService.GetSecret(getSecretOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -12519,7 +14426,7 @@ var _ = Describe(`CodeEngineV2`, func() { res.WriteHeader(200) })) }) - It(`Invoke GetDomainMapping successfully`, func() { + It(`Invoke GetSecret successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -12527,14 +14434,14 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the GetDomainMappingOptions model - getDomainMappingOptionsModel := new(codeenginev2.GetDomainMappingOptions) - getDomainMappingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - getDomainMappingOptionsModel.Name = core.StringPtr("www.example.com") - getDomainMappingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetSecretOptions model + getSecretOptionsModel := new(codeenginev2.GetSecretOptions) + getSecretOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + getSecretOptionsModel.Name = core.StringPtr("my-secret") + getSecretOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := codeEngineService.GetDomainMapping(getDomainMappingOptionsModel) + result, response, operationErr := codeEngineService.GetSecret(getSecretOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -12546,86 +14453,16 @@ var _ = Describe(`CodeEngineV2`, func() { }) }) }) - Describe(`DeleteDomainMapping(deleteDomainMappingOptions *DeleteDomainMappingOptions)`, func() { - deleteDomainMappingPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/domain_mappings/www.example.com" - Context(`Using mock server endpoint`, func() { - BeforeEach(func() { - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(deleteDomainMappingPath)) - Expect(req.Method).To(Equal("DELETE")) - - res.WriteHeader(202) - })) - }) - It(`Invoke DeleteDomainMapping successfully`, func() { - codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - }) - Expect(serviceErr).To(BeNil()) - Expect(codeEngineService).ToNot(BeNil()) - - // Invoke operation with nil options model (negative test) - response, operationErr := codeEngineService.DeleteDomainMapping(nil) - Expect(operationErr).NotTo(BeNil()) - Expect(response).To(BeNil()) - - // Construct an instance of the DeleteDomainMappingOptions model - deleteDomainMappingOptionsModel := new(codeenginev2.DeleteDomainMappingOptions) - deleteDomainMappingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - deleteDomainMappingOptionsModel.Name = core.StringPtr("www.example.com") - deleteDomainMappingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - - // Invoke operation with valid options model (positive test) - response, operationErr = codeEngineService.DeleteDomainMapping(deleteDomainMappingOptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) - }) - It(`Invoke DeleteDomainMapping with error: Operation validation and request error`, func() { - codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - }) - Expect(serviceErr).To(BeNil()) - Expect(codeEngineService).ToNot(BeNil()) - - // Construct an instance of the DeleteDomainMappingOptions model - deleteDomainMappingOptionsModel := new(codeenginev2.DeleteDomainMappingOptions) - deleteDomainMappingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - deleteDomainMappingOptionsModel.Name = core.StringPtr("www.example.com") - deleteDomainMappingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - // Invoke operation with empty URL (negative test) - err := codeEngineService.SetServiceURL("") - Expect(err).To(BeNil()) - response, operationErr := codeEngineService.DeleteDomainMapping(deleteDomainMappingOptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) - Expect(response).To(BeNil()) - // Construct a second instance of the DeleteDomainMappingOptions model with no property values - deleteDomainMappingOptionsModelNew := new(codeenginev2.DeleteDomainMappingOptions) - // Invoke operation with invalid model (negative test) - response, operationErr = codeEngineService.DeleteDomainMapping(deleteDomainMappingOptionsModelNew) - Expect(operationErr).ToNot(BeNil()) - Expect(response).To(BeNil()) - }) - AfterEach(func() { - testServer.Close() - }) - }) - }) - Describe(`UpdateDomainMapping(updateDomainMappingOptions *UpdateDomainMappingOptions) - Operation response error`, func() { - updateDomainMappingPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/domain_mappings/www.example.com" + Describe(`ReplaceSecret(replaceSecretOptions *ReplaceSecretOptions) - Operation response error`, func() { + replaceSecretPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/secrets/my-secret" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(updateDomainMappingPath)) - Expect(req.Method).To(Equal("PATCH")) + Expect(req.URL.EscapedPath()).To(Equal(replaceSecretPath)) + Expect(req.Method).To(Equal("PUT")) Expect(req.Header["If-Match"]).ToNot(BeNil()) Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) res.Header().Set("Content-type", "application/json") @@ -12633,7 +14470,7 @@ var _ = Describe(`CodeEngineV2`, func() { fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke UpdateDomainMapping with error: Operation response processing error`, func() { + It(`Invoke ReplaceSecret with error: Operation response processing error`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -12641,34 +14478,29 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the ComponentRef model - componentRefModel := new(codeenginev2.ComponentRef) - componentRefModel.Name = core.StringPtr("my-app-1") - componentRefModel.ResourceType = core.StringPtr("app_v2") - - // Construct an instance of the DomainMappingPatch model - domainMappingPatchModel := new(codeenginev2.DomainMappingPatch) - domainMappingPatchModel.Component = componentRefModel - domainMappingPatchModel.TlsSecret = core.StringPtr("my-tls-secret") - domainMappingPatchModelAsPatch, asPatchErr := domainMappingPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) + // Construct an instance of the SecretDataSSHSecretData model + secretDataModel := new(codeenginev2.SecretDataSSHSecretData) + secretDataModel.SshKey = core.StringPtr("testString") + secretDataModel.KnownHosts = core.StringPtr("testString") + secretDataModel.SetProperty("foo", core.StringPtr("testString")) - // Construct an instance of the UpdateDomainMappingOptions model - updateDomainMappingOptionsModel := new(codeenginev2.UpdateDomainMappingOptions) - updateDomainMappingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - updateDomainMappingOptionsModel.Name = core.StringPtr("www.example.com") - updateDomainMappingOptionsModel.IfMatch = core.StringPtr("testString") - updateDomainMappingOptionsModel.DomainMapping = domainMappingPatchModelAsPatch - updateDomainMappingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ReplaceSecretOptions model + replaceSecretOptionsModel := new(codeenginev2.ReplaceSecretOptions) + replaceSecretOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + replaceSecretOptionsModel.Name = core.StringPtr("my-secret") + replaceSecretOptionsModel.IfMatch = core.StringPtr("testString") + replaceSecretOptionsModel.Format = core.StringPtr("generic") + replaceSecretOptionsModel.Data = secretDataModel + replaceSecretOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := codeEngineService.UpdateDomainMapping(updateDomainMappingOptionsModel) + result, response, operationErr := codeEngineService.ReplaceSecret(replaceSecretOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again codeEngineService.EnableRetries(0, 0) - result, response, operationErr = codeEngineService.UpdateDomainMapping(updateDomainMappingOptionsModel) + result, response, operationErr = codeEngineService.ReplaceSecret(replaceSecretOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -12678,16 +14510,16 @@ var _ = Describe(`CodeEngineV2`, func() { }) }) }) - Describe(`UpdateDomainMapping(updateDomainMappingOptions *UpdateDomainMappingOptions)`, func() { - updateDomainMappingPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/domain_mappings/www.example.com" + Describe(`ReplaceSecret(replaceSecretOptions *ReplaceSecretOptions)`, func() { + replaceSecretPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/secrets/my-secret" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(updateDomainMappingPath)) - Expect(req.Method).To(Equal("PATCH")) + Expect(req.URL.EscapedPath()).To(Equal(replaceSecretPath)) + Expect(req.Method).To(Equal("PUT")) // For gzip-disabled operation, verify Content-Encoding is not set. Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) @@ -12713,10 +14545,10 @@ var _ = Describe(`CodeEngineV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"cname_target": "custom.abcdabcdabc.us-east.codeengine.appdomain.cloud", "component": {"name": "my-app-1", "resource_type": "app_v2"}, "created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/domain_mappings/www.example.com", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "www.example.com", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "domain_mapping_v2", "status": "ready", "status_details": {"reason": "ready"}, "tls_secret": "my-tls-secret", "user_managed": false, "visibility": "public"}`) + fmt.Fprintf(res, "%s", `{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "Inner"}, "entity_tag": "2385407409", "format": "generic", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-secret", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "ResourceType", "service_access": {"resource_key": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "name": "Name"}, "role": {"crn": "crn:v1:bluemix:public:iam::::serviceRole:Writer", "name": "Manager"}, "service_instance": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "type": "Type"}, "serviceid": {"crn": "Crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}}, "service_operator": {"apikey_id": "ApiKey-17041d26-55e4-40a8-8ab5-5a69b68e204b", "resource_group_ids": ["ResourceGroupIds"], "serviceid": {"crn": "Crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}, "user_managed": false}}`) })) }) - It(`Invoke UpdateDomainMapping successfully with retries`, func() { + It(`Invoke ReplaceSecret successfully with retries`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -12725,36 +14557,31 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(codeEngineService).ToNot(BeNil()) codeEngineService.EnableRetries(0, 0) - // Construct an instance of the ComponentRef model - componentRefModel := new(codeenginev2.ComponentRef) - componentRefModel.Name = core.StringPtr("my-app-1") - componentRefModel.ResourceType = core.StringPtr("app_v2") - - // Construct an instance of the DomainMappingPatch model - domainMappingPatchModel := new(codeenginev2.DomainMappingPatch) - domainMappingPatchModel.Component = componentRefModel - domainMappingPatchModel.TlsSecret = core.StringPtr("my-tls-secret") - domainMappingPatchModelAsPatch, asPatchErr := domainMappingPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) + // Construct an instance of the SecretDataSSHSecretData model + secretDataModel := new(codeenginev2.SecretDataSSHSecretData) + secretDataModel.SshKey = core.StringPtr("testString") + secretDataModel.KnownHosts = core.StringPtr("testString") + secretDataModel.SetProperty("foo", core.StringPtr("testString")) - // Construct an instance of the UpdateDomainMappingOptions model - updateDomainMappingOptionsModel := new(codeenginev2.UpdateDomainMappingOptions) - updateDomainMappingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - updateDomainMappingOptionsModel.Name = core.StringPtr("www.example.com") - updateDomainMappingOptionsModel.IfMatch = core.StringPtr("testString") - updateDomainMappingOptionsModel.DomainMapping = domainMappingPatchModelAsPatch - updateDomainMappingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ReplaceSecretOptions model + replaceSecretOptionsModel := new(codeenginev2.ReplaceSecretOptions) + replaceSecretOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + replaceSecretOptionsModel.Name = core.StringPtr("my-secret") + replaceSecretOptionsModel.IfMatch = core.StringPtr("testString") + replaceSecretOptionsModel.Format = core.StringPtr("generic") + replaceSecretOptionsModel.Data = secretDataModel + replaceSecretOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := codeEngineService.UpdateDomainMappingWithContext(ctx, updateDomainMappingOptionsModel) + _, _, operationErr := codeEngineService.ReplaceSecretWithContext(ctx, replaceSecretOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again codeEngineService.DisableRetries() - result, response, operationErr := codeEngineService.UpdateDomainMapping(updateDomainMappingOptionsModel) + result, response, operationErr := codeEngineService.ReplaceSecret(replaceSecretOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -12762,7 +14589,7 @@ var _ = Describe(`CodeEngineV2`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = codeEngineService.UpdateDomainMappingWithContext(ctx, updateDomainMappingOptionsModel) + _, _, operationErr = codeEngineService.ReplaceSecretWithContext(ctx, replaceSecretOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -12776,8 +14603,8 @@ var _ = Describe(`CodeEngineV2`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(updateDomainMappingPath)) - Expect(req.Method).To(Equal("PATCH")) + Expect(req.URL.EscapedPath()).To(Equal(replaceSecretPath)) + Expect(req.Method).To(Equal("PUT")) // For gzip-disabled operation, verify Content-Encoding is not set. Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) @@ -12800,10 +14627,10 @@ var _ = Describe(`CodeEngineV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"cname_target": "custom.abcdabcdabc.us-east.codeengine.appdomain.cloud", "component": {"name": "my-app-1", "resource_type": "app_v2"}, "created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/domain_mappings/www.example.com", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "www.example.com", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "domain_mapping_v2", "status": "ready", "status_details": {"reason": "ready"}, "tls_secret": "my-tls-secret", "user_managed": false, "visibility": "public"}`) + fmt.Fprintf(res, "%s", `{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "Inner"}, "entity_tag": "2385407409", "format": "generic", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-secret", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "ResourceType", "service_access": {"resource_key": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "name": "Name"}, "role": {"crn": "crn:v1:bluemix:public:iam::::serviceRole:Writer", "name": "Manager"}, "service_instance": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "type": "Type"}, "serviceid": {"crn": "Crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}}, "service_operator": {"apikey_id": "ApiKey-17041d26-55e4-40a8-8ab5-5a69b68e204b", "resource_group_ids": ["ResourceGroupIds"], "serviceid": {"crn": "Crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}, "user_managed": false}}`) })) }) - It(`Invoke UpdateDomainMapping successfully`, func() { + It(`Invoke ReplaceSecret successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -12812,39 +14639,34 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(codeEngineService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := codeEngineService.UpdateDomainMapping(nil) + result, response, operationErr := codeEngineService.ReplaceSecret(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the ComponentRef model - componentRefModel := new(codeenginev2.ComponentRef) - componentRefModel.Name = core.StringPtr("my-app-1") - componentRefModel.ResourceType = core.StringPtr("app_v2") - - // Construct an instance of the DomainMappingPatch model - domainMappingPatchModel := new(codeenginev2.DomainMappingPatch) - domainMappingPatchModel.Component = componentRefModel - domainMappingPatchModel.TlsSecret = core.StringPtr("my-tls-secret") - domainMappingPatchModelAsPatch, asPatchErr := domainMappingPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) + // Construct an instance of the SecretDataSSHSecretData model + secretDataModel := new(codeenginev2.SecretDataSSHSecretData) + secretDataModel.SshKey = core.StringPtr("testString") + secretDataModel.KnownHosts = core.StringPtr("testString") + secretDataModel.SetProperty("foo", core.StringPtr("testString")) - // Construct an instance of the UpdateDomainMappingOptions model - updateDomainMappingOptionsModel := new(codeenginev2.UpdateDomainMappingOptions) - updateDomainMappingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - updateDomainMappingOptionsModel.Name = core.StringPtr("www.example.com") - updateDomainMappingOptionsModel.IfMatch = core.StringPtr("testString") - updateDomainMappingOptionsModel.DomainMapping = domainMappingPatchModelAsPatch - updateDomainMappingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ReplaceSecretOptions model + replaceSecretOptionsModel := new(codeenginev2.ReplaceSecretOptions) + replaceSecretOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + replaceSecretOptionsModel.Name = core.StringPtr("my-secret") + replaceSecretOptionsModel.IfMatch = core.StringPtr("testString") + replaceSecretOptionsModel.Format = core.StringPtr("generic") + replaceSecretOptionsModel.Data = secretDataModel + replaceSecretOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = codeEngineService.UpdateDomainMapping(updateDomainMappingOptionsModel) + result, response, operationErr = codeEngineService.ReplaceSecret(replaceSecretOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke UpdateDomainMapping with error: Operation validation and request error`, func() { + It(`Invoke ReplaceSecret with error: Operation validation and request error`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -12852,37 +14674,32 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the ComponentRef model - componentRefModel := new(codeenginev2.ComponentRef) - componentRefModel.Name = core.StringPtr("my-app-1") - componentRefModel.ResourceType = core.StringPtr("app_v2") - - // Construct an instance of the DomainMappingPatch model - domainMappingPatchModel := new(codeenginev2.DomainMappingPatch) - domainMappingPatchModel.Component = componentRefModel - domainMappingPatchModel.TlsSecret = core.StringPtr("my-tls-secret") - domainMappingPatchModelAsPatch, asPatchErr := domainMappingPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) + // Construct an instance of the SecretDataSSHSecretData model + secretDataModel := new(codeenginev2.SecretDataSSHSecretData) + secretDataModel.SshKey = core.StringPtr("testString") + secretDataModel.KnownHosts = core.StringPtr("testString") + secretDataModel.SetProperty("foo", core.StringPtr("testString")) - // Construct an instance of the UpdateDomainMappingOptions model - updateDomainMappingOptionsModel := new(codeenginev2.UpdateDomainMappingOptions) - updateDomainMappingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - updateDomainMappingOptionsModel.Name = core.StringPtr("www.example.com") - updateDomainMappingOptionsModel.IfMatch = core.StringPtr("testString") - updateDomainMappingOptionsModel.DomainMapping = domainMappingPatchModelAsPatch - updateDomainMappingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ReplaceSecretOptions model + replaceSecretOptionsModel := new(codeenginev2.ReplaceSecretOptions) + replaceSecretOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + replaceSecretOptionsModel.Name = core.StringPtr("my-secret") + replaceSecretOptionsModel.IfMatch = core.StringPtr("testString") + replaceSecretOptionsModel.Format = core.StringPtr("generic") + replaceSecretOptionsModel.Data = secretDataModel + replaceSecretOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := codeEngineService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := codeEngineService.UpdateDomainMapping(updateDomainMappingOptionsModel) + result, response, operationErr := codeEngineService.ReplaceSecret(replaceSecretOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct a second instance of the UpdateDomainMappingOptions model with no property values - updateDomainMappingOptionsModelNew := new(codeenginev2.UpdateDomainMappingOptions) + // Construct a second instance of the ReplaceSecretOptions model with no property values + replaceSecretOptionsModelNew := new(codeenginev2.ReplaceSecretOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = codeEngineService.UpdateDomainMapping(updateDomainMappingOptionsModelNew) + result, response, operationErr = codeEngineService.ReplaceSecret(replaceSecretOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -12900,7 +14717,7 @@ var _ = Describe(`CodeEngineV2`, func() { res.WriteHeader(200) })) }) - It(`Invoke UpdateDomainMapping successfully`, func() { + It(`Invoke ReplaceSecret successfully`, func() { codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -12908,28 +14725,23 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(serviceErr).To(BeNil()) Expect(codeEngineService).ToNot(BeNil()) - // Construct an instance of the ComponentRef model - componentRefModel := new(codeenginev2.ComponentRef) - componentRefModel.Name = core.StringPtr("my-app-1") - componentRefModel.ResourceType = core.StringPtr("app_v2") - - // Construct an instance of the DomainMappingPatch model - domainMappingPatchModel := new(codeenginev2.DomainMappingPatch) - domainMappingPatchModel.Component = componentRefModel - domainMappingPatchModel.TlsSecret = core.StringPtr("my-tls-secret") - domainMappingPatchModelAsPatch, asPatchErr := domainMappingPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) + // Construct an instance of the SecretDataSSHSecretData model + secretDataModel := new(codeenginev2.SecretDataSSHSecretData) + secretDataModel.SshKey = core.StringPtr("testString") + secretDataModel.KnownHosts = core.StringPtr("testString") + secretDataModel.SetProperty("foo", core.StringPtr("testString")) - // Construct an instance of the UpdateDomainMappingOptions model - updateDomainMappingOptionsModel := new(codeenginev2.UpdateDomainMappingOptions) - updateDomainMappingOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") - updateDomainMappingOptionsModel.Name = core.StringPtr("www.example.com") - updateDomainMappingOptionsModel.IfMatch = core.StringPtr("testString") - updateDomainMappingOptionsModel.DomainMapping = domainMappingPatchModelAsPatch - updateDomainMappingOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ReplaceSecretOptions model + replaceSecretOptionsModel := new(codeenginev2.ReplaceSecretOptions) + replaceSecretOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + replaceSecretOptionsModel.Name = core.StringPtr("my-secret") + replaceSecretOptionsModel.IfMatch = core.StringPtr("testString") + replaceSecretOptionsModel.Format = core.StringPtr("generic") + replaceSecretOptionsModel.Data = secretDataModel + replaceSecretOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := codeEngineService.UpdateDomainMapping(updateDomainMappingOptionsModel) + result, response, operationErr := codeEngineService.ReplaceSecret(replaceSecretOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -12941,6 +14753,76 @@ var _ = Describe(`CodeEngineV2`, func() { }) }) }) + Describe(`DeleteSecret(deleteSecretOptions *DeleteSecretOptions)`, func() { + deleteSecretPath := "/projects/15314cc3-85b4-4338-903f-c28cdee6d005/secrets/my-secret" + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(deleteSecretPath)) + Expect(req.Method).To(Equal("DELETE")) + + res.WriteHeader(202) + })) + }) + It(`Invoke DeleteSecret successfully`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + response, operationErr := codeEngineService.DeleteSecret(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + + // Construct an instance of the DeleteSecretOptions model + deleteSecretOptionsModel := new(codeenginev2.DeleteSecretOptions) + deleteSecretOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + deleteSecretOptionsModel.Name = core.StringPtr("my-secret") + deleteSecretOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + response, operationErr = codeEngineService.DeleteSecret(deleteSecretOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + }) + It(`Invoke DeleteSecret with error: Operation validation and request error`, func() { + codeEngineService, serviceErr := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(codeEngineService).ToNot(BeNil()) + + // Construct an instance of the DeleteSecretOptions model + deleteSecretOptionsModel := new(codeenginev2.DeleteSecretOptions) + deleteSecretOptionsModel.ProjectID = core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005") + deleteSecretOptionsModel.Name = core.StringPtr("my-secret") + deleteSecretOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := codeEngineService.SetServiceURL("") + Expect(err).To(BeNil()) + response, operationErr := codeEngineService.DeleteSecret(deleteSecretOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + // Construct a second instance of the DeleteSecretOptions model with no property values + deleteSecretOptionsModelNew := new(codeenginev2.DeleteSecretOptions) + // Invoke operation with invalid model (negative test) + response, operationErr = codeEngineService.DeleteSecret(deleteSecretOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) Describe(`Model constructor tests`, func() { Context(`Using a service client instance`, func() { codeEngineService, _ := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ @@ -13203,6 +15085,61 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(createDomainMappingOptionsModel.TlsSecret).To(Equal(core.StringPtr("my-tls-secret"))) Expect(createDomainMappingOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewCreateFunctionOptions successfully`, func() { + // Construct an instance of the EnvVarPrototype model + envVarPrototypeModel := new(codeenginev2.EnvVarPrototype) + Expect(envVarPrototypeModel).ToNot(BeNil()) + envVarPrototypeModel.Key = core.StringPtr("MY_VARIABLE") + envVarPrototypeModel.Name = core.StringPtr("SOME") + envVarPrototypeModel.Prefix = core.StringPtr("PREFIX_") + envVarPrototypeModel.Reference = core.StringPtr("my-secret") + envVarPrototypeModel.Type = core.StringPtr("literal") + envVarPrototypeModel.Value = core.StringPtr("VALUE") + Expect(envVarPrototypeModel.Key).To(Equal(core.StringPtr("MY_VARIABLE"))) + Expect(envVarPrototypeModel.Name).To(Equal(core.StringPtr("SOME"))) + Expect(envVarPrototypeModel.Prefix).To(Equal(core.StringPtr("PREFIX_"))) + Expect(envVarPrototypeModel.Reference).To(Equal(core.StringPtr("my-secret"))) + Expect(envVarPrototypeModel.Type).To(Equal(core.StringPtr("literal"))) + Expect(envVarPrototypeModel.Value).To(Equal(core.StringPtr("VALUE"))) + + // Construct an instance of the CreateFunctionOptions model + projectID := "15314cc3-85b4-4338-903f-c28cdee6d005" + createFunctionOptionsCodeReference := "data:text/plain;base64," + createFunctionOptionsName := "my-function" + createFunctionOptionsRuntime := "nodejs-18" + createFunctionOptionsModel := codeEngineService.NewCreateFunctionOptions(projectID, createFunctionOptionsCodeReference, createFunctionOptionsName, createFunctionOptionsRuntime) + createFunctionOptionsModel.SetProjectID("15314cc3-85b4-4338-903f-c28cdee6d005") + createFunctionOptionsModel.SetCodeReference("data:text/plain;base64,") + createFunctionOptionsModel.SetName("my-function") + createFunctionOptionsModel.SetRuntime("nodejs-18") + createFunctionOptionsModel.SetCodeBinary(false) + createFunctionOptionsModel.SetCodeMain("main") + createFunctionOptionsModel.SetCodeSecret("my-secret") + createFunctionOptionsModel.SetManagedDomainMappings("local_public") + createFunctionOptionsModel.SetRunEnvVariables([]codeenginev2.EnvVarPrototype{*envVarPrototypeModel}) + createFunctionOptionsModel.SetScaleConcurrency(int64(1)) + createFunctionOptionsModel.SetScaleCpuLimit("1") + createFunctionOptionsModel.SetScaleDownDelay(int64(300)) + createFunctionOptionsModel.SetScaleMaxExecutionTime(int64(60)) + createFunctionOptionsModel.SetScaleMemoryLimit("1G") + createFunctionOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(createFunctionOptionsModel).ToNot(BeNil()) + Expect(createFunctionOptionsModel.ProjectID).To(Equal(core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"))) + Expect(createFunctionOptionsModel.CodeReference).To(Equal(core.StringPtr("data:text/plain;base64,"))) + Expect(createFunctionOptionsModel.Name).To(Equal(core.StringPtr("my-function"))) + Expect(createFunctionOptionsModel.Runtime).To(Equal(core.StringPtr("nodejs-18"))) + Expect(createFunctionOptionsModel.CodeBinary).To(Equal(core.BoolPtr(false))) + Expect(createFunctionOptionsModel.CodeMain).To(Equal(core.StringPtr("main"))) + Expect(createFunctionOptionsModel.CodeSecret).To(Equal(core.StringPtr("my-secret"))) + Expect(createFunctionOptionsModel.ManagedDomainMappings).To(Equal(core.StringPtr("local_public"))) + Expect(createFunctionOptionsModel.RunEnvVariables).To(Equal([]codeenginev2.EnvVarPrototype{*envVarPrototypeModel})) + Expect(createFunctionOptionsModel.ScaleConcurrency).To(Equal(core.Int64Ptr(int64(1)))) + Expect(createFunctionOptionsModel.ScaleCpuLimit).To(Equal(core.StringPtr("1"))) + Expect(createFunctionOptionsModel.ScaleDownDelay).To(Equal(core.Int64Ptr(int64(300)))) + Expect(createFunctionOptionsModel.ScaleMaxExecutionTime).To(Equal(core.Int64Ptr(int64(60)))) + Expect(createFunctionOptionsModel.ScaleMemoryLimit).To(Equal(core.StringPtr("1G"))) + Expect(createFunctionOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) It(`Invoke NewCreateJobOptions successfully`, func() { // Construct an instance of the EnvVarPrototype model envVarPrototypeModel := new(codeenginev2.EnvVarPrototype) @@ -13551,6 +15488,19 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(deleteDomainMappingOptionsModel.Name).To(Equal(core.StringPtr("www.example.com"))) Expect(deleteDomainMappingOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewDeleteFunctionOptions successfully`, func() { + // Construct an instance of the DeleteFunctionOptions model + projectID := "15314cc3-85b4-4338-903f-c28cdee6d005" + name := "my-function" + deleteFunctionOptionsModel := codeEngineService.NewDeleteFunctionOptions(projectID, name) + deleteFunctionOptionsModel.SetProjectID("15314cc3-85b4-4338-903f-c28cdee6d005") + deleteFunctionOptionsModel.SetName("my-function") + deleteFunctionOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(deleteFunctionOptionsModel).ToNot(BeNil()) + Expect(deleteFunctionOptionsModel.ProjectID).To(Equal(core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"))) + Expect(deleteFunctionOptionsModel.Name).To(Equal(core.StringPtr("my-function"))) + Expect(deleteFunctionOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) It(`Invoke NewDeleteJobOptions successfully`, func() { // Construct an instance of the DeleteJobOptions model projectID := "15314cc3-85b4-4338-903f-c28cdee6d005" @@ -13694,6 +15644,19 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(getDomainMappingOptionsModel.Name).To(Equal(core.StringPtr("www.example.com"))) Expect(getDomainMappingOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewGetFunctionOptions successfully`, func() { + // Construct an instance of the GetFunctionOptions model + projectID := "15314cc3-85b4-4338-903f-c28cdee6d005" + name := "my-function" + getFunctionOptionsModel := codeEngineService.NewGetFunctionOptions(projectID, name) + getFunctionOptionsModel.SetProjectID("15314cc3-85b4-4338-903f-c28cdee6d005") + getFunctionOptionsModel.SetName("my-function") + getFunctionOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(getFunctionOptionsModel).ToNot(BeNil()) + Expect(getFunctionOptionsModel.ProjectID).To(Equal(core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"))) + Expect(getFunctionOptionsModel.Name).To(Equal(core.StringPtr("my-function"))) + Expect(getFunctionOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) It(`Invoke NewGetJobOptions successfully`, func() { // Construct an instance of the GetJobOptions model projectID := "15314cc3-85b4-4338-903f-c28cdee6d005" @@ -13763,6 +15726,23 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(getSecretOptionsModel.Name).To(Equal(core.StringPtr("my-secret"))) Expect(getSecretOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewListAppInstancesOptions successfully`, func() { + // Construct an instance of the ListAppInstancesOptions model + projectID := "15314cc3-85b4-4338-903f-c28cdee6d005" + appName := "my-app" + listAppInstancesOptionsModel := codeEngineService.NewListAppInstancesOptions(projectID, appName) + listAppInstancesOptionsModel.SetProjectID("15314cc3-85b4-4338-903f-c28cdee6d005") + listAppInstancesOptionsModel.SetAppName("my-app") + listAppInstancesOptionsModel.SetLimit(int64(100)) + listAppInstancesOptionsModel.SetStart("testString") + listAppInstancesOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(listAppInstancesOptionsModel).ToNot(BeNil()) + Expect(listAppInstancesOptionsModel.ProjectID).To(Equal(core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"))) + Expect(listAppInstancesOptionsModel.AppName).To(Equal(core.StringPtr("my-app"))) + Expect(listAppInstancesOptionsModel.Limit).To(Equal(core.Int64Ptr(int64(100)))) + Expect(listAppInstancesOptionsModel.Start).To(Equal(core.StringPtr("testString"))) + Expect(listAppInstancesOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) It(`Invoke NewListAppRevisionsOptions successfully`, func() { // Construct an instance of the ListAppRevisionsOptions model projectID := "15314cc3-85b4-4338-903f-c28cdee6d005" @@ -13866,6 +15846,27 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(listDomainMappingsOptionsModel.Start).To(Equal(core.StringPtr("testString"))) Expect(listDomainMappingsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewListFunctionRuntimesOptions successfully`, func() { + // Construct an instance of the ListFunctionRuntimesOptions model + listFunctionRuntimesOptionsModel := codeEngineService.NewListFunctionRuntimesOptions() + listFunctionRuntimesOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(listFunctionRuntimesOptionsModel).ToNot(BeNil()) + Expect(listFunctionRuntimesOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) + It(`Invoke NewListFunctionsOptions successfully`, func() { + // Construct an instance of the ListFunctionsOptions model + projectID := "15314cc3-85b4-4338-903f-c28cdee6d005" + listFunctionsOptionsModel := codeEngineService.NewListFunctionsOptions(projectID) + listFunctionsOptionsModel.SetProjectID("15314cc3-85b4-4338-903f-c28cdee6d005") + listFunctionsOptionsModel.SetLimit(int64(100)) + listFunctionsOptionsModel.SetStart("testString") + listFunctionsOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(listFunctionsOptionsModel).ToNot(BeNil()) + Expect(listFunctionsOptionsModel.ProjectID).To(Equal(core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"))) + Expect(listFunctionsOptionsModel.Limit).To(Equal(core.Int64Ptr(int64(100)))) + Expect(listFunctionsOptionsModel.Start).To(Equal(core.StringPtr("testString"))) + Expect(listFunctionsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) It(`Invoke NewListJobRunsOptions successfully`, func() { // Construct an instance of the ListJobRunsOptions model projectID := "15314cc3-85b4-4338-903f-c28cdee6d005" @@ -14043,6 +16044,25 @@ var _ = Describe(`CodeEngineV2`, func() { Expect(updateDomainMappingOptionsModel.DomainMapping).To(Equal(map[string]interface{}{"anyKey": "anyValue"})) Expect(updateDomainMappingOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewUpdateFunctionOptions successfully`, func() { + // Construct an instance of the UpdateFunctionOptions model + projectID := "15314cc3-85b4-4338-903f-c28cdee6d005" + name := "my-function" + ifMatch := "testString" + function := map[string]interface{}{"anyKey": "anyValue"} + updateFunctionOptionsModel := codeEngineService.NewUpdateFunctionOptions(projectID, name, ifMatch, function) + updateFunctionOptionsModel.SetProjectID("15314cc3-85b4-4338-903f-c28cdee6d005") + updateFunctionOptionsModel.SetName("my-function") + updateFunctionOptionsModel.SetIfMatch("testString") + updateFunctionOptionsModel.SetFunction(map[string]interface{}{"anyKey": "anyValue"}) + updateFunctionOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(updateFunctionOptionsModel).ToNot(BeNil()) + Expect(updateFunctionOptionsModel.ProjectID).To(Equal(core.StringPtr("15314cc3-85b4-4338-903f-c28cdee6d005"))) + Expect(updateFunctionOptionsModel.Name).To(Equal(core.StringPtr("my-function"))) + Expect(updateFunctionOptionsModel.IfMatch).To(Equal(core.StringPtr("testString"))) + Expect(updateFunctionOptionsModel.Function).To(Equal(map[string]interface{}{"anyKey": "anyValue"})) + Expect(updateFunctionOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) It(`Invoke NewUpdateJobOptions successfully`, func() { // Construct an instance of the UpdateJobOptions model projectID := "15314cc3-85b4-4338-903f-c28cdee6d005" @@ -14101,6 +16121,494 @@ var _ = Describe(`CodeEngineV2`, func() { }) }) }) + Describe(`Model unmarshaling tests`, func() { + It(`Invoke UnmarshalAppPatch successfully`, func() { + // Construct an instance of the model. + model := new(codeenginev2.AppPatch) + model.ImagePort = core.Int64Ptr(int64(8080)) + model.ImageReference = core.StringPtr("icr.io/codeengine/helloworld") + model.ImageSecret = core.StringPtr("my-secret") + model.ManagedDomainMappings = core.StringPtr("local_public") + model.ProbeLiveness = nil + model.ProbeReadiness = nil + model.RunArguments = []string{"testString"} + model.RunAsUser = core.Int64Ptr(int64(1001)) + model.RunCommands = []string{"testString"} + model.RunEnvVariables = nil + model.RunServiceAccount = core.StringPtr("default") + model.RunVolumeMounts = nil + model.ScaleConcurrency = core.Int64Ptr(int64(100)) + model.ScaleConcurrencyTarget = core.Int64Ptr(int64(80)) + model.ScaleCpuLimit = core.StringPtr("1") + model.ScaleDownDelay = core.Int64Ptr(int64(300)) + model.ScaleEphemeralStorageLimit = core.StringPtr("4G") + model.ScaleInitialInstances = core.Int64Ptr(int64(1)) + model.ScaleMaxInstances = core.Int64Ptr(int64(10)) + model.ScaleMemoryLimit = core.StringPtr("4G") + model.ScaleMinInstances = core.Int64Ptr(int64(1)) + model.ScaleRequestTimeout = core.Int64Ptr(int64(300)) + + b, err := json.Marshal(model) + Expect(err).To(BeNil()) + + var raw map[string]json.RawMessage + err = json.Unmarshal(b, &raw) + Expect(err).To(BeNil()) + + var result *codeenginev2.AppPatch + err = codeenginev2.UnmarshalAppPatch(raw, &result) + Expect(err).To(BeNil()) + Expect(result).ToNot(BeNil()) + Expect(result).To(Equal(model)) + }) + It(`Invoke UnmarshalBuildPatch successfully`, func() { + // Construct an instance of the model. + model := new(codeenginev2.BuildPatch) + model.OutputImage = core.StringPtr("private.de.icr.io/icr_namespace/image-name") + model.OutputSecret = core.StringPtr("ce-auto-icr-private-eu-de") + model.SourceContextDir = core.StringPtr("some/subfolder") + model.SourceRevision = core.StringPtr("main") + model.SourceSecret = core.StringPtr("testString") + model.SourceType = core.StringPtr("git") + model.SourceURL = core.StringPtr("https://github.com/IBM/CodeEngine") + model.StrategySize = core.StringPtr("medium") + model.StrategySpecFile = core.StringPtr("Dockerfile") + model.StrategyType = core.StringPtr("dockerfile") + model.Timeout = core.Int64Ptr(int64(600)) + + b, err := json.Marshal(model) + Expect(err).To(BeNil()) + + var raw map[string]json.RawMessage + err = json.Unmarshal(b, &raw) + Expect(err).To(BeNil()) + + var result *codeenginev2.BuildPatch + err = codeenginev2.UnmarshalBuildPatch(raw, &result) + Expect(err).To(BeNil()) + Expect(result).ToNot(BeNil()) + Expect(result).To(Equal(model)) + }) + It(`Invoke UnmarshalComponentRef successfully`, func() { + // Construct an instance of the model. + model := new(codeenginev2.ComponentRef) + model.Name = core.StringPtr("my-app-1") + model.ResourceType = core.StringPtr("app_v2") + + b, err := json.Marshal(model) + Expect(err).To(BeNil()) + + var raw map[string]json.RawMessage + err = json.Unmarshal(b, &raw) + Expect(err).To(BeNil()) + + var result *codeenginev2.ComponentRef + err = codeenginev2.UnmarshalComponentRef(raw, &result) + Expect(err).To(BeNil()) + Expect(result).ToNot(BeNil()) + Expect(result).To(Equal(model)) + }) + It(`Invoke UnmarshalDomainMappingPatch successfully`, func() { + // Construct an instance of the model. + model := new(codeenginev2.DomainMappingPatch) + model.Component = nil + model.TlsSecret = core.StringPtr("my-tls-secret") + + b, err := json.Marshal(model) + Expect(err).To(BeNil()) + + var raw map[string]json.RawMessage + err = json.Unmarshal(b, &raw) + Expect(err).To(BeNil()) + + var result *codeenginev2.DomainMappingPatch + err = codeenginev2.UnmarshalDomainMappingPatch(raw, &result) + Expect(err).To(BeNil()) + Expect(result).ToNot(BeNil()) + Expect(result).To(Equal(model)) + }) + It(`Invoke UnmarshalEnvVarPrototype successfully`, func() { + // Construct an instance of the model. + model := new(codeenginev2.EnvVarPrototype) + model.Key = core.StringPtr("MY_VARIABLE") + model.Name = core.StringPtr("SOME") + model.Prefix = core.StringPtr("PREFIX_") + model.Reference = core.StringPtr("my-secret") + model.Type = core.StringPtr("literal") + model.Value = core.StringPtr("VALUE") + + b, err := json.Marshal(model) + Expect(err).To(BeNil()) + + var raw map[string]json.RawMessage + err = json.Unmarshal(b, &raw) + Expect(err).To(BeNil()) + + var result *codeenginev2.EnvVarPrototype + err = codeenginev2.UnmarshalEnvVarPrototype(raw, &result) + Expect(err).To(BeNil()) + Expect(result).ToNot(BeNil()) + Expect(result).To(Equal(model)) + }) + It(`Invoke UnmarshalFunctionPatch successfully`, func() { + // Construct an instance of the model. + model := new(codeenginev2.FunctionPatch) + model.CodeBinary = core.BoolPtr(false) + model.CodeMain = core.StringPtr("main") + model.CodeReference = core.StringPtr("data:text/plain;base64,") + model.CodeSecret = core.StringPtr("my-secret") + model.ManagedDomainMappings = core.StringPtr("local_public") + model.RunEnvVariables = nil + model.Runtime = core.StringPtr("nodejs-18") + model.ScaleConcurrency = core.Int64Ptr(int64(1)) + model.ScaleCpuLimit = core.StringPtr("1") + model.ScaleDownDelay = core.Int64Ptr(int64(300)) + model.ScaleMaxExecutionTime = core.Int64Ptr(int64(60)) + model.ScaleMemoryLimit = core.StringPtr("1G") + + b, err := json.Marshal(model) + Expect(err).To(BeNil()) + + var raw map[string]json.RawMessage + err = json.Unmarshal(b, &raw) + Expect(err).To(BeNil()) + + var result *codeenginev2.FunctionPatch + err = codeenginev2.UnmarshalFunctionPatch(raw, &result) + Expect(err).To(BeNil()) + Expect(result).ToNot(BeNil()) + Expect(result).To(Equal(model)) + }) + It(`Invoke UnmarshalJobPatch successfully`, func() { + // Construct an instance of the model. + model := new(codeenginev2.JobPatch) + model.ImageReference = core.StringPtr("icr.io/codeengine/helloworld") + model.ImageSecret = core.StringPtr("my-secret") + model.RunArguments = []string{"testString"} + model.RunAsUser = core.Int64Ptr(int64(1001)) + model.RunCommands = []string{"testString"} + model.RunEnvVariables = nil + model.RunMode = core.StringPtr("task") + model.RunServiceAccount = core.StringPtr("default") + model.RunVolumeMounts = nil + model.ScaleArraySpec = core.StringPtr("1-5,7-8,10") + model.ScaleCpuLimit = core.StringPtr("1") + model.ScaleEphemeralStorageLimit = core.StringPtr("4G") + model.ScaleMaxExecutionTime = core.Int64Ptr(int64(7200)) + model.ScaleMemoryLimit = core.StringPtr("4G") + model.ScaleRetryLimit = core.Int64Ptr(int64(3)) + + b, err := json.Marshal(model) + Expect(err).To(BeNil()) + + var raw map[string]json.RawMessage + err = json.Unmarshal(b, &raw) + Expect(err).To(BeNil()) + + var result *codeenginev2.JobPatch + err = codeenginev2.UnmarshalJobPatch(raw, &result) + Expect(err).To(BeNil()) + Expect(result).ToNot(BeNil()) + Expect(result).To(Equal(model)) + }) + It(`Invoke UnmarshalOperatorSecretPrototypeProps successfully`, func() { + // Construct an instance of the model. + model := new(codeenginev2.OperatorSecretPrototypeProps) + model.ResourceGroupIds = []string{"testString"} + model.Serviceid = nil + + b, err := json.Marshal(model) + Expect(err).To(BeNil()) + + var raw map[string]json.RawMessage + err = json.Unmarshal(b, &raw) + Expect(err).To(BeNil()) + + var result *codeenginev2.OperatorSecretPrototypeProps + err = codeenginev2.UnmarshalOperatorSecretPrototypeProps(raw, &result) + Expect(err).To(BeNil()) + Expect(result).ToNot(BeNil()) + Expect(result).To(Equal(model)) + }) + It(`Invoke UnmarshalProbePrototype successfully`, func() { + // Construct an instance of the model. + model := new(codeenginev2.ProbePrototype) + model.FailureThreshold = core.Int64Ptr(int64(5)) + model.InitialDelay = core.Int64Ptr(int64(5)) + model.Interval = core.Int64Ptr(int64(5)) + model.Path = core.StringPtr("testString") + model.Port = core.Int64Ptr(int64(8080)) + model.Timeout = core.Int64Ptr(int64(300)) + model.Type = core.StringPtr("tcp") + + b, err := json.Marshal(model) + Expect(err).To(BeNil()) + + var raw map[string]json.RawMessage + err = json.Unmarshal(b, &raw) + Expect(err).To(BeNil()) + + var result *codeenginev2.ProbePrototype + err = codeenginev2.UnmarshalProbePrototype(raw, &result) + Expect(err).To(BeNil()) + Expect(result).ToNot(BeNil()) + Expect(result).To(Equal(model)) + }) + It(`Invoke UnmarshalResourceKeyRefPrototype successfully`, func() { + // Construct an instance of the model. + model := new(codeenginev2.ResourceKeyRefPrototype) + model.ID = core.StringPtr("4e49b3e0-27a8-48d2-a784-c7ee48bb863b") + + b, err := json.Marshal(model) + Expect(err).To(BeNil()) + + var raw map[string]json.RawMessage + err = json.Unmarshal(b, &raw) + Expect(err).To(BeNil()) + + var result *codeenginev2.ResourceKeyRefPrototype + err = codeenginev2.UnmarshalResourceKeyRefPrototype(raw, &result) + Expect(err).To(BeNil()) + Expect(result).ToNot(BeNil()) + Expect(result).To(Equal(model)) + }) + It(`Invoke UnmarshalRoleRefPrototype successfully`, func() { + // Construct an instance of the model. + model := new(codeenginev2.RoleRefPrototype) + model.Crn = core.StringPtr("crn:v1:bluemix:public:iam::::serviceRole:Writer") + + b, err := json.Marshal(model) + Expect(err).To(BeNil()) + + var raw map[string]json.RawMessage + err = json.Unmarshal(b, &raw) + Expect(err).To(BeNil()) + + var result *codeenginev2.RoleRefPrototype + err = codeenginev2.UnmarshalRoleRefPrototype(raw, &result) + Expect(err).To(BeNil()) + Expect(result).ToNot(BeNil()) + Expect(result).To(Equal(model)) + }) + It(`Invoke UnmarshalSecretData successfully`, func() { + // Construct an instance of the model. + model := new(codeenginev2.SecretData) + model.SshKey = core.StringPtr("testString") + model.KnownHosts = core.StringPtr("testString") + model.Username = core.StringPtr("testString") + model.Password = core.StringPtr("testString") + model.Server = core.StringPtr("testString") + model.Email = core.StringPtr("testString") + model.TlsCert = core.StringPtr("testString") + model.TlsKey = core.StringPtr("testString") + + b, err := json.Marshal(model) + Expect(err).To(BeNil()) + + var raw map[string]json.RawMessage + err = json.Unmarshal(b, &raw) + Expect(err).To(BeNil()) + + var result *codeenginev2.SecretData + err = codeenginev2.UnmarshalSecretData(raw, &result) + Expect(err).To(BeNil()) + Expect(result).ToNot(BeNil()) + Expect(result).To(Equal(model)) + }) + It(`Invoke UnmarshalServiceAccessSecretPrototypeProps successfully`, func() { + // Construct an instance of the model. + model := new(codeenginev2.ServiceAccessSecretPrototypeProps) + model.ResourceKey = nil + model.Role = nil + model.ServiceInstance = nil + model.Serviceid = nil + + b, err := json.Marshal(model) + Expect(err).To(BeNil()) + + var raw map[string]json.RawMessage + err = json.Unmarshal(b, &raw) + Expect(err).To(BeNil()) + + var result *codeenginev2.ServiceAccessSecretPrototypeProps + err = codeenginev2.UnmarshalServiceAccessSecretPrototypeProps(raw, &result) + Expect(err).To(BeNil()) + Expect(result).ToNot(BeNil()) + Expect(result).To(Equal(model)) + }) + It(`Invoke UnmarshalServiceIDRef successfully`, func() { + // Construct an instance of the model. + model := new(codeenginev2.ServiceIDRef) + model.Crn = core.StringPtr("testString") + model.ID = core.StringPtr("ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637") + + b, err := json.Marshal(model) + Expect(err).To(BeNil()) + + var raw map[string]json.RawMessage + err = json.Unmarshal(b, &raw) + Expect(err).To(BeNil()) + + var result *codeenginev2.ServiceIDRef + err = codeenginev2.UnmarshalServiceIDRef(raw, &result) + Expect(err).To(BeNil()) + Expect(result).ToNot(BeNil()) + Expect(result).To(Equal(model)) + }) + It(`Invoke UnmarshalServiceIDRefPrototype successfully`, func() { + // Construct an instance of the model. + model := new(codeenginev2.ServiceIDRefPrototype) + model.ID = core.StringPtr("ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637") + + b, err := json.Marshal(model) + Expect(err).To(BeNil()) + + var raw map[string]json.RawMessage + err = json.Unmarshal(b, &raw) + Expect(err).To(BeNil()) + + var result *codeenginev2.ServiceIDRefPrototype + err = codeenginev2.UnmarshalServiceIDRefPrototype(raw, &result) + Expect(err).To(BeNil()) + Expect(result).ToNot(BeNil()) + Expect(result).To(Equal(model)) + }) + It(`Invoke UnmarshalServiceInstanceRefPrototype successfully`, func() { + // Construct an instance of the model. + model := new(codeenginev2.ServiceInstanceRefPrototype) + model.ID = core.StringPtr("4e49b3e0-27a8-48d2-a784-c7ee48bb863b") + + b, err := json.Marshal(model) + Expect(err).To(BeNil()) + + var raw map[string]json.RawMessage + err = json.Unmarshal(b, &raw) + Expect(err).To(BeNil()) + + var result *codeenginev2.ServiceInstanceRefPrototype + err = codeenginev2.UnmarshalServiceInstanceRefPrototype(raw, &result) + Expect(err).To(BeNil()) + Expect(result).ToNot(BeNil()) + Expect(result).To(Equal(model)) + }) + It(`Invoke UnmarshalVolumeMountPrototype successfully`, func() { + // Construct an instance of the model. + model := new(codeenginev2.VolumeMountPrototype) + model.MountPath = core.StringPtr("/app") + model.Name = core.StringPtr("codeengine-mount-b69u90") + model.Reference = core.StringPtr("my-secret") + model.Type = core.StringPtr("secret") + + b, err := json.Marshal(model) + Expect(err).To(BeNil()) + + var raw map[string]json.RawMessage + err = json.Unmarshal(b, &raw) + Expect(err).To(BeNil()) + + var result *codeenginev2.VolumeMountPrototype + err = codeenginev2.UnmarshalVolumeMountPrototype(raw, &result) + Expect(err).To(BeNil()) + Expect(result).ToNot(BeNil()) + Expect(result).To(Equal(model)) + }) + It(`Invoke UnmarshalSecretDataBasicAuthSecretData successfully`, func() { + // Construct an instance of the model. + model := new(codeenginev2.SecretDataBasicAuthSecretData) + model.Username = core.StringPtr("testString") + model.Password = core.StringPtr("testString") + + b, err := json.Marshal(model) + Expect(err).To(BeNil()) + + var raw map[string]json.RawMessage + err = json.Unmarshal(b, &raw) + Expect(err).To(BeNil()) + + var result *codeenginev2.SecretDataBasicAuthSecretData + err = codeenginev2.UnmarshalSecretDataBasicAuthSecretData(raw, &result) + Expect(err).To(BeNil()) + Expect(result).ToNot(BeNil()) + Expect(result).To(Equal(model)) + }) + It(`Invoke UnmarshalSecretDataGenericSecretData successfully`, func() { + // Construct an instance of the model. + model := new(codeenginev2.SecretDataGenericSecretData) + + b, err := json.Marshal(model) + Expect(err).To(BeNil()) + + var raw map[string]json.RawMessage + err = json.Unmarshal(b, &raw) + Expect(err).To(BeNil()) + + var result *codeenginev2.SecretDataGenericSecretData + err = codeenginev2.UnmarshalSecretDataGenericSecretData(raw, &result) + Expect(err).To(BeNil()) + Expect(result).ToNot(BeNil()) + Expect(result).To(Equal(model)) + }) + It(`Invoke UnmarshalSecretDataRegistrySecretData successfully`, func() { + // Construct an instance of the model. + model := new(codeenginev2.SecretDataRegistrySecretData) + model.Username = core.StringPtr("testString") + model.Password = core.StringPtr("testString") + model.Server = core.StringPtr("testString") + model.Email = core.StringPtr("testString") + + b, err := json.Marshal(model) + Expect(err).To(BeNil()) + + var raw map[string]json.RawMessage + err = json.Unmarshal(b, &raw) + Expect(err).To(BeNil()) + + var result *codeenginev2.SecretDataRegistrySecretData + err = codeenginev2.UnmarshalSecretDataRegistrySecretData(raw, &result) + Expect(err).To(BeNil()) + Expect(result).ToNot(BeNil()) + Expect(result).To(Equal(model)) + }) + It(`Invoke UnmarshalSecretDataSSHSecretData successfully`, func() { + // Construct an instance of the model. + model := new(codeenginev2.SecretDataSSHSecretData) + model.SshKey = core.StringPtr("testString") + model.KnownHosts = core.StringPtr("testString") + + b, err := json.Marshal(model) + Expect(err).To(BeNil()) + + var raw map[string]json.RawMessage + err = json.Unmarshal(b, &raw) + Expect(err).To(BeNil()) + + var result *codeenginev2.SecretDataSSHSecretData + err = codeenginev2.UnmarshalSecretDataSSHSecretData(raw, &result) + Expect(err).To(BeNil()) + Expect(result).ToNot(BeNil()) + Expect(result).To(Equal(model)) + }) + It(`Invoke UnmarshalSecretDataTLSSecretData successfully`, func() { + // Construct an instance of the model. + model := new(codeenginev2.SecretDataTLSSecretData) + model.TlsCert = core.StringPtr("testString") + model.TlsKey = core.StringPtr("testString") + + b, err := json.Marshal(model) + Expect(err).To(BeNil()) + + var raw map[string]json.RawMessage + err = json.Unmarshal(b, &raw) + Expect(err).To(BeNil()) + + var result *codeenginev2.SecretDataTLSSecretData + err = codeenginev2.UnmarshalSecretDataTLSSecretData(raw, &result) + Expect(err).To(BeNil()) + Expect(result).ToNot(BeNil()) + Expect(result).To(Equal(model)) + }) + }) + Describe(`Utility function tests`, func() { It(`Invoke CreateMockByteArray() successfully`, func() { mockByteArray := CreateMockByteArray("This is a test") @@ -14130,8 +16638,7 @@ var _ = Describe(`CodeEngineV2`, func() { // func CreateMockByteArray(mockData string) *[]byte { - ba := make([]byte, 0) - ba = append(ba, mockData...) + ba := []byte(mockData) return &ba } diff --git a/common/version.go b/common/version.go index 65e5781..ff06fc5 100644 --- a/common/version.go +++ b/common/version.go @@ -17,4 +17,4 @@ package common // Version of the SDK -const Version = "4.3.0" +const Version = "4.4.0" diff --git a/example/v2/README.md b/example/v2/README.md index f7273b5..74e6562 100644 --- a/example/v2/README.md +++ b/example/v2/README.md @@ -82,4 +82,16 @@ createDomainMappingOpts := codeEngineService.NewCreateDomainMappingOptions( *createdTLSSecret.Name, ) createdDomainMapping, _, err := codeEngineService.CreateDomainMapping(createDomainMappingOpts) +``` + +### Create a Code Engine function +```go +createFunctionOpts := codeEngineService.NewCreateFunctionOptions( + *createdProject.ID, + "data:text/plain;base64,YXN5bmMgZnVuY3Rpb24gbWFpbihwYXJhbXMpIHsKICByZXR1cm4gewogICAgICBzdGF0dXNDb2RlOiAyMDAsCiAgICAgIGhlYWRlcnM6IHsgJ0NvbnRlbnQtVHlwZSc6ICdhcHBsaWNhdGlvbi9qc29uJyB9LAogICAgICBib2R5OiBwYXJhbXMgfTsKfQptb2R1bGUuZXhwb3J0cy5tYWluID0gbWFpbjs=", + "my-function", + "nodejs-18", +) + +createdFunction, _, err := codeEngineService.CreateFunction(createFunctionOpts) ``` \ No newline at end of file diff --git a/example/v2/example_v2.go b/example/v2/example_v2.go index f9b1f48..c6ea774 100644 --- a/example/v2/example_v2.go +++ b/example/v2/example_v2.go @@ -549,6 +549,100 @@ func main() { } fmt.Printf("Deleted secret: '%d'\n", resp.StatusCode) + // List Function Runtimes + listFunctionRuntimesOptions := codeEngineService.NewListFunctionRuntimesOptions() + + functionRuntimeList, _, err := codeEngineService.ListFunctionRuntimes(listFunctionRuntimesOptions) + if err != nil { + fmt.Printf("ListFunctionRuntimes error: %s\n", err.Error()) + os.Exit(1) + return + } + fmt.Printf("Obtained Function runtime list '%d'", len(functionRuntimeList.FunctionRuntimes)) + + // List Functions + listFunctionsOptions := codeEngineService.NewListFunctionsOptions( + *createdProject.ID, + ) + + functionsList, _, err := codeEngineService.ListFunctions(listFunctionsOptions) + if err != nil { + fmt.Printf("ListFunctions error: %s\n", err.Error()) + os.Exit(1) + return + } + fmt.Printf("Obtained Functions list '%d'", len(functionsList.Functions)) + + // Create Function + createFunctionOptions := codeEngineService.NewCreateFunctionOptions( + *createdProject.ID, + "data:text/plain;base64,YXN5bmMgZnVuY3Rpb24gbWFpbihwYXJhbXMpIHsKICByZXR1cm4gewogICAgICBzdGF0dXNDb2RlOiAyMDAsCiAgICAgIGhlYWRlcnM6IHsgJ0NvbnRlbnQtVHlwZSc6ICdhcHBsaWNhdGlvbi9qc29uJyB9LAogICAgICBib2R5OiBwYXJhbXMgfTsKfQptb2R1bGUuZXhwb3J0cy5tYWluID0gbWFpbjs=", + "my-function", + "nodejs-18", + ) + + createdFunction, _, err := codeEngineService.CreateFunction(createFunctionOptions) + if err != nil { + fmt.Printf("CreateFunction error: %s\n", err.Error()) + os.Exit(1) + return + } + fmt.Printf("Created Function '%s'\n", *createdFunction.Name) + + //Get Function + getFunctionOptions := codeEngineService.NewGetFunctionOptions( + *createdProject.ID, + "my-function", + ) + + obtainedFunction, _, err := codeEngineService.GetFunction(getFunctionOptions) + if err != nil { + fmt.Printf("GetFunction error: %s\n", err.Error()) + os.Exit(1) + return + } + fmt.Printf("Obtained Function '%s'\n", *obtainedFunction.Name) + + // Update Function + functionUpdateModel := &codeenginev2.FunctionPatch{ + ScaleMaxExecutionTime: core.Int64Ptr(30), + } + updateFunctionAsPatch, err := functionUpdateModel.AsPatch() + if err != nil { + fmt.Printf("functionUpdateModel.AsPatch error: %s\n", err.Error()) + os.Exit(1) + return + } + + updateFunctionOptions := codeEngineService.NewUpdateFunctionOptions( + *createdProject.ID, + "my-function", + "*", + updateFunctionAsPatch, + ) + updatedFunction, _, err := codeEngineService.UpdateFunction(updateFunctionOptions) + if err != nil { + fmt.Printf("UpdateFunction error: %s\n", err.Error()) + os.Exit(1) + return + } + fmt.Printf("Updated Function '%s'\n", *updatedFunction.Name) + + // Delete Function + deleteFunctionOptions := codeEngineService.NewDeleteFunctionOptions( + *createdProject.ID, + "my-function", + ) + + resp, err = codeEngineService.DeleteFunction(deleteFunctionOptions) + if err != nil { + fmt.Printf("DeleteFunction error: %s (transaction-id: '%s')\n", err.Error(), resp.Headers.Get("X-Transaction-Id")) + os.Exit(1) + return + } + fmt.Printf("Deleted Function: '%d'\n", resp.StatusCode) + + // Delete Project deleteProjectOptions := codeEngineService.NewDeleteProjectOptions( *createdProject.ID, )