From e9fc330fb54d3df72805d6adb3babdb0ed0130a7 Mon Sep 17 00:00:00 2001 From: Cleve Littlefield Date: Wed, 22 May 2024 18:00:59 -0700 Subject: [PATCH] Initial golang and typescript SDK and templates (#271) * Initial golang and typescript SDK and templates * Some fixes to tests * fix esc package name for go sdk * add files * Add copyright to go sdk * pr comments * More copyrights * Fix prettier issues * Add changelog * Add support for pulumi source and user agent --- .gitignore | 3 + .vscode/settings.json | 7 + CHANGELOG_PENDING.md | 3 + Makefile | 8 + openapitools.json | 7 + sdk/esc-api.rest | 46 + sdk/go/.openapi-generator-ignore | 31 + sdk/go/.openapi-generator/FILES | 27 + sdk/go/.openapi-generator/VERSION | 1 + sdk/go/api_esc.go | 2095 +++++++++++++++++ sdk/go/api_esc_extensions.go | 285 +++ sdk/go/api_esc_test.go | 208 ++ sdk/go/client.go | 673 ++++++ sdk/go/configuration.go | 219 ++ sdk/go/go.mod | 13 + sdk/go/go.sum | 14 + sdk/go/model_access.go | 163 ++ sdk/go/model_accessor.go | 223 ++ sdk/go/model_check_environment.go | 271 +++ sdk/go/model_environment.go | 236 ++ sdk/go/model_environment_definition.go | 163 ++ sdk/go/model_environment_definition_values.go | 230 ++ sdk/go/model_environment_diagnostic.go | 243 ++ sdk/go/model_environment_diagnostics.go | 127 + sdk/go/model_error.go | 187 ++ sdk/go/model_evaluated_execution_context.go | 164 ++ sdk/go/model_expr.go | 489 ++++ sdk/go/model_expr_builtin.go | 268 +++ sdk/go/model_interpolation.go | 195 ++ sdk/go/model_open_environment.go | 196 ++ sdk/go/model_org_environment.go | 251 ++ sdk/go/model_org_environments.go | 163 ++ sdk/go/model_pos.go | 218 ++ sdk/go/model_property_accessor.go | 259 ++ sdk/go/model_range.go | 215 ++ sdk/go/model_reference.go | 159 ++ sdk/go/model_trace.go | 163 ++ sdk/go/model_value.go | 263 +++ sdk/go/response.go | 48 + sdk/go/utils.go | 348 +++ sdk/swagger.yaml | 724 ++++++ sdk/templates/go/README.mustache | 235 ++ sdk/templates/go/api.mustache | 446 ++++ sdk/templates/go/api_doc.mustache | 92 + sdk/templates/go/api_test.mustache | 54 + sdk/templates/go/client.mustache | 764 ++++++ sdk/templates/go/configuration.mustache | 332 +++ sdk/templates/go/go.mod.mustache | 13 + sdk/templates/go/go.sum.mustache | 15 + sdk/templates/go/model.mustache | 20 + sdk/templates/go/model_anyof.mustache | 76 + sdk/templates/go/model_doc.mustache | 97 + sdk/templates/go/model_enum.mustache | 101 + sdk/templates/go/model_oneof.mustache | 144 ++ sdk/templates/go/model_simple.mustache | 519 ++++ sdk/templates/go/nullable_model.mustache | 35 + sdk/templates/go/openapi.mustache | 1 + sdk/templates/go/partial_header.mustache | 19 + sdk/templates/go/response.mustache | 38 + sdk/templates/go/signing.mustache | 453 ++++ sdk/templates/go/utils.mustache | 338 +++ sdk/templates/openapitools.json | 7 + sdk/templates/typescript/README.mustache | 46 + sdk/templates/typescript/api.mustache | 33 + sdk/templates/typescript/apiInner.mustache | 452 ++++ sdk/templates/typescript/baseApi.mustache | 116 + sdk/templates/typescript/common.mustache | 142 ++ .../typescript/configuration.mustache | 99 + sdk/templates/typescript/git_push.sh.mustache | 57 + sdk/templates/typescript/gitignore | 4 + sdk/templates/typescript/index.mustache | 7 + sdk/templates/typescript/licenseInfo.mustache | 13 + sdk/templates/typescript/model.mustache | 16 + sdk/templates/typescript/modelAllOf.mustache | 6 + sdk/templates/typescript/modelEnum.mustache | 17 + .../typescript/modelGeneric.mustache | 62 + sdk/templates/typescript/modelIndex.mustache | 2 + .../typescript/modelObjectEnum.mustache | 14 + sdk/templates/typescript/modelOneOf.mustache | 15 + .../typescript/modelStringEnum.mustache | 12 + sdk/templates/typescript/npmignore | 1 + sdk/templates/typescript/package.mustache | 40 + .../typescript/tsconfig.esm.mustache | 7 + sdk/templates/typescript/tsconfig.mustache | 26 + sdk/typescript/.eslintrc.js | 25 + sdk/typescript/esc/index.ts | 262 +++ sdk/typescript/esc/raw/.npmignore | 1 + .../esc/raw/.openapi-generator-ignore | 28 + .../esc/raw/.openapi-generator/FILES | 7 + .../esc/raw/.openapi-generator/VERSION | 1 + sdk/typescript/esc/raw/api.ts | 1574 +++++++++++++ sdk/typescript/esc/raw/base.ts | 88 + sdk/typescript/esc/raw/common.ts | 152 ++ sdk/typescript/esc/raw/configuration.ts | 112 + sdk/typescript/esc/raw/index.ts | 20 + sdk/typescript/esc/raw/tsconfig.json | 21 + sdk/typescript/jasmine.json | 13 + sdk/typescript/package.json | 46 + sdk/typescript/test/client.spec.ts | 161 ++ sdk/typescript/tsconfig.json | 23 + sdk/typescript/yarn.lock | 1456 ++++++++++++ 101 files changed, 18582 insertions(+) create mode 100644 .vscode/settings.json create mode 100644 openapitools.json create mode 100644 sdk/esc-api.rest create mode 100644 sdk/go/.openapi-generator-ignore create mode 100644 sdk/go/.openapi-generator/FILES create mode 100644 sdk/go/.openapi-generator/VERSION create mode 100644 sdk/go/api_esc.go create mode 100644 sdk/go/api_esc_extensions.go create mode 100644 sdk/go/api_esc_test.go create mode 100644 sdk/go/client.go create mode 100644 sdk/go/configuration.go create mode 100644 sdk/go/go.mod create mode 100644 sdk/go/go.sum create mode 100644 sdk/go/model_access.go create mode 100644 sdk/go/model_accessor.go create mode 100644 sdk/go/model_check_environment.go create mode 100644 sdk/go/model_environment.go create mode 100644 sdk/go/model_environment_definition.go create mode 100644 sdk/go/model_environment_definition_values.go create mode 100644 sdk/go/model_environment_diagnostic.go create mode 100644 sdk/go/model_environment_diagnostics.go create mode 100644 sdk/go/model_error.go create mode 100644 sdk/go/model_evaluated_execution_context.go create mode 100644 sdk/go/model_expr.go create mode 100644 sdk/go/model_expr_builtin.go create mode 100644 sdk/go/model_interpolation.go create mode 100644 sdk/go/model_open_environment.go create mode 100644 sdk/go/model_org_environment.go create mode 100644 sdk/go/model_org_environments.go create mode 100644 sdk/go/model_pos.go create mode 100644 sdk/go/model_property_accessor.go create mode 100644 sdk/go/model_range.go create mode 100644 sdk/go/model_reference.go create mode 100644 sdk/go/model_trace.go create mode 100644 sdk/go/model_value.go create mode 100644 sdk/go/response.go create mode 100644 sdk/go/utils.go create mode 100644 sdk/swagger.yaml create mode 100644 sdk/templates/go/README.mustache create mode 100644 sdk/templates/go/api.mustache create mode 100644 sdk/templates/go/api_doc.mustache create mode 100644 sdk/templates/go/api_test.mustache create mode 100644 sdk/templates/go/client.mustache create mode 100644 sdk/templates/go/configuration.mustache create mode 100644 sdk/templates/go/go.mod.mustache create mode 100644 sdk/templates/go/go.sum.mustache create mode 100644 sdk/templates/go/model.mustache create mode 100644 sdk/templates/go/model_anyof.mustache create mode 100644 sdk/templates/go/model_doc.mustache create mode 100644 sdk/templates/go/model_enum.mustache create mode 100644 sdk/templates/go/model_oneof.mustache create mode 100644 sdk/templates/go/model_simple.mustache create mode 100644 sdk/templates/go/nullable_model.mustache create mode 100644 sdk/templates/go/openapi.mustache create mode 100644 sdk/templates/go/partial_header.mustache create mode 100644 sdk/templates/go/response.mustache create mode 100644 sdk/templates/go/signing.mustache create mode 100644 sdk/templates/go/utils.mustache create mode 100644 sdk/templates/openapitools.json create mode 100644 sdk/templates/typescript/README.mustache create mode 100644 sdk/templates/typescript/api.mustache create mode 100644 sdk/templates/typescript/apiInner.mustache create mode 100644 sdk/templates/typescript/baseApi.mustache create mode 100644 sdk/templates/typescript/common.mustache create mode 100644 sdk/templates/typescript/configuration.mustache create mode 100644 sdk/templates/typescript/git_push.sh.mustache create mode 100644 sdk/templates/typescript/gitignore create mode 100644 sdk/templates/typescript/index.mustache create mode 100644 sdk/templates/typescript/licenseInfo.mustache create mode 100644 sdk/templates/typescript/model.mustache create mode 100644 sdk/templates/typescript/modelAllOf.mustache create mode 100644 sdk/templates/typescript/modelEnum.mustache create mode 100644 sdk/templates/typescript/modelGeneric.mustache create mode 100644 sdk/templates/typescript/modelIndex.mustache create mode 100644 sdk/templates/typescript/modelObjectEnum.mustache create mode 100644 sdk/templates/typescript/modelOneOf.mustache create mode 100644 sdk/templates/typescript/modelStringEnum.mustache create mode 100644 sdk/templates/typescript/npmignore create mode 100644 sdk/templates/typescript/package.mustache create mode 100644 sdk/templates/typescript/tsconfig.esm.mustache create mode 100644 sdk/templates/typescript/tsconfig.mustache create mode 100644 sdk/typescript/.eslintrc.js create mode 100644 sdk/typescript/esc/index.ts create mode 100644 sdk/typescript/esc/raw/.npmignore create mode 100644 sdk/typescript/esc/raw/.openapi-generator-ignore create mode 100644 sdk/typescript/esc/raw/.openapi-generator/FILES create mode 100644 sdk/typescript/esc/raw/.openapi-generator/VERSION create mode 100644 sdk/typescript/esc/raw/api.ts create mode 100644 sdk/typescript/esc/raw/base.ts create mode 100644 sdk/typescript/esc/raw/common.ts create mode 100644 sdk/typescript/esc/raw/configuration.ts create mode 100644 sdk/typescript/esc/raw/index.ts create mode 100644 sdk/typescript/esc/raw/tsconfig.json create mode 100644 sdk/typescript/jasmine.json create mode 100644 sdk/typescript/package.json create mode 100644 sdk/typescript/test/client.spec.ts create mode 100644 sdk/typescript/tsconfig.json create mode 100644 sdk/typescript/yarn.lock diff --git a/.gitignore b/.gitignore index 2136eeaa..12b7ecb8 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,6 @@ go.work .history/ # Built Visual Studio Code Extensions *.vsix + +sdk/typescript/node_modules/* +sdk/typescript/bin/* \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..d4aeecb4 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "jasmineExplorer.nodeArgv": [ + "-r", + "ts-node/register" + ], + "jasmineExplorer.config": "sdk/typescript/jasmine.json", +} \ No newline at end of file diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index 404f201f..9304a2cd 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -21,6 +21,9 @@ - Add support for rolling back to a specific version of an environment. [#305](https://github.com/pulumi/esc/pull/305) +- Add a new ESC SDK for Go and Typescript + [#271](https://github.com/pulumi/esc/pull/271) + ### Bug Fixes - Ensure that redacted output is flushed in `esc run` diff --git a/Makefile b/Makefile index 0bc59af0..6a2a2800 100644 --- a/Makefile +++ b/Makefile @@ -41,3 +41,11 @@ test:: build test_cover:: build ${GO} test --timeout 30m -count 1 -coverpkg=github.com/pulumi/esc/... -race -coverprofile=coverage.out -parallel ${CONCURRENCY} ./... + +.PHONY: generate_go_client_sdk +generate_go_client_sdk: + GO_POST_PROCESS_FILE="/usr/local/bin/gofmt -w" openapi-generator-cli generate -i ./sdk/swagger.yaml -p packageName=esc_sdk,withGoMod=false,isGoSubmodule=true,userAgent=esc-sdk/go/${VERSION} -t ./sdk/templates/go -g go -o ./sdk/go --git-repo-id esc --git-user-id pulumi + +.PHONY: generate_ts_client_sdk +generate_ts_client_sdk: + TS_POST_PROCESS_FILE="/usr/local/bin/prettier --write" openapi-generator-cli generate -i ./sdk/swagger.yaml -p npmName=@pulumi/esc-sdk,userAgent=esc-sdk/ts/${VERSION} -t ./sdk/templates/typescript --enable-post-process-file -g typescript-axios -o ./sdk/typescript/esc/raw --git-repo-id esc --git-user-id pulumi \ No newline at end of file diff --git a/openapitools.json b/openapitools.json new file mode 100644 index 00000000..55716882 --- /dev/null +++ b/openapitools.json @@ -0,0 +1,7 @@ +{ + "$schema": "./node_modules/@openapitools/openapi-generator-cli/config.schema.json", + "spaces": 2, + "generator-cli": { + "version": "7.4.0" + } +} diff --git a/sdk/esc-api.rest b/sdk/esc-api.rest new file mode 100644 index 00000000..0d90becb --- /dev/null +++ b/sdk/esc-api.rest @@ -0,0 +1,46 @@ +@token = {{$processEnv PULUMI_ACCESS_TOKEN}} +@organization = {{$processEnv PULUMI_ORG}} + +GET https://api.pulumi.com/api/preview/environments/{{organization}} HTTP/1.1 +Authorization: token {{token}} +### + +GET https://api.pulumi.com/api/preview/environments/{{organization}}/sdk-test HTTP/1.1 +Authorization: token {{token}} + +### +# @name openAPI +POST https://api.pulumi.com/api/preview/environments/{{organization}}/sdk-test/open?duration=1h HTTP/1.1 +Authorization: token {{token}} + +@openId = {{openAPI.response.body.id}} +### +GET https://api.pulumi.com/api/preview/environments/{{organization}}/sdk-test/open/{{openId}} HTTP/1.1 +Authorization: token {{token}} + +### + +HEAD https://api.pulumi.com/api/preview/environments/{{organization}}/sdk-test HTTP/1.1 +Authorization: token {{token}} + +### + +POST https://api.pulumi.com/api/preview/environments/{{organization}}/sdk-test HTTP/1.1 +Authorization: token {{token}} +Content-Type: application/yaml + +### + +PATCH https://api.pulumi.com/api/preview/environments/{{organization}}/sdk-test HTTP/1.1 +Authorization: token {{token}} +Content-Type: application/yaml + +values: + foo: bar + baz: auto + test: 123 + +### + +DELETE https://api.pulumi.com/api/preview/environments/{{organization}}/sdk-test HTTP/1.1 +Authorization: token {{token}} \ No newline at end of file diff --git a/sdk/go/.openapi-generator-ignore b/sdk/go/.openapi-generator-ignore new file mode 100644 index 00000000..22b2a9d7 --- /dev/null +++ b/sdk/go/.openapi-generator-ignore @@ -0,0 +1,31 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md + +git_push.sh +.travis.yml +.gitignore +README.md +test/* +docs/* +api/* \ No newline at end of file diff --git a/sdk/go/.openapi-generator/FILES b/sdk/go/.openapi-generator/FILES new file mode 100644 index 00000000..bacd402f --- /dev/null +++ b/sdk/go/.openapi-generator/FILES @@ -0,0 +1,27 @@ +api_esc.go +client.go +configuration.go +model_access.go +model_accessor.go +model_check_environment.go +model_environment.go +model_environment_definition.go +model_environment_definition_values.go +model_environment_diagnostic.go +model_environment_diagnostics.go +model_error.go +model_evaluated_execution_context.go +model_expr.go +model_expr_builtin.go +model_interpolation.go +model_open_environment.go +model_org_environment.go +model_org_environments.go +model_pos.go +model_property_accessor.go +model_range.go +model_reference.go +model_trace.go +model_value.go +response.go +utils.go diff --git a/sdk/go/.openapi-generator/VERSION b/sdk/go/.openapi-generator/VERSION new file mode 100644 index 00000000..ba7f754d --- /dev/null +++ b/sdk/go/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.4.0 diff --git a/sdk/go/api_esc.go b/sdk/go/api_esc.go new file mode 100644 index 00000000..2d2d1447 --- /dev/null +++ b/sdk/go/api_esc.go @@ -0,0 +1,2095 @@ +// Copyright 2024, Pulumi Corporation. All rights reserved. +/* +ESC (Environments, Secrets, Config) API + +Pulumi ESC allows you to compose and manage hierarchical collections of configuration and secrets and consume them in various ways. + +API version: 0.1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package esc_sdk + +import ( + "bytes" + "context" + "io" + "net/http" + "net/url" + "strings" +) + + +// EscAPIService EscAPI service +type EscAPIService service + +type ApiCheckEnvironmentYamlRequest struct { + ctx context.Context + ApiService *EscAPIService + orgName string + body *string +} + +// Environment Yaml content +func (r ApiCheckEnvironmentYamlRequest) Body(body string) ApiCheckEnvironmentYamlRequest { + r.body = &body + return r +} + +func (r ApiCheckEnvironmentYamlRequest) Execute() (*CheckEnvironment, *http.Response, error) { + return r.ApiService.CheckEnvironmentYamlExecute(r) +} + +/* +CheckEnvironmentYaml Checks an environment definition for errors + +Checks an environment definition for errors + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param orgName Organization name + @return ApiCheckEnvironmentYamlRequest +*/ +func (a *EscAPIService) CheckEnvironmentYaml(ctx context.Context, orgName string) ApiCheckEnvironmentYamlRequest { + return ApiCheckEnvironmentYamlRequest{ + ApiService: a, + ctx: ctx, + orgName: orgName, + } +} + +// Execute executes the request +// @return CheckEnvironment +func (a *EscAPIService) CheckEnvironmentYamlExecute(r ApiCheckEnvironmentYamlRequest) (*CheckEnvironment, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *CheckEnvironment + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EscAPIService.CheckEnvironmentYaml") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/environments/{orgName}/yaml/check" + localVarPath = strings.Replace(localVarPath, "{"+"orgName"+"}", url.PathEscape(parameterValueToString(r.orgName, "orgName")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if strlen(r.orgName) < 3 { + return localVarReturnValue, nil, reportError("orgName must have at least 3 elements") + } + if strlen(r.orgName) > 40 { + return localVarReturnValue, nil, reportError("orgName must have less than 40 elements") + } + if r.body == nil { + return localVarReturnValue, nil, reportError("body is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/x-yaml"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + parameterAddToHeaderOrQuery(localVarHeaderParams, "X-Pulumi-Source", "esc-sdk", "") + parameterAddToHeaderOrQuery(localVarHeaderParams, "User-Agent", "esc-sdk/0.8.3-dev.0", "") + // body params + localVarPostBody = r.body + if r.ctx != nil { + // API Key Authentication + if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { + if apiKey, ok := auth["Authorization"]; ok { + var key string + if apiKey.Prefix != "" { + key = apiKey.Prefix + " " + apiKey.Key + } else { + key = apiKey.Key + } + localVarHeaderParams["Authorization"] = key + } + } + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v CheckEnvironment + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type ApiCreateEnvironmentRequest struct { + ctx context.Context + ApiService *EscAPIService + orgName string + envName string +} + +func (r ApiCreateEnvironmentRequest) Execute() (*Error, *http.Response, error) { + return r.ApiService.CreateEnvironmentExecute(r) +} + +/* +CreateEnvironment Create a new environment + +Creates an environment in the given org with the given name. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param orgName Organization name + @param envName Environment name + @return ApiCreateEnvironmentRequest +*/ +func (a *EscAPIService) CreateEnvironment(ctx context.Context, orgName string, envName string) ApiCreateEnvironmentRequest { + return ApiCreateEnvironmentRequest{ + ApiService: a, + ctx: ctx, + orgName: orgName, + envName: envName, + } +} + +// Execute executes the request +// @return Error +func (a *EscAPIService) CreateEnvironmentExecute(r ApiCreateEnvironmentRequest) (*Error, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *Error + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EscAPIService.CreateEnvironment") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/environments/{orgName}/{envName}" + localVarPath = strings.Replace(localVarPath, "{"+"orgName"+"}", url.PathEscape(parameterValueToString(r.orgName, "orgName")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"envName"+"}", url.PathEscape(parameterValueToString(r.envName, "envName")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if strlen(r.orgName) < 3 { + return localVarReturnValue, nil, reportError("orgName must have at least 3 elements") + } + if strlen(r.orgName) > 40 { + return localVarReturnValue, nil, reportError("orgName must have less than 40 elements") + } + if strlen(r.envName) < 1 { + return localVarReturnValue, nil, reportError("envName must have at least 1 elements") + } + if strlen(r.envName) > 100 { + return localVarReturnValue, nil, reportError("envName must have less than 100 elements") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + parameterAddToHeaderOrQuery(localVarHeaderParams, "X-Pulumi-Source", "esc-sdk", "") + parameterAddToHeaderOrQuery(localVarHeaderParams, "User-Agent", "esc-sdk/0.8.3-dev.0", "") + if r.ctx != nil { + // API Key Authentication + if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { + if apiKey, ok := auth["Authorization"]; ok { + var key string + if apiKey.Prefix != "" { + key = apiKey.Prefix + " " + apiKey.Key + } else { + key = apiKey.Key + } + localVarHeaderParams["Authorization"] = key + } + } + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 409 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type ApiDecryptEnvironmentRequest struct { + ctx context.Context + ApiService *EscAPIService + orgName string + envName string +} + +func (r ApiDecryptEnvironmentRequest) Execute() (*EnvironmentDefinition, *http.Response, error) { + return r.ApiService.DecryptEnvironmentExecute(r) +} + +/* +DecryptEnvironment Reads the definition for the given environment with static secrets in plaintext + +Reads the definition for the given environment with static secrets in plaintext + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param orgName Organization name + @param envName Environment name + @return ApiDecryptEnvironmentRequest +*/ +func (a *EscAPIService) DecryptEnvironment(ctx context.Context, orgName string, envName string) ApiDecryptEnvironmentRequest { + return ApiDecryptEnvironmentRequest{ + ApiService: a, + ctx: ctx, + orgName: orgName, + envName: envName, + } +} + +// Execute executes the request +// @return EnvironmentDefinition +func (a *EscAPIService) DecryptEnvironmentExecute(r ApiDecryptEnvironmentRequest) (*EnvironmentDefinition, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *EnvironmentDefinition + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EscAPIService.DecryptEnvironment") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/environments/{orgName}/{envName}/decrypt" + localVarPath = strings.Replace(localVarPath, "{"+"orgName"+"}", url.PathEscape(parameterValueToString(r.orgName, "orgName")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"envName"+"}", url.PathEscape(parameterValueToString(r.envName, "envName")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if strlen(r.orgName) < 3 { + return localVarReturnValue, nil, reportError("orgName must have at least 3 elements") + } + if strlen(r.orgName) > 40 { + return localVarReturnValue, nil, reportError("orgName must have less than 40 elements") + } + if strlen(r.envName) < 1 { + return localVarReturnValue, nil, reportError("envName must have at least 1 elements") + } + if strlen(r.envName) > 100 { + return localVarReturnValue, nil, reportError("envName must have less than 100 elements") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/x-yaml", "application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + parameterAddToHeaderOrQuery(localVarHeaderParams, "X-Pulumi-Source", "esc-sdk", "") + parameterAddToHeaderOrQuery(localVarHeaderParams, "User-Agent", "esc-sdk/0.8.3-dev.0", "") + if r.ctx != nil { + // API Key Authentication + if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { + if apiKey, ok := auth["Authorization"]; ok { + var key string + if apiKey.Prefix != "" { + key = apiKey.Prefix + " " + apiKey.Key + } else { + key = apiKey.Key + } + localVarHeaderParams["Authorization"] = key + } + } + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type ApiDeleteEnvironmentRequest struct { + ctx context.Context + ApiService *EscAPIService + orgName string + envName string +} + +func (r ApiDeleteEnvironmentRequest) Execute() (*Error, *http.Response, error) { + return r.ApiService.DeleteEnvironmentExecute(r) +} + +/* +DeleteEnvironment Delete an environment + +Delete an environment + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param orgName Organization name + @param envName Environment name + @return ApiDeleteEnvironmentRequest +*/ +func (a *EscAPIService) DeleteEnvironment(ctx context.Context, orgName string, envName string) ApiDeleteEnvironmentRequest { + return ApiDeleteEnvironmentRequest{ + ApiService: a, + ctx: ctx, + orgName: orgName, + envName: envName, + } +} + +// Execute executes the request +// @return Error +func (a *EscAPIService) DeleteEnvironmentExecute(r ApiDeleteEnvironmentRequest) (*Error, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodDelete + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *Error + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EscAPIService.DeleteEnvironment") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/environments/{orgName}/{envName}" + localVarPath = strings.Replace(localVarPath, "{"+"orgName"+"}", url.PathEscape(parameterValueToString(r.orgName, "orgName")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"envName"+"}", url.PathEscape(parameterValueToString(r.envName, "envName")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if strlen(r.orgName) < 3 { + return localVarReturnValue, nil, reportError("orgName must have at least 3 elements") + } + if strlen(r.orgName) > 40 { + return localVarReturnValue, nil, reportError("orgName must have less than 40 elements") + } + if strlen(r.envName) < 1 { + return localVarReturnValue, nil, reportError("envName must have at least 1 elements") + } + if strlen(r.envName) > 100 { + return localVarReturnValue, nil, reportError("envName must have less than 100 elements") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + parameterAddToHeaderOrQuery(localVarHeaderParams, "X-Pulumi-Source", "esc-sdk", "") + parameterAddToHeaderOrQuery(localVarHeaderParams, "User-Agent", "esc-sdk/0.8.3-dev.0", "") + if r.ctx != nil { + // API Key Authentication + if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { + if apiKey, ok := auth["Authorization"]; ok { + var key string + if apiKey.Prefix != "" { + key = apiKey.Prefix + " " + apiKey.Key + } else { + key = apiKey.Key + } + localVarHeaderParams["Authorization"] = key + } + } + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type ApiGetEnvironmentRequest struct { + ctx context.Context + ApiService *EscAPIService + orgName string + envName string +} + +func (r ApiGetEnvironmentRequest) Execute() (*EnvironmentDefinition, *http.Response, error) { + return r.ApiService.GetEnvironmentExecute(r) +} + +/* +GetEnvironment Read an environment + +Read an environment + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param orgName Organization name + @param envName Environment name + @return ApiGetEnvironmentRequest +*/ +func (a *EscAPIService) GetEnvironment(ctx context.Context, orgName string, envName string) ApiGetEnvironmentRequest { + return ApiGetEnvironmentRequest{ + ApiService: a, + ctx: ctx, + orgName: orgName, + envName: envName, + } +} + +// Execute executes the request +// @return EnvironmentDefinition +func (a *EscAPIService) GetEnvironmentExecute(r ApiGetEnvironmentRequest) (*EnvironmentDefinition, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *EnvironmentDefinition + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EscAPIService.GetEnvironment") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/environments/{orgName}/{envName}" + localVarPath = strings.Replace(localVarPath, "{"+"orgName"+"}", url.PathEscape(parameterValueToString(r.orgName, "orgName")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"envName"+"}", url.PathEscape(parameterValueToString(r.envName, "envName")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if strlen(r.orgName) < 3 { + return localVarReturnValue, nil, reportError("orgName must have at least 3 elements") + } + if strlen(r.orgName) > 40 { + return localVarReturnValue, nil, reportError("orgName must have less than 40 elements") + } + if strlen(r.envName) < 1 { + return localVarReturnValue, nil, reportError("envName must have at least 1 elements") + } + if strlen(r.envName) > 100 { + return localVarReturnValue, nil, reportError("envName must have less than 100 elements") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/x-yaml", "application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + parameterAddToHeaderOrQuery(localVarHeaderParams, "X-Pulumi-Source", "esc-sdk", "") + parameterAddToHeaderOrQuery(localVarHeaderParams, "User-Agent", "esc-sdk/0.8.3-dev.0", "") + if r.ctx != nil { + // API Key Authentication + if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { + if apiKey, ok := auth["Authorization"]; ok { + var key string + if apiKey.Prefix != "" { + key = apiKey.Prefix + " " + apiKey.Key + } else { + key = apiKey.Key + } + localVarHeaderParams["Authorization"] = key + } + } + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type ApiGetEnvironmentETagRequest struct { + ctx context.Context + ApiService *EscAPIService + orgName string + envName string +} + +func (r ApiGetEnvironmentETagRequest) Execute() (*http.Response, error) { + return r.ApiService.GetEnvironmentETagExecute(r) +} + +/* +GetEnvironmentETag Return an Environment ETag + +Returns the ETag for the given environment if it exists. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param orgName Organization name + @param envName Environment name + @return ApiGetEnvironmentETagRequest +*/ +func (a *EscAPIService) GetEnvironmentETag(ctx context.Context, orgName string, envName string) ApiGetEnvironmentETagRequest { + return ApiGetEnvironmentETagRequest{ + ApiService: a, + ctx: ctx, + orgName: orgName, + envName: envName, + } +} + +// Execute executes the request +func (a *EscAPIService) GetEnvironmentETagExecute(r ApiGetEnvironmentETagRequest) (*http.Response, error) { + var ( + localVarHTTPMethod = http.MethodHead + localVarPostBody interface{} + formFiles []formFile + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EscAPIService.GetEnvironmentETag") + if err != nil { + return nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/environments/{orgName}/{envName}" + localVarPath = strings.Replace(localVarPath, "{"+"orgName"+"}", url.PathEscape(parameterValueToString(r.orgName, "orgName")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"envName"+"}", url.PathEscape(parameterValueToString(r.envName, "envName")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if strlen(r.orgName) < 3 { + return nil, reportError("orgName must have at least 3 elements") + } + if strlen(r.orgName) > 40 { + return nil, reportError("orgName must have less than 40 elements") + } + if strlen(r.envName) < 1 { + return nil, reportError("envName must have at least 1 elements") + } + if strlen(r.envName) > 100 { + return nil, reportError("envName must have less than 100 elements") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + parameterAddToHeaderOrQuery(localVarHeaderParams, "X-Pulumi-Source", "esc-sdk", "") + parameterAddToHeaderOrQuery(localVarHeaderParams, "User-Agent", "esc-sdk/0.8.3-dev.0", "") + if r.ctx != nil { + // API Key Authentication + if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { + if apiKey, ok := auth["Authorization"]; ok { + var key string + if apiKey.Prefix != "" { + key = apiKey.Prefix + " " + apiKey.Key + } else { + key = apiKey.Key + } + localVarHeaderParams["Authorization"] = key + } + } + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarHTTPResponse, newErr + } + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} + +type ApiListEnvironmentsRequest struct { + ctx context.Context + ApiService *EscAPIService + orgName string + continuationToken *string +} + +// continuation Token from previous query to fetch next page of results +func (r ApiListEnvironmentsRequest) ContinuationToken(continuationToken string) ApiListEnvironmentsRequest { + r.continuationToken = &continuationToken + return r +} + +func (r ApiListEnvironmentsRequest) Execute() (*OrgEnvironments, *http.Response, error) { + return r.ApiService.ListEnvironmentsExecute(r) +} + +/* +ListEnvironments List environments in the organization + +List environments in the organization available to the current user + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param orgName Organization name + @return ApiListEnvironmentsRequest +*/ +func (a *EscAPIService) ListEnvironments(ctx context.Context, orgName string) ApiListEnvironmentsRequest { + return ApiListEnvironmentsRequest{ + ApiService: a, + ctx: ctx, + orgName: orgName, + } +} + +// Execute executes the request +// @return OrgEnvironments +func (a *EscAPIService) ListEnvironmentsExecute(r ApiListEnvironmentsRequest) (*OrgEnvironments, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *OrgEnvironments + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EscAPIService.ListEnvironments") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/environments/{orgName}" + localVarPath = strings.Replace(localVarPath, "{"+"orgName"+"}", url.PathEscape(parameterValueToString(r.orgName, "orgName")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if strlen(r.orgName) < 3 { + return localVarReturnValue, nil, reportError("orgName must have at least 3 elements") + } + if strlen(r.orgName) > 40 { + return localVarReturnValue, nil, reportError("orgName must have less than 40 elements") + } + + if r.continuationToken != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "continuationToken", r.continuationToken, "") + } + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + parameterAddToHeaderOrQuery(localVarHeaderParams, "X-Pulumi-Source", "esc-sdk", "") + parameterAddToHeaderOrQuery(localVarHeaderParams, "User-Agent", "esc-sdk/0.8.3-dev.0", "") + if r.ctx != nil { + // API Key Authentication + if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { + if apiKey, ok := auth["Authorization"]; ok { + var key string + if apiKey.Prefix != "" { + key = apiKey.Prefix + " " + apiKey.Key + } else { + key = apiKey.Key + } + localVarHeaderParams["Authorization"] = key + } + } + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type ApiOpenEnvironmentRequest struct { + ctx context.Context + ApiService *EscAPIService + orgName string + envName string + duration *string +} + +// open duration - A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as “300ms”, “1.5h” or “2h45m”. Valid time units are “ns”, “us” (or “µs”), “ms”, “s”, “m”, “h”. +func (r ApiOpenEnvironmentRequest) Duration(duration string) ApiOpenEnvironmentRequest { + r.duration = &duration + return r +} + +func (r ApiOpenEnvironmentRequest) Execute() (*OpenEnvironment, *http.Response, error) { + return r.ApiService.OpenEnvironmentExecute(r) +} + +/* +OpenEnvironment Open an environment session + +Opens a session the given environment for the indicated duration. This returns a session id that can be used to then read values. The default duration is 1 hour. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param orgName Organization name + @param envName Environment name + @return ApiOpenEnvironmentRequest +*/ +func (a *EscAPIService) OpenEnvironment(ctx context.Context, orgName string, envName string) ApiOpenEnvironmentRequest { + return ApiOpenEnvironmentRequest{ + ApiService: a, + ctx: ctx, + orgName: orgName, + envName: envName, + } +} + +// Execute executes the request +// @return OpenEnvironment +func (a *EscAPIService) OpenEnvironmentExecute(r ApiOpenEnvironmentRequest) (*OpenEnvironment, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *OpenEnvironment + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EscAPIService.OpenEnvironment") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/environments/{orgName}/{envName}/open" + localVarPath = strings.Replace(localVarPath, "{"+"orgName"+"}", url.PathEscape(parameterValueToString(r.orgName, "orgName")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"envName"+"}", url.PathEscape(parameterValueToString(r.envName, "envName")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if strlen(r.orgName) < 3 { + return localVarReturnValue, nil, reportError("orgName must have at least 3 elements") + } + if strlen(r.orgName) > 40 { + return localVarReturnValue, nil, reportError("orgName must have less than 40 elements") + } + if strlen(r.envName) < 1 { + return localVarReturnValue, nil, reportError("envName must have at least 1 elements") + } + if strlen(r.envName) > 100 { + return localVarReturnValue, nil, reportError("envName must have less than 100 elements") + } + + if r.duration != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "duration", r.duration, "") + } else { + var defaultValue string = "1h" + r.duration = &defaultValue + } + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + parameterAddToHeaderOrQuery(localVarHeaderParams, "X-Pulumi-Source", "esc-sdk", "") + parameterAddToHeaderOrQuery(localVarHeaderParams, "User-Agent", "esc-sdk/0.8.3-dev.0", "") + if r.ctx != nil { + // API Key Authentication + if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { + if apiKey, ok := auth["Authorization"]; ok { + var key string + if apiKey.Prefix != "" { + key = apiKey.Prefix + " " + apiKey.Key + } else { + key = apiKey.Key + } + localVarHeaderParams["Authorization"] = key + } + } + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v EnvironmentDiagnostics + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type ApiReadOpenEnvironmentRequest struct { + ctx context.Context + ApiService *EscAPIService + orgName string + envName string + openSessionID string +} + +func (r ApiReadOpenEnvironmentRequest) Execute() (*Environment, *http.Response, error) { + return r.ApiService.ReadOpenEnvironmentExecute(r) +} + +/* +ReadOpenEnvironment Read an open environment + +Reads and decrypts secrets including retrieving dynamic secrets from providers. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param orgName Organization name + @param envName Environment name + @param openSessionID Open session ID returned from environment open + @return ApiReadOpenEnvironmentRequest +*/ +func (a *EscAPIService) ReadOpenEnvironment(ctx context.Context, orgName string, envName string, openSessionID string) ApiReadOpenEnvironmentRequest { + return ApiReadOpenEnvironmentRequest{ + ApiService: a, + ctx: ctx, + orgName: orgName, + envName: envName, + openSessionID: openSessionID, + } +} + +// Execute executes the request +// @return Environment +func (a *EscAPIService) ReadOpenEnvironmentExecute(r ApiReadOpenEnvironmentRequest) (*Environment, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *Environment + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EscAPIService.ReadOpenEnvironment") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/environments/{orgName}/{envName}/open/{openSessionID}" + localVarPath = strings.Replace(localVarPath, "{"+"orgName"+"}", url.PathEscape(parameterValueToString(r.orgName, "orgName")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"envName"+"}", url.PathEscape(parameterValueToString(r.envName, "envName")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"openSessionID"+"}", url.PathEscape(parameterValueToString(r.openSessionID, "openSessionID")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if strlen(r.orgName) < 3 { + return localVarReturnValue, nil, reportError("orgName must have at least 3 elements") + } + if strlen(r.orgName) > 40 { + return localVarReturnValue, nil, reportError("orgName must have less than 40 elements") + } + if strlen(r.envName) < 1 { + return localVarReturnValue, nil, reportError("envName must have at least 1 elements") + } + if strlen(r.envName) > 100 { + return localVarReturnValue, nil, reportError("envName must have less than 100 elements") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + parameterAddToHeaderOrQuery(localVarHeaderParams, "X-Pulumi-Source", "esc-sdk", "") + parameterAddToHeaderOrQuery(localVarHeaderParams, "User-Agent", "esc-sdk/0.8.3-dev.0", "") + if r.ctx != nil { + // API Key Authentication + if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { + if apiKey, ok := auth["Authorization"]; ok { + var key string + if apiKey.Prefix != "" { + key = apiKey.Prefix + " " + apiKey.Key + } else { + key = apiKey.Key + } + localVarHeaderParams["Authorization"] = key + } + } + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type ApiReadOpenEnvironmentPropertyRequest struct { + ctx context.Context + ApiService *EscAPIService + orgName string + envName string + openSessionID string + property *string +} + +// Path to a specific property using Pulumi path syntax https://www.pulumi.com/docs/concepts/config/#structured-configuration +func (r ApiReadOpenEnvironmentPropertyRequest) Property(property string) ApiReadOpenEnvironmentPropertyRequest { + r.property = &property + return r +} + +func (r ApiReadOpenEnvironmentPropertyRequest) Execute() (*Value, *http.Response, error) { + return r.ApiService.ReadOpenEnvironmentPropertyExecute(r) +} + +/* +ReadOpenEnvironmentProperty Read an open environment + +Reads and decrypts secrets including retrieving dynamic secrets from providers. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param orgName Organization name + @param envName Environment name + @param openSessionID Open session ID returned from environment open + @return ApiReadOpenEnvironmentPropertyRequest +*/ +func (a *EscAPIService) ReadOpenEnvironmentProperty(ctx context.Context, orgName string, envName string, openSessionID string) ApiReadOpenEnvironmentPropertyRequest { + return ApiReadOpenEnvironmentPropertyRequest{ + ApiService: a, + ctx: ctx, + orgName: orgName, + envName: envName, + openSessionID: openSessionID, + } +} + +// Execute executes the request +// @return Value +func (a *EscAPIService) ReadOpenEnvironmentPropertyExecute(r ApiReadOpenEnvironmentPropertyRequest) (*Value, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *Value + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EscAPIService.ReadOpenEnvironmentProperty") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/environments/{orgName}/{envName}/open//{openSessionID}" + localVarPath = strings.Replace(localVarPath, "{"+"orgName"+"}", url.PathEscape(parameterValueToString(r.orgName, "orgName")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"envName"+"}", url.PathEscape(parameterValueToString(r.envName, "envName")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"openSessionID"+"}", url.PathEscape(parameterValueToString(r.openSessionID, "openSessionID")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if strlen(r.orgName) < 3 { + return localVarReturnValue, nil, reportError("orgName must have at least 3 elements") + } + if strlen(r.orgName) > 40 { + return localVarReturnValue, nil, reportError("orgName must have less than 40 elements") + } + if strlen(r.envName) < 1 { + return localVarReturnValue, nil, reportError("envName must have at least 1 elements") + } + if strlen(r.envName) > 100 { + return localVarReturnValue, nil, reportError("envName must have less than 100 elements") + } + if r.property == nil { + return localVarReturnValue, nil, reportError("property is required and must be specified") + } + + parameterAddToHeaderOrQuery(localVarQueryParams, "property", r.property, "") + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + parameterAddToHeaderOrQuery(localVarHeaderParams, "X-Pulumi-Source", "esc-sdk", "") + parameterAddToHeaderOrQuery(localVarHeaderParams, "User-Agent", "esc-sdk/0.8.3-dev.0", "") + if r.ctx != nil { + // API Key Authentication + if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { + if apiKey, ok := auth["Authorization"]; ok { + var key string + if apiKey.Prefix != "" { + key = apiKey.Prefix + " " + apiKey.Key + } else { + key = apiKey.Key + } + localVarHeaderParams["Authorization"] = key + } + } + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type ApiUpdateEnvironmentYamlRequest struct { + ctx context.Context + ApiService *EscAPIService + orgName string + envName string + body *string +} + +// Environment Yaml content +func (r ApiUpdateEnvironmentYamlRequest) Body(body string) ApiUpdateEnvironmentYamlRequest { + r.body = &body + return r +} + +func (r ApiUpdateEnvironmentYamlRequest) Execute() (*EnvironmentDiagnostics, *http.Response, error) { + return r.ApiService.UpdateEnvironmentYamlExecute(r) +} + +/* +UpdateEnvironmentYaml Update an existing environment with Yaml file + +Validates and updates the given environment's definition. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param orgName Organization name + @param envName Environment name + @return ApiUpdateEnvironmentYamlRequest +*/ +func (a *EscAPIService) UpdateEnvironmentYaml(ctx context.Context, orgName string, envName string) ApiUpdateEnvironmentYamlRequest { + return ApiUpdateEnvironmentYamlRequest{ + ApiService: a, + ctx: ctx, + orgName: orgName, + envName: envName, + } +} + +// Execute executes the request +// @return EnvironmentDiagnostics +func (a *EscAPIService) UpdateEnvironmentYamlExecute(r ApiUpdateEnvironmentYamlRequest) (*EnvironmentDiagnostics, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPatch + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *EnvironmentDiagnostics + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EscAPIService.UpdateEnvironmentYaml") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/environments/{orgName}/{envName}" + localVarPath = strings.Replace(localVarPath, "{"+"orgName"+"}", url.PathEscape(parameterValueToString(r.orgName, "orgName")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"envName"+"}", url.PathEscape(parameterValueToString(r.envName, "envName")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if strlen(r.orgName) < 3 { + return localVarReturnValue, nil, reportError("orgName must have at least 3 elements") + } + if strlen(r.orgName) > 40 { + return localVarReturnValue, nil, reportError("orgName must have less than 40 elements") + } + if strlen(r.envName) < 1 { + return localVarReturnValue, nil, reportError("envName must have at least 1 elements") + } + if strlen(r.envName) > 100 { + return localVarReturnValue, nil, reportError("envName must have less than 100 elements") + } + if r.body == nil { + return localVarReturnValue, nil, reportError("body is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/x-yaml"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + parameterAddToHeaderOrQuery(localVarHeaderParams, "X-Pulumi-Source", "esc-sdk", "") + parameterAddToHeaderOrQuery(localVarHeaderParams, "User-Agent", "esc-sdk/0.8.3-dev.0", "") + // body params + localVarPostBody = r.body + if r.ctx != nil { + // API Key Authentication + if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { + if apiKey, ok := auth["Authorization"]; ok { + var key string + if apiKey.Prefix != "" { + key = apiKey.Prefix + " " + apiKey.Key + } else { + key = apiKey.Key + } + localVarHeaderParams["Authorization"] = key + } + } + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v EnvironmentDiagnostics + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 409 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} diff --git a/sdk/go/api_esc_extensions.go b/sdk/go/api_esc_extensions.go new file mode 100644 index 00000000..b8d3a291 --- /dev/null +++ b/sdk/go/api_esc_extensions.go @@ -0,0 +1,285 @@ +// Copyright 2024, Pulumi Corporation. All rights reserved. + +package esc_sdk + +import ( + "context" + "errors" + "io" + + "gopkg.in/ghodss/yaml.v1" +) + +type EscClient struct { + rawClient *RawAPIClient + EscAPI *EscAPIService +} + +func NewClient(cfg *Configuration) *EscClient { + client := &EscClient{rawClient: NewRawAPIClient(cfg)} + client.EscAPI = client.rawClient.EscAPI + return client +} + +func (c *EscClient) ListEnvironments(ctx context.Context, org string, continuationToken *string) (*OrgEnvironments, error) { + request := c.EscAPI.ListEnvironments(ctx, org) + if continuationToken != nil { + request = request.ContinuationToken(*continuationToken) + } + + envs, _, err := request.Execute() + return envs, err +} + +func (c *EscClient) GetEnvironment(ctx context.Context, org, envName string) (*EnvironmentDefinition, string, error) { + env, resp, err := c.EscAPI.GetEnvironment(ctx, org, envName).Execute() + if err != nil { + return nil, "", err + } + + body, err := io.ReadAll(resp.Body) + if err != nil { + return nil, "", err + } + + return env, string(body), nil +} + +func (c *EscClient) OpenEnvironment(ctx context.Context, org, envName string) (*OpenEnvironment, error) { + openInfo, _, err := c.EscAPI.OpenEnvironment(ctx, org, envName).Execute() + return openInfo, err +} + +func (c *EscClient) ReadOpenEnvironment(ctx context.Context, org, envName, openEnvID string) (*Environment, map[string]any, error) { + env, _, err := c.EscAPI.ReadOpenEnvironment(ctx, org, envName, openEnvID).Execute() + if err != nil { + return nil, nil, err + } + + propertyMap := *env.Properties + for k, v := range propertyMap { + v.Value = mapValues(v.Value) + propertyMap[k] = v + } + + values := make(map[string]any, len(propertyMap)) + for k := range propertyMap { + v := propertyMap[k] + values[k] = mapValuesPrimitive(&v) + } + + return env, values, nil +} + +func (c *EscClient) OpenAndReadEnvironment(ctx context.Context, org, envName string) (*Environment, map[string]any, error) { + openInfo, err := c.OpenEnvironment(ctx, org, envName) + if err != nil { + return nil, nil, err + } + + return c.ReadOpenEnvironment(ctx, org, envName, openInfo.Id) +} + +func (c *EscClient) ReadEnvironmentProperty(ctx context.Context, org, envName, openEnvID, propPath string) (*Value, any, error) { + prop, _, err := c.EscAPI.ReadOpenEnvironmentProperty(ctx, org, envName, openEnvID).Property(propPath).Execute() + v := mapValuesPrimitive(prop.Value) + return prop, v, err +} + +func (c *EscClient) CreateEnvironment(ctx context.Context, org, envName string) error { + _, _, err := c.EscAPI.CreateEnvironment(ctx, org, envName).Execute() + return err +} + +func (c *EscClient) UpdateEnvironmentYaml(ctx context.Context, org, envName, yaml string) (*EnvironmentDiagnostics, error) { + diags, _, err := c.EscAPI.UpdateEnvironmentYaml(ctx, org, envName).Body(yaml).Execute() + return diags, err +} + +func (c *EscClient) UpdateEnvironment(ctx context.Context, org, envName string, env *EnvironmentDefinition) (*EnvironmentDiagnostics, error) { + yaml, err := MarshalEnvironmentDefinition(env) + if err != nil { + return nil, err + } + + diags, _, err := c.EscAPI.UpdateEnvironmentYaml(ctx, org, envName).Body(yaml).Execute() + return diags, err +} + +func (c *EscClient) DeleteEnvironment(ctx context.Context, org, envName string) error { + _, _, err := c.EscAPI.DeleteEnvironment(ctx, org, envName).Execute() + return err +} + +func (c *EscClient) CheckEnvironment(ctx context.Context, org string, env *EnvironmentDefinition) (*CheckEnvironment, error) { + yaml, err := MarshalEnvironmentDefinition(env) + if err != nil { + return nil, err + } + + return c.CheckEnvironmentYaml(ctx, org, yaml) +} + +func (c *EscClient) CheckEnvironmentYaml(ctx context.Context, org, yaml string) (*CheckEnvironment, error) { + check, _, err := c.EscAPI.CheckEnvironmentYaml(ctx, org).Body(yaml).Execute() + var genericOpenApiError *GenericOpenAPIError + if err != nil && errors.As(err, &genericOpenApiError) { + model := genericOpenApiError.Model().(CheckEnvironment) + return &model, err + } + + return check, err +} + +func (c *EscClient) DecryptEnvironment(ctx context.Context, org, envName string) (*EnvironmentDefinition, string, error) { + env, resp, err := c.EscAPI.DecryptEnvironment(ctx, org, envName).Execute() + + body, bodyErr := io.ReadAll(resp.Body) + if err != nil { + return nil, "", bodyErr + } + + return env, string(body), err +} + +func MarshalEnvironmentDefinition(env *EnvironmentDefinition) (string, error) { + var bs []byte + bs, err := yaml.Marshal(env) + if err == nil { + return string(bs), nil + } + + return "", err +} + +func mapValuesPrimitive(value any) any { + switch val := value.(type) { + case *Value: + return mapValuesPrimitive(val.Value) + case map[string]Value: + output := make(map[string]any, len(val)) + for k, v := range val { + output[k] = mapValuesPrimitive(v.Value) + } + + return output + case []any: + for i, v := range val { + val[i] = mapValuesPrimitive(v) + } + return val + default: + return value + } +} + +func mapValues(value any) any { + if val := getValue(getMapSafe(value)); val != nil { + val.Value = mapValues(val.Value) + return val + } + if mapData, isMap := value.(map[string]any); isMap { + output := map[string]Value{} + for key, v := range mapData { + value := mapValues(v) + if value == nil { + continue + } + + if v, ok := value.(*Value); ok && v != nil { + output[key] = *v + } else { + output[key] = Value{ + Value: value, + } + } + } + return output + } else if sliceData, isSlice := value.([]any); isSlice { + for i, v := range sliceData { + sliceData[i] = mapValues(v) + } + return sliceData + } + + return value +} + +func getValue(data map[string]any) *Value { + _, hasValue := data["value"] + _, hasTrace := data["trace"] + if hasValue && hasTrace { + return &Value{ + Value: mapValues(data["value"]), + Secret: getBoolPtr(data, "secret"), + Unknown: getBoolPtr(data, "unknown"), + Trace: getTrace(data["trace"].(map[string]any)), + } + } + + return nil +} + +func getTrace(data map[string]any) Trace { + def := getRange(getMapSafe(data["def"])) + base := getValue(getMapSafe(data["base"])) + if def != nil || base != nil { + return Trace{ + Def: def, + Base: base, + } + } + + return Trace{} +} + +func getMapSafe(data any) map[string]any { + if data == nil { + return nil + } + + val, _ := data.(map[string]any) + return val +} + +func getRange(data map[string]any) *Range { + begin := getPos(getMapSafe(data["begin"])) + end := getPos(getMapSafe(data["end"])) + environment := data["environment"].(string) + if begin != nil && end != nil { + return &Range{ + Environment: environment, + Begin: *begin, + End: *end, + } + } + + return nil +} + +func getPos(data map[string]any) *Pos { + line, hasLine := data["line"].(float64) + column, hasColumn := data["column"].(float64) + byteData, hasByte := data["byte"].(float64) + if hasLine || hasColumn || hasByte { + return &Pos{ + Line: int32(line), + Column: int32(column), + Byte: int32(byteData), + } + } + + return nil +} + +func getBoolPtr(data map[string]any, key string) *bool { + val, exists := data[key] + if exists { + v, ok := val.(bool) + if ok { + return &v + } + } + + return nil +} diff --git a/sdk/go/api_esc_test.go b/sdk/go/api_esc_test.go new file mode 100644 index 00000000..7ca48783 --- /dev/null +++ b/sdk/go/api_esc_test.go @@ -0,0 +1,208 @@ +// Copyright 2024, Pulumi Corporation. All rights reserved. + +/* +ESC (Environments, Secrets, Config) API + +Testing EscAPIService + +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); + +package esc_sdk + +import ( + "context" + "os" + "strings" + "testing" + "time" + + "github.com/stretchr/testify/require" +) + +const ENV_PREFIX = "sdk-go-test-" + +func Test_EscClient(t *testing.T) { + accessToken := os.Getenv("PULUMI_ACCESS_TOKEN") + require.NotEmpty(t, accessToken) + orgName := os.Getenv("PULUMI_ORG") + require.NotEmpty(t, orgName) + configuration := NewConfiguration() + apiClient := NewClient(configuration) + auth := context.WithValue( + context.Background(), + ContextAPIKeys, + map[string]APIKey{ + "Authorization": {Key: accessToken, Prefix: "token"}, + }, + ) + + removeAllGoTestEnvs(t, apiClient, auth, orgName) + + baseEnvName := ENV_PREFIX + "base-" + time.Now().Format("20060102150405") + err := apiClient.CreateEnvironment(auth, orgName, baseEnvName) + require.Nil(t, err) + t.Cleanup(func() { + err := apiClient.DeleteEnvironment(auth, orgName, baseEnvName) + require.Nil(t, err) + }) + + baseEnv := &EnvironmentDefinition{ + Values: &EnvironmentDefinitionValues{ + AdditionalProperties: map[string]any{ + "base": baseEnvName, + }, + }, + } + + _, err = apiClient.UpdateEnvironment(auth, orgName, baseEnvName, baseEnv) + require.Nil(t, err) + + t.Run("should create, list, update, get, decrypt, open and delete an environment", func(t *testing.T) { + envName := ENV_PREFIX + time.Now().Format("20060102150405") + err := apiClient.CreateEnvironment(auth, orgName, envName) + require.Nil(t, err) + t.Cleanup(func() { + err := apiClient.DeleteEnvironment(auth, orgName, envName) + require.Nil(t, err) + }) + + envs, err := apiClient.ListEnvironments(auth, orgName, nil) + require.Nil(t, err) + + requireFindEnvironment(t, envs, envName) + + yaml := "imports:\n - " + baseEnvName + "\n" + ` +values: + foo: bar + my_secret: + fn::secret: "shh! don't tell anyone" + my_array: [1, 2, 3] + pulumiConfig: + foo: ${foo} + environmentVariables: + FOO: ${foo} +` + + diags, err := apiClient.UpdateEnvironmentYaml(auth, orgName, envName, yaml) + require.Nil(t, err) + require.NotNil(t, diags) + require.Len(t, diags.Diagnostics, 0) + + env, newYaml, err := apiClient.GetEnvironment(auth, orgName, envName) + require.Nil(t, err) + require.NotNil(t, newYaml) + + assertEnvDef(t, env, baseEnvName) + + require.NotNil(t, env.Values.AdditionalProperties["my_secret"].(map[string]any)) + + decryptEnv, _, err := apiClient.DecryptEnvironment(auth, orgName, envName) + require.Nil(t, err) + + assertEnvDef(t, decryptEnv, baseEnvName) + + mySecret, ok := decryptEnv.Values.AdditionalProperties["my_secret"].(map[string]any) + require.True(t, ok) + require.Equal(t, "shh! don't tell anyone", mySecret["fn::secret"]) + + _, values, err := apiClient.OpenAndReadEnvironment(auth, orgName, envName) + require.Nil(t, err) + + require.Equal(t, baseEnvName, values["base"]) + require.Equal(t, "bar", values["foo"]) + require.Equal(t, []any{1.0, 2.0, 3.0}, values["my_array"]) + require.Equal(t, "shh! don't tell anyone", values["my_secret"]) + pulumiConfig, ok := values["pulumiConfig"].(map[string]any) + require.True(t, ok) + require.Equal(t, "bar", pulumiConfig["foo"]) + environmentVariables, ok := values["environmentVariables"].(map[string]any) + require.True(t, ok) + require.Equal(t, "bar", environmentVariables["FOO"]) + + openInfo, err := apiClient.OpenEnvironment(auth, orgName, envName) + require.Nil(t, err) + + v, value, err := apiClient.ReadEnvironmentProperty(auth, orgName, envName, openInfo.Id, "pulumiConfig.foo") + require.Nil(t, err) + require.Equal(t, "bar", v.Value) + require.Equal(t, "bar", value) + }) + + t.Run("check environment definition valid", func(t *testing.T) { + env := &EnvironmentDefinition{ + Values: &EnvironmentDefinitionValues{ + AdditionalProperties: map[string]any{ + "foo": "bar", + }, + }, + } + + diags, err := apiClient.CheckEnvironment(auth, orgName, env) + require.Nil(t, err) + require.NotNil(t, diags) + require.Len(t, diags.Diagnostics, 0) + }) + + t.Run("check environment yaml invalid", func(t *testing.T) { + yaml := ` +values: + foo: bar + pulumiConfig: + foo: ${bad_ref} +` + diags, err := apiClient.CheckEnvironmentYaml(auth, orgName, yaml) + require.Error(t, err, "400 Bad Request") + require.NotNil(t, diags) + require.Len(t, diags.Diagnostics, 1) + require.Equal(t, "unknown property \"bad_ref\"", diags.Diagnostics[0].Summary) + + }) +} + +func assertEnvDef(t *testing.T, env *EnvironmentDefinition, baseEnvName string) { + require.Len(t, env.Imports, 1) + require.Equal(t, baseEnvName, env.Imports[0]) + require.Equal(t, "bar", env.Values.AdditionalProperties["foo"]) + require.Equal(t, []any{1.0, 2.0, 3.0}, env.Values.AdditionalProperties["my_array"]) + + require.Equal(t, "${foo}", env.Values.PulumiConfig["foo"]) + require.NotNil(t, env.Values.EnvironmentVariables) + envVariables := *env.Values.EnvironmentVariables + require.Equal(t, "${foo}", envVariables["FOO"]) +} + +func requireFindEnvironment(t *testing.T, envs *OrgEnvironments, envName string) { + found := false + for _, env := range envs.Environments { + if env.Name == envName { + found = true + } + } + + require.True(t, found) +} + +func removeAllGoTestEnvs(t *testing.T, apiClient *EscClient, auth context.Context, orgName string) { + var continuationToken *string + for { + envs, err := apiClient.ListEnvironments(auth, orgName, continuationToken) + require.Nil(t, err) + + if len(envs.Environments) == 0 { + break + } + for _, env := range envs.Environments { + if strings.HasPrefix(env.Name, ENV_PREFIX) { + err := apiClient.DeleteEnvironment(auth, orgName, env.Name) + require.Nil(t, err) + } + } + + continuationToken = envs.NextToken + if continuationToken == nil || *continuationToken == "" { + break + } + } +} diff --git a/sdk/go/client.go b/sdk/go/client.go new file mode 100644 index 00000000..0bfe207a --- /dev/null +++ b/sdk/go/client.go @@ -0,0 +1,673 @@ +// Copyright 2024, Pulumi Corporation. All rights reserved. +/* +ESC (Environments, Secrets, Config) API + +Pulumi ESC allows you to compose and manage hierarchical collections of configuration and secrets and consume them in various ways. + +API version: 0.1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package esc_sdk + +import ( + "bytes" + "context" + "encoding/json" + "encoding/xml" + "errors" + "fmt" + "io" + "log" + "mime/multipart" + "net/http" + "net/http/httputil" + "net/url" + "os" + "path/filepath" + "reflect" + "regexp" + "strconv" + "strings" + "time" + "unicode/utf8" + "gopkg.in/ghodss/yaml.v1" + +) + +var ( + JsonCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:[^;]+\+)?json)`) + XmlCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:[^;]+\+)?xml)`) + YamlCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:x-)?(?:[^;]+\+)?yaml)`) + queryParamSplit = regexp.MustCompile(`(^|&)([^&]+)`) + queryDescape = strings.NewReplacer( "%5B", "[", "%5D", "]" ) +) + +// RawAPIClient manages communication with the ESC (Environments, Secrets, Config) API API v0.1.0 +// In most cases there should be only one, shared, RawAPIClient. +type RawAPIClient struct { + cfg *Configuration + common service // Reuse a single struct instead of allocating one for each service on the heap. + + // API Services + + EscAPI *EscAPIService +} + +type service struct { + client *RawAPIClient +} + +// NewRawAPIClient creates a new API client. Requires a userAgent string describing your application. +// optionally a custom http.Client to allow for advanced features such as caching. +func NewRawAPIClient(cfg *Configuration) *RawAPIClient { + if cfg.HTTPClient == nil { + cfg.HTTPClient = http.DefaultClient + } + + c := &RawAPIClient{} + c.cfg = cfg + c.common.client = c + + // API Services + c.EscAPI = (*EscAPIService)(&c.common) + + return c +} + +func atoi(in string) (int, error) { + return strconv.Atoi(in) +} + +// selectHeaderContentType select a content type from the available list. +func selectHeaderContentType(contentTypes []string) string { + if len(contentTypes) == 0 { + return "" + } + if contains(contentTypes, "application/json") { + return "application/json" + } + return contentTypes[0] // use the first content type specified in 'consumes' +} + +// selectHeaderAccept join all accept types and return +func selectHeaderAccept(accepts []string) string { + if len(accepts) == 0 { + return "" + } + + if contains(accepts, "application/json") { + return "application/json" + } + + return strings.Join(accepts, ",") +} + +// contains is a case insensitive match, finding needle in a haystack +func contains(haystack []string, needle string) bool { + for _, a := range haystack { + if strings.EqualFold(a, needle) { + return true + } + } + return false +} + +// Verify optional parameters are of the correct type. +func typeCheckParameter(obj interface{}, expected string, name string) error { + // Make sure there is an object. + if obj == nil { + return nil + } + + // Check the type is as expected. + if reflect.TypeOf(obj).String() != expected { + return fmt.Errorf("expected %s to be of type %s but received %s", name, expected, reflect.TypeOf(obj).String()) + } + return nil +} + +func parameterValueToString( obj interface{}, key string ) string { + if reflect.TypeOf(obj).Kind() != reflect.Ptr { + return fmt.Sprintf("%v", obj) + } + var param,ok = obj.(MappedNullable) + if !ok { + return "" + } + dataMap,err := param.ToMap() + if err != nil { + return "" + } + return fmt.Sprintf("%v", dataMap[key]) +} + +// parameterAddToHeaderOrQuery adds the provided object to the request header or url query +// supporting deep object syntax +func parameterAddToHeaderOrQuery(headerOrQueryParams interface{}, keyPrefix string, obj interface{}, collectionType string) { + var v = reflect.ValueOf(obj) + var value = "" + if v == reflect.ValueOf(nil) { + value = "null" + } else { + switch v.Kind() { + case reflect.Invalid: + value = "invalid" + + case reflect.Struct: + if t,ok := obj.(MappedNullable); ok { + dataMap,err := t.ToMap() + if err != nil { + return + } + parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, dataMap, collectionType) + return + } + if t, ok := obj.(time.Time); ok { + parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, t.Format(time.RFC3339), collectionType) + return + } + value = v.Type().String() + " value" + case reflect.Slice: + var indValue = reflect.ValueOf(obj) + if indValue == reflect.ValueOf(nil) { + return + } + var lenIndValue = indValue.Len() + for i:=0;i 0 || (len(formFiles) > 0) { + if body != nil { + return nil, errors.New("Cannot specify postBody and multipart form at the same time.") + } + body = &bytes.Buffer{} + w := multipart.NewWriter(body) + + for k, v := range formParams { + for _, iv := range v { + if strings.HasPrefix(k, "@") { // file + err = addFile(w, k[1:], iv) + if err != nil { + return nil, err + } + } else { // form value + w.WriteField(k, iv) + } + } + } + for _, formFile := range formFiles { + if len(formFile.fileBytes) > 0 && formFile.fileName != "" { + w.Boundary() + part, err := w.CreateFormFile(formFile.formFileName, filepath.Base(formFile.fileName)) + if err != nil { + return nil, err + } + _, err = part.Write(formFile.fileBytes) + if err != nil { + return nil, err + } + } + } + + // Set the Boundary in the Content-Type + headerParams["Content-Type"] = w.FormDataContentType() + + // Set Content-Length + headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) + w.Close() + } + + if strings.HasPrefix(headerParams["Content-Type"], "application/x-www-form-urlencoded") && len(formParams) > 0 { + if body != nil { + return nil, errors.New("Cannot specify postBody and x-www-form-urlencoded form at the same time.") + } + body = &bytes.Buffer{} + body.WriteString(formParams.Encode()) + // Set Content-Length + headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) + } + + // Setup path and query parameters + url, err := url.Parse(path) + if err != nil { + return nil, err + } + + // Override request host, if applicable + if c.cfg.Host != "" { + url.Host = c.cfg.Host + } + + // Override request scheme, if applicable + if c.cfg.Scheme != "" { + url.Scheme = c.cfg.Scheme + } + + // Adding Query Param + query := url.Query() + for k, v := range queryParams { + for _, iv := range v { + query.Add(k, iv) + } + } + + // Encode the parameters. + url.RawQuery = queryParamSplit.ReplaceAllStringFunc(query.Encode(), func(s string) string { + pieces := strings.Split(s, "=") + pieces[0] = queryDescape.Replace(pieces[0]) + return strings.Join(pieces, "=") + }) + + // Generate a new request + if body != nil { + localVarRequest, err = http.NewRequest(method, url.String(), body) + } else { + localVarRequest, err = http.NewRequest(method, url.String(), nil) + } + if err != nil { + return nil, err + } + + // add header parameters, if any + if len(headerParams) > 0 { + headers := http.Header{} + for h, v := range headerParams { + headers[h] = []string{v} + } + localVarRequest.Header = headers + } + + // Add the user agent to the request. + localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent) + + if ctx != nil { + // add context to the request + localVarRequest = localVarRequest.WithContext(ctx) + + // Walk through any authentication. + + } + + for header, value := range c.cfg.DefaultHeader { + localVarRequest.Header.Add(header, value) + } + return localVarRequest, nil +} + +func (c *RawAPIClient) decode(v interface{}, b []byte, contentType string) (err error) { + if len(b) == 0 { + return nil + } + if s, ok := v.(*string); ok { + *s = string(b) + return nil + } + if f, ok := v.(*os.File); ok { + f, err = os.CreateTemp("", "HttpClientFile") + if err != nil { + return + } + _, err = f.Write(b) + if err != nil { + return + } + _, err = f.Seek(0, io.SeekStart) + return + } + if f, ok := v.(**os.File); ok { + *f, err = os.CreateTemp("", "HttpClientFile") + if err != nil { + return + } + _, err = (*f).Write(b) + if err != nil { + return + } + _, err = (*f).Seek(0, io.SeekStart) + return + } + if XmlCheck.MatchString(contentType) { + if err = xml.Unmarshal(b, v); err != nil { + return err + } + return nil + } + if JsonCheck.MatchString(contentType) { + if actualObj, ok := v.(interface{ GetActualInstance() interface{} }); ok { // oneOf, anyOf schemas + if unmarshalObj, ok := actualObj.(interface{ UnmarshalJSON([]byte) error }); ok { // make sure it has UnmarshalJSON defined + if err = unmarshalObj.UnmarshalJSON(b); err != nil { + return err + } + } else { + return errors.New("Unknown type with GetActualInstance but no unmarshalObj.UnmarshalJSON defined") + } + } else if err = json.Unmarshal(b, v); err != nil { // simple model + return err + } + return nil + } + if YamlCheck.MatchString(contentType) { + if err = yaml.Unmarshal(b, v); err != nil { + return err + } + return nil + } + return errors.New("undefined response type") +} + +// Add a file to the multipart request +func addFile(w *multipart.Writer, fieldName, path string) error { + file, err := os.Open(filepath.Clean(path)) + if err != nil { + return err + } + err = file.Close() + if err != nil { + return err + } + + part, err := w.CreateFormFile(fieldName, filepath.Base(path)) + if err != nil { + return err + } + _, err = io.Copy(part, file) + + return err +} + +// Prevent trying to import "fmt" +func reportError(format string, a ...interface{}) error { + return fmt.Errorf(format, a...) +} + +// A wrapper for strict JSON decoding +func newStrictDecoder(data []byte) *json.Decoder { + dec := json.NewDecoder(bytes.NewBuffer(data)) + dec.DisallowUnknownFields() + return dec +} + +// Set request body from an interface{} +func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err error) { + bodyBuf = &bytes.Buffer{} + + if reader, ok := body.(io.Reader); ok { + _, err = bodyBuf.ReadFrom(reader) + } else if fp, ok := body.(*os.File); ok { + _, err = bodyBuf.ReadFrom(fp) + } else if b, ok := body.([]byte); ok { + _, err = bodyBuf.Write(b) + } else if s, ok := body.(string); ok { + _, err = bodyBuf.WriteString(s) + } else if s, ok := body.(*string); ok { + _, err = bodyBuf.WriteString(*s) + } else if JsonCheck.MatchString(contentType) { + err = json.NewEncoder(bodyBuf).Encode(body) + } else if XmlCheck.MatchString(contentType) { + var bs []byte + bs, err = xml.Marshal(body) + if err == nil { + bodyBuf.Write(bs) + } + } else if YamlCheck.MatchString(contentType) { + var bs []byte + bs, err = yaml.Marshal(body) + if err == nil { + bodyBuf.Write(bs) + } + } + + if err != nil { + return nil, err + } + + if bodyBuf.Len() == 0 { + err = fmt.Errorf("invalid body type %s\n", contentType) + return nil, err + } + return bodyBuf, nil +} + +// detectContentType method is used to figure out `Request.Body` content type for request header +func detectContentType(body interface{}) string { + contentType := "text/plain; charset=utf-8" + kind := reflect.TypeOf(body).Kind() + + switch kind { + case reflect.Struct, reflect.Map, reflect.Ptr: + contentType = "application/json; charset=utf-8" + case reflect.String: + contentType = "text/plain; charset=utf-8" + default: + if b, ok := body.([]byte); ok { + contentType = http.DetectContentType(b) + } else if kind == reflect.Slice { + contentType = "application/json; charset=utf-8" + } + } + + return contentType +} + +// Ripped from https://github.com/gregjones/httpcache/blob/master/httpcache.go +type cacheControl map[string]string + +func parseCacheControl(headers http.Header) cacheControl { + cc := cacheControl{} + ccHeader := headers.Get("Cache-Control") + for _, part := range strings.Split(ccHeader, ",") { + part = strings.Trim(part, " ") + if part == "" { + continue + } + if strings.ContainsRune(part, '=') { + keyval := strings.Split(part, "=") + cc[strings.Trim(keyval[0], " ")] = strings.Trim(keyval[1], ",") + } else { + cc[part] = "" + } + } + return cc +} + +// CacheExpires helper function to determine remaining time before repeating a request. +func CacheExpires(r *http.Response) time.Time { + // Figure out when the cache expires. + var expires time.Time + now, err := time.Parse(time.RFC1123, r.Header.Get("date")) + if err != nil { + return time.Now() + } + respCacheControl := parseCacheControl(r.Header) + + if maxAge, ok := respCacheControl["max-age"]; ok { + lifetime, err := time.ParseDuration(maxAge + "s") + if err != nil { + expires = now + } else { + expires = now.Add(lifetime) + } + } else { + expiresHeader := r.Header.Get("Expires") + if expiresHeader != "" { + expires, err = time.Parse(time.RFC1123, expiresHeader) + if err != nil { + expires = now + } + } + } + return expires +} + +func strlen(s string) int { + return utf8.RuneCountInString(s) +} + +// GenericOpenAPIError Provides access to the body, error and model on returned errors. +type GenericOpenAPIError struct { + body []byte + error string + model interface{} +} + +// Error returns non-empty string if there was an error. +func (e GenericOpenAPIError) Error() string { + return e.error +} + +// Body returns the raw bytes of the response +func (e GenericOpenAPIError) Body() []byte { + return e.body +} + +// Model returns the unpacked model of the error +func (e GenericOpenAPIError) Model() interface{} { + return e.model +} + +// format error message using title and detail when model implements rfc7807 +func formatErrorMessage(status string, v interface{}) string { + str := "" + metaValue := reflect.ValueOf(v).Elem() + + if metaValue.Kind() == reflect.Struct { + field := metaValue.FieldByName("Title") + if field != (reflect.Value{}) { + str = fmt.Sprintf("%s", field.Interface()) + } + + field = metaValue.FieldByName("Detail") + if field != (reflect.Value{}) { + str = fmt.Sprintf("%s (%s)", str, field.Interface()) + } + } + + return strings.TrimSpace(fmt.Sprintf("%s %s", status, str)) +} diff --git a/sdk/go/configuration.go b/sdk/go/configuration.go new file mode 100644 index 00000000..0912a110 --- /dev/null +++ b/sdk/go/configuration.go @@ -0,0 +1,219 @@ +// Copyright 2024, Pulumi Corporation. All rights reserved. +/* +ESC (Environments, Secrets, Config) API + +Pulumi ESC allows you to compose and manage hierarchical collections of configuration and secrets and consume them in various ways. + +API version: 0.1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package esc_sdk + +import ( + "context" + "fmt" + "net/http" + "strings" +) + +// contextKeys are used to identify the type of value in the context. +// Since these are string, it is possible to get a short description of the +// context key for logging and debugging using key.String(). + +type contextKey string + +func (c contextKey) String() string { + return "auth " + string(c) +} + +var ( + // ContextAPIKeys takes a string apikey as authentication for the request + ContextAPIKeys = contextKey("apiKeys") + + // ContextServerIndex uses a server configuration from the index. + ContextServerIndex = contextKey("serverIndex") + + // ContextOperationServerIndices uses a server configuration from the index mapping. + ContextOperationServerIndices = contextKey("serverOperationIndices") + + // ContextServerVariables overrides a server configuration variables. + ContextServerVariables = contextKey("serverVariables") + + // ContextOperationServerVariables overrides a server configuration variables using operation specific values. + ContextOperationServerVariables = contextKey("serverOperationVariables") +) + +// BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth +type BasicAuth struct { + UserName string `json:"userName,omitempty"` + Password string `json:"password,omitempty"` +} + +// APIKey provides API key based authentication to a request passed via context using ContextAPIKey +type APIKey struct { + Key string + Prefix string +} + +// ServerVariable stores the information about a server variable +type ServerVariable struct { + Description string + DefaultValue string + EnumValues []string +} + +// ServerConfiguration stores the information about a server +type ServerConfiguration struct { + URL string + Description string + Variables map[string]ServerVariable +} + +// ServerConfigurations stores multiple ServerConfiguration items +type ServerConfigurations []ServerConfiguration + +// Configuration stores the configuration of the API client +type Configuration struct { + Host string `json:"host,omitempty"` + Scheme string `json:"scheme,omitempty"` + DefaultHeader map[string]string `json:"defaultHeader,omitempty"` + UserAgent string `json:"userAgent,omitempty"` + Debug bool `json:"debug,omitempty"` + Servers ServerConfigurations + OperationServers map[string]ServerConfigurations + HTTPClient *http.Client +} + +// NewConfiguration returns a new Configuration object +func NewConfiguration() *Configuration { + cfg := &Configuration{ + DefaultHeader: make(map[string]string), + UserAgent: "esc-sdk", + Debug: false, + Servers: ServerConfigurations{ + { + URL: "https://api.pulumi.com/api/preview", + Description: "Pulumi Cloud Production Preview API", + }, + }, + OperationServers: map[string]ServerConfigurations{ + }, + } + return cfg +} + +// AddDefaultHeader adds a new HTTP header to the default header in the request +func (c *Configuration) AddDefaultHeader(key string, value string) { + c.DefaultHeader[key] = value +} + +// URL formats template on a index using given variables +func (sc ServerConfigurations) URL(index int, variables map[string]string) (string, error) { + if index < 0 || len(sc) <= index { + return "", fmt.Errorf("index %v out of range %v", index, len(sc)-1) + } + server := sc[index] + url := server.URL + + // go through variables and replace placeholders + for name, variable := range server.Variables { + if value, ok := variables[name]; ok { + found := bool(len(variable.EnumValues) == 0) + for _, enumValue := range variable.EnumValues { + if value == enumValue { + found = true + } + } + if !found { + return "", fmt.Errorf("the variable %s in the server URL has invalid value %v. Must be %v", name, value, variable.EnumValues) + } + url = strings.Replace(url, "{"+name+"}", value, -1) + } else { + url = strings.Replace(url, "{"+name+"}", variable.DefaultValue, -1) + } + } + return url, nil +} + +// ServerURL returns URL based on server settings +func (c *Configuration) ServerURL(index int, variables map[string]string) (string, error) { + return c.Servers.URL(index, variables) +} + +func getServerIndex(ctx context.Context) (int, error) { + si := ctx.Value(ContextServerIndex) + if si != nil { + if index, ok := si.(int); ok { + return index, nil + } + return 0, reportError("Invalid type %T should be int", si) + } + return 0, nil +} + +func getServerOperationIndex(ctx context.Context, endpoint string) (int, error) { + osi := ctx.Value(ContextOperationServerIndices) + if osi != nil { + if operationIndices, ok := osi.(map[string]int); !ok { + return 0, reportError("Invalid type %T should be map[string]int", osi) + } else { + index, ok := operationIndices[endpoint] + if ok { + return index, nil + } + } + } + return getServerIndex(ctx) +} + +func getServerVariables(ctx context.Context) (map[string]string, error) { + sv := ctx.Value(ContextServerVariables) + if sv != nil { + if variables, ok := sv.(map[string]string); ok { + return variables, nil + } + return nil, reportError("ctx value of ContextServerVariables has invalid type %T should be map[string]string", sv) + } + return nil, nil +} + +func getServerOperationVariables(ctx context.Context, endpoint string) (map[string]string, error) { + osv := ctx.Value(ContextOperationServerVariables) + if osv != nil { + if operationVariables, ok := osv.(map[string]map[string]string); !ok { + return nil, reportError("ctx value of ContextOperationServerVariables has invalid type %T should be map[string]map[string]string", osv) + } else { + variables, ok := operationVariables[endpoint] + if ok { + return variables, nil + } + } + } + return getServerVariables(ctx) +} + +// ServerURLWithContext returns a new server URL given an endpoint +func (c *Configuration) ServerURLWithContext(ctx context.Context, endpoint string) (string, error) { + sc, ok := c.OperationServers[endpoint] + if !ok { + sc = c.Servers + } + + if ctx == nil { + return sc.URL(0, nil) + } + + index, err := getServerOperationIndex(ctx, endpoint) + if err != nil { + return "", err + } + + variables, err := getServerOperationVariables(ctx, endpoint) + if err != nil { + return "", err + } + + return sc.URL(index, variables) +} diff --git a/sdk/go/go.mod b/sdk/go/go.mod new file mode 100644 index 00000000..b5c45ef2 --- /dev/null +++ b/sdk/go/go.mod @@ -0,0 +1,13 @@ +module github.com/pulumi/esc-sdk + +go 1.18 + +require github.com/stretchr/testify v1.8.4 + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + gopkg.in/ghodss/yaml.v1 v1.0.0 + gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/sdk/go/go.sum b/sdk/go/go.sum new file mode 100644 index 00000000..a6d64ead --- /dev/null +++ b/sdk/go/go.sum @@ -0,0 +1,14 @@ +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/ghodss/yaml.v1 v1.0.0 h1:JlY4R6oVz+ZSvcDhVfNQ/k/8Xo6yb2s1PBhslPZPX4c= +gopkg.in/ghodss/yaml.v1 v1.0.0/go.mod h1:HDvRMPQLqycKPs9nWLuzZWxsxRzISLCRORiDpBUOMqg= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/go/model_access.go b/sdk/go/model_access.go new file mode 100644 index 00000000..c699a291 --- /dev/null +++ b/sdk/go/model_access.go @@ -0,0 +1,163 @@ +// Copyright 2024, Pulumi Corporation. All rights reserved. +/* +ESC (Environments, Secrets, Config) API + +Pulumi ESC allows you to compose and manage hierarchical collections of configuration and secrets and consume them in various ways. + +API version: 0.1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package esc_sdk + +import ( + "encoding/json" +) + +// checks if the Access type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &Access{} + +// Access struct for Access +type Access struct { + Receiver *Range `json:"receiver,omitempty"` + Accessors []Accessor `json:"accessors,omitempty"` +} + +// NewAccess instantiates a new Access object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewAccess() *Access { + this := Access{} + return &this +} + +// NewAccessWithDefaults instantiates a new Access object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewAccessWithDefaults() *Access { + this := Access{} + return &this +} + +// GetReceiver returns the Receiver field value if set, zero value otherwise. +func (o *Access) GetReceiver() Range { + if o == nil || IsNil(o.Receiver) { + var ret Range + return ret + } + return *o.Receiver +} + +// GetReceiverOk returns a tuple with the Receiver field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Access) GetReceiverOk() (*Range, bool) { + if o == nil || IsNil(o.Receiver) { + return nil, false + } + return o.Receiver, true +} + +// HasReceiver returns a boolean if a field has been set. +func (o *Access) HasReceiver() bool { + if o != nil && !IsNil(o.Receiver) { + return true + } + + return false +} + +// SetReceiver gets a reference to the given Range and assigns it to the Receiver field. +func (o *Access) SetReceiver(v Range) { + o.Receiver = &v +} + +// GetAccessors returns the Accessors field value if set, zero value otherwise. +func (o *Access) GetAccessors() []Accessor { + if o == nil || IsNil(o.Accessors) { + var ret []Accessor + return ret + } + return o.Accessors +} + +// GetAccessorsOk returns a tuple with the Accessors field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Access) GetAccessorsOk() ([]Accessor, bool) { + if o == nil || IsNil(o.Accessors) { + return nil, false + } + return o.Accessors, true +} + +// HasAccessors returns a boolean if a field has been set. +func (o *Access) HasAccessors() bool { + if o != nil && !IsNil(o.Accessors) { + return true + } + + return false +} + +// SetAccessors gets a reference to the given []Accessor and assigns it to the Accessors field. +func (o *Access) SetAccessors(v []Accessor) { + o.Accessors = v +} + +func (o Access) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o Access) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Receiver) { + toSerialize["receiver"] = o.Receiver + } + if !IsNil(o.Accessors) { + toSerialize["accessors"] = o.Accessors + } + return toSerialize, nil +} + +type NullableAccess struct { + value *Access + isSet bool +} + +func (v NullableAccess) Get() *Access { + return v.value +} + +func (v *NullableAccess) Set(val *Access) { + v.value = val + v.isSet = true +} + +func (v NullableAccess) IsSet() bool { + return v.isSet +} + +func (v *NullableAccess) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableAccess(val *Access) *NullableAccess { + return &NullableAccess{value: val, isSet: true} +} + +func (v NullableAccess) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableAccess) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/sdk/go/model_accessor.go b/sdk/go/model_accessor.go new file mode 100644 index 00000000..8877b5bb --- /dev/null +++ b/sdk/go/model_accessor.go @@ -0,0 +1,223 @@ +// Copyright 2024, Pulumi Corporation. All rights reserved. +/* +ESC (Environments, Secrets, Config) API + +Pulumi ESC allows you to compose and manage hierarchical collections of configuration and secrets and consume them in various ways. + +API version: 0.1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package esc_sdk + +import ( + "encoding/json" + "bytes" + "fmt" +) + +// checks if the Accessor type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &Accessor{} + +// Accessor struct for Accessor +type Accessor struct { + Index *int32 `json:"index,omitempty"` + Key string `json:"key"` + Range Range `json:"range"` +} + +type _Accessor Accessor + +// NewAccessor instantiates a new Accessor object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewAccessor(key string, range_ Range) *Accessor { + this := Accessor{} + this.Key = key + this.Range = range_ + return &this +} + +// NewAccessorWithDefaults instantiates a new Accessor object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewAccessorWithDefaults() *Accessor { + this := Accessor{} + return &this +} + +// GetIndex returns the Index field value if set, zero value otherwise. +func (o *Accessor) GetIndex() int32 { + if o == nil || IsNil(o.Index) { + var ret int32 + return ret + } + return *o.Index +} + +// GetIndexOk returns a tuple with the Index field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Accessor) GetIndexOk() (*int32, bool) { + if o == nil || IsNil(o.Index) { + return nil, false + } + return o.Index, true +} + +// HasIndex returns a boolean if a field has been set. +func (o *Accessor) HasIndex() bool { + if o != nil && !IsNil(o.Index) { + return true + } + + return false +} + +// SetIndex gets a reference to the given int32 and assigns it to the Index field. +func (o *Accessor) SetIndex(v int32) { + o.Index = &v +} + +// GetKey returns the Key field value +func (o *Accessor) GetKey() string { + if o == nil { + var ret string + return ret + } + + return o.Key +} + +// GetKeyOk returns a tuple with the Key field value +// and a boolean to check if the value has been set. +func (o *Accessor) GetKeyOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Key, true +} + +// SetKey sets field value +func (o *Accessor) SetKey(v string) { + o.Key = v +} + +// GetRange returns the Range field value +func (o *Accessor) GetRange() Range { + if o == nil { + var ret Range + return ret + } + + return o.Range +} + +// GetRangeOk returns a tuple with the Range field value +// and a boolean to check if the value has been set. +func (o *Accessor) GetRangeOk() (*Range, bool) { + if o == nil { + return nil, false + } + return &o.Range, true +} + +// SetRange sets field value +func (o *Accessor) SetRange(v Range) { + o.Range = v +} + +func (o Accessor) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o Accessor) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Index) { + toSerialize["index"] = o.Index + } + toSerialize["key"] = o.Key + toSerialize["range"] = o.Range + return toSerialize, nil +} + +func (o *Accessor) UnmarshalJSON(data []byte) (err error) { + // This validates that all required properties are included in the JSON object + // by unmarshalling the object into a generic map with string keys and checking + // that every required field exists as a key in the generic map. + requiredProperties := []string{ + "key", + "range", + } + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err; + } + + for _, requiredProperty := range(requiredProperties) { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } + } + + varAccessor := _Accessor{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varAccessor) + + if err != nil { + return err + } + + *o = Accessor(varAccessor) + + return err +} + +type NullableAccessor struct { + value *Accessor + isSet bool +} + +func (v NullableAccessor) Get() *Accessor { + return v.value +} + +func (v *NullableAccessor) Set(val *Accessor) { + v.value = val + v.isSet = true +} + +func (v NullableAccessor) IsSet() bool { + return v.isSet +} + +func (v *NullableAccessor) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableAccessor(val *Accessor) *NullableAccessor { + return &NullableAccessor{value: val, isSet: true} +} + +func (v NullableAccessor) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableAccessor) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/sdk/go/model_check_environment.go b/sdk/go/model_check_environment.go new file mode 100644 index 00000000..11da0a98 --- /dev/null +++ b/sdk/go/model_check_environment.go @@ -0,0 +1,271 @@ +// Copyright 2024, Pulumi Corporation. All rights reserved. +/* +ESC (Environments, Secrets, Config) API + +Pulumi ESC allows you to compose and manage hierarchical collections of configuration and secrets and consume them in various ways. + +API version: 0.1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package esc_sdk + +import ( + "encoding/json" +) + +// checks if the CheckEnvironment type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &CheckEnvironment{} + +// CheckEnvironment struct for CheckEnvironment +type CheckEnvironment struct { + Exprs *map[string]Expr `json:"exprs,omitempty"` + Properties *map[string]Value `json:"properties,omitempty"` + Schema map[string]interface{} `json:"schema,omitempty"` + ExecutionContext *EvaluatedExecutionContext `json:"executionContext,omitempty"` + Diagnostics []EnvironmentDiagnostic `json:"diagnostics,omitempty"` +} + +// NewCheckEnvironment instantiates a new CheckEnvironment object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewCheckEnvironment() *CheckEnvironment { + this := CheckEnvironment{} + return &this +} + +// NewCheckEnvironmentWithDefaults instantiates a new CheckEnvironment object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewCheckEnvironmentWithDefaults() *CheckEnvironment { + this := CheckEnvironment{} + return &this +} + +// GetExprs returns the Exprs field value if set, zero value otherwise. +func (o *CheckEnvironment) GetExprs() map[string]Expr { + if o == nil || IsNil(o.Exprs) { + var ret map[string]Expr + return ret + } + return *o.Exprs +} + +// GetExprsOk returns a tuple with the Exprs field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CheckEnvironment) GetExprsOk() (*map[string]Expr, bool) { + if o == nil || IsNil(o.Exprs) { + return nil, false + } + return o.Exprs, true +} + +// HasExprs returns a boolean if a field has been set. +func (o *CheckEnvironment) HasExprs() bool { + if o != nil && !IsNil(o.Exprs) { + return true + } + + return false +} + +// SetExprs gets a reference to the given map[string]Expr and assigns it to the Exprs field. +func (o *CheckEnvironment) SetExprs(v map[string]Expr) { + o.Exprs = &v +} + +// GetProperties returns the Properties field value if set, zero value otherwise. +func (o *CheckEnvironment) GetProperties() map[string]Value { + if o == nil || IsNil(o.Properties) { + var ret map[string]Value + return ret + } + return *o.Properties +} + +// GetPropertiesOk returns a tuple with the Properties field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CheckEnvironment) GetPropertiesOk() (*map[string]Value, bool) { + if o == nil || IsNil(o.Properties) { + return nil, false + } + return o.Properties, true +} + +// HasProperties returns a boolean if a field has been set. +func (o *CheckEnvironment) HasProperties() bool { + if o != nil && !IsNil(o.Properties) { + return true + } + + return false +} + +// SetProperties gets a reference to the given map[string]Value and assigns it to the Properties field. +func (o *CheckEnvironment) SetProperties(v map[string]Value) { + o.Properties = &v +} + +// GetSchema returns the Schema field value if set, zero value otherwise. +func (o *CheckEnvironment) GetSchema() map[string]interface{} { + if o == nil || IsNil(o.Schema) { + var ret map[string]interface{} + return ret + } + return o.Schema +} + +// GetSchemaOk returns a tuple with the Schema field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CheckEnvironment) GetSchemaOk() (map[string]interface{}, bool) { + if o == nil || IsNil(o.Schema) { + return map[string]interface{}{}, false + } + return o.Schema, true +} + +// HasSchema returns a boolean if a field has been set. +func (o *CheckEnvironment) HasSchema() bool { + if o != nil && !IsNil(o.Schema) { + return true + } + + return false +} + +// SetSchema gets a reference to the given map[string]interface{} and assigns it to the Schema field. +func (o *CheckEnvironment) SetSchema(v map[string]interface{}) { + o.Schema = v +} + +// GetExecutionContext returns the ExecutionContext field value if set, zero value otherwise. +func (o *CheckEnvironment) GetExecutionContext() EvaluatedExecutionContext { + if o == nil || IsNil(o.ExecutionContext) { + var ret EvaluatedExecutionContext + return ret + } + return *o.ExecutionContext +} + +// GetExecutionContextOk returns a tuple with the ExecutionContext field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CheckEnvironment) GetExecutionContextOk() (*EvaluatedExecutionContext, bool) { + if o == nil || IsNil(o.ExecutionContext) { + return nil, false + } + return o.ExecutionContext, true +} + +// HasExecutionContext returns a boolean if a field has been set. +func (o *CheckEnvironment) HasExecutionContext() bool { + if o != nil && !IsNil(o.ExecutionContext) { + return true + } + + return false +} + +// SetExecutionContext gets a reference to the given EvaluatedExecutionContext and assigns it to the ExecutionContext field. +func (o *CheckEnvironment) SetExecutionContext(v EvaluatedExecutionContext) { + o.ExecutionContext = &v +} + +// GetDiagnostics returns the Diagnostics field value if set, zero value otherwise. +func (o *CheckEnvironment) GetDiagnostics() []EnvironmentDiagnostic { + if o == nil || IsNil(o.Diagnostics) { + var ret []EnvironmentDiagnostic + return ret + } + return o.Diagnostics +} + +// GetDiagnosticsOk returns a tuple with the Diagnostics field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CheckEnvironment) GetDiagnosticsOk() ([]EnvironmentDiagnostic, bool) { + if o == nil || IsNil(o.Diagnostics) { + return nil, false + } + return o.Diagnostics, true +} + +// HasDiagnostics returns a boolean if a field has been set. +func (o *CheckEnvironment) HasDiagnostics() bool { + if o != nil && !IsNil(o.Diagnostics) { + return true + } + + return false +} + +// SetDiagnostics gets a reference to the given []EnvironmentDiagnostic and assigns it to the Diagnostics field. +func (o *CheckEnvironment) SetDiagnostics(v []EnvironmentDiagnostic) { + o.Diagnostics = v +} + +func (o CheckEnvironment) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o CheckEnvironment) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Exprs) { + toSerialize["exprs"] = o.Exprs + } + if !IsNil(o.Properties) { + toSerialize["properties"] = o.Properties + } + if !IsNil(o.Schema) { + toSerialize["schema"] = o.Schema + } + if !IsNil(o.ExecutionContext) { + toSerialize["executionContext"] = o.ExecutionContext + } + if !IsNil(o.Diagnostics) { + toSerialize["diagnostics"] = o.Diagnostics + } + return toSerialize, nil +} + +type NullableCheckEnvironment struct { + value *CheckEnvironment + isSet bool +} + +func (v NullableCheckEnvironment) Get() *CheckEnvironment { + return v.value +} + +func (v *NullableCheckEnvironment) Set(val *CheckEnvironment) { + v.value = val + v.isSet = true +} + +func (v NullableCheckEnvironment) IsSet() bool { + return v.isSet +} + +func (v *NullableCheckEnvironment) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableCheckEnvironment(val *CheckEnvironment) *NullableCheckEnvironment { + return &NullableCheckEnvironment{value: val, isSet: true} +} + +func (v NullableCheckEnvironment) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableCheckEnvironment) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/sdk/go/model_environment.go b/sdk/go/model_environment.go new file mode 100644 index 00000000..3713b43e --- /dev/null +++ b/sdk/go/model_environment.go @@ -0,0 +1,236 @@ +// Copyright 2024, Pulumi Corporation. All rights reserved. +/* +ESC (Environments, Secrets, Config) API + +Pulumi ESC allows you to compose and manage hierarchical collections of configuration and secrets and consume them in various ways. + +API version: 0.1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package esc_sdk + +import ( + "encoding/json" +) + +// checks if the Environment type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &Environment{} + +// Environment struct for Environment +type Environment struct { + Exprs *map[string]Expr `json:"exprs,omitempty"` + Properties *map[string]Value `json:"properties,omitempty"` + Schema interface{} `json:"schema,omitempty"` + ExecutionContext *EvaluatedExecutionContext `json:"executionContext,omitempty"` +} + +// NewEnvironment instantiates a new Environment object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewEnvironment() *Environment { + this := Environment{} + return &this +} + +// NewEnvironmentWithDefaults instantiates a new Environment object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewEnvironmentWithDefaults() *Environment { + this := Environment{} + return &this +} + +// GetExprs returns the Exprs field value if set, zero value otherwise. +func (o *Environment) GetExprs() map[string]Expr { + if o == nil || IsNil(o.Exprs) { + var ret map[string]Expr + return ret + } + return *o.Exprs +} + +// GetExprsOk returns a tuple with the Exprs field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Environment) GetExprsOk() (*map[string]Expr, bool) { + if o == nil || IsNil(o.Exprs) { + return nil, false + } + return o.Exprs, true +} + +// HasExprs returns a boolean if a field has been set. +func (o *Environment) HasExprs() bool { + if o != nil && !IsNil(o.Exprs) { + return true + } + + return false +} + +// SetExprs gets a reference to the given map[string]Expr and assigns it to the Exprs field. +func (o *Environment) SetExprs(v map[string]Expr) { + o.Exprs = &v +} + +// GetProperties returns the Properties field value if set, zero value otherwise. +func (o *Environment) GetProperties() map[string]Value { + if o == nil || IsNil(o.Properties) { + var ret map[string]Value + return ret + } + return *o.Properties +} + +// GetPropertiesOk returns a tuple with the Properties field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Environment) GetPropertiesOk() (*map[string]Value, bool) { + if o == nil || IsNil(o.Properties) { + return nil, false + } + return o.Properties, true +} + +// HasProperties returns a boolean if a field has been set. +func (o *Environment) HasProperties() bool { + if o != nil && !IsNil(o.Properties) { + return true + } + + return false +} + +// SetProperties gets a reference to the given map[string]Value and assigns it to the Properties field. +func (o *Environment) SetProperties(v map[string]Value) { + o.Properties = &v +} + +// GetSchema returns the Schema field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *Environment) GetSchema() interface{} { + if o == nil { + var ret interface{} + return ret + } + return o.Schema +} + +// GetSchemaOk returns a tuple with the Schema field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned +func (o *Environment) GetSchemaOk() (*interface{}, bool) { + if o == nil || IsNil(o.Schema) { + return nil, false + } + return &o.Schema, true +} + +// HasSchema returns a boolean if a field has been set. +func (o *Environment) HasSchema() bool { + if o != nil && IsNil(o.Schema) { + return true + } + + return false +} + +// SetSchema gets a reference to the given interface{} and assigns it to the Schema field. +func (o *Environment) SetSchema(v interface{}) { + o.Schema = v +} + +// GetExecutionContext returns the ExecutionContext field value if set, zero value otherwise. +func (o *Environment) GetExecutionContext() EvaluatedExecutionContext { + if o == nil || IsNil(o.ExecutionContext) { + var ret EvaluatedExecutionContext + return ret + } + return *o.ExecutionContext +} + +// GetExecutionContextOk returns a tuple with the ExecutionContext field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Environment) GetExecutionContextOk() (*EvaluatedExecutionContext, bool) { + if o == nil || IsNil(o.ExecutionContext) { + return nil, false + } + return o.ExecutionContext, true +} + +// HasExecutionContext returns a boolean if a field has been set. +func (o *Environment) HasExecutionContext() bool { + if o != nil && !IsNil(o.ExecutionContext) { + return true + } + + return false +} + +// SetExecutionContext gets a reference to the given EvaluatedExecutionContext and assigns it to the ExecutionContext field. +func (o *Environment) SetExecutionContext(v EvaluatedExecutionContext) { + o.ExecutionContext = &v +} + +func (o Environment) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o Environment) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Exprs) { + toSerialize["exprs"] = o.Exprs + } + if !IsNil(o.Properties) { + toSerialize["properties"] = o.Properties + } + if o.Schema != nil { + toSerialize["schema"] = o.Schema + } + if !IsNil(o.ExecutionContext) { + toSerialize["executionContext"] = o.ExecutionContext + } + return toSerialize, nil +} + +type NullableEnvironment struct { + value *Environment + isSet bool +} + +func (v NullableEnvironment) Get() *Environment { + return v.value +} + +func (v *NullableEnvironment) Set(val *Environment) { + v.value = val + v.isSet = true +} + +func (v NullableEnvironment) IsSet() bool { + return v.isSet +} + +func (v *NullableEnvironment) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableEnvironment(val *Environment) *NullableEnvironment { + return &NullableEnvironment{value: val, isSet: true} +} + +func (v NullableEnvironment) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableEnvironment) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/sdk/go/model_environment_definition.go b/sdk/go/model_environment_definition.go new file mode 100644 index 00000000..b5cde593 --- /dev/null +++ b/sdk/go/model_environment_definition.go @@ -0,0 +1,163 @@ +// Copyright 2024, Pulumi Corporation. All rights reserved. +/* +ESC (Environments, Secrets, Config) API + +Pulumi ESC allows you to compose and manage hierarchical collections of configuration and secrets and consume them in various ways. + +API version: 0.1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package esc_sdk + +import ( + "encoding/json" +) + +// checks if the EnvironmentDefinition type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &EnvironmentDefinition{} + +// EnvironmentDefinition struct for EnvironmentDefinition +type EnvironmentDefinition struct { + Imports []string `json:"imports,omitempty"` + Values *EnvironmentDefinitionValues `json:"values,omitempty"` +} + +// NewEnvironmentDefinition instantiates a new EnvironmentDefinition object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewEnvironmentDefinition() *EnvironmentDefinition { + this := EnvironmentDefinition{} + return &this +} + +// NewEnvironmentDefinitionWithDefaults instantiates a new EnvironmentDefinition object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewEnvironmentDefinitionWithDefaults() *EnvironmentDefinition { + this := EnvironmentDefinition{} + return &this +} + +// GetImports returns the Imports field value if set, zero value otherwise. +func (o *EnvironmentDefinition) GetImports() []string { + if o == nil || IsNil(o.Imports) { + var ret []string + return ret + } + return o.Imports +} + +// GetImportsOk returns a tuple with the Imports field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *EnvironmentDefinition) GetImportsOk() ([]string, bool) { + if o == nil || IsNil(o.Imports) { + return nil, false + } + return o.Imports, true +} + +// HasImports returns a boolean if a field has been set. +func (o *EnvironmentDefinition) HasImports() bool { + if o != nil && !IsNil(o.Imports) { + return true + } + + return false +} + +// SetImports gets a reference to the given []string and assigns it to the Imports field. +func (o *EnvironmentDefinition) SetImports(v []string) { + o.Imports = v +} + +// GetValues returns the Values field value if set, zero value otherwise. +func (o *EnvironmentDefinition) GetValues() EnvironmentDefinitionValues { + if o == nil || IsNil(o.Values) { + var ret EnvironmentDefinitionValues + return ret + } + return *o.Values +} + +// GetValuesOk returns a tuple with the Values field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *EnvironmentDefinition) GetValuesOk() (*EnvironmentDefinitionValues, bool) { + if o == nil || IsNil(o.Values) { + return nil, false + } + return o.Values, true +} + +// HasValues returns a boolean if a field has been set. +func (o *EnvironmentDefinition) HasValues() bool { + if o != nil && !IsNil(o.Values) { + return true + } + + return false +} + +// SetValues gets a reference to the given EnvironmentDefinitionValues and assigns it to the Values field. +func (o *EnvironmentDefinition) SetValues(v EnvironmentDefinitionValues) { + o.Values = &v +} + +func (o EnvironmentDefinition) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o EnvironmentDefinition) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Imports) { + toSerialize["imports"] = o.Imports + } + if !IsNil(o.Values) { + toSerialize["values"] = o.Values + } + return toSerialize, nil +} + +type NullableEnvironmentDefinition struct { + value *EnvironmentDefinition + isSet bool +} + +func (v NullableEnvironmentDefinition) Get() *EnvironmentDefinition { + return v.value +} + +func (v *NullableEnvironmentDefinition) Set(val *EnvironmentDefinition) { + v.value = val + v.isSet = true +} + +func (v NullableEnvironmentDefinition) IsSet() bool { + return v.isSet +} + +func (v *NullableEnvironmentDefinition) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableEnvironmentDefinition(val *EnvironmentDefinition) *NullableEnvironmentDefinition { + return &NullableEnvironmentDefinition{value: val, isSet: true} +} + +func (v NullableEnvironmentDefinition) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableEnvironmentDefinition) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/sdk/go/model_environment_definition_values.go b/sdk/go/model_environment_definition_values.go new file mode 100644 index 00000000..60863a06 --- /dev/null +++ b/sdk/go/model_environment_definition_values.go @@ -0,0 +1,230 @@ +// Copyright 2024, Pulumi Corporation. All rights reserved. +/* +ESC (Environments, Secrets, Config) API + +Pulumi ESC allows you to compose and manage hierarchical collections of configuration and secrets and consume them in various ways. + +API version: 0.1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package esc_sdk + +import ( + "encoding/json" +) + +// checks if the EnvironmentDefinitionValues type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &EnvironmentDefinitionValues{} + +// EnvironmentDefinitionValues struct for EnvironmentDefinitionValues +type EnvironmentDefinitionValues struct { + PulumiConfig map[string]interface{} `json:"pulumiConfig,omitempty"` + EnvironmentVariables *map[string]string `json:"environmentVariables,omitempty"` + Files *map[string]string `json:"files,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _EnvironmentDefinitionValues EnvironmentDefinitionValues + +// NewEnvironmentDefinitionValues instantiates a new EnvironmentDefinitionValues object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewEnvironmentDefinitionValues() *EnvironmentDefinitionValues { + this := EnvironmentDefinitionValues{} + return &this +} + +// NewEnvironmentDefinitionValuesWithDefaults instantiates a new EnvironmentDefinitionValues object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewEnvironmentDefinitionValuesWithDefaults() *EnvironmentDefinitionValues { + this := EnvironmentDefinitionValues{} + return &this +} + +// GetPulumiConfig returns the PulumiConfig field value if set, zero value otherwise. +func (o *EnvironmentDefinitionValues) GetPulumiConfig() map[string]interface{} { + if o == nil || IsNil(o.PulumiConfig) { + var ret map[string]interface{} + return ret + } + return o.PulumiConfig +} + +// GetPulumiConfigOk returns a tuple with the PulumiConfig field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *EnvironmentDefinitionValues) GetPulumiConfigOk() (map[string]interface{}, bool) { + if o == nil || IsNil(o.PulumiConfig) { + return map[string]interface{}{}, false + } + return o.PulumiConfig, true +} + +// HasPulumiConfig returns a boolean if a field has been set. +func (o *EnvironmentDefinitionValues) HasPulumiConfig() bool { + if o != nil && !IsNil(o.PulumiConfig) { + return true + } + + return false +} + +// SetPulumiConfig gets a reference to the given map[string]interface{} and assigns it to the PulumiConfig field. +func (o *EnvironmentDefinitionValues) SetPulumiConfig(v map[string]interface{}) { + o.PulumiConfig = v +} + +// GetEnvironmentVariables returns the EnvironmentVariables field value if set, zero value otherwise. +func (o *EnvironmentDefinitionValues) GetEnvironmentVariables() map[string]string { + if o == nil || IsNil(o.EnvironmentVariables) { + var ret map[string]string + return ret + } + return *o.EnvironmentVariables +} + +// GetEnvironmentVariablesOk returns a tuple with the EnvironmentVariables field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *EnvironmentDefinitionValues) GetEnvironmentVariablesOk() (*map[string]string, bool) { + if o == nil || IsNil(o.EnvironmentVariables) { + return nil, false + } + return o.EnvironmentVariables, true +} + +// HasEnvironmentVariables returns a boolean if a field has been set. +func (o *EnvironmentDefinitionValues) HasEnvironmentVariables() bool { + if o != nil && !IsNil(o.EnvironmentVariables) { + return true + } + + return false +} + +// SetEnvironmentVariables gets a reference to the given map[string]string and assigns it to the EnvironmentVariables field. +func (o *EnvironmentDefinitionValues) SetEnvironmentVariables(v map[string]string) { + o.EnvironmentVariables = &v +} + +// GetFiles returns the Files field value if set, zero value otherwise. +func (o *EnvironmentDefinitionValues) GetFiles() map[string]string { + if o == nil || IsNil(o.Files) { + var ret map[string]string + return ret + } + return *o.Files +} + +// GetFilesOk returns a tuple with the Files field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *EnvironmentDefinitionValues) GetFilesOk() (*map[string]string, bool) { + if o == nil || IsNil(o.Files) { + return nil, false + } + return o.Files, true +} + +// HasFiles returns a boolean if a field has been set. +func (o *EnvironmentDefinitionValues) HasFiles() bool { + if o != nil && !IsNil(o.Files) { + return true + } + + return false +} + +// SetFiles gets a reference to the given map[string]string and assigns it to the Files field. +func (o *EnvironmentDefinitionValues) SetFiles(v map[string]string) { + o.Files = &v +} + +func (o EnvironmentDefinitionValues) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o EnvironmentDefinitionValues) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.PulumiConfig) { + toSerialize["pulumiConfig"] = o.PulumiConfig + } + if !IsNil(o.EnvironmentVariables) { + toSerialize["environmentVariables"] = o.EnvironmentVariables + } + if !IsNil(o.Files) { + toSerialize["files"] = o.Files + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *EnvironmentDefinitionValues) UnmarshalJSON(data []byte) (err error) { + varEnvironmentDefinitionValues := _EnvironmentDefinitionValues{} + + err = json.Unmarshal(data, &varEnvironmentDefinitionValues) + + if err != nil { + return err + } + + *o = EnvironmentDefinitionValues(varEnvironmentDefinitionValues) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "pulumiConfig") + delete(additionalProperties, "environmentVariables") + delete(additionalProperties, "files") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableEnvironmentDefinitionValues struct { + value *EnvironmentDefinitionValues + isSet bool +} + +func (v NullableEnvironmentDefinitionValues) Get() *EnvironmentDefinitionValues { + return v.value +} + +func (v *NullableEnvironmentDefinitionValues) Set(val *EnvironmentDefinitionValues) { + v.value = val + v.isSet = true +} + +func (v NullableEnvironmentDefinitionValues) IsSet() bool { + return v.isSet +} + +func (v *NullableEnvironmentDefinitionValues) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableEnvironmentDefinitionValues(val *EnvironmentDefinitionValues) *NullableEnvironmentDefinitionValues { + return &NullableEnvironmentDefinitionValues{value: val, isSet: true} +} + +func (v NullableEnvironmentDefinitionValues) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableEnvironmentDefinitionValues) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/sdk/go/model_environment_diagnostic.go b/sdk/go/model_environment_diagnostic.go new file mode 100644 index 00000000..8d2a9715 --- /dev/null +++ b/sdk/go/model_environment_diagnostic.go @@ -0,0 +1,243 @@ +// Copyright 2024, Pulumi Corporation. All rights reserved. +/* +ESC (Environments, Secrets, Config) API + +Pulumi ESC allows you to compose and manage hierarchical collections of configuration and secrets and consume them in various ways. + +API version: 0.1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package esc_sdk + +import ( + "encoding/json" + "fmt" +) + +// checks if the EnvironmentDiagnostic type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &EnvironmentDiagnostic{} + +// EnvironmentDiagnostic struct for EnvironmentDiagnostic +type EnvironmentDiagnostic struct { + Summary string `json:"summary"` + Path *string `json:"path,omitempty"` + Range *Range `json:"range,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _EnvironmentDiagnostic EnvironmentDiagnostic + +// NewEnvironmentDiagnostic instantiates a new EnvironmentDiagnostic object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewEnvironmentDiagnostic(summary string) *EnvironmentDiagnostic { + this := EnvironmentDiagnostic{} + this.Summary = summary + return &this +} + +// NewEnvironmentDiagnosticWithDefaults instantiates a new EnvironmentDiagnostic object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewEnvironmentDiagnosticWithDefaults() *EnvironmentDiagnostic { + this := EnvironmentDiagnostic{} + return &this +} + +// GetSummary returns the Summary field value +func (o *EnvironmentDiagnostic) GetSummary() string { + if o == nil { + var ret string + return ret + } + + return o.Summary +} + +// GetSummaryOk returns a tuple with the Summary field value +// and a boolean to check if the value has been set. +func (o *EnvironmentDiagnostic) GetSummaryOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Summary, true +} + +// SetSummary sets field value +func (o *EnvironmentDiagnostic) SetSummary(v string) { + o.Summary = v +} + +// GetPath returns the Path field value if set, zero value otherwise. +func (o *EnvironmentDiagnostic) GetPath() string { + if o == nil || IsNil(o.Path) { + var ret string + return ret + } + return *o.Path +} + +// GetPathOk returns a tuple with the Path field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *EnvironmentDiagnostic) GetPathOk() (*string, bool) { + if o == nil || IsNil(o.Path) { + return nil, false + } + return o.Path, true +} + +// HasPath returns a boolean if a field has been set. +func (o *EnvironmentDiagnostic) HasPath() bool { + if o != nil && !IsNil(o.Path) { + return true + } + + return false +} + +// SetPath gets a reference to the given string and assigns it to the Path field. +func (o *EnvironmentDiagnostic) SetPath(v string) { + o.Path = &v +} + +// GetRange returns the Range field value if set, zero value otherwise. +func (o *EnvironmentDiagnostic) GetRange() Range { + if o == nil || IsNil(o.Range) { + var ret Range + return ret + } + return *o.Range +} + +// GetRangeOk returns a tuple with the Range field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *EnvironmentDiagnostic) GetRangeOk() (*Range, bool) { + if o == nil || IsNil(o.Range) { + return nil, false + } + return o.Range, true +} + +// HasRange returns a boolean if a field has been set. +func (o *EnvironmentDiagnostic) HasRange() bool { + if o != nil && !IsNil(o.Range) { + return true + } + + return false +} + +// SetRange gets a reference to the given Range and assigns it to the Range field. +func (o *EnvironmentDiagnostic) SetRange(v Range) { + o.Range = &v +} + +func (o EnvironmentDiagnostic) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o EnvironmentDiagnostic) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["summary"] = o.Summary + if !IsNil(o.Path) { + toSerialize["path"] = o.Path + } + if !IsNil(o.Range) { + toSerialize["range"] = o.Range + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *EnvironmentDiagnostic) UnmarshalJSON(data []byte) (err error) { + // This validates that all required properties are included in the JSON object + // by unmarshalling the object into a generic map with string keys and checking + // that every required field exists as a key in the generic map. + requiredProperties := []string{ + "summary", + } + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err; + } + + for _, requiredProperty := range(requiredProperties) { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } + } + + varEnvironmentDiagnostic := _EnvironmentDiagnostic{} + + err = json.Unmarshal(data, &varEnvironmentDiagnostic) + + if err != nil { + return err + } + + *o = EnvironmentDiagnostic(varEnvironmentDiagnostic) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "summary") + delete(additionalProperties, "path") + delete(additionalProperties, "range") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableEnvironmentDiagnostic struct { + value *EnvironmentDiagnostic + isSet bool +} + +func (v NullableEnvironmentDiagnostic) Get() *EnvironmentDiagnostic { + return v.value +} + +func (v *NullableEnvironmentDiagnostic) Set(val *EnvironmentDiagnostic) { + v.value = val + v.isSet = true +} + +func (v NullableEnvironmentDiagnostic) IsSet() bool { + return v.isSet +} + +func (v *NullableEnvironmentDiagnostic) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableEnvironmentDiagnostic(val *EnvironmentDiagnostic) *NullableEnvironmentDiagnostic { + return &NullableEnvironmentDiagnostic{value: val, isSet: true} +} + +func (v NullableEnvironmentDiagnostic) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableEnvironmentDiagnostic) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/sdk/go/model_environment_diagnostics.go b/sdk/go/model_environment_diagnostics.go new file mode 100644 index 00000000..863311d5 --- /dev/null +++ b/sdk/go/model_environment_diagnostics.go @@ -0,0 +1,127 @@ +// Copyright 2024, Pulumi Corporation. All rights reserved. +/* +ESC (Environments, Secrets, Config) API + +Pulumi ESC allows you to compose and manage hierarchical collections of configuration and secrets and consume them in various ways. + +API version: 0.1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package esc_sdk + +import ( + "encoding/json" +) + +// checks if the EnvironmentDiagnostics type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &EnvironmentDiagnostics{} + +// EnvironmentDiagnostics struct for EnvironmentDiagnostics +type EnvironmentDiagnostics struct { + Diagnostics []EnvironmentDiagnostic `json:"diagnostics,omitempty"` +} + +// NewEnvironmentDiagnostics instantiates a new EnvironmentDiagnostics object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewEnvironmentDiagnostics() *EnvironmentDiagnostics { + this := EnvironmentDiagnostics{} + return &this +} + +// NewEnvironmentDiagnosticsWithDefaults instantiates a new EnvironmentDiagnostics object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewEnvironmentDiagnosticsWithDefaults() *EnvironmentDiagnostics { + this := EnvironmentDiagnostics{} + return &this +} + +// GetDiagnostics returns the Diagnostics field value if set, zero value otherwise. +func (o *EnvironmentDiagnostics) GetDiagnostics() []EnvironmentDiagnostic { + if o == nil || IsNil(o.Diagnostics) { + var ret []EnvironmentDiagnostic + return ret + } + return o.Diagnostics +} + +// GetDiagnosticsOk returns a tuple with the Diagnostics field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *EnvironmentDiagnostics) GetDiagnosticsOk() ([]EnvironmentDiagnostic, bool) { + if o == nil || IsNil(o.Diagnostics) { + return nil, false + } + return o.Diagnostics, true +} + +// HasDiagnostics returns a boolean if a field has been set. +func (o *EnvironmentDiagnostics) HasDiagnostics() bool { + if o != nil && !IsNil(o.Diagnostics) { + return true + } + + return false +} + +// SetDiagnostics gets a reference to the given []EnvironmentDiagnostic and assigns it to the Diagnostics field. +func (o *EnvironmentDiagnostics) SetDiagnostics(v []EnvironmentDiagnostic) { + o.Diagnostics = v +} + +func (o EnvironmentDiagnostics) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o EnvironmentDiagnostics) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Diagnostics) { + toSerialize["diagnostics"] = o.Diagnostics + } + return toSerialize, nil +} + +type NullableEnvironmentDiagnostics struct { + value *EnvironmentDiagnostics + isSet bool +} + +func (v NullableEnvironmentDiagnostics) Get() *EnvironmentDiagnostics { + return v.value +} + +func (v *NullableEnvironmentDiagnostics) Set(val *EnvironmentDiagnostics) { + v.value = val + v.isSet = true +} + +func (v NullableEnvironmentDiagnostics) IsSet() bool { + return v.isSet +} + +func (v *NullableEnvironmentDiagnostics) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableEnvironmentDiagnostics(val *EnvironmentDiagnostics) *NullableEnvironmentDiagnostics { + return &NullableEnvironmentDiagnostics{value: val, isSet: true} +} + +func (v NullableEnvironmentDiagnostics) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableEnvironmentDiagnostics) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/sdk/go/model_error.go b/sdk/go/model_error.go new file mode 100644 index 00000000..20e50d32 --- /dev/null +++ b/sdk/go/model_error.go @@ -0,0 +1,187 @@ +// Copyright 2024, Pulumi Corporation. All rights reserved. +/* +ESC (Environments, Secrets, Config) API + +Pulumi ESC allows you to compose and manage hierarchical collections of configuration and secrets and consume them in various ways. + +API version: 0.1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package esc_sdk + +import ( + "encoding/json" + "bytes" + "fmt" +) + +// checks if the Error type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &Error{} + +// Error struct for Error +type Error struct { + Message string `json:"message"` + Code int32 `json:"code"` +} + +type _Error Error + +// NewError instantiates a new Error object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewError(message string, code int32) *Error { + this := Error{} + this.Message = message + this.Code = code + return &this +} + +// NewErrorWithDefaults instantiates a new Error object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewErrorWithDefaults() *Error { + this := Error{} + return &this +} + +// GetMessage returns the Message field value +func (o *Error) GetMessage() string { + if o == nil { + var ret string + return ret + } + + return o.Message +} + +// GetMessageOk returns a tuple with the Message field value +// and a boolean to check if the value has been set. +func (o *Error) GetMessageOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Message, true +} + +// SetMessage sets field value +func (o *Error) SetMessage(v string) { + o.Message = v +} + +// GetCode returns the Code field value +func (o *Error) GetCode() int32 { + if o == nil { + var ret int32 + return ret + } + + return o.Code +} + +// GetCodeOk returns a tuple with the Code field value +// and a boolean to check if the value has been set. +func (o *Error) GetCodeOk() (*int32, bool) { + if o == nil { + return nil, false + } + return &o.Code, true +} + +// SetCode sets field value +func (o *Error) SetCode(v int32) { + o.Code = v +} + +func (o Error) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o Error) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["message"] = o.Message + toSerialize["code"] = o.Code + return toSerialize, nil +} + +func (o *Error) UnmarshalJSON(data []byte) (err error) { + // This validates that all required properties are included in the JSON object + // by unmarshalling the object into a generic map with string keys and checking + // that every required field exists as a key in the generic map. + requiredProperties := []string{ + "message", + "code", + } + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err; + } + + for _, requiredProperty := range(requiredProperties) { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } + } + + varError := _Error{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varError) + + if err != nil { + return err + } + + *o = Error(varError) + + return err +} + +type NullableError struct { + value *Error + isSet bool +} + +func (v NullableError) Get() *Error { + return v.value +} + +func (v *NullableError) Set(val *Error) { + v.value = val + v.isSet = true +} + +func (v NullableError) IsSet() bool { + return v.isSet +} + +func (v *NullableError) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableError(val *Error) *NullableError { + return &NullableError{value: val, isSet: true} +} + +func (v NullableError) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableError) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/sdk/go/model_evaluated_execution_context.go b/sdk/go/model_evaluated_execution_context.go new file mode 100644 index 00000000..89b30a9b --- /dev/null +++ b/sdk/go/model_evaluated_execution_context.go @@ -0,0 +1,164 @@ +// Copyright 2024, Pulumi Corporation. All rights reserved. +/* +ESC (Environments, Secrets, Config) API + +Pulumi ESC allows you to compose and manage hierarchical collections of configuration and secrets and consume them in various ways. + +API version: 0.1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package esc_sdk + +import ( + "encoding/json" +) + +// checks if the EvaluatedExecutionContext type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &EvaluatedExecutionContext{} + +// EvaluatedExecutionContext struct for EvaluatedExecutionContext +type EvaluatedExecutionContext struct { + Properties *map[string]Value `json:"properties,omitempty"` + Schema interface{} `json:"schema,omitempty"` +} + +// NewEvaluatedExecutionContext instantiates a new EvaluatedExecutionContext object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewEvaluatedExecutionContext() *EvaluatedExecutionContext { + this := EvaluatedExecutionContext{} + return &this +} + +// NewEvaluatedExecutionContextWithDefaults instantiates a new EvaluatedExecutionContext object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewEvaluatedExecutionContextWithDefaults() *EvaluatedExecutionContext { + this := EvaluatedExecutionContext{} + return &this +} + +// GetProperties returns the Properties field value if set, zero value otherwise. +func (o *EvaluatedExecutionContext) GetProperties() map[string]Value { + if o == nil || IsNil(o.Properties) { + var ret map[string]Value + return ret + } + return *o.Properties +} + +// GetPropertiesOk returns a tuple with the Properties field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *EvaluatedExecutionContext) GetPropertiesOk() (*map[string]Value, bool) { + if o == nil || IsNil(o.Properties) { + return nil, false + } + return o.Properties, true +} + +// HasProperties returns a boolean if a field has been set. +func (o *EvaluatedExecutionContext) HasProperties() bool { + if o != nil && !IsNil(o.Properties) { + return true + } + + return false +} + +// SetProperties gets a reference to the given map[string]Value and assigns it to the Properties field. +func (o *EvaluatedExecutionContext) SetProperties(v map[string]Value) { + o.Properties = &v +} + +// GetSchema returns the Schema field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *EvaluatedExecutionContext) GetSchema() interface{} { + if o == nil { + var ret interface{} + return ret + } + return o.Schema +} + +// GetSchemaOk returns a tuple with the Schema field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned +func (o *EvaluatedExecutionContext) GetSchemaOk() (*interface{}, bool) { + if o == nil || IsNil(o.Schema) { + return nil, false + } + return &o.Schema, true +} + +// HasSchema returns a boolean if a field has been set. +func (o *EvaluatedExecutionContext) HasSchema() bool { + if o != nil && IsNil(o.Schema) { + return true + } + + return false +} + +// SetSchema gets a reference to the given interface{} and assigns it to the Schema field. +func (o *EvaluatedExecutionContext) SetSchema(v interface{}) { + o.Schema = v +} + +func (o EvaluatedExecutionContext) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o EvaluatedExecutionContext) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Properties) { + toSerialize["properties"] = o.Properties + } + if o.Schema != nil { + toSerialize["schema"] = o.Schema + } + return toSerialize, nil +} + +type NullableEvaluatedExecutionContext struct { + value *EvaluatedExecutionContext + isSet bool +} + +func (v NullableEvaluatedExecutionContext) Get() *EvaluatedExecutionContext { + return v.value +} + +func (v *NullableEvaluatedExecutionContext) Set(val *EvaluatedExecutionContext) { + v.value = val + v.isSet = true +} + +func (v NullableEvaluatedExecutionContext) IsSet() bool { + return v.isSet +} + +func (v *NullableEvaluatedExecutionContext) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableEvaluatedExecutionContext(val *EvaluatedExecutionContext) *NullableEvaluatedExecutionContext { + return &NullableEvaluatedExecutionContext{value: val, isSet: true} +} + +func (v NullableEvaluatedExecutionContext) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableEvaluatedExecutionContext) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/sdk/go/model_expr.go b/sdk/go/model_expr.go new file mode 100644 index 00000000..729b2253 --- /dev/null +++ b/sdk/go/model_expr.go @@ -0,0 +1,489 @@ +// Copyright 2024, Pulumi Corporation. All rights reserved. +/* +ESC (Environments, Secrets, Config) API + +Pulumi ESC allows you to compose and manage hierarchical collections of configuration and secrets and consume them in various ways. + +API version: 0.1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package esc_sdk + +import ( + "encoding/json" +) + +// checks if the Expr type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &Expr{} + +// Expr struct for Expr +type Expr struct { + Range *Range `json:"range,omitempty"` + Base *Expr `json:"base,omitempty"` + Schema interface{} `json:"schema,omitempty"` + KeyRanges *map[string]Range `json:"keyRanges,omitempty"` + Literal interface{} `json:"literal,omitempty"` + Interpolate []Interpolation `json:"interpolate,omitempty"` + Symbol []PropertyAccessor `json:"symbol,omitempty"` + Access []Access `json:"access,omitempty"` + List []Expr `json:"list,omitempty"` + Object *map[string]Expr `json:"object,omitempty"` + Builtin *ExprBuiltin `json:"builtin,omitempty"` +} + +// NewExpr instantiates a new Expr object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewExpr() *Expr { + this := Expr{} + return &this +} + +// NewExprWithDefaults instantiates a new Expr object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewExprWithDefaults() *Expr { + this := Expr{} + return &this +} + +// GetRange returns the Range field value if set, zero value otherwise. +func (o *Expr) GetRange() Range { + if o == nil || IsNil(o.Range) { + var ret Range + return ret + } + return *o.Range +} + +// GetRangeOk returns a tuple with the Range field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Expr) GetRangeOk() (*Range, bool) { + if o == nil || IsNil(o.Range) { + return nil, false + } + return o.Range, true +} + +// HasRange returns a boolean if a field has been set. +func (o *Expr) HasRange() bool { + if o != nil && !IsNil(o.Range) { + return true + } + + return false +} + +// SetRange gets a reference to the given Range and assigns it to the Range field. +func (o *Expr) SetRange(v Range) { + o.Range = &v +} + +// GetBase returns the Base field value if set, zero value otherwise. +func (o *Expr) GetBase() Expr { + if o == nil || IsNil(o.Base) { + var ret Expr + return ret + } + return *o.Base +} + +// GetBaseOk returns a tuple with the Base field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Expr) GetBaseOk() (*Expr, bool) { + if o == nil || IsNil(o.Base) { + return nil, false + } + return o.Base, true +} + +// HasBase returns a boolean if a field has been set. +func (o *Expr) HasBase() bool { + if o != nil && !IsNil(o.Base) { + return true + } + + return false +} + +// SetBase gets a reference to the given Expr and assigns it to the Base field. +func (o *Expr) SetBase(v Expr) { + o.Base = &v +} + +// GetSchema returns the Schema field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *Expr) GetSchema() interface{} { + if o == nil { + var ret interface{} + return ret + } + return o.Schema +} + +// GetSchemaOk returns a tuple with the Schema field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned +func (o *Expr) GetSchemaOk() (*interface{}, bool) { + if o == nil || IsNil(o.Schema) { + return nil, false + } + return &o.Schema, true +} + +// HasSchema returns a boolean if a field has been set. +func (o *Expr) HasSchema() bool { + if o != nil && IsNil(o.Schema) { + return true + } + + return false +} + +// SetSchema gets a reference to the given interface{} and assigns it to the Schema field. +func (o *Expr) SetSchema(v interface{}) { + o.Schema = v +} + +// GetKeyRanges returns the KeyRanges field value if set, zero value otherwise. +func (o *Expr) GetKeyRanges() map[string]Range { + if o == nil || IsNil(o.KeyRanges) { + var ret map[string]Range + return ret + } + return *o.KeyRanges +} + +// GetKeyRangesOk returns a tuple with the KeyRanges field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Expr) GetKeyRangesOk() (*map[string]Range, bool) { + if o == nil || IsNil(o.KeyRanges) { + return nil, false + } + return o.KeyRanges, true +} + +// HasKeyRanges returns a boolean if a field has been set. +func (o *Expr) HasKeyRanges() bool { + if o != nil && !IsNil(o.KeyRanges) { + return true + } + + return false +} + +// SetKeyRanges gets a reference to the given map[string]Range and assigns it to the KeyRanges field. +func (o *Expr) SetKeyRanges(v map[string]Range) { + o.KeyRanges = &v +} + +// GetLiteral returns the Literal field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *Expr) GetLiteral() interface{} { + if o == nil { + var ret interface{} + return ret + } + return o.Literal +} + +// GetLiteralOk returns a tuple with the Literal field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned +func (o *Expr) GetLiteralOk() (*interface{}, bool) { + if o == nil || IsNil(o.Literal) { + return nil, false + } + return &o.Literal, true +} + +// HasLiteral returns a boolean if a field has been set. +func (o *Expr) HasLiteral() bool { + if o != nil && IsNil(o.Literal) { + return true + } + + return false +} + +// SetLiteral gets a reference to the given interface{} and assigns it to the Literal field. +func (o *Expr) SetLiteral(v interface{}) { + o.Literal = v +} + +// GetInterpolate returns the Interpolate field value if set, zero value otherwise. +func (o *Expr) GetInterpolate() []Interpolation { + if o == nil || IsNil(o.Interpolate) { + var ret []Interpolation + return ret + } + return o.Interpolate +} + +// GetInterpolateOk returns a tuple with the Interpolate field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Expr) GetInterpolateOk() ([]Interpolation, bool) { + if o == nil || IsNil(o.Interpolate) { + return nil, false + } + return o.Interpolate, true +} + +// HasInterpolate returns a boolean if a field has been set. +func (o *Expr) HasInterpolate() bool { + if o != nil && !IsNil(o.Interpolate) { + return true + } + + return false +} + +// SetInterpolate gets a reference to the given []Interpolation and assigns it to the Interpolate field. +func (o *Expr) SetInterpolate(v []Interpolation) { + o.Interpolate = v +} + +// GetSymbol returns the Symbol field value if set, zero value otherwise. +func (o *Expr) GetSymbol() []PropertyAccessor { + if o == nil || IsNil(o.Symbol) { + var ret []PropertyAccessor + return ret + } + return o.Symbol +} + +// GetSymbolOk returns a tuple with the Symbol field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Expr) GetSymbolOk() ([]PropertyAccessor, bool) { + if o == nil || IsNil(o.Symbol) { + return nil, false + } + return o.Symbol, true +} + +// HasSymbol returns a boolean if a field has been set. +func (o *Expr) HasSymbol() bool { + if o != nil && !IsNil(o.Symbol) { + return true + } + + return false +} + +// SetSymbol gets a reference to the given []PropertyAccessor and assigns it to the Symbol field. +func (o *Expr) SetSymbol(v []PropertyAccessor) { + o.Symbol = v +} + +// GetAccess returns the Access field value if set, zero value otherwise. +func (o *Expr) GetAccess() []Access { + if o == nil || IsNil(o.Access) { + var ret []Access + return ret + } + return o.Access +} + +// GetAccessOk returns a tuple with the Access field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Expr) GetAccessOk() ([]Access, bool) { + if o == nil || IsNil(o.Access) { + return nil, false + } + return o.Access, true +} + +// HasAccess returns a boolean if a field has been set. +func (o *Expr) HasAccess() bool { + if o != nil && !IsNil(o.Access) { + return true + } + + return false +} + +// SetAccess gets a reference to the given []Access and assigns it to the Access field. +func (o *Expr) SetAccess(v []Access) { + o.Access = v +} + +// GetList returns the List field value if set, zero value otherwise. +func (o *Expr) GetList() []Expr { + if o == nil || IsNil(o.List) { + var ret []Expr + return ret + } + return o.List +} + +// GetListOk returns a tuple with the List field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Expr) GetListOk() ([]Expr, bool) { + if o == nil || IsNil(o.List) { + return nil, false + } + return o.List, true +} + +// HasList returns a boolean if a field has been set. +func (o *Expr) HasList() bool { + if o != nil && !IsNil(o.List) { + return true + } + + return false +} + +// SetList gets a reference to the given []Expr and assigns it to the List field. +func (o *Expr) SetList(v []Expr) { + o.List = v +} + +// GetObject returns the Object field value if set, zero value otherwise. +func (o *Expr) GetObject() map[string]Expr { + if o == nil || IsNil(o.Object) { + var ret map[string]Expr + return ret + } + return *o.Object +} + +// GetObjectOk returns a tuple with the Object field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Expr) GetObjectOk() (*map[string]Expr, bool) { + if o == nil || IsNil(o.Object) { + return nil, false + } + return o.Object, true +} + +// HasObject returns a boolean if a field has been set. +func (o *Expr) HasObject() bool { + if o != nil && !IsNil(o.Object) { + return true + } + + return false +} + +// SetObject gets a reference to the given map[string]Expr and assigns it to the Object field. +func (o *Expr) SetObject(v map[string]Expr) { + o.Object = &v +} + +// GetBuiltin returns the Builtin field value if set, zero value otherwise. +func (o *Expr) GetBuiltin() ExprBuiltin { + if o == nil || IsNil(o.Builtin) { + var ret ExprBuiltin + return ret + } + return *o.Builtin +} + +// GetBuiltinOk returns a tuple with the Builtin field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Expr) GetBuiltinOk() (*ExprBuiltin, bool) { + if o == nil || IsNil(o.Builtin) { + return nil, false + } + return o.Builtin, true +} + +// HasBuiltin returns a boolean if a field has been set. +func (o *Expr) HasBuiltin() bool { + if o != nil && !IsNil(o.Builtin) { + return true + } + + return false +} + +// SetBuiltin gets a reference to the given ExprBuiltin and assigns it to the Builtin field. +func (o *Expr) SetBuiltin(v ExprBuiltin) { + o.Builtin = &v +} + +func (o Expr) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o Expr) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Range) { + toSerialize["range"] = o.Range + } + if !IsNil(o.Base) { + toSerialize["base"] = o.Base + } + if o.Schema != nil { + toSerialize["schema"] = o.Schema + } + if !IsNil(o.KeyRanges) { + toSerialize["keyRanges"] = o.KeyRanges + } + if o.Literal != nil { + toSerialize["literal"] = o.Literal + } + if !IsNil(o.Interpolate) { + toSerialize["interpolate"] = o.Interpolate + } + if !IsNil(o.Symbol) { + toSerialize["symbol"] = o.Symbol + } + if !IsNil(o.Access) { + toSerialize["access"] = o.Access + } + if !IsNil(o.List) { + toSerialize["list"] = o.List + } + if !IsNil(o.Object) { + toSerialize["object"] = o.Object + } + if !IsNil(o.Builtin) { + toSerialize["builtin"] = o.Builtin + } + return toSerialize, nil +} + +type NullableExpr struct { + value *Expr + isSet bool +} + +func (v NullableExpr) Get() *Expr { + return v.value +} + +func (v *NullableExpr) Set(val *Expr) { + v.value = val + v.isSet = true +} + +func (v NullableExpr) IsSet() bool { + return v.isSet +} + +func (v *NullableExpr) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableExpr(val *Expr) *NullableExpr { + return &NullableExpr{value: val, isSet: true} +} + +func (v NullableExpr) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableExpr) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/sdk/go/model_expr_builtin.go b/sdk/go/model_expr_builtin.go new file mode 100644 index 00000000..980a056a --- /dev/null +++ b/sdk/go/model_expr_builtin.go @@ -0,0 +1,268 @@ +// Copyright 2024, Pulumi Corporation. All rights reserved. +/* +ESC (Environments, Secrets, Config) API + +Pulumi ESC allows you to compose and manage hierarchical collections of configuration and secrets and consume them in various ways. + +API version: 0.1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package esc_sdk + +import ( + "encoding/json" + "bytes" + "fmt" +) + +// checks if the ExprBuiltin type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ExprBuiltin{} + +// ExprBuiltin struct for ExprBuiltin +type ExprBuiltin struct { + Name string `json:"name"` + NameRange *Range `json:"nameRange,omitempty"` + ArgSchema interface{} `json:"argSchema,omitempty"` + Arg *Expr `json:"arg,omitempty"` +} + +type _ExprBuiltin ExprBuiltin + +// NewExprBuiltin instantiates a new ExprBuiltin object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewExprBuiltin(name string) *ExprBuiltin { + this := ExprBuiltin{} + this.Name = name + return &this +} + +// NewExprBuiltinWithDefaults instantiates a new ExprBuiltin object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewExprBuiltinWithDefaults() *ExprBuiltin { + this := ExprBuiltin{} + return &this +} + +// GetName returns the Name field value +func (o *ExprBuiltin) GetName() string { + if o == nil { + var ret string + return ret + } + + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *ExprBuiltin) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value +func (o *ExprBuiltin) SetName(v string) { + o.Name = v +} + +// GetNameRange returns the NameRange field value if set, zero value otherwise. +func (o *ExprBuiltin) GetNameRange() Range { + if o == nil || IsNil(o.NameRange) { + var ret Range + return ret + } + return *o.NameRange +} + +// GetNameRangeOk returns a tuple with the NameRange field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ExprBuiltin) GetNameRangeOk() (*Range, bool) { + if o == nil || IsNil(o.NameRange) { + return nil, false + } + return o.NameRange, true +} + +// HasNameRange returns a boolean if a field has been set. +func (o *ExprBuiltin) HasNameRange() bool { + if o != nil && !IsNil(o.NameRange) { + return true + } + + return false +} + +// SetNameRange gets a reference to the given Range and assigns it to the NameRange field. +func (o *ExprBuiltin) SetNameRange(v Range) { + o.NameRange = &v +} + +// GetArgSchema returns the ArgSchema field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *ExprBuiltin) GetArgSchema() interface{} { + if o == nil { + var ret interface{} + return ret + } + return o.ArgSchema +} + +// GetArgSchemaOk returns a tuple with the ArgSchema field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned +func (o *ExprBuiltin) GetArgSchemaOk() (*interface{}, bool) { + if o == nil || IsNil(o.ArgSchema) { + return nil, false + } + return &o.ArgSchema, true +} + +// HasArgSchema returns a boolean if a field has been set. +func (o *ExprBuiltin) HasArgSchema() bool { + if o != nil && IsNil(o.ArgSchema) { + return true + } + + return false +} + +// SetArgSchema gets a reference to the given interface{} and assigns it to the ArgSchema field. +func (o *ExprBuiltin) SetArgSchema(v interface{}) { + o.ArgSchema = v +} + +// GetArg returns the Arg field value if set, zero value otherwise. +func (o *ExprBuiltin) GetArg() Expr { + if o == nil || IsNil(o.Arg) { + var ret Expr + return ret + } + return *o.Arg +} + +// GetArgOk returns a tuple with the Arg field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ExprBuiltin) GetArgOk() (*Expr, bool) { + if o == nil || IsNil(o.Arg) { + return nil, false + } + return o.Arg, true +} + +// HasArg returns a boolean if a field has been set. +func (o *ExprBuiltin) HasArg() bool { + if o != nil && !IsNil(o.Arg) { + return true + } + + return false +} + +// SetArg gets a reference to the given Expr and assigns it to the Arg field. +func (o *ExprBuiltin) SetArg(v Expr) { + o.Arg = &v +} + +func (o ExprBuiltin) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o ExprBuiltin) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["name"] = o.Name + if !IsNil(o.NameRange) { + toSerialize["nameRange"] = o.NameRange + } + if o.ArgSchema != nil { + toSerialize["argSchema"] = o.ArgSchema + } + if !IsNil(o.Arg) { + toSerialize["arg"] = o.Arg + } + return toSerialize, nil +} + +func (o *ExprBuiltin) UnmarshalJSON(data []byte) (err error) { + // This validates that all required properties are included in the JSON object + // by unmarshalling the object into a generic map with string keys and checking + // that every required field exists as a key in the generic map. + requiredProperties := []string{ + "name", + } + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err; + } + + for _, requiredProperty := range(requiredProperties) { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } + } + + varExprBuiltin := _ExprBuiltin{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varExprBuiltin) + + if err != nil { + return err + } + + *o = ExprBuiltin(varExprBuiltin) + + return err +} + +type NullableExprBuiltin struct { + value *ExprBuiltin + isSet bool +} + +func (v NullableExprBuiltin) Get() *ExprBuiltin { + return v.value +} + +func (v *NullableExprBuiltin) Set(val *ExprBuiltin) { + v.value = val + v.isSet = true +} + +func (v NullableExprBuiltin) IsSet() bool { + return v.isSet +} + +func (v *NullableExprBuiltin) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableExprBuiltin(val *ExprBuiltin) *NullableExprBuiltin { + return &NullableExprBuiltin{value: val, isSet: true} +} + +func (v NullableExprBuiltin) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableExprBuiltin) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/sdk/go/model_interpolation.go b/sdk/go/model_interpolation.go new file mode 100644 index 00000000..19cc3f56 --- /dev/null +++ b/sdk/go/model_interpolation.go @@ -0,0 +1,195 @@ +// Copyright 2024, Pulumi Corporation. All rights reserved. +/* +ESC (Environments, Secrets, Config) API + +Pulumi ESC allows you to compose and manage hierarchical collections of configuration and secrets and consume them in various ways. + +API version: 0.1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package esc_sdk + +import ( + "encoding/json" + "bytes" + "fmt" +) + +// checks if the Interpolation type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &Interpolation{} + +// Interpolation struct for Interpolation +type Interpolation struct { + Text string `json:"text"` + Value []PropertyAccessor `json:"value,omitempty"` +} + +type _Interpolation Interpolation + +// NewInterpolation instantiates a new Interpolation object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewInterpolation(text string) *Interpolation { + this := Interpolation{} + this.Text = text + return &this +} + +// NewInterpolationWithDefaults instantiates a new Interpolation object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewInterpolationWithDefaults() *Interpolation { + this := Interpolation{} + return &this +} + +// GetText returns the Text field value +func (o *Interpolation) GetText() string { + if o == nil { + var ret string + return ret + } + + return o.Text +} + +// GetTextOk returns a tuple with the Text field value +// and a boolean to check if the value has been set. +func (o *Interpolation) GetTextOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Text, true +} + +// SetText sets field value +func (o *Interpolation) SetText(v string) { + o.Text = v +} + +// GetValue returns the Value field value if set, zero value otherwise. +func (o *Interpolation) GetValue() []PropertyAccessor { + if o == nil || IsNil(o.Value) { + var ret []PropertyAccessor + return ret + } + return o.Value +} + +// GetValueOk returns a tuple with the Value field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Interpolation) GetValueOk() ([]PropertyAccessor, bool) { + if o == nil || IsNil(o.Value) { + return nil, false + } + return o.Value, true +} + +// HasValue returns a boolean if a field has been set. +func (o *Interpolation) HasValue() bool { + if o != nil && !IsNil(o.Value) { + return true + } + + return false +} + +// SetValue gets a reference to the given []PropertyAccessor and assigns it to the Value field. +func (o *Interpolation) SetValue(v []PropertyAccessor) { + o.Value = v +} + +func (o Interpolation) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o Interpolation) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["text"] = o.Text + if !IsNil(o.Value) { + toSerialize["value"] = o.Value + } + return toSerialize, nil +} + +func (o *Interpolation) UnmarshalJSON(data []byte) (err error) { + // This validates that all required properties are included in the JSON object + // by unmarshalling the object into a generic map with string keys and checking + // that every required field exists as a key in the generic map. + requiredProperties := []string{ + "text", + } + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err; + } + + for _, requiredProperty := range(requiredProperties) { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } + } + + varInterpolation := _Interpolation{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varInterpolation) + + if err != nil { + return err + } + + *o = Interpolation(varInterpolation) + + return err +} + +type NullableInterpolation struct { + value *Interpolation + isSet bool +} + +func (v NullableInterpolation) Get() *Interpolation { + return v.value +} + +func (v *NullableInterpolation) Set(val *Interpolation) { + v.value = val + v.isSet = true +} + +func (v NullableInterpolation) IsSet() bool { + return v.isSet +} + +func (v *NullableInterpolation) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableInterpolation(val *Interpolation) *NullableInterpolation { + return &NullableInterpolation{value: val, isSet: true} +} + +func (v NullableInterpolation) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableInterpolation) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/sdk/go/model_open_environment.go b/sdk/go/model_open_environment.go new file mode 100644 index 00000000..5f7a93da --- /dev/null +++ b/sdk/go/model_open_environment.go @@ -0,0 +1,196 @@ +// Copyright 2024, Pulumi Corporation. All rights reserved. +/* +ESC (Environments, Secrets, Config) API + +Pulumi ESC allows you to compose and manage hierarchical collections of configuration and secrets and consume them in various ways. + +API version: 0.1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package esc_sdk + +import ( + "encoding/json" + "bytes" + "fmt" +) + +// checks if the OpenEnvironment type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &OpenEnvironment{} + +// OpenEnvironment struct for OpenEnvironment +type OpenEnvironment struct { + // Open environment session identifier + Id string `json:"id"` + Diagnostics *EnvironmentDiagnostics `json:"diagnostics,omitempty"` +} + +type _OpenEnvironment OpenEnvironment + +// NewOpenEnvironment instantiates a new OpenEnvironment object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewOpenEnvironment(id string) *OpenEnvironment { + this := OpenEnvironment{} + this.Id = id + return &this +} + +// NewOpenEnvironmentWithDefaults instantiates a new OpenEnvironment object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewOpenEnvironmentWithDefaults() *OpenEnvironment { + this := OpenEnvironment{} + return &this +} + +// GetId returns the Id field value +func (o *OpenEnvironment) GetId() string { + if o == nil { + var ret string + return ret + } + + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *OpenEnvironment) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value +func (o *OpenEnvironment) SetId(v string) { + o.Id = v +} + +// GetDiagnostics returns the Diagnostics field value if set, zero value otherwise. +func (o *OpenEnvironment) GetDiagnostics() EnvironmentDiagnostics { + if o == nil || IsNil(o.Diagnostics) { + var ret EnvironmentDiagnostics + return ret + } + return *o.Diagnostics +} + +// GetDiagnosticsOk returns a tuple with the Diagnostics field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *OpenEnvironment) GetDiagnosticsOk() (*EnvironmentDiagnostics, bool) { + if o == nil || IsNil(o.Diagnostics) { + return nil, false + } + return o.Diagnostics, true +} + +// HasDiagnostics returns a boolean if a field has been set. +func (o *OpenEnvironment) HasDiagnostics() bool { + if o != nil && !IsNil(o.Diagnostics) { + return true + } + + return false +} + +// SetDiagnostics gets a reference to the given EnvironmentDiagnostics and assigns it to the Diagnostics field. +func (o *OpenEnvironment) SetDiagnostics(v EnvironmentDiagnostics) { + o.Diagnostics = &v +} + +func (o OpenEnvironment) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o OpenEnvironment) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["id"] = o.Id + if !IsNil(o.Diagnostics) { + toSerialize["diagnostics"] = o.Diagnostics + } + return toSerialize, nil +} + +func (o *OpenEnvironment) UnmarshalJSON(data []byte) (err error) { + // This validates that all required properties are included in the JSON object + // by unmarshalling the object into a generic map with string keys and checking + // that every required field exists as a key in the generic map. + requiredProperties := []string{ + "id", + } + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err; + } + + for _, requiredProperty := range(requiredProperties) { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } + } + + varOpenEnvironment := _OpenEnvironment{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varOpenEnvironment) + + if err != nil { + return err + } + + *o = OpenEnvironment(varOpenEnvironment) + + return err +} + +type NullableOpenEnvironment struct { + value *OpenEnvironment + isSet bool +} + +func (v NullableOpenEnvironment) Get() *OpenEnvironment { + return v.value +} + +func (v *NullableOpenEnvironment) Set(val *OpenEnvironment) { + v.value = val + v.isSet = true +} + +func (v NullableOpenEnvironment) IsSet() bool { + return v.isSet +} + +func (v *NullableOpenEnvironment) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableOpenEnvironment(val *OpenEnvironment) *NullableOpenEnvironment { + return &NullableOpenEnvironment{value: val, isSet: true} +} + +func (v NullableOpenEnvironment) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableOpenEnvironment) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/sdk/go/model_org_environment.go b/sdk/go/model_org_environment.go new file mode 100644 index 00000000..4c147086 --- /dev/null +++ b/sdk/go/model_org_environment.go @@ -0,0 +1,251 @@ +// Copyright 2024, Pulumi Corporation. All rights reserved. +/* +ESC (Environments, Secrets, Config) API + +Pulumi ESC allows you to compose and manage hierarchical collections of configuration and secrets and consume them in various ways. + +API version: 0.1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package esc_sdk + +import ( + "encoding/json" + "bytes" + "fmt" +) + +// checks if the OrgEnvironment type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &OrgEnvironment{} + +// OrgEnvironment struct for OrgEnvironment +type OrgEnvironment struct { + Organization *string `json:"organization,omitempty"` + Name string `json:"name"` + Created string `json:"created"` + Modified string `json:"modified"` +} + +type _OrgEnvironment OrgEnvironment + +// NewOrgEnvironment instantiates a new OrgEnvironment object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewOrgEnvironment(name string, created string, modified string) *OrgEnvironment { + this := OrgEnvironment{} + this.Name = name + this.Created = created + this.Modified = modified + return &this +} + +// NewOrgEnvironmentWithDefaults instantiates a new OrgEnvironment object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewOrgEnvironmentWithDefaults() *OrgEnvironment { + this := OrgEnvironment{} + return &this +} + +// GetOrganization returns the Organization field value if set, zero value otherwise. +func (o *OrgEnvironment) GetOrganization() string { + if o == nil || IsNil(o.Organization) { + var ret string + return ret + } + return *o.Organization +} + +// GetOrganizationOk returns a tuple with the Organization field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *OrgEnvironment) GetOrganizationOk() (*string, bool) { + if o == nil || IsNil(o.Organization) { + return nil, false + } + return o.Organization, true +} + +// HasOrganization returns a boolean if a field has been set. +func (o *OrgEnvironment) HasOrganization() bool { + if o != nil && !IsNil(o.Organization) { + return true + } + + return false +} + +// SetOrganization gets a reference to the given string and assigns it to the Organization field. +func (o *OrgEnvironment) SetOrganization(v string) { + o.Organization = &v +} + +// GetName returns the Name field value +func (o *OrgEnvironment) GetName() string { + if o == nil { + var ret string + return ret + } + + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *OrgEnvironment) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value +func (o *OrgEnvironment) SetName(v string) { + o.Name = v +} + +// GetCreated returns the Created field value +func (o *OrgEnvironment) GetCreated() string { + if o == nil { + var ret string + return ret + } + + return o.Created +} + +// GetCreatedOk returns a tuple with the Created field value +// and a boolean to check if the value has been set. +func (o *OrgEnvironment) GetCreatedOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Created, true +} + +// SetCreated sets field value +func (o *OrgEnvironment) SetCreated(v string) { + o.Created = v +} + +// GetModified returns the Modified field value +func (o *OrgEnvironment) GetModified() string { + if o == nil { + var ret string + return ret + } + + return o.Modified +} + +// GetModifiedOk returns a tuple with the Modified field value +// and a boolean to check if the value has been set. +func (o *OrgEnvironment) GetModifiedOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Modified, true +} + +// SetModified sets field value +func (o *OrgEnvironment) SetModified(v string) { + o.Modified = v +} + +func (o OrgEnvironment) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o OrgEnvironment) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Organization) { + toSerialize["organization"] = o.Organization + } + toSerialize["name"] = o.Name + toSerialize["created"] = o.Created + toSerialize["modified"] = o.Modified + return toSerialize, nil +} + +func (o *OrgEnvironment) UnmarshalJSON(data []byte) (err error) { + // This validates that all required properties are included in the JSON object + // by unmarshalling the object into a generic map with string keys and checking + // that every required field exists as a key in the generic map. + requiredProperties := []string{ + "name", + "created", + "modified", + } + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err; + } + + for _, requiredProperty := range(requiredProperties) { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } + } + + varOrgEnvironment := _OrgEnvironment{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varOrgEnvironment) + + if err != nil { + return err + } + + *o = OrgEnvironment(varOrgEnvironment) + + return err +} + +type NullableOrgEnvironment struct { + value *OrgEnvironment + isSet bool +} + +func (v NullableOrgEnvironment) Get() *OrgEnvironment { + return v.value +} + +func (v *NullableOrgEnvironment) Set(val *OrgEnvironment) { + v.value = val + v.isSet = true +} + +func (v NullableOrgEnvironment) IsSet() bool { + return v.isSet +} + +func (v *NullableOrgEnvironment) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableOrgEnvironment(val *OrgEnvironment) *NullableOrgEnvironment { + return &NullableOrgEnvironment{value: val, isSet: true} +} + +func (v NullableOrgEnvironment) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableOrgEnvironment) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/sdk/go/model_org_environments.go b/sdk/go/model_org_environments.go new file mode 100644 index 00000000..b281dc12 --- /dev/null +++ b/sdk/go/model_org_environments.go @@ -0,0 +1,163 @@ +// Copyright 2024, Pulumi Corporation. All rights reserved. +/* +ESC (Environments, Secrets, Config) API + +Pulumi ESC allows you to compose and manage hierarchical collections of configuration and secrets and consume them in various ways. + +API version: 0.1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package esc_sdk + +import ( + "encoding/json" +) + +// checks if the OrgEnvironments type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &OrgEnvironments{} + +// OrgEnvironments struct for OrgEnvironments +type OrgEnvironments struct { + Environments []OrgEnvironment `json:"environments,omitempty"` + NextToken *string `json:"nextToken,omitempty"` +} + +// NewOrgEnvironments instantiates a new OrgEnvironments object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewOrgEnvironments() *OrgEnvironments { + this := OrgEnvironments{} + return &this +} + +// NewOrgEnvironmentsWithDefaults instantiates a new OrgEnvironments object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewOrgEnvironmentsWithDefaults() *OrgEnvironments { + this := OrgEnvironments{} + return &this +} + +// GetEnvironments returns the Environments field value if set, zero value otherwise. +func (o *OrgEnvironments) GetEnvironments() []OrgEnvironment { + if o == nil || IsNil(o.Environments) { + var ret []OrgEnvironment + return ret + } + return o.Environments +} + +// GetEnvironmentsOk returns a tuple with the Environments field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *OrgEnvironments) GetEnvironmentsOk() ([]OrgEnvironment, bool) { + if o == nil || IsNil(o.Environments) { + return nil, false + } + return o.Environments, true +} + +// HasEnvironments returns a boolean if a field has been set. +func (o *OrgEnvironments) HasEnvironments() bool { + if o != nil && !IsNil(o.Environments) { + return true + } + + return false +} + +// SetEnvironments gets a reference to the given []OrgEnvironment and assigns it to the Environments field. +func (o *OrgEnvironments) SetEnvironments(v []OrgEnvironment) { + o.Environments = v +} + +// GetNextToken returns the NextToken field value if set, zero value otherwise. +func (o *OrgEnvironments) GetNextToken() string { + if o == nil || IsNil(o.NextToken) { + var ret string + return ret + } + return *o.NextToken +} + +// GetNextTokenOk returns a tuple with the NextToken field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *OrgEnvironments) GetNextTokenOk() (*string, bool) { + if o == nil || IsNil(o.NextToken) { + return nil, false + } + return o.NextToken, true +} + +// HasNextToken returns a boolean if a field has been set. +func (o *OrgEnvironments) HasNextToken() bool { + if o != nil && !IsNil(o.NextToken) { + return true + } + + return false +} + +// SetNextToken gets a reference to the given string and assigns it to the NextToken field. +func (o *OrgEnvironments) SetNextToken(v string) { + o.NextToken = &v +} + +func (o OrgEnvironments) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o OrgEnvironments) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Environments) { + toSerialize["environments"] = o.Environments + } + if !IsNil(o.NextToken) { + toSerialize["nextToken"] = o.NextToken + } + return toSerialize, nil +} + +type NullableOrgEnvironments struct { + value *OrgEnvironments + isSet bool +} + +func (v NullableOrgEnvironments) Get() *OrgEnvironments { + return v.value +} + +func (v *NullableOrgEnvironments) Set(val *OrgEnvironments) { + v.value = val + v.isSet = true +} + +func (v NullableOrgEnvironments) IsSet() bool { + return v.isSet +} + +func (v *NullableOrgEnvironments) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableOrgEnvironments(val *OrgEnvironments) *NullableOrgEnvironments { + return &NullableOrgEnvironments{value: val, isSet: true} +} + +func (v NullableOrgEnvironments) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableOrgEnvironments) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/sdk/go/model_pos.go b/sdk/go/model_pos.go new file mode 100644 index 00000000..b878e16b --- /dev/null +++ b/sdk/go/model_pos.go @@ -0,0 +1,218 @@ +// Copyright 2024, Pulumi Corporation. All rights reserved. +/* +ESC (Environments, Secrets, Config) API + +Pulumi ESC allows you to compose and manage hierarchical collections of configuration and secrets and consume them in various ways. + +API version: 0.1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package esc_sdk + +import ( + "encoding/json" + "bytes" + "fmt" +) + +// checks if the Pos type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &Pos{} + +// Pos struct for Pos +type Pos struct { + // Line is the source code line where this position points. Lines are counted starting at 1 and incremented for each newline character encountered. + Line int32 `json:"line"` + // Column is the source code column where this position points. Columns are counted in visual cells starting at 1, and are incremented roughly per grapheme cluster encountered. + Column int32 `json:"column"` + // Byte is the byte offset into the file where the indicated position begins. + Byte int32 `json:"byte"` +} + +type _Pos Pos + +// NewPos instantiates a new Pos object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewPos(line int32, column int32, byte_ int32) *Pos { + this := Pos{} + this.Line = line + this.Column = column + this.Byte = byte_ + return &this +} + +// NewPosWithDefaults instantiates a new Pos object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewPosWithDefaults() *Pos { + this := Pos{} + return &this +} + +// GetLine returns the Line field value +func (o *Pos) GetLine() int32 { + if o == nil { + var ret int32 + return ret + } + + return o.Line +} + +// GetLineOk returns a tuple with the Line field value +// and a boolean to check if the value has been set. +func (o *Pos) GetLineOk() (*int32, bool) { + if o == nil { + return nil, false + } + return &o.Line, true +} + +// SetLine sets field value +func (o *Pos) SetLine(v int32) { + o.Line = v +} + +// GetColumn returns the Column field value +func (o *Pos) GetColumn() int32 { + if o == nil { + var ret int32 + return ret + } + + return o.Column +} + +// GetColumnOk returns a tuple with the Column field value +// and a boolean to check if the value has been set. +func (o *Pos) GetColumnOk() (*int32, bool) { + if o == nil { + return nil, false + } + return &o.Column, true +} + +// SetColumn sets field value +func (o *Pos) SetColumn(v int32) { + o.Column = v +} + +// GetByte returns the Byte field value +func (o *Pos) GetByte() int32 { + if o == nil { + var ret int32 + return ret + } + + return o.Byte +} + +// GetByteOk returns a tuple with the Byte field value +// and a boolean to check if the value has been set. +func (o *Pos) GetByteOk() (*int32, bool) { + if o == nil { + return nil, false + } + return &o.Byte, true +} + +// SetByte sets field value +func (o *Pos) SetByte(v int32) { + o.Byte = v +} + +func (o Pos) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o Pos) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["line"] = o.Line + toSerialize["column"] = o.Column + toSerialize["byte"] = o.Byte + return toSerialize, nil +} + +func (o *Pos) UnmarshalJSON(data []byte) (err error) { + // This validates that all required properties are included in the JSON object + // by unmarshalling the object into a generic map with string keys and checking + // that every required field exists as a key in the generic map. + requiredProperties := []string{ + "line", + "column", + "byte", + } + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err; + } + + for _, requiredProperty := range(requiredProperties) { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } + } + + varPos := _Pos{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varPos) + + if err != nil { + return err + } + + *o = Pos(varPos) + + return err +} + +type NullablePos struct { + value *Pos + isSet bool +} + +func (v NullablePos) Get() *Pos { + return v.value +} + +func (v *NullablePos) Set(val *Pos) { + v.value = val + v.isSet = true +} + +func (v NullablePos) IsSet() bool { + return v.isSet +} + +func (v *NullablePos) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullablePos(val *Pos) *NullablePos { + return &NullablePos{value: val, isSet: true} +} + +func (v NullablePos) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullablePos) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/sdk/go/model_property_accessor.go b/sdk/go/model_property_accessor.go new file mode 100644 index 00000000..7444f345 --- /dev/null +++ b/sdk/go/model_property_accessor.go @@ -0,0 +1,259 @@ +// Copyright 2024, Pulumi Corporation. All rights reserved. +/* +ESC (Environments, Secrets, Config) API + +Pulumi ESC allows you to compose and manage hierarchical collections of configuration and secrets and consume them in various ways. + +API version: 0.1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package esc_sdk + +import ( + "encoding/json" + "bytes" + "fmt" +) + +// checks if the PropertyAccessor type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &PropertyAccessor{} + +// PropertyAccessor struct for PropertyAccessor +type PropertyAccessor struct { + Index *int32 `json:"index,omitempty"` + Key string `json:"key"` + Range Range `json:"range"` + Value *Range `json:"value,omitempty"` +} + +type _PropertyAccessor PropertyAccessor + +// NewPropertyAccessor instantiates a new PropertyAccessor object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewPropertyAccessor(key string, range_ Range) *PropertyAccessor { + this := PropertyAccessor{} + this.Key = key + this.Range = range_ + return &this +} + +// NewPropertyAccessorWithDefaults instantiates a new PropertyAccessor object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewPropertyAccessorWithDefaults() *PropertyAccessor { + this := PropertyAccessor{} + return &this +} + +// GetIndex returns the Index field value if set, zero value otherwise. +func (o *PropertyAccessor) GetIndex() int32 { + if o == nil || IsNil(o.Index) { + var ret int32 + return ret + } + return *o.Index +} + +// GetIndexOk returns a tuple with the Index field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PropertyAccessor) GetIndexOk() (*int32, bool) { + if o == nil || IsNil(o.Index) { + return nil, false + } + return o.Index, true +} + +// HasIndex returns a boolean if a field has been set. +func (o *PropertyAccessor) HasIndex() bool { + if o != nil && !IsNil(o.Index) { + return true + } + + return false +} + +// SetIndex gets a reference to the given int32 and assigns it to the Index field. +func (o *PropertyAccessor) SetIndex(v int32) { + o.Index = &v +} + +// GetKey returns the Key field value +func (o *PropertyAccessor) GetKey() string { + if o == nil { + var ret string + return ret + } + + return o.Key +} + +// GetKeyOk returns a tuple with the Key field value +// and a boolean to check if the value has been set. +func (o *PropertyAccessor) GetKeyOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Key, true +} + +// SetKey sets field value +func (o *PropertyAccessor) SetKey(v string) { + o.Key = v +} + +// GetRange returns the Range field value +func (o *PropertyAccessor) GetRange() Range { + if o == nil { + var ret Range + return ret + } + + return o.Range +} + +// GetRangeOk returns a tuple with the Range field value +// and a boolean to check if the value has been set. +func (o *PropertyAccessor) GetRangeOk() (*Range, bool) { + if o == nil { + return nil, false + } + return &o.Range, true +} + +// SetRange sets field value +func (o *PropertyAccessor) SetRange(v Range) { + o.Range = v +} + +// GetValue returns the Value field value if set, zero value otherwise. +func (o *PropertyAccessor) GetValue() Range { + if o == nil || IsNil(o.Value) { + var ret Range + return ret + } + return *o.Value +} + +// GetValueOk returns a tuple with the Value field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PropertyAccessor) GetValueOk() (*Range, bool) { + if o == nil || IsNil(o.Value) { + return nil, false + } + return o.Value, true +} + +// HasValue returns a boolean if a field has been set. +func (o *PropertyAccessor) HasValue() bool { + if o != nil && !IsNil(o.Value) { + return true + } + + return false +} + +// SetValue gets a reference to the given Range and assigns it to the Value field. +func (o *PropertyAccessor) SetValue(v Range) { + o.Value = &v +} + +func (o PropertyAccessor) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o PropertyAccessor) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Index) { + toSerialize["index"] = o.Index + } + toSerialize["key"] = o.Key + toSerialize["range"] = o.Range + if !IsNil(o.Value) { + toSerialize["value"] = o.Value + } + return toSerialize, nil +} + +func (o *PropertyAccessor) UnmarshalJSON(data []byte) (err error) { + // This validates that all required properties are included in the JSON object + // by unmarshalling the object into a generic map with string keys and checking + // that every required field exists as a key in the generic map. + requiredProperties := []string{ + "key", + "range", + } + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err; + } + + for _, requiredProperty := range(requiredProperties) { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } + } + + varPropertyAccessor := _PropertyAccessor{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varPropertyAccessor) + + if err != nil { + return err + } + + *o = PropertyAccessor(varPropertyAccessor) + + return err +} + +type NullablePropertyAccessor struct { + value *PropertyAccessor + isSet bool +} + +func (v NullablePropertyAccessor) Get() *PropertyAccessor { + return v.value +} + +func (v *NullablePropertyAccessor) Set(val *PropertyAccessor) { + v.value = val + v.isSet = true +} + +func (v NullablePropertyAccessor) IsSet() bool { + return v.isSet +} + +func (v *NullablePropertyAccessor) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullablePropertyAccessor(val *PropertyAccessor) *NullablePropertyAccessor { + return &NullablePropertyAccessor{value: val, isSet: true} +} + +func (v NullablePropertyAccessor) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullablePropertyAccessor) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/sdk/go/model_range.go b/sdk/go/model_range.go new file mode 100644 index 00000000..aa97f77c --- /dev/null +++ b/sdk/go/model_range.go @@ -0,0 +1,215 @@ +// Copyright 2024, Pulumi Corporation. All rights reserved. +/* +ESC (Environments, Secrets, Config) API + +Pulumi ESC allows you to compose and manage hierarchical collections of configuration and secrets and consume them in various ways. + +API version: 0.1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package esc_sdk + +import ( + "encoding/json" + "bytes" + "fmt" +) + +// checks if the Range type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &Range{} + +// Range struct for Range +type Range struct { + Environment string `json:"environment"` + Begin Pos `json:"begin"` + End Pos `json:"end"` +} + +type _Range Range + +// NewRange instantiates a new Range object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewRange(environment string, begin Pos, end Pos) *Range { + this := Range{} + this.Environment = environment + this.Begin = begin + this.End = end + return &this +} + +// NewRangeWithDefaults instantiates a new Range object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewRangeWithDefaults() *Range { + this := Range{} + return &this +} + +// GetEnvironment returns the Environment field value +func (o *Range) GetEnvironment() string { + if o == nil { + var ret string + return ret + } + + return o.Environment +} + +// GetEnvironmentOk returns a tuple with the Environment field value +// and a boolean to check if the value has been set. +func (o *Range) GetEnvironmentOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Environment, true +} + +// SetEnvironment sets field value +func (o *Range) SetEnvironment(v string) { + o.Environment = v +} + +// GetBegin returns the Begin field value +func (o *Range) GetBegin() Pos { + if o == nil { + var ret Pos + return ret + } + + return o.Begin +} + +// GetBeginOk returns a tuple with the Begin field value +// and a boolean to check if the value has been set. +func (o *Range) GetBeginOk() (*Pos, bool) { + if o == nil { + return nil, false + } + return &o.Begin, true +} + +// SetBegin sets field value +func (o *Range) SetBegin(v Pos) { + o.Begin = v +} + +// GetEnd returns the End field value +func (o *Range) GetEnd() Pos { + if o == nil { + var ret Pos + return ret + } + + return o.End +} + +// GetEndOk returns a tuple with the End field value +// and a boolean to check if the value has been set. +func (o *Range) GetEndOk() (*Pos, bool) { + if o == nil { + return nil, false + } + return &o.End, true +} + +// SetEnd sets field value +func (o *Range) SetEnd(v Pos) { + o.End = v +} + +func (o Range) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o Range) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["environment"] = o.Environment + toSerialize["begin"] = o.Begin + toSerialize["end"] = o.End + return toSerialize, nil +} + +func (o *Range) UnmarshalJSON(data []byte) (err error) { + // This validates that all required properties are included in the JSON object + // by unmarshalling the object into a generic map with string keys and checking + // that every required field exists as a key in the generic map. + requiredProperties := []string{ + "environment", + "begin", + "end", + } + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err; + } + + for _, requiredProperty := range(requiredProperties) { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } + } + + varRange := _Range{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varRange) + + if err != nil { + return err + } + + *o = Range(varRange) + + return err +} + +type NullableRange struct { + value *Range + isSet bool +} + +func (v NullableRange) Get() *Range { + return v.value +} + +func (v *NullableRange) Set(val *Range) { + v.value = val + v.isSet = true +} + +func (v NullableRange) IsSet() bool { + return v.isSet +} + +func (v *NullableRange) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableRange(val *Range) *NullableRange { + return &NullableRange{value: val, isSet: true} +} + +func (v NullableRange) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableRange) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/sdk/go/model_reference.go b/sdk/go/model_reference.go new file mode 100644 index 00000000..851b0c03 --- /dev/null +++ b/sdk/go/model_reference.go @@ -0,0 +1,159 @@ +// Copyright 2024, Pulumi Corporation. All rights reserved. +/* +ESC (Environments, Secrets, Config) API + +Pulumi ESC allows you to compose and manage hierarchical collections of configuration and secrets and consume them in various ways. + +API version: 0.1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package esc_sdk + +import ( + "encoding/json" + "bytes" + "fmt" +) + +// checks if the Reference type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &Reference{} + +// Reference struct for Reference +type Reference struct { + Ref string `json:"$ref"` +} + +type _Reference Reference + +// NewReference instantiates a new Reference object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewReference(ref string) *Reference { + this := Reference{} + this.Ref = ref + return &this +} + +// NewReferenceWithDefaults instantiates a new Reference object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewReferenceWithDefaults() *Reference { + this := Reference{} + return &this +} + +// GetRef returns the Ref field value +func (o *Reference) GetRef() string { + if o == nil { + var ret string + return ret + } + + return o.Ref +} + +// GetRefOk returns a tuple with the Ref field value +// and a boolean to check if the value has been set. +func (o *Reference) GetRefOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Ref, true +} + +// SetRef sets field value +func (o *Reference) SetRef(v string) { + o.Ref = v +} + +func (o Reference) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o Reference) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["$ref"] = o.Ref + return toSerialize, nil +} + +func (o *Reference) UnmarshalJSON(data []byte) (err error) { + // This validates that all required properties are included in the JSON object + // by unmarshalling the object into a generic map with string keys and checking + // that every required field exists as a key in the generic map. + requiredProperties := []string{ + "$ref", + } + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err; + } + + for _, requiredProperty := range(requiredProperties) { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } + } + + varReference := _Reference{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varReference) + + if err != nil { + return err + } + + *o = Reference(varReference) + + return err +} + +type NullableReference struct { + value *Reference + isSet bool +} + +func (v NullableReference) Get() *Reference { + return v.value +} + +func (v *NullableReference) Set(val *Reference) { + v.value = val + v.isSet = true +} + +func (v NullableReference) IsSet() bool { + return v.isSet +} + +func (v *NullableReference) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableReference(val *Reference) *NullableReference { + return &NullableReference{value: val, isSet: true} +} + +func (v NullableReference) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableReference) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/sdk/go/model_trace.go b/sdk/go/model_trace.go new file mode 100644 index 00000000..7c740ecf --- /dev/null +++ b/sdk/go/model_trace.go @@ -0,0 +1,163 @@ +// Copyright 2024, Pulumi Corporation. All rights reserved. +/* +ESC (Environments, Secrets, Config) API + +Pulumi ESC allows you to compose and manage hierarchical collections of configuration and secrets and consume them in various ways. + +API version: 0.1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package esc_sdk + +import ( + "encoding/json" +) + +// checks if the Trace type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &Trace{} + +// Trace struct for Trace +type Trace struct { + Def *Range `json:"def,omitempty"` + Base *Value `json:"base,omitempty"` +} + +// NewTrace instantiates a new Trace object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewTrace() *Trace { + this := Trace{} + return &this +} + +// NewTraceWithDefaults instantiates a new Trace object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewTraceWithDefaults() *Trace { + this := Trace{} + return &this +} + +// GetDef returns the Def field value if set, zero value otherwise. +func (o *Trace) GetDef() Range { + if o == nil || IsNil(o.Def) { + var ret Range + return ret + } + return *o.Def +} + +// GetDefOk returns a tuple with the Def field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Trace) GetDefOk() (*Range, bool) { + if o == nil || IsNil(o.Def) { + return nil, false + } + return o.Def, true +} + +// HasDef returns a boolean if a field has been set. +func (o *Trace) HasDef() bool { + if o != nil && !IsNil(o.Def) { + return true + } + + return false +} + +// SetDef gets a reference to the given Range and assigns it to the Def field. +func (o *Trace) SetDef(v Range) { + o.Def = &v +} + +// GetBase returns the Base field value if set, zero value otherwise. +func (o *Trace) GetBase() Value { + if o == nil || IsNil(o.Base) { + var ret Value + return ret + } + return *o.Base +} + +// GetBaseOk returns a tuple with the Base field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Trace) GetBaseOk() (*Value, bool) { + if o == nil || IsNil(o.Base) { + return nil, false + } + return o.Base, true +} + +// HasBase returns a boolean if a field has been set. +func (o *Trace) HasBase() bool { + if o != nil && !IsNil(o.Base) { + return true + } + + return false +} + +// SetBase gets a reference to the given Value and assigns it to the Base field. +func (o *Trace) SetBase(v Value) { + o.Base = &v +} + +func (o Trace) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o Trace) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Def) { + toSerialize["def"] = o.Def + } + if !IsNil(o.Base) { + toSerialize["base"] = o.Base + } + return toSerialize, nil +} + +type NullableTrace struct { + value *Trace + isSet bool +} + +func (v NullableTrace) Get() *Trace { + return v.value +} + +func (v *NullableTrace) Set(val *Trace) { + v.value = val + v.isSet = true +} + +func (v NullableTrace) IsSet() bool { + return v.isSet +} + +func (v *NullableTrace) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableTrace(val *Trace) *NullableTrace { + return &NullableTrace{value: val, isSet: true} +} + +func (v NullableTrace) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableTrace) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/sdk/go/model_value.go b/sdk/go/model_value.go new file mode 100644 index 00000000..b0d9d3b9 --- /dev/null +++ b/sdk/go/model_value.go @@ -0,0 +1,263 @@ +// Copyright 2024, Pulumi Corporation. All rights reserved. +/* +ESC (Environments, Secrets, Config) API + +Pulumi ESC allows you to compose and manage hierarchical collections of configuration and secrets and consume them in various ways. + +API version: 0.1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package esc_sdk + +import ( + "encoding/json" + "bytes" + "fmt" +) + +// checks if the Value type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &Value{} + +// Value struct for Value +type Value struct { + Value interface{} `json:"value"` + Secret *bool `json:"secret,omitempty"` + Unknown *bool `json:"unknown,omitempty"` + Trace Trace `json:"trace"` +} + +type _Value Value + +// NewValue instantiates a new Value object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewValue(value interface{}, trace Trace) *Value { + this := Value{} + this.Value = value + this.Trace = trace + return &this +} + +// NewValueWithDefaults instantiates a new Value object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewValueWithDefaults() *Value { + this := Value{} + return &this +} + +// GetValue returns the Value field value +// If the value is explicit nil, the zero value for interface{} will be returned +func (o *Value) GetValue() interface{} { + if o == nil { + var ret interface{} + return ret + } + + return o.Value +} + +// GetValueOk returns a tuple with the Value field value +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned +func (o *Value) GetValueOk() (*interface{}, bool) { + if o == nil || IsNil(o.Value) { + return nil, false + } + return &o.Value, true +} + +// SetValue sets field value +func (o *Value) SetValue(v interface{}) { + o.Value = v +} + +// GetSecret returns the Secret field value if set, zero value otherwise. +func (o *Value) GetSecret() bool { + if o == nil || IsNil(o.Secret) { + var ret bool + return ret + } + return *o.Secret +} + +// GetSecretOk returns a tuple with the Secret field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Value) GetSecretOk() (*bool, bool) { + if o == nil || IsNil(o.Secret) { + return nil, false + } + return o.Secret, true +} + +// HasSecret returns a boolean if a field has been set. +func (o *Value) HasSecret() bool { + if o != nil && !IsNil(o.Secret) { + return true + } + + return false +} + +// SetSecret gets a reference to the given bool and assigns it to the Secret field. +func (o *Value) SetSecret(v bool) { + o.Secret = &v +} + +// GetUnknown returns the Unknown field value if set, zero value otherwise. +func (o *Value) GetUnknown() bool { + if o == nil || IsNil(o.Unknown) { + var ret bool + return ret + } + return *o.Unknown +} + +// GetUnknownOk returns a tuple with the Unknown field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Value) GetUnknownOk() (*bool, bool) { + if o == nil || IsNil(o.Unknown) { + return nil, false + } + return o.Unknown, true +} + +// HasUnknown returns a boolean if a field has been set. +func (o *Value) HasUnknown() bool { + if o != nil && !IsNil(o.Unknown) { + return true + } + + return false +} + +// SetUnknown gets a reference to the given bool and assigns it to the Unknown field. +func (o *Value) SetUnknown(v bool) { + o.Unknown = &v +} + +// GetTrace returns the Trace field value +func (o *Value) GetTrace() Trace { + if o == nil { + var ret Trace + return ret + } + + return o.Trace +} + +// GetTraceOk returns a tuple with the Trace field value +// and a boolean to check if the value has been set. +func (o *Value) GetTraceOk() (*Trace, bool) { + if o == nil { + return nil, false + } + return &o.Trace, true +} + +// SetTrace sets field value +func (o *Value) SetTrace(v Trace) { + o.Trace = v +} + +func (o Value) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o Value) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if o.Value != nil { + toSerialize["value"] = o.Value + } + if !IsNil(o.Secret) { + toSerialize["secret"] = o.Secret + } + if !IsNil(o.Unknown) { + toSerialize["unknown"] = o.Unknown + } + toSerialize["trace"] = o.Trace + return toSerialize, nil +} + +func (o *Value) UnmarshalJSON(data []byte) (err error) { + // This validates that all required properties are included in the JSON object + // by unmarshalling the object into a generic map with string keys and checking + // that every required field exists as a key in the generic map. + requiredProperties := []string{ + "value", + "trace", + } + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err; + } + + for _, requiredProperty := range(requiredProperties) { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } + } + + varValue := _Value{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varValue) + + if err != nil { + return err + } + + *o = Value(varValue) + + return err +} + +type NullableValue struct { + value *Value + isSet bool +} + +func (v NullableValue) Get() *Value { + return v.value +} + +func (v *NullableValue) Set(val *Value) { + v.value = val + v.isSet = true +} + +func (v NullableValue) IsSet() bool { + return v.isSet +} + +func (v *NullableValue) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableValue(val *Value) *NullableValue { + return &NullableValue{value: val, isSet: true} +} + +func (v NullableValue) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableValue) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/sdk/go/response.go b/sdk/go/response.go new file mode 100644 index 00000000..0a2a9f6d --- /dev/null +++ b/sdk/go/response.go @@ -0,0 +1,48 @@ +// Copyright 2024, Pulumi Corporation. All rights reserved. +/* +ESC (Environments, Secrets, Config) API + +Pulumi ESC allows you to compose and manage hierarchical collections of configuration and secrets and consume them in various ways. + +API version: 0.1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package esc_sdk + +import ( + "net/http" +) + +// APIResponse stores the API response returned by the server. +type APIResponse struct { + *http.Response `json:"-"` + Message string `json:"message,omitempty"` + // Operation is the name of the OpenAPI operation. + Operation string `json:"operation,omitempty"` + // RequestURL is the request URL. This value is always available, even if the + // embedded *http.Response is nil. + RequestURL string `json:"url,omitempty"` + // Method is the HTTP method used for the request. This value is always + // available, even if the embedded *http.Response is nil. + Method string `json:"method,omitempty"` + // Payload holds the contents of the response body (which may be nil or empty). + // This is provided here as the raw response.Body() reader will have already + // been drained. + Payload []byte `json:"-"` +} + +// NewAPIResponse returns a new APIResponse object. +func NewAPIResponse(r *http.Response) *APIResponse { + + response := &APIResponse{Response: r} + return response +} + +// NewAPIResponseWithError returns a new APIResponse object with the provided error message. +func NewAPIResponseWithError(errorMessage string) *APIResponse { + + response := &APIResponse{Message: errorMessage} + return response +} diff --git a/sdk/go/utils.go b/sdk/go/utils.go new file mode 100644 index 00000000..0fa2f8c0 --- /dev/null +++ b/sdk/go/utils.go @@ -0,0 +1,348 @@ +// Copyright 2024, Pulumi Corporation. All rights reserved. +/* +ESC (Environments, Secrets, Config) API + +Pulumi ESC allows you to compose and manage hierarchical collections of configuration and secrets and consume them in various ways. + +API version: 0.1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package esc_sdk + +import ( + "encoding/json" + "reflect" + "time" +) + +// PtrBool is a helper routine that returns a pointer to given boolean value. +func PtrBool(v bool) *bool { return &v } + +// PtrInt is a helper routine that returns a pointer to given integer value. +func PtrInt(v int) *int { return &v } + +// PtrInt32 is a helper routine that returns a pointer to given integer value. +func PtrInt32(v int32) *int32 { return &v } + +// PtrInt64 is a helper routine that returns a pointer to given integer value. +func PtrInt64(v int64) *int64 { return &v } + +// PtrFloat32 is a helper routine that returns a pointer to given float value. +func PtrFloat32(v float32) *float32 { return &v } + +// PtrFloat64 is a helper routine that returns a pointer to given float value. +func PtrFloat64(v float64) *float64 { return &v } + +// PtrString is a helper routine that returns a pointer to given string value. +func PtrString(v string) *string { return &v } + +// PtrTime is helper routine that returns a pointer to given Time value. +func PtrTime(v time.Time) *time.Time { return &v } + +type NullableBool struct { + value *bool + isSet bool +} + +func (v NullableBool) Get() *bool { + return v.value +} + +func (v *NullableBool) Set(val *bool) { + v.value = val + v.isSet = true +} + +func (v NullableBool) IsSet() bool { + return v.isSet +} + +func (v *NullableBool) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableBool(val *bool) *NullableBool { + return &NullableBool{value: val, isSet: true} +} + +func (v NullableBool) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableBool) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableInt struct { + value *int + isSet bool +} + +func (v NullableInt) Get() *int { + return v.value +} + +func (v *NullableInt) Set(val *int) { + v.value = val + v.isSet = true +} + +func (v NullableInt) IsSet() bool { + return v.isSet +} + +func (v *NullableInt) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableInt(val *int) *NullableInt { + return &NullableInt{value: val, isSet: true} +} + +func (v NullableInt) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableInt) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableInt32 struct { + value *int32 + isSet bool +} + +func (v NullableInt32) Get() *int32 { + return v.value +} + +func (v *NullableInt32) Set(val *int32) { + v.value = val + v.isSet = true +} + +func (v NullableInt32) IsSet() bool { + return v.isSet +} + +func (v *NullableInt32) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableInt32(val *int32) *NullableInt32 { + return &NullableInt32{value: val, isSet: true} +} + +func (v NullableInt32) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableInt32) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableInt64 struct { + value *int64 + isSet bool +} + +func (v NullableInt64) Get() *int64 { + return v.value +} + +func (v *NullableInt64) Set(val *int64) { + v.value = val + v.isSet = true +} + +func (v NullableInt64) IsSet() bool { + return v.isSet +} + +func (v *NullableInt64) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableInt64(val *int64) *NullableInt64 { + return &NullableInt64{value: val, isSet: true} +} + +func (v NullableInt64) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableInt64) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableFloat32 struct { + value *float32 + isSet bool +} + +func (v NullableFloat32) Get() *float32 { + return v.value +} + +func (v *NullableFloat32) Set(val *float32) { + v.value = val + v.isSet = true +} + +func (v NullableFloat32) IsSet() bool { + return v.isSet +} + +func (v *NullableFloat32) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableFloat32(val *float32) *NullableFloat32 { + return &NullableFloat32{value: val, isSet: true} +} + +func (v NullableFloat32) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableFloat32) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableFloat64 struct { + value *float64 + isSet bool +} + +func (v NullableFloat64) Get() *float64 { + return v.value +} + +func (v *NullableFloat64) Set(val *float64) { + v.value = val + v.isSet = true +} + +func (v NullableFloat64) IsSet() bool { + return v.isSet +} + +func (v *NullableFloat64) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableFloat64(val *float64) *NullableFloat64 { + return &NullableFloat64{value: val, isSet: true} +} + +func (v NullableFloat64) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableFloat64) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableString struct { + value *string + isSet bool +} + +func (v NullableString) Get() *string { + return v.value +} + +func (v *NullableString) Set(val *string) { + v.value = val + v.isSet = true +} + +func (v NullableString) IsSet() bool { + return v.isSet +} + +func (v *NullableString) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableString(val *string) *NullableString { + return &NullableString{value: val, isSet: true} +} + +func (v NullableString) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableString) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableTime struct { + value *time.Time + isSet bool +} + +func (v NullableTime) Get() *time.Time { + return v.value +} + +func (v *NullableTime) Set(val *time.Time) { + v.value = val + v.isSet = true +} + +func (v NullableTime) IsSet() bool { + return v.isSet +} + +func (v *NullableTime) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableTime(val *time.Time) *NullableTime { + return &NullableTime{value: val, isSet: true} +} + +func (v NullableTime) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableTime) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +// IsNil checks if an input is nil +func IsNil(i interface{}) bool { + if i == nil { + return true + } + switch reflect.TypeOf(i).Kind() { + case reflect.Chan, reflect.Func, reflect.Map, reflect.Ptr, reflect.UnsafePointer, reflect.Interface, reflect.Slice: + return reflect.ValueOf(i).IsNil() + case reflect.Array: + return reflect.ValueOf(i).IsZero() + } + return false +} + +type MappedNullable interface { + ToMap() (map[string]interface{}, error) +} diff --git a/sdk/swagger.yaml b/sdk/swagger.yaml new file mode 100644 index 00000000..abcc3a09 --- /dev/null +++ b/sdk/swagger.yaml @@ -0,0 +1,724 @@ +--- +openapi: "3.0.3" +info: + title: ESC (Environments, Secrets, Config) API + description: "Pulumi ESC allows you to compose and manage hierarchical collections\ + \ of configuration and secrets and consume them in various ways." + version: "0.1.0" + license: + name: Apache 2.0 + url: https://www.apache.org/licenses/LICENSE-2.0.html +servers: + - url: https://api.pulumi.com/api/preview + description: Pulumi Cloud Production Preview API +components: + securitySchemes: + Authorization: + type: apiKey + name: Authorization + in: header + schemas: + Error: + type: object + properties: + message: + type: string + code: + type: integer + required: + - message + - code + Range: + type: object + properties: + environment: + type: string + begin: + $ref: "#/components/schemas/Pos" + end: + $ref: "#/components/schemas/Pos" + required: + - environment + - begin + - end + Reference: + type: object + required: + - $ref + properties: + $ref: + type: string + format: uri-reference + Accessor: + type: object + properties: + index: + type: integer + key: + type: string + range: + $ref: "#/components/schemas/Range" + required: + - key + - range + PropertyAccessor: + allOf: + - $ref: "#/components/schemas/Accessor" + - type: object + properties: + value: + $ref: "#/components/schemas/Range" + Access: + type: object + properties: + receiver: + $ref: "#/components/schemas/Range" + accessors: + type: array + items: + $ref: "#/components/schemas/Accessor" + Interpolation: + type: object + properties: + text: + type: string + value: + type: array + items: + $ref: "#/components/schemas/PropertyAccessor" + required: + - text + ExprBuiltin: + type: object + properties: + name: + type: string + nameRange: + $ref: "#/components/schemas/Range" + argSchema: {} + arg: + $ref: "#/components/schemas/Expr" + required: + - name + Expr: + type: object + properties: + range: + $ref: "#/components/schemas/Range" + base: + $ref: "#/components/schemas/Expr" + schema: {} + keyRanges: + type: object + additionalProperties: + $ref: "#/components/schemas/Range" + literal: {} + interpolate: + type: array + items: + $ref: "#/components/schemas/Interpolation" + symbol: + type: array + items: + $ref: "#/components/schemas/PropertyAccessor" + access: + type: array + items: + $ref: "#/components/schemas/Access" + list: + type: array + items: + $ref: "#/components/schemas/Expr" + object: + type: object + additionalProperties: + $ref: "#/components/schemas/Expr" + builtin: + $ref: "#/components/schemas/ExprBuiltin" + EvaluatedExecutionContext: + type: object + properties: + properties: + type: object + additionalProperties: + $ref: "#/components/schemas/Value" + schema: {} + Environment: + type: object + properties: + exprs: + type: object + additionalProperties: + $ref: "#/components/schemas/Expr" + properties: + type: object + additionalProperties: + $ref: "#/components/schemas/Value" + schema: {} + executionContext: + $ref: "#/components/schemas/EvaluatedExecutionContext" + CheckEnvironment: + type: object + allOf: + - $ref: "#/components/schemas/Environment" + - $ref: "#/components/schemas/EnvironmentDiagnostics" + Trace: + type: object + properties: + def: + $ref: "#/components/schemas/Range" + base: + $ref: "#/components/schemas/Value" + Value: + type: object + properties: + value: {} + secret: + type: boolean + unknown: + type: boolean + trace: + $ref: "#/components/schemas/Trace" + required: + - trace + - value + Pos: + type: object + properties: + line: + type: integer + description: "Line is the source code line where this position points. Lines are counted starting at 1 and incremented for each newline character encountered." + column: + type: integer + description: "Column is the source code column where this position points. Columns are counted in visual cells starting at 1, and are incremented roughly per grapheme cluster encountered." + byte: + type: integer + description: "Byte is the byte offset into the file where the indicated position begins." + required: + - line + - column + - byte + EnvironmentDiagnostic: + type: object + properties: + summary: + type: string + path: + type: string + range: + $ref: "#/components/schemas/Range" + additionalProperties: + type: object + required: + - summary + EnvironmentDiagnostics: + type: object + properties: + diagnostics: + type: array + items: + $ref: "#/components/schemas/EnvironmentDiagnostic" + EnvironmentDefinitionValues: + type: object + properties: + pulumiConfig: + type: object + additionalProperties: true + environmentVariables: + type: object + additionalProperties: + type: string + files: + type: object + additionalProperties: + type: string + additionalProperties: + type: object + EnvironmentDefinition: + type: object + properties: + imports: + type: array + items: + type: string + values: + $ref: "#/components/schemas/EnvironmentDefinitionValues" + example: + application/x-yaml: + imports: + - base-env + values: + foo: bar + pulumiConfig: + foo: ${foo} + environmentVariables: + MY_KEY: my-value + OrgEnvironment: + type: object + properties: + organization: + type: string + name: + type: string + created: + type: string + modified: + type: string + required: + - name + - created + - modified + OpenEnvironment: + type: object + properties: + id: + type: string + description: Open environment session identifier + diagnostics: + $ref: "#/components/schemas/EnvironmentDiagnostics" + required: + - id + example: + application/json: + id: "42562" + OrgEnvironments: + type: object + properties: + environments: + type: array + items: + $ref: "#/components/schemas/OrgEnvironment" + nextToken: + type: string + parameters: + orgName: + name: orgName + in: path + description: Organization name + schema: + type: string + minLength: 3 + maxLength: 40 + pattern: ^[a-zA-Z0-9][a-zA-Z0-9-_]{1,38}[a-zA-Z0-9]$ + required: true + allowEmptyValue: false + envName: + name: envName + in: path + description: Environment name + schema: + type: string + minLength: 1 + maxLength: 100 + pattern: ^(?!(\.|\.\.|open|yaml))[a-zA-Z0-9-_.]+$ + required: true + allowEmptyValue: false + + responses: + ListOrgEnvironments: + description: List of environments + content: + application/json: + schema: + $ref: "#/components/schemas/OrgEnvironments" + SuccessWithMessage: + description: Success with message + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + example: + message: "" + code: "200" + SuccessWithDiagnostics: + description: Success with diagnostics + content: + application/json: + schema: + $ref: "#/components/schemas/EnvironmentDiagnostics" + example: + diagnostics: "" + code: "200" + HeadSuccess: + description: Success + headers: + Etag: + description: Specific version of the environment + schema: + type: string + CheckSuccess: + description: Success + content: + application/json: + schema: + $ref: "#/components/schemas/CheckEnvironment" + CheckBadRequest: + description: BadRequest + content: + application/json: + schema: + $ref: "#/components/schemas/CheckEnvironment" + DecryptSuccess: + description: Success + content: + application/x-yaml: + schema: + $ref: "#/components/schemas/EnvironmentDefinition" + OpenEnvironmentSuccess: + description: Success + content: + application/json: + schema: + $ref: "#/components/schemas/OpenEnvironment" + ReadOpenEnvironmentSuccess: + description: Success + content: + application/json: + schema: + $ref: "#/components/schemas/Environment" + ReadOpenEnvironmentPropertySuccess: + description: Success + content: + application/json: + schema: + $ref: "#/components/schemas/Value" + BadRequestWithDiagnostics: + description: Bad Request with diagnostics + content: + application/json: + schema: + $ref: "#/components/schemas/EnvironmentDiagnostics" + example: + message: Bad request + code: "400" + BadRequest: + description: Bad Request + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + example: + message: Bad request + code: "400" + Conflict: + description: Conflict + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + example: + message: Conflict + code: 409 + Unauthorized: + description: Unauthorized + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + example: + message: Unauthorized + code: 401 + InternalServerError: + description: "Internal Server Error" + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + example: + message: Internal Server Error + code: 500 + NotFound: + description: Not Found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + example: + message: Not Found + code: 404 +security: + - Authorization: [] +paths: + /environments/{orgName}: + parameters: + - $ref: "#/components/parameters/orgName" + - name: continuationToken + in: query + required: false + description: continuation Token from previous query to fetch next page of results + schema: + type: string + get: + tags: + - esc + operationId: ListEnvironments + summary: List environments in the organization + description: List environments in the organization available to the current user + responses: + "200": + $ref: "#/components/responses/ListOrgEnvironments" + "401": + $ref: "#/components/responses/Unauthorized" + "404": + $ref: "#/components/responses/NotFound" + "500": + $ref: "#/components/responses/InternalServerError" + "default": + $ref: "#/components/responses/InternalServerError" + /environments/{orgName}/{envName}: + parameters: + - $ref: "#/components/parameters/orgName" + - $ref: "#/components/parameters/envName" + post: + tags: + - esc + operationId: CreateEnvironment + summary: Create a new environment + description: Creates an environment in the given org with the given name. + responses: + "200": + $ref: '#/components/responses/SuccessWithMessage' + "400": + $ref: "#/components/responses/BadRequest" + "401": + $ref: "#/components/responses/Unauthorized" + "404": + $ref: "#/components/responses/NotFound" + "409": + $ref: "#/components/responses/Conflict" + "500": + $ref: "#/components/responses/InternalServerError" + "default": + $ref: "#/components/responses/InternalServerError" + patch: + tags: + - esc + operationId: UpdateEnvironmentYaml + summary: Update an existing environment with Yaml file + description: Validates and updates the given environment's definition. + requestBody: + description: Environment Yaml content + required: true + content: + application/x-yaml: + schema: + type: string + responses: + "200": + $ref: "#/components/responses/SuccessWithDiagnostics" + "400": + $ref: "#/components/responses/BadRequestWithDiagnostics" + "401": + $ref: "#/components/responses/Unauthorized" + "404": + $ref: "#/components/responses/NotFound" + "409": + $ref: "#/components/responses/Conflict" + "500": + $ref: "#/components/responses/InternalServerError" + "default": + $ref: "#/components/responses/InternalServerError" + head: + tags: + - esc + operationId: GetEnvironmentETag + summary: Return an Environment ETag + description: Returns the ETag for the given environment if it exists. + responses: + "200": + $ref: "#/components/responses/HeadSuccess" + "400": + $ref: "#/components/responses/BadRequest" + "401": + $ref: "#/components/responses/Unauthorized" + "404": + description: Not Found + "500": + $ref: "#/components/responses/InternalServerError" + "default": + $ref: "#/components/responses/InternalServerError" + get: + tags: + - esc + operationId: GetEnvironment + summary: Read an environment + description: Read an environment + responses: + "200": + description: Success + content: + application/x-yaml: + schema: + $ref: "#/components/schemas/EnvironmentDefinition" + "400": + $ref: "#/components/responses/BadRequest" + "401": + $ref: "#/components/responses/Unauthorized" + "404": + $ref: "#/components/responses/NotFound" + "500": + $ref: "#/components/responses/InternalServerError" + "default": + $ref: "#/components/responses/InternalServerError" + delete: + tags: + - esc + operationId: DeleteEnvironment + summary: Delete an environment + description: Delete an environment + responses: + "200": + $ref: '#/components/responses/SuccessWithMessage' + "400": + $ref: "#/components/responses/BadRequest" + "401": + $ref: "#/components/responses/Unauthorized" + "404": + $ref: "#/components/responses/NotFound" + "500": + $ref: "#/components/responses/InternalServerError" + "default": + $ref: "#/components/responses/InternalServerError" + /environments/{orgName}/yaml/check: + parameters: + - $ref: "#/components/parameters/orgName" + post: + tags: + - esc + operationId: CheckEnvironmentYaml + summary: Checks an environment definition for errors + description: Checks an environment definition for errors + requestBody: + description: Environment Yaml content + required: true + content: + application/x-yaml: + schema: + type: string + responses: + "200": + $ref: "#/components/responses/CheckSuccess" + "400": + $ref: "#/components/responses/CheckBadRequest" + "401": + $ref: "#/components/responses/Unauthorized" + "404": + $ref: "#/components/responses/NotFound" + "500": + $ref: "#/components/responses/InternalServerError" + "default": + $ref: "#/components/responses/InternalServerError" + /environments/{orgName}/{envName}/decrypt: + parameters: + - $ref: "#/components/parameters/orgName" + - $ref: "#/components/parameters/envName" + get: + tags: + - esc + operationId: DecryptEnvironment + summary: Reads the definition for the given environment with static secrets in plaintext + description: Reads the definition for the given environment with static secrets in plaintext + responses: + "200": + $ref: "#/components/responses/DecryptSuccess" + "400": + $ref: "#/components/responses/BadRequest" + "401": + $ref: "#/components/responses/Unauthorized" + "404": + $ref: "#/components/responses/NotFound" + "500": + $ref: "#/components/responses/InternalServerError" + "default": + $ref: "#/components/responses/InternalServerError" + /environments/{orgName}/{envName}/open: + parameters: + - $ref: "#/components/parameters/orgName" + - $ref: "#/components/parameters/envName" + - name: duration + in: query + required: false + description: open duration - A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as “300ms”, “1.5h” or “2h45m”. Valid time units are “ns”, “us” (or “µs”), “ms”, “s”, “m”, “h”. + schema: + type: string + pattern: ^(\d*\.\d+|\d+)(ns|us|µs|ms|s|m|h)?(\d*\.\d+|\d+)?(ns|us|µs|ms|s|m|h)?$ + default: 1h + post: + tags: + - esc + operationId: OpenEnvironment + summary: Open an environment session + description: Opens a session the given environment for the indicated duration. This returns a session id that can be used to then read values. The default duration is 1 hour. + responses: + "200": + $ref: "#/components/responses/OpenEnvironmentSuccess" + "400": + $ref: "#/components/responses/BadRequestWithDiagnostics" + "401": + $ref: "#/components/responses/Unauthorized" + "404": + $ref: "#/components/responses/NotFound" + "500": + $ref: "#/components/responses/InternalServerError" + "default": + $ref: "#/components/responses/InternalServerError" + /environments/{orgName}/{envName}/open/{openSessionID}: + parameters: + - $ref: "#/components/parameters/orgName" + - $ref: "#/components/parameters/envName" + - name: openSessionID + in: path + required: true + description: Open session ID returned from environment open + schema: + type: string + get: + tags: + - esc + operationId: ReadOpenEnvironment + summary: Read an open environment + description: Reads and decrypts secrets including retrieving dynamic secrets from providers. + responses: + "200": + $ref: "#/components/responses/ReadOpenEnvironmentSuccess" + "401": + $ref: "#/components/responses/Unauthorized" + "404": + $ref: "#/components/responses/NotFound" + "500": + $ref: "#/components/responses/InternalServerError" + "default": + $ref: "#/components/responses/InternalServerError" + /environments/{orgName}/{envName}/open//{openSessionID}: + parameters: + - $ref: "#/components/parameters/orgName" + - $ref: "#/components/parameters/envName" + - name: openSessionID + in: path + required: true + description: Open session ID returned from environment open + schema: + type: string + - name: property + in: query + required: true + description: Path to a specific property using Pulumi path syntax https://www.pulumi.com/docs/concepts/config/#structured-configuration + schema: + type: string + get: + tags: + - esc + operationId: ReadOpenEnvironmentProperty + summary: Read an open environment + description: Reads and decrypts secrets including retrieving dynamic secrets from providers. + responses: + "200": + $ref: "#/components/responses/ReadOpenEnvironmentPropertySuccess" + "401": + $ref: "#/components/responses/Unauthorized" + "404": + $ref: "#/components/responses/NotFound" + "500": + $ref: "#/components/responses/InternalServerError" + "default": + $ref: "#/components/responses/InternalServerError" \ No newline at end of file diff --git a/sdk/templates/go/README.mustache b/sdk/templates/go/README.mustache new file mode 100644 index 00000000..6e98ea75 --- /dev/null +++ b/sdk/templates/go/README.mustache @@ -0,0 +1,235 @@ +# Go API client for {{packageName}} + +{{#appDescriptionWithNewLines}} +{{{.}}} +{{/appDescriptionWithNewLines}} + +## Overview +This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-spec](https://www.openapis.org/) from a remote server, you can easily generate an API client. + +- API version: {{appVersion}} +- Package version: {{packageVersion}} +{{^hideGenerationTimestamp}} +- Build date: {{generatedDate}} +{{/hideGenerationTimestamp}} +- Build package: {{generatorClass}} +{{#infoUrl}} +For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) +{{/infoUrl}} + +## Installation + +Install the following dependencies: + +```sh +go get github.com/stretchr/testify/assert +{{#hasOAuthMethods}} +go get golang.org/x/oauth2 +{{/hasOAuthMethods}} +go get golang.org/x/net/context +``` + +Put the package under your project folder and add the following in import: + +```go +import {{packageName}} "{{gitHost}}/{{gitUserId}}/{{gitRepoId}}{{#isGoSubmodule}}/{{packageName}}{{/isGoSubmodule}}" +``` + +To use a proxy, set the environment variable `HTTP_PROXY`: + +```go +os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port") +``` + +## Configuration of Server URL + +Default configuration comes with `Servers` field that contains server objects as defined in the OpenAPI specification. + +### Select Server Configuration + +For using other server than the one defined on index 0 set context value `{{packageName}}.ContextServerIndex` of type `int`. + +```go +ctx := context.WithValue(context.Background(), {{packageName}}.ContextServerIndex, 1) +``` + +### Templated Server URL + +Templated server URL is formatted using default variables from configuration or from context value `{{packageName}}.ContextServerVariables` of type `map[string]string`. + +```go +ctx := context.WithValue(context.Background(), {{packageName}}.ContextServerVariables, map[string]string{ + "basePath": "v2", +}) +``` + +Note, enum values are always validated and all unused variables are silently ignored. + +### URLs Configuration per Operation + +Each operation can use different server URL defined using `OperationServers` map in the `Configuration`. +An operation is uniquely identified by `"{classname}Service.{nickname}"` string. +Similar rules for overriding default operation server index and variables applies by using `{{packageName}}.ContextOperationServerIndices` and `{{packageName}}.ContextOperationServerVariables` context maps. + +```go +ctx := context.WithValue(context.Background(), {{packageName}}.ContextOperationServerIndices, map[string]int{ + "{classname}Service.{nickname}": 2, +}) +ctx = context.WithValue(context.Background(), {{packageName}}.ContextOperationServerVariables, map[string]map[string]string{ + "{classname}Service.{nickname}": { + "port": "8443", + }, +}) +``` + +## Documentation for API Endpoints + +All URIs are relative to *{{basePath}}* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{summary}} +{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} + +## Documentation For Models + +{{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}{{{classname}}}.md) +{{/model}}{{/models}} + +## Documentation For Authorization + +{{^authMethods}}Endpoints do not require authorization.{{/authMethods}} +{{#hasAuthMethods}}Authentication schemes defined for the API:{{/hasAuthMethods}} +{{#authMethods}} +### {{{name}}} + +{{#isApiKey}} +- **Type**: API key +- **API key parameter name**: {{{keyParamName}}} +- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}} + +Note, each API key must be added to a map of `map[string]APIKey` where the key is: {{keyParamName}} and passed in as the auth context for each request. + +Example + +```go +auth := context.WithValue( + context.Background(), + {{packageName}}.ContextAPIKeys, + map[string]{{packageName}}.APIKey{ + "{{keyParamName}}": {Key: "API_KEY_STRING"}, + }, + ) +r, err := client.Service.Operation(auth, args) +``` + +{{/isApiKey}} +{{#isBasic}} +{{#isBasicBearer}} +- **Type**: HTTP Bearer token authentication + +Example + +```go +auth := context.WithValue(context.Background(), {{packageName}}.ContextAccessToken, "BEARER_TOKEN_STRING") +r, err := client.Service.Operation(auth, args) +``` + +{{/isBasicBearer}} +{{#isBasicBasic}} +- **Type**: HTTP basic authentication + +Example + +```go +auth := context.WithValue(context.Background(), {{packageName}}.ContextBasicAuth, {{packageName}}.BasicAuth{ + UserName: "username", + Password: "password", +}) +r, err := client.Service.Operation(auth, args) +``` + +{{/isBasicBasic}} +{{#isHttpSignature}} +- **Type**: HTTP signature authentication + +Example + +```go + authConfig := {{packageName}}.HttpSignatureAuth{ + KeyId: "my-key-id", + PrivateKeyPath: "rsa.pem", + Passphrase: "my-passphrase", + SigningScheme: {{packageName}}.HttpSigningSchemeHs2019, + SignedHeaders: []string{ + {{packageName}}.HttpSignatureParameterRequestTarget, // The special (request-target) parameter expresses the HTTP request target. + {{packageName}}.HttpSignatureParameterCreated, // Time when request was signed, formatted as a Unix timestamp integer value. + "Host", // The Host request header specifies the domain name of the server, and optionally the TCP port number. + "Date", // The date and time at which the message was originated. + "Content-Type", // The Media type of the body of the request. + "Digest", // A cryptographic digest of the request body. + }, + SigningAlgorithm: {{packageName}}.HttpSigningAlgorithmRsaPSS, + SignatureMaxValidity: 5 * time.Minute, + } + var authCtx context.Context + var err error + if authCtx, err = authConfig.ContextWithValue(context.Background()); err != nil { + // Process error + } + r, err = client.Service.Operation(auth, args) + +``` +{{/isHttpSignature}} +{{/isBasic}} +{{#isOAuth}} + +- **Type**: OAuth +- **Flow**: {{{flow}}} +- **Authorization URL**: {{{authorizationUrl}}} +- **Scopes**: {{^scopes}}N/A{{/scopes}} +{{#scopes}} - **{{{scope}}}**: {{{description}}} +{{/scopes}} + +Example + +```go +auth := context.WithValue(context.Background(), {{packageName}}.ContextAccessToken, "ACCESSTOKENSTRING") +r, err := client.Service.Operation(auth, args) +``` + +Or via OAuth2 module to automatically refresh tokens and perform user authentication. + +```go +import "golang.org/x/oauth2" + +/* Perform OAuth2 round trip request and obtain a token */ + +tokenSource := oauth2cfg.TokenSource(createContext(httpClient), &token) +auth := context.WithValue(oauth2.NoContext, {{packageName}}.ContextOAuth2, tokenSource) +r, err := client.Service.Operation(auth, args) +``` + +{{/isOAuth}} +{{/authMethods}} + +## Documentation for Utility Methods + +Due to the fact that model structure members are all pointers, this package contains +a number of utility functions to easily obtain pointers to values of basic types. +Each of these functions takes a value of the given basic type and returns a pointer to it: + +* `PtrBool` +* `PtrInt` +* `PtrInt32` +* `PtrInt64` +* `PtrFloat` +* `PtrFloat32` +* `PtrFloat64` +* `PtrString` +* `PtrTime` + +## Author + +{{#apiInfo}}{{#apis}}{{#-last}}{{infoEmail}} +{{/-last}}{{/apis}}{{/apiInfo}} diff --git a/sdk/templates/go/api.mustache b/sdk/templates/go/api.mustache new file mode 100644 index 00000000..5ad14781 --- /dev/null +++ b/sdk/templates/go/api.mustache @@ -0,0 +1,446 @@ +{{>partial_header}} +package {{packageName}} + +{{#operations}} +import ( + "bytes" + "context" + "io" + "net/http" + "net/url" +{{#imports}} "{{import}}" +{{/imports}} +) + +{{#generateInterfaces}} + +type {{classname}} interface { + {{#operation}} + + /* + {{operationId}} {{{summary}}}{{^summary}}Method for {{operationId}}{{/summary}} + {{#notes}} + + {{{unescapedNotes}}} + {{/notes}} + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().{{#pathParams}} + @param {{paramName}}{{#description}} {{{.}}}{{/description}}{{/pathParams}} + @return {{#structPrefix}}{{&classname}}{{/structPrefix}}{{^structPrefix}}Api{{/structPrefix}}{{operationId}}Request + {{#isDeprecated}} + + Deprecated + {{/isDeprecated}} + */ + {{{nickname}}}(ctx context.Context{{#pathParams}}, {{paramName}} {{{dataType}}}{{/pathParams}}) {{#structPrefix}}{{&classname}}{{/structPrefix}}{{^structPrefix}}Api{{/structPrefix}}{{operationId}}Request + + // {{nickname}}Execute executes the request{{#returnType}} + // @return {{{.}}}{{/returnType}} + {{#isDeprecated}} + // Deprecated + {{/isDeprecated}} + {{nickname}}Execute(r {{#structPrefix}}{{&classname}}{{/structPrefix}}{{^structPrefix}}Api{{/structPrefix}}{{operationId}}Request) ({{#returnType}}{{^isArray}}{{^returnTypeIsPrimitive}}{{^isResponseFile}}*{{/isResponseFile}}{{/returnTypeIsPrimitive}}{{/isArray}}{{{.}}}, {{/returnType}}*http.Response, error) + {{/operation}} +} +{{/generateInterfaces}} + +// {{classname}}Service {{classname}} service +type {{classname}}Service service +{{#operation}} + +type {{#structPrefix}}{{&classname}}{{/structPrefix}}{{^structPrefix}}Api{{/structPrefix}}{{operationId}}Request struct { + ctx context.Context{{#generateInterfaces}} + ApiService {{classname}} +{{/generateInterfaces}}{{^generateInterfaces}} + ApiService *{{classname}}Service +{{/generateInterfaces}} +{{#allParams}} + {{paramName}} {{^isPathParam}}{{^isFile}}*{{/isFile}}{{/isPathParam}}{{{dataType}}} +{{/allParams}} +} + +{{#allParams}} +{{^isPathParam}} +{{#description}} +// {{.}} +{{/description}} +{{#isDeprecated}} +// Deprecated +{{/isDeprecated}} +func (r {{#structPrefix}}{{&classname}}{{/structPrefix}}{{^structPrefix}}Api{{/structPrefix}}{{operationId}}Request) {{vendorExtensions.x-export-param-name}}({{paramName}} {{{dataType}}}) {{#structPrefix}}{{&classname}}{{/structPrefix}}{{^structPrefix}}Api{{/structPrefix}}{{operationId}}Request { + r.{{paramName}} = {{^isFile}}&{{/isFile}}{{paramName}} + return r +} + +{{/isPathParam}} +{{/allParams}} +func (r {{#structPrefix}}{{&classname}}{{/structPrefix}}{{^structPrefix}}Api{{/structPrefix}}{{operationId}}Request) Execute() ({{#returnType}}{{^isArray}}{{^returnTypeIsPrimitive}}{{^isResponseFile}}*{{/isResponseFile}}{{/returnTypeIsPrimitive}}{{/isArray}}{{{.}}}, {{/returnType}}*http.Response, error) { + return r.ApiService.{{nickname}}Execute(r) +} + +/* +{{operationId}} {{{summary}}}{{^summary}}Method for {{operationId}}{{/summary}} +{{#notes}} + +{{{unescapedNotes}}} +{{/notes}} + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().{{#pathParams}} + @param {{paramName}}{{#description}} {{{.}}}{{/description}}{{/pathParams}} + @return {{#structPrefix}}{{&classname}}{{/structPrefix}}{{^structPrefix}}Api{{/structPrefix}}{{operationId}}Request +{{#isDeprecated}} + +Deprecated +{{/isDeprecated}} +*/ +func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#pathParams}}, {{paramName}} {{{dataType}}}{{/pathParams}}) {{#structPrefix}}{{&classname}}{{/structPrefix}}{{^structPrefix}}Api{{/structPrefix}}{{operationId}}Request { + return {{#structPrefix}}{{&classname}}{{/structPrefix}}{{^structPrefix}}Api{{/structPrefix}}{{operationId}}Request{ + ApiService: a, + ctx: ctx, + {{#pathParams}} + {{paramName}}: {{paramName}}, + {{/pathParams}} + } +} + +// Execute executes the request{{#returnType}} +// @return {{{.}}}{{/returnType}} +{{#isDeprecated}} +// Deprecated +{{/isDeprecated}} +func (a *{{{classname}}}Service) {{nickname}}Execute(r {{#structPrefix}}{{&classname}}{{/structPrefix}}{{^structPrefix}}Api{{/structPrefix}}{{operationId}}Request) ({{#returnType}}{{^isArray}}{{^returnTypeIsPrimitive}}{{^isResponseFile}}*{{/isResponseFile}}{{/returnTypeIsPrimitive}}{{/isArray}}{{{.}}}, {{/returnType}}*http.Response, error) { + var ( + localVarHTTPMethod = http.Method{{httpMethod}} + localVarPostBody interface{} + formFiles []formFile + {{#returnType}} + localVarReturnValue {{^isArray}}{{^returnTypeIsPrimitive}}{{^isResponseFile}}*{{/isResponseFile}}{{/returnTypeIsPrimitive}}{{/isArray}}{{{.}}} + {{/returnType}} + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "{{{classname}}}Service.{{{nickname}}}") + if err != nil { + return {{#returnType}}localVarReturnValue, {{/returnType}}nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "{{{path}}}"{{#pathParams}} + localVarPath = strings.Replace(localVarPath, "{"+"{{{baseName}}}"+"}", url.PathEscape(parameterValueToString(r.{{paramName}}, "{{paramName}}")), -1){{/pathParams}} + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + {{#allParams}} + {{#required}} + {{^isPathParam}} + if r.{{paramName}} == nil { + return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} is required and must be specified") + } + {{/isPathParam}} + {{#minItems}} + if len({{^isPathParam}}*{{/isPathParam}}r.{{paramName}}) < {{minItems}} { + return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} must have at least {{minItems}} elements") + } + {{/minItems}} + {{#maxItems}} + if len({{^isPathParam}}*{{/isPathParam}}r.{{paramName}}) > {{maxItems}} { + return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} must have less than {{maxItems}} elements") + } + {{/maxItems}} + {{#minLength}} + if strlen({{^isPathParam}}*{{/isPathParam}}r.{{paramName}}) < {{minLength}} { + return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} must have at least {{minLength}} elements") + } + {{/minLength}} + {{#maxLength}} + if strlen({{^isPathParam}}*{{/isPathParam}}r.{{paramName}}) > {{maxLength}} { + return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} must have less than {{maxLength}} elements") + } + {{/maxLength}} + {{#minimum}} + {{#isString}} + {{paramName}}Txt, err := atoi({{^isPathParam}}*{{/isPathParam}}r.{{paramName}}) + if {{paramName}}Txt < {{minimum}} { + {{/isString}} + {{^isString}} + if {{^isPathParam}}*{{/isPathParam}}r.{{paramName}} < {{minimum}} { + {{/isString}} + return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} must be greater than {{minimum}}") + } + {{/minimum}} + {{#maximum}} + {{#isString}} + {{paramName}}Txt, err := atoi({{^isPathParam}}*{{/isPathParam}}r.{{paramName}}) + if {{paramName}}Txt > {{maximum}} { + {{/isString}} + {{^isString}} + if {{^isPathParam}}*{{/isPathParam}}r.{{paramName}} > {{maximum}} { + {{/isString}} + return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} must be less than {{maximum}}") + } + {{/maximum}} + {{/required}} + {{/allParams}} + + {{#queryParams}} + {{#required}} + {{#isCollectionFormatMulti}} + { + t := *r.{{paramName}} + if reflect.TypeOf(t).Kind() == reflect.Slice { + s := reflect.ValueOf(t) + for i := 0; i < s.Len(); i++ { + parameterAddToHeaderOrQuery(localVarQueryParams, "{{{baseName}}}", s.Index(i).Interface(), "{{collectionFormat}}") + } + } else { + parameterAddToHeaderOrQuery(localVarQueryParams, "{{{baseName}}}", t, "{{collectionFormat}}") + } + } + {{/isCollectionFormatMulti}} + {{^isCollectionFormatMulti}} + parameterAddToHeaderOrQuery(localVarQueryParams, "{{{baseName}}}", r.{{paramName}}, "{{collectionFormat}}") + {{/isCollectionFormatMulti}} + {{/required}} + {{^required}} + if r.{{paramName}} != nil { + {{#isCollectionFormatMulti}} + t := *r.{{paramName}} + if reflect.TypeOf(t).Kind() == reflect.Slice { + s := reflect.ValueOf(t) + for i := 0; i < s.Len(); i++ { + parameterAddToHeaderOrQuery(localVarQueryParams, "{{{baseName}}}", s.Index(i).Interface(), "{{collectionFormat}}") + } + } else { + parameterAddToHeaderOrQuery(localVarQueryParams, "{{{baseName}}}", t, "{{collectionFormat}}") + } + {{/isCollectionFormatMulti}} + {{^isCollectionFormatMulti}} + parameterAddToHeaderOrQuery(localVarQueryParams, "{{{baseName}}}", r.{{paramName}}, "{{collectionFormat}}") + {{/isCollectionFormatMulti}} + {{#defaultValue}}} else { + var defaultValue {{{dataType}}} = {{{.}}} + r.{{paramName}} = &defaultValue + {{/defaultValue}}} + {{/required}} + {{/queryParams}} + // to determine the Content-Type header +{{=<% %>=}} + localVarHTTPContentTypes := []string{<%#consumes%>"<%&mediaType%>"<%^-last%>, <%/-last%><%/consumes%>} +<%={{ }}=%> + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header +{{=<% %>=}} + localVarHTTPHeaderAccepts := []string{<%#produces%>"<%&mediaType%>"<%^-last%>, <%/-last%><%/produces%>} +<%={{ }}=%> + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + parameterAddToHeaderOrQuery(localVarHeaderParams, "X-Pulumi-Source", "esc-sdk", "") + parameterAddToHeaderOrQuery(localVarHeaderParams, "User-Agent", "{{userAgent}}", "") +{{#headerParams}} + {{#required}} + parameterAddToHeaderOrQuery(localVarHeaderParams, "{{{baseName}}}", r.{{paramName}}, "{{collectionFormat}}") + {{/required}} + {{^required}} + if r.{{paramName}} != nil { + parameterAddToHeaderOrQuery(localVarHeaderParams, "{{{baseName}}}", r.{{paramName}}, "{{collectionFormat}}") + } + {{/required}} +{{/headerParams}} +{{#formParams}} +{{#isFile}} +{{#isArray}} + var {{paramName}}LocalVarFormFileName string + var {{paramName}}LocalVarFileName string + var {{paramName}}LocalVarFileBytes []byte + + {{paramName}}LocalVarFormFileName = "{{{baseName}}}" + {{paramName}}LocalVarFile := r.{{paramName}} + + if {{paramName}}LocalVarFile != nil { + // loop through the array to prepare multiple files upload + for _, {{paramName}}LocalVarFileValue := range {{paramName}}LocalVarFile { + fbs, _ := io.ReadAll({{paramName}}LocalVarFileValue) + + {{paramName}}LocalVarFileBytes = fbs + {{paramName}}LocalVarFileName = {{paramName}}LocalVarFileValue.Name() + {{paramName}}LocalVarFileValue.Close() + formFiles = append(formFiles, formFile{fileBytes: {{paramName}}LocalVarFileBytes, fileName: {{paramName}}LocalVarFileName, formFileName: {{paramName}}LocalVarFormFileName}) + } + } +{{/isArray}} +{{^isArray}} + var {{paramName}}LocalVarFormFileName string + var {{paramName}}LocalVarFileName string + var {{paramName}}LocalVarFileBytes []byte + + {{paramName}}LocalVarFormFileName = "{{{baseName}}}" + {{paramName}}LocalVarFile := r.{{paramName}} + + if {{paramName}}LocalVarFile != nil { + fbs, _ := io.ReadAll({{paramName}}LocalVarFile) + + {{paramName}}LocalVarFileBytes = fbs + {{paramName}}LocalVarFileName = {{paramName}}LocalVarFile.Name() + {{paramName}}LocalVarFile.Close() + formFiles = append(formFiles, formFile{fileBytes: {{paramName}}LocalVarFileBytes, fileName: {{paramName}}LocalVarFileName, formFileName: {{paramName}}LocalVarFormFileName}) + } +{{/isArray}} +{{/isFile}} +{{^isFile}} +{{#required}} + parameterAddToHeaderOrQuery(localVarFormParams, "{{{baseName}}}", r.{{paramName}}, "{{collectionFormat}}") +{{/required}} +{{^required}} +{{#isModel}} + if r.{{paramName}} != nil { + paramJson, err := parameterToJson(*r.{{paramName}}) + if err != nil { + return {{#returnType}}localVarReturnValue, {{/returnType}}nil, err + } + localVarFormParams.Add("{{{baseName}}}", paramJson) + } +{{/isModel}} +{{^isModel}} + if r.{{paramName}} != nil { + parameterAddToHeaderOrQuery(localVarFormParams, "{{{baseName}}}", r.{{paramName}}, "{{collectionFormat}}") + } +{{/isModel}} +{{/required}} +{{/isFile}} +{{/formParams}} +{{#bodyParams}} + // body params + localVarPostBody = r.{{paramName}} +{{/bodyParams}} +{{#authMethods}} +{{#isApiKey}} +{{^isKeyInCookie}} + if r.ctx != nil { + // API Key Authentication + if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { + {{#vendorExtensions.x-auth-id-alias}} + if apiKey, ok := auth["{{.}}"]; ok { + var key string + if prefix, ok := auth["{{name}}"]; ok && prefix.Prefix != "" { + key = prefix.Prefix + " " + apiKey.Key + } else { + key = apiKey.Key + } + {{/vendorExtensions.x-auth-id-alias}} + {{^vendorExtensions.x-auth-id-alias}} + if apiKey, ok := auth["{{name}}"]; ok { + var key string + if apiKey.Prefix != "" { + key = apiKey.Prefix + " " + apiKey.Key + } else { + key = apiKey.Key + } + {{/vendorExtensions.x-auth-id-alias}} + {{#isKeyInHeader}} + localVarHeaderParams["{{keyParamName}}"] = key + {{/isKeyInHeader}} + {{#isKeyInQuery}} + localVarQueryParams.Add("{{keyParamName}}", key) + {{/isKeyInQuery}} + } + } + } +{{/isKeyInCookie}} +{{/isApiKey}} +{{/authMethods}} + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return {{#returnType}}localVarReturnValue, {{/returnType}}nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHTTPResponse, err + } + +{{#withCustomMiddlewareFunction}} + if a.client.cfg.ResponseMiddleware != nil { + err = a.client.cfg.ResponseMiddleware(localVarHTTPResponse, localVarBody) + if err != nil { + return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHTTPResponse, err + } + } + +{{/withCustomMiddlewareFunction}} + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + {{#responses}} + {{#dataType}} + {{^is1xx}} + {{^is2xx}} + {{#range}} + {{#is3xx}} + if localVarHTTPResponse.StatusCode >= 300 && localVarHTTPResponse.StatusCode < 400 { + {{/is3xx}} + {{#is4xx}} + if localVarHTTPResponse.StatusCode >= 400 && localVarHTTPResponse.StatusCode < 500 { + {{/is4xx}} + {{#is5xx}} + if localVarHTTPResponse.StatusCode >= 500 { + {{/is5xx}} + {{/range}} + {{^range}} + {{^wildcard}} + if localVarHTTPResponse.StatusCode == {{{code}}} { + {{/wildcard}} + {{/range}} + var v {{{dataType}}} + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + {{^-last}} + return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHTTPResponse, newErr + {{/-last}} + {{^wildcard}} + } + {{/wildcard}} + {{/is2xx}} + {{/is1xx}} + {{/dataType}} + {{/responses}} + return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHTTPResponse, newErr + } + + {{#returnType}} + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHTTPResponse, newErr + } + + {{/returnType}} + return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHTTPResponse, nil +} +{{/operation}} +{{/operations}} diff --git a/sdk/templates/go/api_doc.mustache b/sdk/templates/go/api_doc.mustache new file mode 100644 index 00000000..151baa93 --- /dev/null +++ b/sdk/templates/go/api_doc.mustache @@ -0,0 +1,92 @@ +# {{invokerPackage}}\{{classname}}{{#description}} + +{{.}}{{/description}} + +All URIs are relative to *{{basePath}}* + +Method | HTTP request | Description +------------- | ------------- | ------------- +{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{summary}} +{{/operation}}{{/operations}} + +{{#operations}} +{{#operation}} + +## {{{operationId}}} + +> {{#returnType}}{{{.}}} {{/returnType}}{{{operationId}}}(ctx{{#pathParams}}, {{paramName}}{{/pathParams}}){{#allParams}}{{^isPathParam}}.{{vendorExtensions.x-export-param-name}}({{paramName}}){{/isPathParam}}{{/allParams}}.Execute() + +{{{summary}}}{{#notes}} + +{{{unespacedNotes}}}{{/notes}} + +### Example + +```go +package main + +import ( + "context" + "fmt" + "os" +{{#vendorExtensions.x-go-import}} +{{{vendorExtensions.x-go-import}}} +{{/vendorExtensions.x-go-import}} + {{goImportAlias}} "{{gitHost}}/{{gitUserId}}/{{gitRepoId}}{{#isGoSubmodule}}/{{packageName}}{{/isGoSubmodule}}" +) + +func main() { + {{#allParams}} + {{paramName}} := {{{vendorExtensions.x-go-example}}} // {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} + {{/allParams}} + + configuration := {{goImportAlias}}.NewConfiguration() + apiClient := {{goImportAlias}}.NewAPIClient(configuration) + {{#returnType}}resp, {{/returnType}}r, err := apiClient.{{classname}}.{{operationId}}(context.Background(){{#pathParams}}, {{paramName}}{{/pathParams}}){{#allParams}}{{^isPathParam}}.{{vendorExtensions.x-export-param-name}}({{paramName}}){{/isPathParam}}{{/allParams}}.Execute() + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `{{classname}}.{{operationId}}``: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + {{#returnType}} + // response from `{{operationId}}`: {{{.}}} + fmt.Fprintf(os.Stdout, "Response from `{{classname}}.{{operationId}}`: %v\n", resp) + {{/returnType}} +} +``` + +### Path Parameters + +{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#pathParams}}{{#-last}} +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc.{{/-last}}{{/pathParams}}{{#pathParams}} +**{{paramName}}** | {{^isPrimitiveType}}{{^isFile}}[{{/isFile}}{{/isPrimitiveType}}**{{dataType}}**{{^isPrimitiveType}}{{^isFile}}]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}} | {{description}} | {{#defaultValue}}[default to {{.}}]{{/defaultValue}}{{/pathParams}} + +### Other Parameters + +Other parameters are passed through a pointer to a api{{{nickname}}}Request struct via the builder pattern +{{#allParams}}{{#-last}} + +Name | Type | Description | Notes +------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}}{{#allParams}} +{{^isPathParam}} **{{paramName}}** | {{#isContainer}}{{#isArray}}{{#items}}{{^isPrimitiveType}}{{^isFile}}[{{/isFile}}{{/isPrimitiveType}}**[]{{dataType}}**{{^isPrimitiveType}}{{^isFile}}]({{^baseType}}{{dataType}}{{/baseType}}{{baseType}}.md){{/isFile}}{{/isPrimitiveType}}{{/items}}{{/isArray}}{{#isMap}}{{#items}}{{^isPrimitiveType}}{{^isFile}}[{{/isFile}}{{/isPrimitiveType}}**map[string]{{dataType}}**{{^isPrimitiveType}}{{^isFile}}]({{^baseType}}{{dataType}}{{/baseType}}{{baseType}}.md){{/isFile}}{{/isPrimitiveType}}{{/items}}{{/isMap}}{{/isContainer}}{{^isContainer}}{{^isPrimitiveType}}{{^isFile}}[{{/isFile}}{{/isPrimitiveType}}**{{dataType}}**{{^isPrimitiveType}}{{^isFile}}]({{^baseType}}{{dataType}}{{/baseType}}{{baseType}}.md){{/isFile}}{{/isPrimitiveType}}{{/isContainer}} | {{description}} | {{#defaultValue}}[default to {{.}}]{{/defaultValue}}{{/isPathParam}}{{/allParams}} + +### Return type + +{{#returnType}}{{#returnTypeIsPrimitive}}**{{{returnType}}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{{returnType}}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}} (empty response body){{/returnType}} + +### Authorization + +{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{{name}}}](../README.md#{{{name}}}){{^-last}}, {{/-last}}{{/authMethods}} + +### HTTP request headers + +- **Content-Type**: {{#consumes}}{{{mediaType}}}{{^-last}}, {{/-last}}{{/consumes}}{{^consumes}}Not defined{{/consumes}} +- **Accept**: {{#produces}}{{{mediaType}}}{{^-last}}, {{/-last}}{{/produces}}{{^produces}}Not defined{{/produces}} + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) +[[Back to Model list]](../README.md#documentation-for-models) +[[Back to README]](../README.md) + +{{/operation}} +{{/operations}} diff --git a/sdk/templates/go/api_test.mustache b/sdk/templates/go/api_test.mustache new file mode 100644 index 00000000..79caa621 --- /dev/null +++ b/sdk/templates/go/api_test.mustache @@ -0,0 +1,54 @@ +/* +{{#appName}} +{{{.}}} +{{/appName}} + +Testing {{classname}}Service + +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); + +package {{packageName}} + +import ( + "context" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "testing" + {{goImportAlias}} "{{gitHost}}/{{gitUserId}}/{{gitRepoId}}{{#isGoSubmodule}}/{{packageName}}{{/isGoSubmodule}}" +) + +func Test_{{packageName}}_{{classname}}Service(t *testing.T) { + + configuration := {{goImportAlias}}.NewConfiguration() + apiClient := {{goImportAlias}}.NewAPIClient(configuration) + +{{#operations}} +{{#operation}} + t.Run("Test {{classname}}Service {{{nickname}}}", func(t *testing.T) { + + {{^pathParams}} + t.Skip("skip test") // remove to run test + {{/pathParams}} + {{#pathParams}} + {{#-first}} + t.Skip("skip test") // remove to run test + + {{/-first}} + var {{paramName}} {{{dataType}}} + {{/pathParams}} + + {{#returnType}}resp, {{/returnType}}httpRes, err := apiClient.{{classname}}.{{operationId}}(context.Background(){{#pathParams}}, {{paramName}}{{/pathParams}}).Execute() + + require.Nil(t, err) + {{#returnType}} + require.NotNil(t, resp) + {{/returnType}} + assert.Equal(t, 200, httpRes.StatusCode) + + }) + +{{/operation}} +{{/operations}} +} diff --git a/sdk/templates/go/client.mustache b/sdk/templates/go/client.mustache new file mode 100644 index 00000000..e79eadd1 --- /dev/null +++ b/sdk/templates/go/client.mustache @@ -0,0 +1,764 @@ +{{>partial_header}} +package {{packageName}} + +import ( + "bytes" + "context" + "encoding/json" + "encoding/xml" + "errors" + "fmt" + "io" + "log" + "mime/multipart" + "net/http" + "net/http/httputil" + "net/url" + "os" + "path/filepath" + "reflect" + "regexp" + "strconv" + "strings" + "time" + "unicode/utf8" + "gopkg.in/ghodss/yaml.v1" + + {{#hasOAuthMethods}} + "golang.org/x/oauth2" + {{/hasOAuthMethods}} + {{#withAWSV4Signature}} + awsv4 "github.com/aws/aws-sdk-go/aws/signer/v4" + awscredentials "github.com/aws/aws-sdk-go/aws/credentials" + {{/withAWSV4Signature}} +) + +var ( + JsonCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:[^;]+\+)?json)`) + XmlCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:[^;]+\+)?xml)`) + YamlCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:x-)?(?:[^;]+\+)?yaml)`) + queryParamSplit = regexp.MustCompile(`(^|&)([^&]+)`) + queryDescape = strings.NewReplacer( "%5B", "[", "%5D", "]" ) +) + +// RawAPIClient manages communication with the {{appName}} API v{{version}} +// In most cases there should be only one, shared, RawAPIClient. +type RawAPIClient struct { + cfg *Configuration + common service // Reuse a single struct instead of allocating one for each service on the heap. + + // API Services +{{#apiInfo}} +{{#apis}} +{{#operations}} + + {{classname}} {{#generateInterfaces}}{{classname}}{{/generateInterfaces}}{{^generateInterfaces}}*{{classname}}Service{{/generateInterfaces}} +{{/operations}} +{{/apis}} +{{/apiInfo}} +} + +type service struct { + client *RawAPIClient +} + +// NewRawAPIClient creates a new API client. Requires a userAgent string describing your application. +// optionally a custom http.Client to allow for advanced features such as caching. +func NewRawAPIClient(cfg *Configuration) *RawAPIClient { + if cfg.HTTPClient == nil { + cfg.HTTPClient = http.DefaultClient + } + + c := &RawAPIClient{} + c.cfg = cfg + c.common.client = c + +{{#apiInfo}} + // API Services +{{#apis}} +{{#operations}} + c.{{classname}} = (*{{classname}}Service)(&c.common) +{{/operations}} +{{/apis}} +{{/apiInfo}} + + return c +} + +func atoi(in string) (int, error) { + return strconv.Atoi(in) +} + +// selectHeaderContentType select a content type from the available list. +func selectHeaderContentType(contentTypes []string) string { + if len(contentTypes) == 0 { + return "" + } + if contains(contentTypes, "application/json") { + return "application/json" + } + return contentTypes[0] // use the first content type specified in 'consumes' +} + +// selectHeaderAccept join all accept types and return +func selectHeaderAccept(accepts []string) string { + if len(accepts) == 0 { + return "" + } + + if contains(accepts, "application/json") { + return "application/json" + } + + return strings.Join(accepts, ",") +} + +// contains is a case insensitive match, finding needle in a haystack +func contains(haystack []string, needle string) bool { + for _, a := range haystack { + if strings.EqualFold(a, needle) { + return true + } + } + return false +} + +// Verify optional parameters are of the correct type. +func typeCheckParameter(obj interface{}, expected string, name string) error { + // Make sure there is an object. + if obj == nil { + return nil + } + + // Check the type is as expected. + if reflect.TypeOf(obj).String() != expected { + return fmt.Errorf("expected %s to be of type %s but received %s", name, expected, reflect.TypeOf(obj).String()) + } + return nil +} + +func parameterValueToString( obj interface{}, key string ) string { + if reflect.TypeOf(obj).Kind() != reflect.Ptr { + return fmt.Sprintf("%v", obj) + } + var param,ok = obj.(MappedNullable) + if !ok { + return "" + } + dataMap,err := param.ToMap() + if err != nil { + return "" + } + return fmt.Sprintf("%v", dataMap[key]) +} + +// parameterAddToHeaderOrQuery adds the provided object to the request header or url query +// supporting deep object syntax +func parameterAddToHeaderOrQuery(headerOrQueryParams interface{}, keyPrefix string, obj interface{}, collectionType string) { + var v = reflect.ValueOf(obj) + var value = "" + if v == reflect.ValueOf(nil) { + value = "null" + } else { + switch v.Kind() { + case reflect.Invalid: + value = "invalid" + + case reflect.Struct: + if t,ok := obj.(MappedNullable); ok { + dataMap,err := t.ToMap() + if err != nil { + return + } + parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, dataMap, collectionType) + return + } + if t, ok := obj.(time.Time); ok { + parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, t.Format(time.RFC3339), collectionType) + return + } + value = v.Type().String() + " value" + case reflect.Slice: + var indValue = reflect.ValueOf(obj) + if indValue == reflect.ValueOf(nil) { + return + } + var lenIndValue = indValue.Len() + for i:=0;i 0 || (len(formFiles) > 0) { + if body != nil { + return nil, errors.New("Cannot specify postBody and multipart form at the same time.") + } + body = &bytes.Buffer{} + w := multipart.NewWriter(body) + + for k, v := range formParams { + for _, iv := range v { + if strings.HasPrefix(k, "@") { // file + err = addFile(w, k[1:], iv) + if err != nil { + return nil, err + } + } else { // form value + w.WriteField(k, iv) + } + } + } + for _, formFile := range formFiles { + if len(formFile.fileBytes) > 0 && formFile.fileName != "" { + w.Boundary() + part, err := w.CreateFormFile(formFile.formFileName, filepath.Base(formFile.fileName)) + if err != nil { + return nil, err + } + _, err = part.Write(formFile.fileBytes) + if err != nil { + return nil, err + } + } + } + + // Set the Boundary in the Content-Type + headerParams["Content-Type"] = w.FormDataContentType() + + // Set Content-Length + headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) + w.Close() + } + + if strings.HasPrefix(headerParams["Content-Type"], "application/x-www-form-urlencoded") && len(formParams) > 0 { + if body != nil { + return nil, errors.New("Cannot specify postBody and x-www-form-urlencoded form at the same time.") + } + body = &bytes.Buffer{} + body.WriteString(formParams.Encode()) + // Set Content-Length + headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) + } + + // Setup path and query parameters + url, err := url.Parse(path) + if err != nil { + return nil, err + } + + // Override request host, if applicable + if c.cfg.Host != "" { + url.Host = c.cfg.Host + } + + // Override request scheme, if applicable + if c.cfg.Scheme != "" { + url.Scheme = c.cfg.Scheme + } + + // Adding Query Param + query := url.Query() + for k, v := range queryParams { + for _, iv := range v { + query.Add(k, iv) + } + } + + // Encode the parameters. + url.RawQuery = queryParamSplit.ReplaceAllStringFunc(query.Encode(), func(s string) string { + pieces := strings.Split(s, "=") + pieces[0] = queryDescape.Replace(pieces[0]) + return strings.Join(pieces, "=") + }) + + // Generate a new request + if body != nil { + localVarRequest, err = http.NewRequest(method, url.String(), body) + } else { + localVarRequest, err = http.NewRequest(method, url.String(), nil) + } + if err != nil { + return nil, err + } + + // add header parameters, if any + if len(headerParams) > 0 { + headers := http.Header{} + for h, v := range headerParams { + headers[h] = []string{v} + } + localVarRequest.Header = headers + } + + // Add the user agent to the request. + localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent) + + if ctx != nil { + // add context to the request + localVarRequest = localVarRequest.WithContext(ctx) + + // Walk through any authentication. + + {{#hasOAuthMethods}} + // OAuth2 authentication + if tok, ok := ctx.Value(ContextOAuth2).(oauth2.TokenSource); ok { + // We were able to grab an oauth2 token from the context + var latestToken *oauth2.Token + if latestToken, err = tok.Token(); err != nil { + return nil, err + } + + latestToken.SetAuthHeader(localVarRequest) + } + + {{/hasOAuthMethods}} + {{#hasHttpBasicMethods}} + // Basic HTTP Authentication + if auth, ok := ctx.Value(ContextBasicAuth).(BasicAuth); ok { + localVarRequest.SetBasicAuth(auth.UserName, auth.Password) + } + + {{/hasHttpBasicMethods}} + {{#hasHttpBearerMethods}} + // AccessToken Authentication + if auth, ok := ctx.Value(ContextAccessToken).(string); ok { + localVarRequest.Header.Add("Authorization", "Bearer "+auth) + } + + {{/hasHttpBearerMethods}} + {{#withAWSV4Signature}} + // AWS Signature v4 Authentication + if auth, ok := ctx.Value(ContextAWSv4).(AWSv4); ok { + creds := awscredentials.NewStaticCredentials(auth.AccessKey, auth.SecretKey, auth.SessionToken) + signer := awsv4.NewSigner(creds) + var reader *strings.Reader + if body == nil { + reader = strings.NewReader("") + } else { + reader = strings.NewReader(body.String()) + } + + // Define default values for region and service to maintain backward compatibility + region := auth.Region + if region == "" { + region = "eu-west-2" + } + service := auth.Service + if service == "" { + service = "oapi" + } + + timestamp := time.Now() + _, err := signer.Sign(localVarRequest, reader, service, region, timestamp) + if err != nil { + return nil, err + } + } + {{/withAWSV4Signature}} + } + + for header, value := range c.cfg.DefaultHeader { + localVarRequest.Header.Add(header, value) + } +{{#withCustomMiddlewareFunction}} + + if c.cfg.Middleware != nil { + c.cfg.Middleware(localVarRequest) + } + + if c.cfg.MiddlewareWithError != nil { + err = c.cfg.MiddlewareWithError(localVarRequest) + if err != nil { + return nil, err + } + } + +{{/withCustomMiddlewareFunction}} +{{#hasHttpSignatureMethods}} + if ctx != nil { + // HTTP Signature Authentication. All request headers must be set (including default headers) + // because the headers may be included in the signature. + if auth, ok := ctx.Value(ContextHttpSignatureAuth).(HttpSignatureAuth); ok { + err = SignRequest(ctx, localVarRequest, auth) + if err != nil { + return nil, err + } + } + } +{{/hasHttpSignatureMethods}} + return localVarRequest, nil +} + +func (c *RawAPIClient) decode(v interface{}, b []byte, contentType string) (err error) { + if len(b) == 0 { + return nil + } + if s, ok := v.(*string); ok { + *s = string(b) + return nil + } + if f, ok := v.(*os.File); ok { + f, err = os.CreateTemp("", "HttpClientFile") + if err != nil { + return + } + _, err = f.Write(b) + if err != nil { + return + } + _, err = f.Seek(0, io.SeekStart) + return + } + if f, ok := v.(**os.File); ok { + *f, err = os.CreateTemp("", "HttpClientFile") + if err != nil { + return + } + _, err = (*f).Write(b) + if err != nil { + return + } + _, err = (*f).Seek(0, io.SeekStart) + return + } + if XmlCheck.MatchString(contentType) { + if err = xml.Unmarshal(b, v); err != nil { + return err + } + return nil + } + if JsonCheck.MatchString(contentType) { + if actualObj, ok := v.(interface{ GetActualInstance() interface{} }); ok { // oneOf, anyOf schemas + if unmarshalObj, ok := actualObj.(interface{ UnmarshalJSON([]byte) error }); ok { // make sure it has UnmarshalJSON defined + if err = unmarshalObj.UnmarshalJSON(b); err != nil { + return err + } + } else { + return errors.New("Unknown type with GetActualInstance but no unmarshalObj.UnmarshalJSON defined") + } + } else if err = json.Unmarshal(b, v); err != nil { // simple model + return err + } + return nil + } + if YamlCheck.MatchString(contentType) { + if err = yaml.Unmarshal(b, v); err != nil { + return err + } + return nil + } + return errors.New("undefined response type") +} + +// Add a file to the multipart request +func addFile(w *multipart.Writer, fieldName, path string) error { + file, err := os.Open(filepath.Clean(path)) + if err != nil { + return err + } + err = file.Close() + if err != nil { + return err + } + + part, err := w.CreateFormFile(fieldName, filepath.Base(path)) + if err != nil { + return err + } + _, err = io.Copy(part, file) + + return err +} + +// Prevent trying to import "fmt" +func reportError(format string, a ...interface{}) error { + return fmt.Errorf(format, a...) +} + +// A wrapper for strict JSON decoding +func newStrictDecoder(data []byte) *json.Decoder { + dec := json.NewDecoder(bytes.NewBuffer(data)) + dec.DisallowUnknownFields() + return dec +} + +// Set request body from an interface{} +func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err error) { + bodyBuf = &bytes.Buffer{} + + if reader, ok := body.(io.Reader); ok { + _, err = bodyBuf.ReadFrom(reader) + } else if fp, ok := body.(*os.File); ok { + _, err = bodyBuf.ReadFrom(fp) + } else if b, ok := body.([]byte); ok { + _, err = bodyBuf.Write(b) + } else if s, ok := body.(string); ok { + _, err = bodyBuf.WriteString(s) + } else if s, ok := body.(*string); ok { + _, err = bodyBuf.WriteString(*s) + } else if JsonCheck.MatchString(contentType) { + err = json.NewEncoder(bodyBuf).Encode(body) + } else if XmlCheck.MatchString(contentType) { + var bs []byte + bs, err = xml.Marshal(body) + if err == nil { + bodyBuf.Write(bs) + } + } else if YamlCheck.MatchString(contentType) { + var bs []byte + bs, err = yaml.Marshal(body) + if err == nil { + bodyBuf.Write(bs) + } + } + + if err != nil { + return nil, err + } + + if bodyBuf.Len() == 0 { + err = fmt.Errorf("invalid body type %s\n", contentType) + return nil, err + } + return bodyBuf, nil +} + +// detectContentType method is used to figure out `Request.Body` content type for request header +func detectContentType(body interface{}) string { + contentType := "text/plain; charset=utf-8" + kind := reflect.TypeOf(body).Kind() + + switch kind { + case reflect.Struct, reflect.Map, reflect.Ptr: + contentType = "application/json; charset=utf-8" + case reflect.String: + contentType = "text/plain; charset=utf-8" + default: + if b, ok := body.([]byte); ok { + contentType = http.DetectContentType(b) + } else if kind == reflect.Slice { + contentType = "application/json; charset=utf-8" + } + } + + return contentType +} + +// Ripped from https://github.com/gregjones/httpcache/blob/master/httpcache.go +type cacheControl map[string]string + +func parseCacheControl(headers http.Header) cacheControl { + cc := cacheControl{} + ccHeader := headers.Get("Cache-Control") + for _, part := range strings.Split(ccHeader, ",") { + part = strings.Trim(part, " ") + if part == "" { + continue + } + if strings.ContainsRune(part, '=') { + keyval := strings.Split(part, "=") + cc[strings.Trim(keyval[0], " ")] = strings.Trim(keyval[1], ",") + } else { + cc[part] = "" + } + } + return cc +} + +// CacheExpires helper function to determine remaining time before repeating a request. +func CacheExpires(r *http.Response) time.Time { + // Figure out when the cache expires. + var expires time.Time + now, err := time.Parse(time.RFC1123, r.Header.Get("date")) + if err != nil { + return time.Now() + } + respCacheControl := parseCacheControl(r.Header) + + if maxAge, ok := respCacheControl["max-age"]; ok { + lifetime, err := time.ParseDuration(maxAge + "s") + if err != nil { + expires = now + } else { + expires = now.Add(lifetime) + } + } else { + expiresHeader := r.Header.Get("Expires") + if expiresHeader != "" { + expires, err = time.Parse(time.RFC1123, expiresHeader) + if err != nil { + expires = now + } + } + } + return expires +} + +func strlen(s string) int { + return utf8.RuneCountInString(s) +} + +// GenericOpenAPIError Provides access to the body, error and model on returned errors. +type GenericOpenAPIError struct { + body []byte + error string + model interface{} +} + +// Error returns non-empty string if there was an error. +func (e GenericOpenAPIError) Error() string { + return e.error +} + +// Body returns the raw bytes of the response +func (e GenericOpenAPIError) Body() []byte { + return e.body +} + +// Model returns the unpacked model of the error +func (e GenericOpenAPIError) Model() interface{} { + return e.model +} + +// format error message using title and detail when model implements rfc7807 +func formatErrorMessage(status string, v interface{}) string { + str := "" + metaValue := reflect.ValueOf(v).Elem() + + if metaValue.Kind() == reflect.Struct { + field := metaValue.FieldByName("Title") + if field != (reflect.Value{}) { + str = fmt.Sprintf("%s", field.Interface()) + } + + field = metaValue.FieldByName("Detail") + if field != (reflect.Value{}) { + str = fmt.Sprintf("%s (%s)", str, field.Interface()) + } + } + + return strings.TrimSpace(fmt.Sprintf("%s %s", status, str)) +} diff --git a/sdk/templates/go/configuration.mustache b/sdk/templates/go/configuration.mustache new file mode 100644 index 00000000..15057e08 --- /dev/null +++ b/sdk/templates/go/configuration.mustache @@ -0,0 +1,332 @@ +{{>partial_header}} +package {{packageName}} + +import ( + "context" + "fmt" + "net/http" + "strings" +) + +// contextKeys are used to identify the type of value in the context. +// Since these are string, it is possible to get a short description of the +// context key for logging and debugging using key.String(). + +type contextKey string + +func (c contextKey) String() string { + return "auth " + string(c) +} + +var ( + {{#hasOAuthMethods}} + // ContextOAuth2 takes an oauth2.TokenSource as authentication for the request. + ContextOAuth2 = contextKey("token") + + {{/hasOAuthMethods}} + {{#hasHttpBasicMethods}} + // ContextBasicAuth takes BasicAuth as authentication for the request. + ContextBasicAuth = contextKey("basic") + + {{/hasHttpBasicMethods}} + {{#hasHttpBearerMethods}} + // ContextAccessToken takes a string oauth2 access token as authentication for the request. + ContextAccessToken = contextKey("accesstoken") + + {{/hasHttpBearerMethods}} + {{#hasApiKeyMethods}} + // ContextAPIKeys takes a string apikey as authentication for the request + ContextAPIKeys = contextKey("apiKeys") + + {{/hasApiKeyMethods}} + {{#withAWSV4Signature}} + // ContextAWSv4 takes an Access Key and a Secret Key for signing AWS Signature v4 + ContextAWSv4 = contextKey("awsv4") + + {{/withAWSV4Signature}} + {{#hasHttpSignatureMethods}} + // ContextHttpSignatureAuth takes HttpSignatureAuth as authentication for the request. + ContextHttpSignatureAuth = contextKey("httpsignature") + + {{/hasHttpSignatureMethods}} + // ContextServerIndex uses a server configuration from the index. + ContextServerIndex = contextKey("serverIndex") + + // ContextOperationServerIndices uses a server configuration from the index mapping. + ContextOperationServerIndices = contextKey("serverOperationIndices") + + // ContextServerVariables overrides a server configuration variables. + ContextServerVariables = contextKey("serverVariables") + + // ContextOperationServerVariables overrides a server configuration variables using operation specific values. + ContextOperationServerVariables = contextKey("serverOperationVariables") +) + +// BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth +type BasicAuth struct { + UserName string `json:"userName,omitempty"` + Password string `json:"password,omitempty"` +} + +// APIKey provides API key based authentication to a request passed via context using ContextAPIKey +type APIKey struct { + Key string + Prefix string +} + +{{#withAWSV4Signature}} +// AWSv4 provides AWS Signature to a request passed via context using ContextAWSv4 +// https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html +type AWSv4 struct { + AccessKey string + SecretKey string + SessionToken string + Region string + Service string +} + +{{/withAWSV4Signature}} +// ServerVariable stores the information about a server variable +type ServerVariable struct { + Description string + DefaultValue string + EnumValues []string +} + +// ServerConfiguration stores the information about a server +type ServerConfiguration struct { + URL string + Description string + Variables map[string]ServerVariable +} + +// ServerConfigurations stores multiple ServerConfiguration items +type ServerConfigurations []ServerConfiguration + +{{#withCustomMiddlewareFunction}} +// MiddlewareFunction provides way to implement custom middleware in the prepareRequest +type MiddlewareFunction func(*http.Request) + +// MiddlewareFunctionWithError provides way to implement custom middleware with errors in the prepareRequest +type MiddlewareFunctionWithError func(*http.Request) error + +// ResponseMiddlewareFunction provides way to implement custom middleware with errors after the response is received +type ResponseMiddlewareFunction func(*http.Response, []byte) error + +{{/withCustomMiddlewareFunction}} +// Configuration stores the configuration of the API client +type Configuration struct { + Host string `json:"host,omitempty"` + Scheme string `json:"scheme,omitempty"` + DefaultHeader map[string]string `json:"defaultHeader,omitempty"` + UserAgent string `json:"userAgent,omitempty"` + Debug bool `json:"debug,omitempty"` + Servers ServerConfigurations + OperationServers map[string]ServerConfigurations + HTTPClient *http.Client + {{#withCustomMiddlewareFunction}} + Middleware MiddlewareFunction + MiddlewareWithError MiddlewareFunctionWithError + ResponseMiddleware ResponseMiddlewareFunction + {{/withCustomMiddlewareFunction}} +} + +// NewConfiguration returns a new Configuration object +func NewConfiguration() *Configuration { + cfg := &Configuration{ + DefaultHeader: make(map[string]string), + UserAgent: "esc-sdk", + Debug: false, + {{#servers}} + {{#-first}} + Servers: ServerConfigurations{ + {{/-first}} + { + URL: "{{{url}}}", + Description: "{{{description}}}{{^description}}No description provided{{/description}}", + {{#variables}} + {{#-first}} + Variables: map[string]ServerVariable{ + {{/-first}} + "{{{name}}}": ServerVariable{ + Description: "{{{description}}}{{^description}}No description provided{{/description}}", + DefaultValue: "{{{defaultValue}}}", + {{#enumValues}} + {{#-first}} + EnumValues: []string{ + {{/-first}} + "{{{.}}}", + {{#-last}} + }, + {{/-last}} + {{/enumValues}} + }, + {{#-last}} + }, + {{/-last}} + {{/variables}} + }, + {{#-last}} + }, + {{/-last}} + {{/servers}} + {{#apiInfo}} + OperationServers: map[string]ServerConfigurations{ + {{#apis}} + {{#operations}} + {{#operation}} + {{#servers}} + {{#-first}} + "{{{classname}}}Service.{{{nickname}}}": { + {{/-first}} + { + URL: "{{{url}}}", + Description: "{{{description}}}{{^description}}No description provided{{/description}}", + {{#variables}} + {{#-first}} + Variables: map[string]ServerVariable{ + {{/-first}} + "{{{name}}}": ServerVariable{ + Description: "{{{description}}}{{^description}}No description provided{{/description}}", + DefaultValue: "{{{defaultValue}}}", + {{#enumValues}} + {{#-first}} + EnumValues: []string{ + {{/-first}} + "{{{.}}}", + {{#-last}} + }, + {{/-last}} + {{/enumValues}} + }, + {{#-last}} + }, + {{/-last}} + {{/variables}} + }, + {{#-last}} + }, + {{/-last}} + {{/servers}} + {{/operation}} + {{/operations}} + {{/apis}} + }, + {{/apiInfo}} + } + return cfg +} + +// AddDefaultHeader adds a new HTTP header to the default header in the request +func (c *Configuration) AddDefaultHeader(key string, value string) { + c.DefaultHeader[key] = value +} + +// URL formats template on a index using given variables +func (sc ServerConfigurations) URL(index int, variables map[string]string) (string, error) { + if index < 0 || len(sc) <= index { + return "", fmt.Errorf("index %v out of range %v", index, len(sc)-1) + } + server := sc[index] + url := server.URL + + // go through variables and replace placeholders + for name, variable := range server.Variables { + if value, ok := variables[name]; ok { + found := bool(len(variable.EnumValues) == 0) + for _, enumValue := range variable.EnumValues { + if value == enumValue { + found = true + } + } + if !found { + return "", fmt.Errorf("the variable %s in the server URL has invalid value %v. Must be %v", name, value, variable.EnumValues) + } + url = strings.Replace(url, "{"+name+"}", value, -1) + } else { + url = strings.Replace(url, "{"+name+"}", variable.DefaultValue, -1) + } + } + return url, nil +} + +// ServerURL returns URL based on server settings +func (c *Configuration) ServerURL(index int, variables map[string]string) (string, error) { + return c.Servers.URL(index, variables) +} + +func getServerIndex(ctx context.Context) (int, error) { + si := ctx.Value(ContextServerIndex) + if si != nil { + if index, ok := si.(int); ok { + return index, nil + } + return 0, reportError("Invalid type %T should be int", si) + } + return 0, nil +} + +func getServerOperationIndex(ctx context.Context, endpoint string) (int, error) { + osi := ctx.Value(ContextOperationServerIndices) + if osi != nil { + if operationIndices, ok := osi.(map[string]int); !ok { + return 0, reportError("Invalid type %T should be map[string]int", osi) + } else { + index, ok := operationIndices[endpoint] + if ok { + return index, nil + } + } + } + return getServerIndex(ctx) +} + +func getServerVariables(ctx context.Context) (map[string]string, error) { + sv := ctx.Value(ContextServerVariables) + if sv != nil { + if variables, ok := sv.(map[string]string); ok { + return variables, nil + } + return nil, reportError("ctx value of ContextServerVariables has invalid type %T should be map[string]string", sv) + } + return nil, nil +} + +func getServerOperationVariables(ctx context.Context, endpoint string) (map[string]string, error) { + osv := ctx.Value(ContextOperationServerVariables) + if osv != nil { + if operationVariables, ok := osv.(map[string]map[string]string); !ok { + return nil, reportError("ctx value of ContextOperationServerVariables has invalid type %T should be map[string]map[string]string", osv) + } else { + variables, ok := operationVariables[endpoint] + if ok { + return variables, nil + } + } + } + return getServerVariables(ctx) +} + +// ServerURLWithContext returns a new server URL given an endpoint +func (c *Configuration) ServerURLWithContext(ctx context.Context, endpoint string) (string, error) { + sc, ok := c.OperationServers[endpoint] + if !ok { + sc = c.Servers + } + + if ctx == nil { + return sc.URL(0, nil) + } + + index, err := getServerOperationIndex(ctx, endpoint) + if err != nil { + return "", err + } + + variables, err := getServerOperationVariables(ctx, endpoint) + if err != nil { + return "", err + } + + return sc.URL(index, variables) +} diff --git a/sdk/templates/go/go.mod.mustache b/sdk/templates/go/go.mod.mustache new file mode 100644 index 00000000..94ef2cd9 --- /dev/null +++ b/sdk/templates/go/go.mod.mustache @@ -0,0 +1,13 @@ +module {{gitHost}}/{{gitUserId}}/{{gitRepoId}}{{#isGoSubmodule}}/{{packageName}}{{/isGoSubmodule}} + +go 1.18 + +require ( + gopkg.in/ghodss/yaml.v1 v1.0.0 + {{#hasOAuthMethods}} + golang.org/x/oauth2 v0.0.0-20210323180902-22b0adad7558 + {{/hasOAuthMethods}} + {{#withAWSV4Signature}} + github.com/aws/aws-sdk-go v1.34.14 + {{/withAWSV4Signature}} +) diff --git a/sdk/templates/go/go.sum.mustache b/sdk/templates/go/go.sum.mustache new file mode 100644 index 00000000..d25a7530 --- /dev/null +++ b/sdk/templates/go/go.sum.mustache @@ -0,0 +1,15 @@ +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI+Ei4I1nO5Jh72wfHlg= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +{{#hasOAuthMethods}} +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +{{/hasOAuthMethods}} +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= diff --git a/sdk/templates/go/model.mustache b/sdk/templates/go/model.mustache new file mode 100644 index 00000000..684af1d3 --- /dev/null +++ b/sdk/templates/go/model.mustache @@ -0,0 +1,20 @@ +{{>partial_header}} +package {{packageName}} + +{{#models}} +import ( + "encoding/json" +{{#imports}} + "{{import}}" +{{/imports}} +) + +{{#model}} +{{#isEnum}} +{{>model_enum}} +{{/isEnum}} +{{^isEnum}} +{{#oneOf}}{{#-first}}{{>model_oneof}}{{/-first}}{{/oneOf}}{{^oneOf}}{{#anyOf}}{{#-first}}{{>model_anyof}}{{/-first}}{{/anyOf}}{{^anyOf}}{{>model_simple}}{{/anyOf}}{{/oneOf}} +{{/isEnum}} +{{/model}} +{{/models}} diff --git a/sdk/templates/go/model_anyof.mustache b/sdk/templates/go/model_anyof.mustache new file mode 100644 index 00000000..3b221d80 --- /dev/null +++ b/sdk/templates/go/model_anyof.mustache @@ -0,0 +1,76 @@ +// {{classname}} {{{description}}}{{^description}}struct for {{{classname}}}{{/description}} +type {{classname}} struct { + {{#anyOf}} + {{{.}}} *{{{.}}} + {{/anyOf}} +} + +// Unmarshal JSON data into any of the pointers in the struct +func (dst *{{classname}}) UnmarshalJSON(data []byte) error { + var err error + {{#isNullable}} + // this object is nullable so check if the payload is null or empty string + if string(data) == "" || string(data) == "{}" { + return nil + } + + {{/isNullable}} + {{#discriminator}} + {{#mappedModels}} + {{#-first}} + // use discriminator value to speed up the lookup + var jsonDict map[string]interface{} + err = json.Unmarshal(data, &jsonDict) + if err != nil { + return fmt.Errorf("failed to unmarshal JSON into map for the discriminator lookup") + } + + {{/-first}} + // check if the discriminator value is '{{{mappingName}}}' + if jsonDict["{{{propertyBaseName}}}"] == "{{{mappingName}}}" { + // try to unmarshal JSON data into {{{modelName}}} + err = json.Unmarshal(data, &dst.{{{modelName}}}); + if err == nil { + json{{{modelName}}}, _ := json.Marshal(dst.{{{modelName}}}) + if string(json{{{modelName}}}) == "{}" { // empty struct + dst.{{{modelName}}} = nil + } else { + return nil // data stored in dst.{{{modelName}}}, return on the first match + } + } else { + dst.{{{modelName}}} = nil + } + } + + {{/mappedModels}} + {{/discriminator}} + {{#anyOf}} + // try to unmarshal JSON data into {{{.}}} + err = json.Unmarshal(data, &dst.{{{.}}}); + if err == nil { + json{{{.}}}, _ := json.Marshal(dst.{{{.}}}) + if string(json{{{.}}}) == "{}" { // empty struct + dst.{{{.}}} = nil + } else { + return nil // data stored in dst.{{{.}}}, return on the first match + } + } else { + dst.{{{.}}} = nil + } + + {{/anyOf}} + return fmt.Errorf("data failed to match schemas in anyOf({{classname}})") +} + +// Marshal data from the first non-nil pointers in the struct to JSON +func (src *{{classname}}) MarshalJSON() ([]byte, error) { +{{#anyOf}} + if src.{{{.}}} != nil { + return json.Marshal(&src.{{{.}}}) + } + +{{/anyOf}} + return nil, nil // no data in anyOf schemas +} + +{{>nullable_model}} diff --git a/sdk/templates/go/model_doc.mustache b/sdk/templates/go/model_doc.mustache new file mode 100644 index 00000000..439e695b --- /dev/null +++ b/sdk/templates/go/model_doc.mustache @@ -0,0 +1,97 @@ +{{#models}}{{#model}}# {{classname}} + +{{^isEnum}} +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +{{#vendorExtensions.x-is-one-of-interface}} +**{{classname}}Interface** | **interface { {{#discriminator}}{{propertyGetter}}() {{propertyType}}{{/discriminator}} }** | An interface that can hold any of the proper implementing types | +{{/vendorExtensions.x-is-one-of-interface}} +{{^vendorExtensions.x-is-one-of-interface}} +{{#vars}}**{{name}}** | {{^required}}Pointer to {{/required}}{{#isContainer}}{{#isArray}}{{#items}}{{^isPrimitiveType}}{{^isFile}}[{{/isFile}}{{/isPrimitiveType}}**[]{{dataType}}**{{^isPrimitiveType}}{{^isFile}}]({{dataType}}.md){{/isFile}}{{/isPrimitiveType}}{{/items}}{{/isArray}}{{#isMap}}{{#items}}{{^isPrimitiveType}}{{^isFile}}[{{/isFile}}{{/isPrimitiveType}}**map[string]{{dataType}}**{{^isPrimitiveType}}{{^isFile}}]({{^baseType}}{{dataType}}{{/baseType}}{{baseType}}.md){{/isFile}}{{/isPrimitiveType}}{{/items}}{{/isMap}}{{/isContainer}}{{^isContainer}}{{^isPrimitiveType}}{{^isFile}}{{^isDateTime}}[{{/isDateTime}}{{/isFile}}{{/isPrimitiveType}}**{{dataType}}**{{^isPrimitiveType}}{{^isFile}}{{^isDateTime}}]({{^baseType}}{{dataType}}{{/baseType}}{{baseType}}.md){{/isDateTime}}{{/isFile}}{{/isPrimitiveType}}{{/isContainer}} | {{description}} | {{^required}}[optional] {{/required}}{{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}} +{{/vars}} +{{/vendorExtensions.x-is-one-of-interface}} + +## Methods + +{{^vendorExtensions.x-is-one-of-interface}} +### New{{classname}} + +`func New{{classname}}({{#vars}}{{#required}}{{nameInCamelCase}} {{dataType}}, {{/required}}{{/vars}}) *{{classname}}` + +New{{classname}} instantiates a new {{classname}} object +This constructor will assign default values to properties that have it defined, +and makes sure properties required by API are set, but the set of arguments +will change when the set of required properties is changed + +### New{{classname}}WithDefaults + +`func New{{classname}}WithDefaults() *{{classname}}` + +New{{classname}}WithDefaults instantiates a new {{classname}} object +This constructor will only assign default values to properties that have it defined, +but it doesn't guarantee that properties required by API are set + +{{#vars}} +### Get{{name}} + +`func (o *{{classname}}) Get{{name}}() {{vendorExtensions.x-go-base-type}}` + +Get{{name}} returns the {{name}} field if non-nil, zero value otherwise. + +### Get{{name}}Ok + +`func (o *{{classname}}) Get{{name}}Ok() (*{{vendorExtensions.x-go-base-type}}, bool)` + +Get{{name}}Ok returns a tuple with the {{name}} field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### Set{{name}} + +`func (o *{{classname}}) Set{{name}}(v {{vendorExtensions.x-go-base-type}})` + +Set{{name}} sets {{name}} field to given value. + +{{^required}} +### Has{{name}} + +`func (o *{{classname}}) Has{{name}}() bool` + +Has{{name}} returns a boolean if a field has been set. +{{/required}} + +{{#isNullable}} +### Set{{name}}Nil + +`func (o *{{classname}}) Set{{name}}Nil(b bool)` + + Set{{name}}Nil sets the value for {{name}} to be an explicit nil + +### Unset{{name}} +`func (o *{{classname}}) Unset{{name}}()` + +Unset{{name}} ensures that no value is present for {{name}}, not even an explicit nil +{{/isNullable}} +{{/vars}} +{{#vendorExtensions.x-implements}} + +### As{{{.}}} + +`func (s *{{classname}}) As{{{.}}}() {{{.}}}` + +Convenience method to wrap this instance of {{classname}} in {{{.}}} +{{/vendorExtensions.x-implements}} +{{/vendorExtensions.x-is-one-of-interface}} +{{/isEnum}} +{{#isEnum}} +## Enum + +{{#allowableValues}}{{#enumVars}} +* `{{name}}` (value: `{{{value}}}`) +{{/enumVars}}{{/allowableValues}} +{{/isEnum}} + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + +{{/model}}{{/models}} diff --git a/sdk/templates/go/model_enum.mustache b/sdk/templates/go/model_enum.mustache new file mode 100644 index 00000000..398f8f0f --- /dev/null +++ b/sdk/templates/go/model_enum.mustache @@ -0,0 +1,101 @@ +// {{{classname}}} {{{description}}}{{^description}}the model '{{{classname}}}'{{/description}} +type {{{classname}}} {{{format}}}{{^format}}{{dataType}}{{/format}} + +// List of {{{name}}} +const ( + {{#allowableValues}} + {{#enumVars}} + {{^-first}} + {{/-first}} + {{#enumClassPrefix}}{{{classname.toUpperCase}}}_{{/enumClassPrefix}}{{name}} {{{classname}}} = {{{value}}} + {{/enumVars}} + {{/allowableValues}} +) + +// All allowed values of {{{classname}}} enum +var Allowed{{{classname}}}EnumValues = []{{{classname}}}{ + {{#allowableValues}} + {{#enumVars}} + {{{value}}}, + {{/enumVars}} + {{/allowableValues}} +} + +func (v *{{{classname}}}) UnmarshalJSON(src []byte) error { + var value {{{format}}}{{^format}}{{dataType}}{{/format}} + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + enumTypeValue := {{{classname}}}(value) + for _, existing := range Allowed{{{classname}}}EnumValues { + if existing == enumTypeValue { + *v = enumTypeValue + return nil + } + } + + return fmt.Errorf("%+v is not a valid {{classname}}", value) +} + +// New{{{classname}}}FromValue returns a pointer to a valid {{{classname}}} +// for the value passed as argument, or an error if the value passed is not allowed by the enum +func New{{{classname}}}FromValue(v {{{format}}}{{^format}}{{dataType}}{{/format}}) (*{{{classname}}}, error) { + ev := {{{classname}}}(v) + if ev.IsValid() { + return &ev, nil + } else { + return nil, fmt.Errorf("invalid value '%v' for {{{classname}}}: valid values are %v", v, Allowed{{{classname}}}EnumValues) + } +} + +// IsValid return true if the value is valid for the enum, false otherwise +func (v {{{classname}}}) IsValid() bool { + for _, existing := range Allowed{{{classname}}}EnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to {{{name}}} value +func (v {{{classname}}}) Ptr() *{{{classname}}} { + return &v +} + +type Nullable{{{classname}}} struct { + value *{{{classname}}} + isSet bool +} + +func (v Nullable{{classname}}) Get() *{{classname}} { + return v.value +} + +func (v *Nullable{{classname}}) Set(val *{{classname}}) { + v.value = val + v.isSet = true +} + +func (v Nullable{{classname}}) IsSet() bool { + return v.isSet +} + +func (v *Nullable{{classname}}) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullable{{classname}}(val *{{classname}}) *Nullable{{classname}} { + return &Nullable{{classname}}{value: val, isSet: true} +} + +func (v Nullable{{{classname}}}) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *Nullable{{{classname}}}) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/sdk/templates/go/model_oneof.mustache b/sdk/templates/go/model_oneof.mustache new file mode 100644 index 00000000..83660147 --- /dev/null +++ b/sdk/templates/go/model_oneof.mustache @@ -0,0 +1,144 @@ +// {{classname}} - {{{description}}}{{^description}}struct for {{{classname}}}{{/description}} +type {{classname}} struct { + {{#oneOf}} + {{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}} *{{{.}}} + {{/oneOf}} +} + +{{#oneOf}} +// {{{.}}}As{{classname}} is a convenience function that returns {{{.}}} wrapped in {{classname}} +func {{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}}As{{classname}}(v *{{{.}}}) {{classname}} { + return {{classname}}{ + {{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}}: v, + } +} + +{{/oneOf}} + +// Unmarshal JSON data into one of the pointers in the struct +func (dst *{{classname}}) UnmarshalJSON(data []byte) error { + var err error + {{#isNullable}} + // this object is nullable so check if the payload is null or empty string + if string(data) == "" || string(data) == "{}" { + return nil + } + + {{/isNullable}} + {{#useOneOfDiscriminatorLookup}} + {{#discriminator}} + {{#mappedModels}} + {{#-first}} + // use discriminator value to speed up the lookup + var jsonDict map[string]interface{} + err = newStrictDecoder(data).Decode(&jsonDict) + if err != nil { + return fmt.Errorf("failed to unmarshal JSON into map for the discriminator lookup") + } + + {{/-first}} + // check if the discriminator value is '{{{mappingName}}}' + if jsonDict["{{{propertyBaseName}}}"] == "{{{mappingName}}}" { + // try to unmarshal JSON data into {{{modelName}}} + err = json.Unmarshal(data, &dst.{{{modelName}}}) + if err == nil { + return nil // data stored in dst.{{{modelName}}}, return on the first match + } else { + dst.{{{modelName}}} = nil + return fmt.Errorf("failed to unmarshal {{classname}} as {{{modelName}}}: %s", err.Error()) + } + } + + {{/mappedModels}} + return nil + {{/discriminator}} + {{^discriminator}} + match := 0 + {{#oneOf}} + // try to unmarshal data into {{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}} + err = json.Unmarshal(data, &dst.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}}) + if err == nil { + json{{{.}}}, _ := json.Marshal(dst.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}}) + if string(json{{{.}}}) == "{}" { // empty struct + dst.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}} = nil + } else { + match++ + } + } else { + dst.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}} = nil + } + + {{/oneOf}} + if match > 1 { // more than 1 match + // reset to nil + {{#oneOf}} + dst.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}} = nil + {{/oneOf}} + + return fmt.Errorf("data matches more than one schema in oneOf({{classname}})") + } else if match == 1 { + return nil // exactly one match + } else { // no match + return fmt.Errorf("data failed to match schemas in oneOf({{classname}})") + } + {{/discriminator}} + {{/useOneOfDiscriminatorLookup}} + {{^useOneOfDiscriminatorLookup}} + match := 0 + {{#oneOf}} + // try to unmarshal data into {{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}} + err = newStrictDecoder(data).Decode(&dst.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}}) + if err == nil { + json{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}}, _ := json.Marshal(dst.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}}) + if string(json{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}}) == "{}" { // empty struct + dst.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}} = nil + } else { + match++ + } + } else { + dst.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}} = nil + } + + {{/oneOf}} + if match > 1 { // more than 1 match + // reset to nil + {{#oneOf}} + dst.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}} = nil + {{/oneOf}} + + return fmt.Errorf("data matches more than one schema in oneOf({{classname}})") + } else if match == 1 { + return nil // exactly one match + } else { // no match + return fmt.Errorf("data failed to match schemas in oneOf({{classname}})") + } + {{/useOneOfDiscriminatorLookup}} +} + +// Marshal data from the first non-nil pointers in the struct to JSON +func (src {{classname}}) MarshalJSON() ([]byte, error) { +{{#oneOf}} + if src.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}} != nil { + return json.Marshal(&src.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}}) + } + +{{/oneOf}} + return nil, nil // no data in oneOf schemas +} + +// Get the actual instance +func (obj *{{classname}}) GetActualInstance() (interface{}) { + if obj == nil { + return nil + } +{{#oneOf}} + if obj.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}} != nil { + return obj.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}} + } + +{{/oneOf}} + // all schemas are nil + return nil +} + +{{>nullable_model}} diff --git a/sdk/templates/go/model_simple.mustache b/sdk/templates/go/model_simple.mustache new file mode 100644 index 00000000..64952edc --- /dev/null +++ b/sdk/templates/go/model_simple.mustache @@ -0,0 +1,519 @@ +// checks if the {{classname}} type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &{{classname}}{} + +// {{classname}} {{{description}}}{{^description}}struct for {{{classname}}}{{/description}} +type {{classname}} struct { +{{#parent}} +{{^isMap}} +{{^isArray}} + {{{parent}}} +{{/isArray}} +{{/isMap}} +{{#isArray}} + Items {{{parent}}} +{{/isArray}} +{{/parent}} +{{#vars}} +{{^-first}} +{{/-first}} +{{#description}} + // {{{.}}} +{{/description}} +{{#deprecated}} + // Deprecated +{{/deprecated}} + {{name}} {{^required}}{{^isNullable}}{{^isArray}}{{^isFreeFormObject}}*{{/isFreeFormObject}}{{/isArray}}{{/isNullable}}{{/required}}{{{dataType}}} `json:"{{{baseName}}}{{^required}},omitempty{{/required}}"{{#withXml}} xml:"{{{baseName}}}{{#isXmlAttribute}},attr{{/isXmlAttribute}}"{{/withXml}}{{#vendorExtensions.x-go-custom-tag}} {{{.}}}{{/vendorExtensions.x-go-custom-tag}}` +{{/vars}} +{{#isAdditionalPropertiesTrue}} + AdditionalProperties map[string]interface{} +{{/isAdditionalPropertiesTrue}} +} + +{{#isAdditionalPropertiesTrue}} +type _{{{classname}}} {{{classname}}} + +{{/isAdditionalPropertiesTrue}} +{{^isAdditionalPropertiesTrue}} +{{#hasRequired}} +type _{{{classname}}} {{{classname}}} + +{{/hasRequired}} +{{/isAdditionalPropertiesTrue}} +// New{{classname}} instantiates a new {{classname}} object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func New{{classname}}({{#requiredVars}}{{nameInCamelCase}} {{dataType}}{{^-last}}, {{/-last}}{{/requiredVars}}) *{{classname}} { + this := {{classname}}{} +{{#allVars}} +{{#required}} + this.{{name}} = {{nameInCamelCase}} +{{/required}} +{{^required}} +{{#defaultValue}} +{{^vendorExtensions.x-golang-is-container}} +{{^isReadOnly}} +{{#isNullable}} + var {{nameInCamelCase}} {{{datatypeWithEnum}}} = {{{.}}} + this.{{name}} = *New{{{dataType}}}(&{{nameInCamelCase}}) +{{/isNullable}} +{{^isNullable}} + var {{nameInCamelCase}} {{{dataType}}} = {{{.}}} + this.{{name}} = &{{nameInCamelCase}} +{{/isNullable}} +{{/isReadOnly}} +{{/vendorExtensions.x-golang-is-container}} +{{/defaultValue}} +{{/required}} +{{/allVars}} + return &this +} + +// New{{classname}}WithDefaults instantiates a new {{classname}} object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func New{{classname}}WithDefaults() *{{classname}} { + this := {{classname}}{} +{{#vars}} +{{#defaultValue}} +{{^vendorExtensions.x-golang-is-container}} +{{^isReadOnly}} +{{#isNullable}} +{{!we use datatypeWithEnum here, since it will represent the non-nullable name of the datatype, e.g. int64 for NullableInt64}} + var {{nameInCamelCase}} {{{datatypeWithEnum}}} = {{{.}}} + this.{{name}} = *New{{{dataType}}}(&{{nameInCamelCase}}) +{{/isNullable}} +{{^isNullable}} + var {{nameInCamelCase}} {{{dataType}}} = {{{.}}} + this.{{name}} = {{^required}}&{{/required}}{{nameInCamelCase}} +{{/isNullable}} +{{/isReadOnly}} +{{/vendorExtensions.x-golang-is-container}} +{{/defaultValue}} +{{/vars}} + return &this +} + +{{#vars}} +{{#required}} +// Get{{name}} returns the {{name}} field value +{{#isNullable}} +// If the value is explicit nil, the zero value for {{vendorExtensions.x-go-base-type}} will be returned +{{/isNullable}} +{{#deprecated}} +// Deprecated +{{/deprecated}} +func (o *{{classname}}) Get{{name}}() {{vendorExtensions.x-go-base-type}} { + if o == nil{{#isNullable}}{{^vendorExtensions.x-golang-is-container}} || o.{{name}}.Get() == nil{{/vendorExtensions.x-golang-is-container}}{{/isNullable}} { + var ret {{vendorExtensions.x-go-base-type}} + return ret + } + +{{#isNullable}} +{{#vendorExtensions.x-golang-is-container}} + return o.{{name}} +{{/vendorExtensions.x-golang-is-container}} +{{^vendorExtensions.x-golang-is-container}} + return *o.{{name}}.Get() +{{/vendorExtensions.x-golang-is-container}} +{{/isNullable}} +{{^isNullable}} + return o.{{name}} +{{/isNullable}} +} + +// Get{{name}}Ok returns a tuple with the {{name}} field value +// and a boolean to check if the value has been set. +{{#isNullable}} +// NOTE: If the value is an explicit nil, `nil, true` will be returned +{{/isNullable}} +{{#deprecated}} +// Deprecated +{{/deprecated}} +func (o *{{classname}}) Get{{name}}Ok() ({{^isArray}}{{^isFreeFormObject}}*{{/isFreeFormObject}}{{/isArray}}{{vendorExtensions.x-go-base-type}}, bool) { + if o == nil{{#isNullable}}{{#vendorExtensions.x-golang-is-container}} || IsNil(o.{{name}}){{/vendorExtensions.x-golang-is-container}}{{/isNullable}} { +{{^isFreeFormObject}} + return nil, false + {{/isFreeFormObject}} + {{#isFreeFormObject}} + return {{vendorExtensions.x-go-base-type}}{}, false + {{/isFreeFormObject}} + } +{{#isNullable}} +{{#vendorExtensions.x-golang-is-container}} + return {{^isArray}}{{^isFreeFormObject}}&{{/isFreeFormObject}}{{/isArray}}o.{{name}}, true +{{/vendorExtensions.x-golang-is-container}} +{{^vendorExtensions.x-golang-is-container}} + return o.{{name}}.Get(), o.{{name}}.IsSet() +{{/vendorExtensions.x-golang-is-container}} +{{/isNullable}} +{{^isNullable}} + return {{^isArray}}{{^isFreeFormObject}}&{{/isFreeFormObject}}{{/isArray}}o.{{name}}, true +{{/isNullable}} +} + +// Set{{name}} sets field value +{{#deprecated}} +// Deprecated +{{/deprecated}} +func (o *{{classname}}) Set{{name}}(v {{vendorExtensions.x-go-base-type}}) { +{{#isNullable}} +{{#vendorExtensions.x-golang-is-container}} + o.{{name}} = v +{{/vendorExtensions.x-golang-is-container}} +{{^vendorExtensions.x-golang-is-container}} + o.{{name}}.Set(&v) +{{/vendorExtensions.x-golang-is-container}} +{{/isNullable}} +{{^isNullable}} + o.{{name}} = v +{{/isNullable}} +} + +{{/required}} +{{^required}} +// Get{{name}} returns the {{name}} field value if set, zero value otherwise{{#isNullable}} (both if not set or set to explicit null){{/isNullable}}. +{{#deprecated}} +// Deprecated +{{/deprecated}} +func (o *{{classname}}) Get{{name}}() {{vendorExtensions.x-go-base-type}} { + if o == nil{{^isNullable}} || IsNil(o.{{name}}){{/isNullable}}{{#isNullable}}{{^vendorExtensions.x-golang-is-container}} || IsNil(o.{{name}}.Get()){{/vendorExtensions.x-golang-is-container}}{{/isNullable}} { + var ret {{vendorExtensions.x-go-base-type}} + return ret + } +{{#isNullable}} +{{#vendorExtensions.x-golang-is-container}} + return o.{{name}} +{{/vendorExtensions.x-golang-is-container}} +{{^vendorExtensions.x-golang-is-container}} + return *o.{{name}}.Get() +{{/vendorExtensions.x-golang-is-container}} +{{/isNullable}} +{{^isNullable}} + return {{^isArray}}{{^isFreeFormObject}}*{{/isFreeFormObject}}{{/isArray}}o.{{name}} +{{/isNullable}} +} + +// Get{{name}}Ok returns a tuple with the {{name}} field value if set, nil otherwise +// and a boolean to check if the value has been set. +{{#isNullable}} +// NOTE: If the value is an explicit nil, `nil, true` will be returned +{{/isNullable}} +{{#deprecated}} +// Deprecated +{{/deprecated}} +func (o *{{classname}}) Get{{name}}Ok() ({{^isArray}}{{^isFreeFormObject}}*{{/isFreeFormObject}}{{/isArray}}{{vendorExtensions.x-go-base-type}}, bool) { + if o == nil{{^isNullable}} || IsNil(o.{{name}}){{/isNullable}}{{#isNullable}}{{#vendorExtensions.x-golang-is-container}} || IsNil(o.{{name}}){{/vendorExtensions.x-golang-is-container}}{{/isNullable}} { + {{^isFreeFormObject}} + return nil, false + {{/isFreeFormObject}} + {{#isFreeFormObject}} + return {{vendorExtensions.x-go-base-type}}{}, false + {{/isFreeFormObject}} + } +{{#isNullable}} +{{#vendorExtensions.x-golang-is-container}} + return {{^isArray}}{{^isFreeFormObject}}&{{/isFreeFormObject}}{{/isArray}}o.{{name}}, true +{{/vendorExtensions.x-golang-is-container}} +{{^vendorExtensions.x-golang-is-container}} + return o.{{name}}.Get(), o.{{name}}.IsSet() +{{/vendorExtensions.x-golang-is-container}} +{{/isNullable}} +{{^isNullable}} + return o.{{name}}, true +{{/isNullable}} +} + +// Has{{name}} returns a boolean if a field has been set. +func (o *{{classname}}) Has{{name}}() bool { + if o != nil && {{^isNullable}}!IsNil(o.{{name}}){{/isNullable}}{{#isNullable}}{{#vendorExtensions.x-golang-is-container}}IsNil(o.{{name}}){{/vendorExtensions.x-golang-is-container}}{{^vendorExtensions.x-golang-is-container}}o.{{name}}.IsSet(){{/vendorExtensions.x-golang-is-container}}{{/isNullable}} { + return true + } + + return false +} + +// Set{{name}} gets a reference to the given {{dataType}} and assigns it to the {{name}} field. +{{#deprecated}} +// Deprecated +{{/deprecated}} +func (o *{{classname}}) Set{{name}}(v {{vendorExtensions.x-go-base-type}}) { +{{#isNullable}} +{{#vendorExtensions.x-golang-is-container}} + o.{{name}} = v +{{/vendorExtensions.x-golang-is-container}} +{{^vendorExtensions.x-golang-is-container}} + o.{{name}}.Set({{^isArray}}{{^isFreeFormObject}}&{{/isFreeFormObject}}{{/isArray}}v) +{{/vendorExtensions.x-golang-is-container}} +{{/isNullable}} +{{^isNullable}} + o.{{name}} = {{^isArray}}{{^isFreeFormObject}}&{{/isFreeFormObject}}{{/isArray}}v +{{/isNullable}} +} +{{#isNullable}} +{{^vendorExtensions.x-golang-is-container}} +// Set{{name}}Nil sets the value for {{name}} to be an explicit nil +func (o *{{classname}}) Set{{name}}Nil() { + o.{{name}}.Set(nil) +} + +// Unset{{name}} ensures that no value is present for {{name}}, not even an explicit nil +func (o *{{classname}}) Unset{{name}}() { + o.{{name}}.Unset() +} +{{/vendorExtensions.x-golang-is-container}} +{{/isNullable}} + +{{/required}} +{{/vars}} +{{#vendorExtensions.x-go-generate-marshal-json}} +func (o {{classname}}) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +{{/vendorExtensions.x-go-generate-marshal-json}} +func (o {{classname}}) ToMap() (map[string]interface{}, error) { + toSerialize := {{#isArray}}make([]interface{}, len(o.Items)){{/isArray}}{{^isArray}}map[string]interface{}{}{{/isArray}} + {{#parent}} + {{^isMap}} + {{^isArray}} + serialized{{parent}}, err{{parent}} := json.Marshal(o.{{parent}}) + if err{{parent}} != nil { + return map[string]interface{}{}, err{{parent}} + } + err{{parent}} = json.Unmarshal([]byte(serialized{{parent}}), &toSerialize) + if err{{parent}} != nil { + return map[string]interface{}{}, err{{parent}} + } + {{/isArray}} + {{/isMap}} + {{#isArray}} + for i, item := range o.Items { + toSerialize[i] = item + } + {{/isArray}} + {{/parent}} + {{#vars}} + {{! if argument is nullable, only serialize it if it is set}} + {{#isNullable}} + {{#vendorExtensions.x-golang-is-container}} + {{! support for container fields is not ideal at this point because of lack of Nullable* types}} + if o.{{name}} != nil { + toSerialize["{{{baseName}}}"] = o.{{name}} + } + {{/vendorExtensions.x-golang-is-container}} + {{^vendorExtensions.x-golang-is-container}} + {{#required}} + toSerialize["{{{baseName}}}"] = o.{{name}}.Get() + {{/required}} + {{^required}} + if o.{{name}}.IsSet() { + toSerialize["{{{baseName}}}"] = o.{{name}}.Get() + } + {{/required}} + {{/vendorExtensions.x-golang-is-container}} + {{/isNullable}} + {{! if argument is not nullable, don't set it if it is nil}} + {{^isNullable}} + {{#required}} + toSerialize["{{{baseName}}}"] = o.{{name}} + {{/required}} + {{^required}} + if !IsNil(o.{{name}}) { + toSerialize["{{{baseName}}}"] = o.{{name}} + } + {{/required}} + {{/isNullable}} + {{/vars}} + {{#isAdditionalPropertiesTrue}} + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + {{/isAdditionalPropertiesTrue}} + return toSerialize, nil +} + +{{#isAdditionalPropertiesTrue}} +func (o *{{{classname}}}) UnmarshalJSON(data []byte) (err error) { +{{/isAdditionalPropertiesTrue}} +{{^isAdditionalPropertiesTrue}} +{{#hasRequired}} +func (o *{{{classname}}}) UnmarshalJSON(data []byte) (err error) { +{{/hasRequired}} +{{/isAdditionalPropertiesTrue}} +{{#hasRequired}} + // This validates that all required properties are included in the JSON object + // by unmarshalling the object into a generic map with string keys and checking + // that every required field exists as a key in the generic map. + requiredProperties := []string{ +{{#requiredVars}} + "{{baseName}}", +{{/requiredVars}} + } + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err; + } + + for _, requiredProperty := range(requiredProperties) { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } + } + +{{/hasRequired}} +{{#isAdditionalPropertiesTrue}} +{{#parent}} +{{^isMap}} + type {{classname}}WithoutEmbeddedStruct struct { + {{#vars}} + {{^-first}} + {{/-first}} + {{#description}} + // {{{.}}} + {{/description}} + {{#deprecated}} + // Deprecated + {{/deprecated}} + {{name}} {{^required}}{{^isNullable}}{{^isArray}}{{^isFreeFormObject}}*{{/isFreeFormObject}}{{/isArray}}{{/isNullable}}{{/required}}{{{dataType}}} `json:"{{{baseName}}}{{^required}},omitempty{{/required}}"{{#withXml}} xml:"{{{baseName}}}{{#isXmlAttribute}},attr{{/isXmlAttribute}}"{{/withXml}}{{#vendorExtensions.x-go-custom-tag}} {{{.}}}{{/vendorExtensions.x-go-custom-tag}}` + {{/vars}} + } + + var{{{classname}}}WithoutEmbeddedStruct := {{{classname}}}WithoutEmbeddedStruct{} + + err = json.Unmarshal(data, &var{{{classname}}}WithoutEmbeddedStruct) + if err == nil { + var{{{classname}}} := _{{{classname}}}{} + {{#vars}} + var{{{classname}}}.{{{name}}} = var{{{classname}}}WithoutEmbeddedStruct.{{{name}}} + {{/vars}} + *o = {{{classname}}}(var{{{classname}}}) + } else { + return err + } + + var{{{classname}}} := _{{{classname}}}{} + + err = json.Unmarshal(data, &var{{{classname}}}) + if err == nil { + o.{{{parent}}} = var{{{classname}}}.{{{parent}}} + } else { + return err + } + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + {{#vars}} + delete(additionalProperties, "{{{baseName}}}") + {{/vars}} + + // remove fields from embedded structs + reflect{{{parent}}} := reflect.ValueOf(o.{{{parent}}}) + for i := 0; i < reflect{{{parent}}}.Type().NumField(); i++ { + t := reflect{{{parent}}}.Type().Field(i) + + if jsonTag := t.Tag.Get("json"); jsonTag != "" { + fieldName := "" + if commaIdx := strings.Index(jsonTag, ","); commaIdx > 0 { + fieldName = jsonTag[:commaIdx] + } else { + fieldName = jsonTag + } + if fieldName != "AdditionalProperties" { + delete(additionalProperties, fieldName) + } + } + } + + o.AdditionalProperties = additionalProperties + } + + return err +{{/isMap}} +{{#isMap}} + var{{{classname}}} := _{{{classname}}}{} + + err = json.Unmarshal(data, &var{{{classname}}}) + + if err != nil { + return err + } + + *o = {{{classname}}}(var{{{classname}}}) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + {{#vars}} + delete(additionalProperties, "{{{baseName}}}") + {{/vars}} + o.AdditionalProperties = additionalProperties + } + + return err +{{/isMap}} +{{/parent}} +{{^parent}} + var{{{classname}}} := _{{{classname}}}{} + + err = json.Unmarshal(data, &var{{{classname}}}) + + if err != nil { + return err + } + + *o = {{{classname}}}(var{{{classname}}}) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + {{#vars}} + delete(additionalProperties, "{{{baseName}}}") + {{/vars}} + o.AdditionalProperties = additionalProperties + } + + return err +{{/parent}} +{{/isAdditionalPropertiesTrue}} +{{#isAdditionalPropertiesTrue}} +} + +{{/isAdditionalPropertiesTrue}} +{{^isAdditionalPropertiesTrue}} +{{#hasRequired}} + var{{{classname}}} := _{{{classname}}}{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&var{{{classname}}}) + + if err != nil { + return err + } + + *o = {{{classname}}}(var{{{classname}}}) + + return err +} + +{{/hasRequired}} +{{/isAdditionalPropertiesTrue}} +{{#isArray}} +func (o *{{{classname}}}) UnmarshalJSON(data []byte) (err error) { + return json.Unmarshal(data, &o.Items) +} + +{{/isArray}} +{{>nullable_model}} diff --git a/sdk/templates/go/nullable_model.mustache b/sdk/templates/go/nullable_model.mustache new file mode 100644 index 00000000..7b60ce6d --- /dev/null +++ b/sdk/templates/go/nullable_model.mustache @@ -0,0 +1,35 @@ +type Nullable{{{classname}}} struct { + value {{^isArray}}{{^isFreeFormObject}}*{{/isFreeFormObject}}{{/isArray}}{{{classname}}} + isSet bool +} + +func (v Nullable{{classname}}) Get() {{^isArray}}{{^isFreeFormObject}}*{{/isFreeFormObject}}{{/isArray}}{{classname}} { + return v.value +} + +func (v *Nullable{{classname}}) Set(val {{^isArray}}{{^isFreeFormObject}}*{{/isFreeFormObject}}{{/isArray}}{{classname}}) { + v.value = val + v.isSet = true +} + +func (v Nullable{{classname}}) IsSet() bool { + return v.isSet +} + +func (v *Nullable{{classname}}) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullable{{classname}}(val {{^isArray}}{{^isFreeFormObject}}*{{/isFreeFormObject}}{{/isArray}}{{classname}}) *Nullable{{classname}} { + return &Nullable{{classname}}{value: val, isSet: true} +} + +func (v Nullable{{{classname}}}) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *Nullable{{{classname}}}) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/sdk/templates/go/openapi.mustache b/sdk/templates/go/openapi.mustache new file mode 100644 index 00000000..51ebafb0 --- /dev/null +++ b/sdk/templates/go/openapi.mustache @@ -0,0 +1 @@ +{{{openapi-yaml}}} \ No newline at end of file diff --git a/sdk/templates/go/partial_header.mustache b/sdk/templates/go/partial_header.mustache new file mode 100644 index 00000000..1ce82d55 --- /dev/null +++ b/sdk/templates/go/partial_header.mustache @@ -0,0 +1,19 @@ +// Copyright 2024, Pulumi Corporation. All rights reserved. +/* +{{#appName}} +{{{.}}} + +{{/appName}} +{{#appDescription}} +{{{.}}} + +{{/appDescription}} +{{#version}} +API version: {{{.}}} +{{/version}} +{{#infoEmail}} +Contact: {{{.}}} +{{/infoEmail}} +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/sdk/templates/go/response.mustache b/sdk/templates/go/response.mustache new file mode 100644 index 00000000..4691e8f4 --- /dev/null +++ b/sdk/templates/go/response.mustache @@ -0,0 +1,38 @@ +{{>partial_header}} +package {{packageName}} + +import ( + "net/http" +) + +// APIResponse stores the API response returned by the server. +type APIResponse struct { + *http.Response `json:"-"` + Message string `json:"message,omitempty"` + // Operation is the name of the OpenAPI operation. + Operation string `json:"operation,omitempty"` + // RequestURL is the request URL. This value is always available, even if the + // embedded *http.Response is nil. + RequestURL string `json:"url,omitempty"` + // Method is the HTTP method used for the request. This value is always + // available, even if the embedded *http.Response is nil. + Method string `json:"method,omitempty"` + // Payload holds the contents of the response body (which may be nil or empty). + // This is provided here as the raw response.Body() reader will have already + // been drained. + Payload []byte `json:"-"` +} + +// NewAPIResponse returns a new APIResponse object. +func NewAPIResponse(r *http.Response) *APIResponse { + + response := &APIResponse{Response: r} + return response +} + +// NewAPIResponseWithError returns a new APIResponse object with the provided error message. +func NewAPIResponseWithError(errorMessage string) *APIResponse { + + response := &APIResponse{Message: errorMessage} + return response +} diff --git a/sdk/templates/go/signing.mustache b/sdk/templates/go/signing.mustache new file mode 100644 index 00000000..57221be2 --- /dev/null +++ b/sdk/templates/go/signing.mustache @@ -0,0 +1,453 @@ +{{>partial_header}} +package {{packageName}} + +import ( + "bytes" + "context" + "crypto" + "crypto/ecdsa" + "crypto/ed25519" + "crypto/rand" + "crypto/rsa" + "crypto/x509" + "encoding/base64" + "encoding/pem" + "fmt" + "io" + "net/http" + "net/textproto" + "os" + "strings" + "time" +) + +const ( + // Constants for HTTP signature parameters. + // The '(request-target)' parameter concatenates the lowercased :method, an + // ASCII space, and the :path pseudo-headers. + HttpSignatureParameterRequestTarget string = "(request-target)" + // The '(created)' parameter expresses when the signature was + // created. The value MUST be a Unix timestamp integer value. + HttpSignatureParameterCreated string = "(created)" + // The '(expires)' parameter expresses when the signature ceases to + // be valid. The value MUST be a Unix timestamp integer value. + HttpSignatureParameterExpires string = "(expires)" +) + +const ( + // Constants for HTTP headers. + // The 'Host' header, as defined in RFC 2616, section 14.23. + HttpHeaderHost string = "Host" + // The 'Date' header. + HttpHeaderDate string = "Date" + // The digest header, as defined in RFC 3230, section 4.3.2. + HttpHeaderDigest string = "Digest" + // The HTTP Authorization header, as defined in RFC 7235, section 4.2. + HttpHeaderAuthorization string = "Authorization" +) + +const ( + // Specifies the Digital Signature Algorithm is derived from metadata + // associated with 'keyId'. Supported DSA algorithms are RSASSA-PKCS1-v1_5, + // RSASSA-PSS, and ECDSA. + // The hash is SHA-512. + // This is the default value. + HttpSigningSchemeHs2019 string = "hs2019" + // Use RSASSA-PKCS1-v1_5 with SHA-512 hash. Deprecated. + HttpSigningSchemeRsaSha512 string = "rsa-sha512" + // Use RSASSA-PKCS1-v1_5 with SHA-256 hash. Deprecated. + HttpSigningSchemeRsaSha256 string = "rsa-sha256" + + // RFC 8017 section 7.2 + // Calculate the message signature using RSASSA-PKCS1-V1_5-SIGN from RSA PKCS#1 v1.5. + // PKCSV1_5 is deterministic. The same message and key will produce an identical + // signature value each time. + HttpSigningAlgorithmRsaPKCS1v15 string = "RSASSA-PKCS1-v1_5" + // Calculate the message signature using probabilistic signature scheme RSASSA-PSS. + // PSS is randomized and will produce a different signature value each time. + HttpSigningAlgorithmRsaPSS string = "RSASSA-PSS" + + // HashAlgorithm Sha256 for generating hash + HttpHashAlgorithmSha256 string = "sha256" + + // HashAlgorithm Sha512 for generating hash + HttpHashAlgorithmSha512 string = "sha512" +) + +var supportedSigningSchemes = map[string]bool{ + HttpSigningSchemeHs2019: true, + HttpSigningSchemeRsaSha512: true, + HttpSigningSchemeRsaSha256: true, +} + + +// HttpSignatureAuth provides HTTP signature authentication to a request passed +// via context using ContextHttpSignatureAuth. +// An 'Authorization' header is calculated by creating a hash of select headers, +// and optionally the body of the HTTP request, then signing the hash value using +// a private key which is available to the client. +// +// SignedHeaders specifies the list of HTTP headers that are included when generating +// the message signature. +// The two special signature headers '(request-target)' and '(created)' SHOULD be +// included in SignedHeaders. +// The '(created)' header expresses when the signature was created. +// The '(request-target)' header is a concatenation of the lowercased :method, an +// ASCII space, and the :path pseudo-headers. +// +// For example, SignedHeaders can be set to: +// (request-target) (created) date host digest +// +// When SignedHeaders is not specified, the client defaults to a single value, '(created)', +// in the list of HTTP headers. +// When SignedHeaders contains the 'Digest' value, the client performs the following operations: +// 1. Calculate a digest of request body, as specified in RFC3230, section 4.3.2. +// 2. Set the 'Digest' header in the request body. +// 3. Include the 'Digest' header and value in the HTTP signature. +type HttpSignatureAuth struct { + KeyId string // A key identifier. + PrivateKeyPath string // The path to the private key. + PrivateKeyReader io.Reader // provide the APIKey using the types which implement io.Reader interface. + Passphrase string // The passphrase to decrypt the private key, if the key is encrypted. + SigningScheme string // The signature scheme, when signing HTTP requests. Supported value is 'hs2019'. + // The signature algorithm, when signing HTTP requests. + // Supported values are RSASSA-PKCS1-v1_5, RSASSA-PSS. + SigningAlgorithm string + HashAlgorithm string // supported values are sha256 and sha512. This also allows using sha256 with hs2019, which defaults to sha512. + SignedHeaders []string // A list of HTTP headers included when generating the signature for the message. + // SignatureMaxValidity specifies the maximum duration of the signature validity. + // The value is used to set the '(expires)' signature parameter in the HTTP request. + // '(expires)' is set to '(created)' plus the value of the SignatureMaxValidity field. + // To specify the '(expires)' signature parameter, set 'SignatureMaxValidity' and add '(expires)' to 'SignedHeaders'. + SignatureMaxValidity time.Duration + privateKey crypto.PrivateKey // The private key used to sign HTTP requests. +} + +// SetPrivateKey accepts a private key string and sets it. +func (h *HttpSignatureAuth) SetPrivateKey(privateKey string) error { + return h.parsePrivateKey([]byte(privateKey)) +} + +// ContextWithValue validates the HttpSignatureAuth configuration parameters and returns a context +// suitable for HTTP signature. An error is returned if the HttpSignatureAuth configuration parameters +// are invalid. +func (h *HttpSignatureAuth) ContextWithValue(ctx context.Context) (context.Context, error) { + if h.KeyId == "" { + return nil, fmt.Errorf("key ID must be specified") + } + if (len(h.PrivateKeyPath) == 0 && h.PrivateKeyReader == nil) && h.privateKey == nil { + return nil, fmt.Errorf("private key path must be specified") + } + if len(h.PrivateKeyPath) > 0 && h.PrivateKeyReader != nil{ + return nil, fmt.Errorf("Specify only one of PrivateKeyPath or PrivateKeyReader") + } + if _, ok := supportedSigningSchemes[h.SigningScheme]; !ok { + return nil, fmt.Errorf("invalid signing scheme: '%v'", h.SigningScheme) + } + m := make(map[string]bool) + for _, h := range h.SignedHeaders { + if strings.EqualFold(h, HttpHeaderAuthorization) { + return nil, fmt.Errorf("signed headers cannot include the 'Authorization' header") + } + m[h] = true + } + if len(m) != len(h.SignedHeaders) { + return nil, fmt.Errorf("list of signed headers cannot have duplicate names") + } + if h.SignatureMaxValidity < 0 { + return nil, fmt.Errorf("signature max validity must be a positive value") + } + if err := h.loadPrivateKey(); err != nil { + return nil, err + } + return context.WithValue(ctx, ContextHttpSignatureAuth, *h), nil +} + +// GetPublicKey returns the public key associated with this HTTP signature configuration. +func (h *HttpSignatureAuth) GetPublicKey() (crypto.PublicKey, error) { + if h.privateKey == nil { + if err := h.loadPrivateKey(); err != nil { + return nil, err + } + } + switch key := h.privateKey.(type) { + case *rsa.PrivateKey: + return key.Public(), nil + case *ecdsa.PrivateKey: + return key.Public(), nil + default: + // Do not change '%T' to anything else such as '%v'! + // The value of the private key must not be returned. + return nil, fmt.Errorf("unsupported key: %T", h.privateKey) + } +} + +// loadPrivateKey reads the private key from the file specified in the HttpSignatureAuth. +// The key is loaded only when privateKey is not already set. +func (h *HttpSignatureAuth) loadPrivateKey() (err error) { + if h.privateKey != nil { + return nil + } + var priv []byte + keyReader := h.PrivateKeyReader + if keyReader == nil { + var file *os.File + file, err = os.Open(h.PrivateKeyPath) + if err != nil { + return fmt.Errorf("cannot load private key '%s'. Error: %v", h.PrivateKeyPath, err) + } + keyReader = file + defer func() { + err = file.Close() + }() + } + priv, err = io.ReadAll(keyReader) + if err != nil{ + return err + } + return h.parsePrivateKey(priv) +} + +// parsePrivateKey decodes privateKey byte array to crypto.PrivateKey type. +func (h *HttpSignatureAuth) parsePrivateKey(priv []byte) error { + pemBlock, _ := pem.Decode(priv) + if pemBlock == nil { + // No PEM data has been found. + return fmt.Errorf("file '%s' does not contain PEM data", h.PrivateKeyPath) + } + var privKey []byte + var err error + if x509.IsEncryptedPEMBlock(pemBlock) { + // The PEM data is encrypted. + privKey, err = x509.DecryptPEMBlock(pemBlock, []byte(h.Passphrase)) + if err != nil { + // Failed to decrypt PEM block. Because of deficiencies in the encrypted-PEM format, + // it's not always possible to detect an incorrect password. + return err + } + } else { + privKey = pemBlock.Bytes + } + switch pemBlock.Type { + case "RSA PRIVATE KEY": + if h.privateKey, err = x509.ParsePKCS1PrivateKey(privKey); err != nil { + return err + } + case "EC PRIVATE KEY", "PRIVATE KEY": + // https://tools.ietf.org/html/rfc5915 section 4. + if h.privateKey, err = x509.ParsePKCS8PrivateKey(privKey); err != nil { + return err + } + default: + return fmt.Errorf("key '%s' is not supported", pemBlock.Type) + } + return nil +} + +// SignRequest signs the request using HTTP signature. +// See https://datatracker.ietf.org/doc/draft-cavage-http-signatures/ +// +// Do not add, remove or change headers that are included in the SignedHeaders +// after SignRequest has been invoked; this is because the header values are +// included in the signature. Any subsequent alteration will cause a signature +// verification failure. +// If there are multiple instances of the same header field, all +// header field values associated with the header field MUST be +// concatenated, separated by a ASCII comma and an ASCII space +// ', ', and used in the order in which they will appear in the +// transmitted HTTP message. +func SignRequest( + ctx context.Context, + r *http.Request, + auth HttpSignatureAuth) error { + + if auth.privateKey == nil { + return fmt.Errorf("private key is not set") + } + now := time.Now() + date := now.UTC().Format(http.TimeFormat) + // The 'created' field expresses when the signature was created. + // The value MUST be a Unix timestamp integer value. See 'HTTP signature' section 2.1.4. + created := now.Unix() + + var h crypto.Hash + var err error + var prefix string + var expiresUnix float64 + + if auth.SignatureMaxValidity < 0 { + return fmt.Errorf("signature validity must be a positive value") + } + if auth.SignatureMaxValidity > 0 { + e := now.Add(auth.SignatureMaxValidity) + expiresUnix = float64(e.Unix()) + float64(e.Nanosecond()) / float64(time.Second) + } + // Determine the cryptographic hash to be used for the signature and the body digest. + switch auth.SigningScheme { + case HttpSigningSchemeRsaSha512: + h = crypto.SHA512 + prefix = "SHA-512=" + case HttpSigningSchemeRsaSha256: + // This is deprecated and should no longer be used. + h = crypto.SHA256 + prefix = "SHA-256=" + case HttpSigningSchemeHs2019: + if auth.HashAlgorithm == HttpHashAlgorithmSha256 { + h = crypto.SHA256 + prefix = "SHA-256=" + } else { + h = crypto.SHA512 + prefix = "SHA-512=" + } + + default: + return fmt.Errorf("unsupported signature scheme: %v", auth.SigningScheme) + } + if !h.Available() { + return fmt.Errorf("hash '%v' is not available", h) + } + + // Build the "(request-target)" signature header. + var sb bytes.Buffer + fmt.Fprintf(&sb, "%s %s", strings.ToLower(r.Method), r.URL.EscapedPath()) + if r.URL.RawQuery != "" { + // The ":path" pseudo-header field includes the path and query parts + // of the target URI (the "path-absolute" production and optionally a + // '?' character followed by the "query" production (see Sections 3.3 + // and 3.4 of [RFC3986] + fmt.Fprintf(&sb, "?%s", r.URL.RawQuery) + } + requestTarget := sb.String() + sb.Reset() + + // Build the string to be signed. + signedHeaders := auth.SignedHeaders + if len(signedHeaders) == 0 { + signedHeaders = []string{HttpSignatureParameterCreated} + } + // Validate the list of signed headers has no duplicates. + m := make(map[string]bool) + for _, h := range signedHeaders { + m[h] = true + } + if len(m) != len(signedHeaders) { + return fmt.Errorf("list of signed headers must not have any duplicates") + } + hasCreatedParameter := false + hasExpiresParameter := false + for i, header := range signedHeaders { + header = strings.ToLower(header) + var value string + switch header { + case strings.ToLower(HttpHeaderAuthorization): + return fmt.Errorf("cannot include the 'Authorization' header as a signed header") + case HttpSignatureParameterRequestTarget: + value = requestTarget + case HttpSignatureParameterCreated: + value = fmt.Sprintf("%d", created) + hasCreatedParameter = true + case HttpSignatureParameterExpires: + if auth.SignatureMaxValidity.Nanoseconds() == 0 { + return fmt.Errorf("cannot set '(expires)' signature parameter. SignatureMaxValidity is not configured") + } + value = fmt.Sprintf("%.3f", expiresUnix) + hasExpiresParameter = true + case "date": + value = date + r.Header.Set(HttpHeaderDate, date) + case "digest": + // Calculate the digest of the HTTP request body. + // Calculate body digest per RFC 3230 section 4.3.2 + bodyHash := h.New() + if r.Body != nil { + // Make a copy of the body io.Reader so that we can read the body to calculate the hash, + // then one more time when marshaling the request. + var body io.Reader + body, err = r.GetBody() + if err != nil { + return err + } + if _, err = io.Copy(bodyHash, body); err != nil { + return err + } + } + d := bodyHash.Sum(nil) + value = prefix + base64.StdEncoding.EncodeToString(d) + r.Header.Set(HttpHeaderDigest, value) + case "host": + value = r.Host + r.Header.Set(HttpHeaderHost, r.Host) + default: + var ok bool + var v []string + canonicalHeader := textproto.CanonicalMIMEHeaderKey(header) + if v, ok = r.Header[canonicalHeader]; !ok { + // If a header specified in the headers parameter cannot be matched with + // a provided header in the message, the implementation MUST produce an error. + return fmt.Errorf("header '%s' does not exist in the request", canonicalHeader) + } + // If there are multiple instances of the same header field, all + // header field values associated with the header field MUST be + // concatenated, separated by a ASCII comma and an ASCII space + // `, `, and used in the order in which they will appear in the + // transmitted HTTP message. + value = strings.Join(v, ", ") + } + if i > 0 { + fmt.Fprintf(&sb, "\n") + } + fmt.Fprintf(&sb, "%s: %s", header, value) + } + if expiresUnix != 0 && !hasExpiresParameter { + return fmt.Errorf("signatureMaxValidity is specified, but '(expired)' parameter is not present") + } + msg := []byte(sb.String()) + msgHash := h.New() + if _, err = msgHash.Write(msg); err != nil { + return err + } + d := msgHash.Sum(nil) + + var signature []byte + switch key := auth.privateKey.(type) { + case *rsa.PrivateKey: + switch auth.SigningAlgorithm { + case HttpSigningAlgorithmRsaPKCS1v15: + signature, err = rsa.SignPKCS1v15(rand.Reader, key, h, d) + case "", HttpSigningAlgorithmRsaPSS: + signature, err = rsa.SignPSS(rand.Reader, key, h, d, nil) + default: + return fmt.Errorf("unsupported signing algorithm: '%s'", auth.SigningAlgorithm) + } + case *ecdsa.PrivateKey: + signature, err = key.Sign(rand.Reader, d, h) + case ed25519.PrivateKey: // requires go 1.13 + signature, err = key.Sign(rand.Reader, msg, crypto.Hash(0)) + default: + return fmt.Errorf("unsupported private key") + } + if err != nil { + return err + } + + sb.Reset() + for i, header := range signedHeaders { + if i > 0 { + sb.WriteRune(' ') + } + sb.WriteString(strings.ToLower(header)) + } + headers_list := sb.String() + sb.Reset() + fmt.Fprintf(&sb, `Signature keyId="%s",algorithm="%s",`, auth.KeyId, auth.SigningScheme) + if hasCreatedParameter { + fmt.Fprintf(&sb, "created=%d,", created) + } + if hasExpiresParameter { + fmt.Fprintf(&sb, "expires=%.3f,", expiresUnix) + } + fmt.Fprintf(&sb, `headers="%s",signature="%s"`, headers_list, base64.StdEncoding.EncodeToString(signature)) + authStr := sb.String() + r.Header.Set(HttpHeaderAuthorization, authStr) + return nil +} diff --git a/sdk/templates/go/utils.mustache b/sdk/templates/go/utils.mustache new file mode 100644 index 00000000..602eaf30 --- /dev/null +++ b/sdk/templates/go/utils.mustache @@ -0,0 +1,338 @@ +{{>partial_header}} +package {{packageName}} + +import ( + "encoding/json" + "reflect" + "time" +) + +// PtrBool is a helper routine that returns a pointer to given boolean value. +func PtrBool(v bool) *bool { return &v } + +// PtrInt is a helper routine that returns a pointer to given integer value. +func PtrInt(v int) *int { return &v } + +// PtrInt32 is a helper routine that returns a pointer to given integer value. +func PtrInt32(v int32) *int32 { return &v } + +// PtrInt64 is a helper routine that returns a pointer to given integer value. +func PtrInt64(v int64) *int64 { return &v } + +// PtrFloat32 is a helper routine that returns a pointer to given float value. +func PtrFloat32(v float32) *float32 { return &v } + +// PtrFloat64 is a helper routine that returns a pointer to given float value. +func PtrFloat64(v float64) *float64 { return &v } + +// PtrString is a helper routine that returns a pointer to given string value. +func PtrString(v string) *string { return &v } + +// PtrTime is helper routine that returns a pointer to given Time value. +func PtrTime(v time.Time) *time.Time { return &v } + +type NullableBool struct { + value *bool + isSet bool +} + +func (v NullableBool) Get() *bool { + return v.value +} + +func (v *NullableBool) Set(val *bool) { + v.value = val + v.isSet = true +} + +func (v NullableBool) IsSet() bool { + return v.isSet +} + +func (v *NullableBool) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableBool(val *bool) *NullableBool { + return &NullableBool{value: val, isSet: true} +} + +func (v NullableBool) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableBool) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableInt struct { + value *int + isSet bool +} + +func (v NullableInt) Get() *int { + return v.value +} + +func (v *NullableInt) Set(val *int) { + v.value = val + v.isSet = true +} + +func (v NullableInt) IsSet() bool { + return v.isSet +} + +func (v *NullableInt) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableInt(val *int) *NullableInt { + return &NullableInt{value: val, isSet: true} +} + +func (v NullableInt) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableInt) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableInt32 struct { + value *int32 + isSet bool +} + +func (v NullableInt32) Get() *int32 { + return v.value +} + +func (v *NullableInt32) Set(val *int32) { + v.value = val + v.isSet = true +} + +func (v NullableInt32) IsSet() bool { + return v.isSet +} + +func (v *NullableInt32) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableInt32(val *int32) *NullableInt32 { + return &NullableInt32{value: val, isSet: true} +} + +func (v NullableInt32) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableInt32) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableInt64 struct { + value *int64 + isSet bool +} + +func (v NullableInt64) Get() *int64 { + return v.value +} + +func (v *NullableInt64) Set(val *int64) { + v.value = val + v.isSet = true +} + +func (v NullableInt64) IsSet() bool { + return v.isSet +} + +func (v *NullableInt64) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableInt64(val *int64) *NullableInt64 { + return &NullableInt64{value: val, isSet: true} +} + +func (v NullableInt64) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableInt64) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableFloat32 struct { + value *float32 + isSet bool +} + +func (v NullableFloat32) Get() *float32 { + return v.value +} + +func (v *NullableFloat32) Set(val *float32) { + v.value = val + v.isSet = true +} + +func (v NullableFloat32) IsSet() bool { + return v.isSet +} + +func (v *NullableFloat32) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableFloat32(val *float32) *NullableFloat32 { + return &NullableFloat32{value: val, isSet: true} +} + +func (v NullableFloat32) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableFloat32) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableFloat64 struct { + value *float64 + isSet bool +} + +func (v NullableFloat64) Get() *float64 { + return v.value +} + +func (v *NullableFloat64) Set(val *float64) { + v.value = val + v.isSet = true +} + +func (v NullableFloat64) IsSet() bool { + return v.isSet +} + +func (v *NullableFloat64) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableFloat64(val *float64) *NullableFloat64 { + return &NullableFloat64{value: val, isSet: true} +} + +func (v NullableFloat64) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableFloat64) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableString struct { + value *string + isSet bool +} + +func (v NullableString) Get() *string { + return v.value +} + +func (v *NullableString) Set(val *string) { + v.value = val + v.isSet = true +} + +func (v NullableString) IsSet() bool { + return v.isSet +} + +func (v *NullableString) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableString(val *string) *NullableString { + return &NullableString{value: val, isSet: true} +} + +func (v NullableString) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableString) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableTime struct { + value *time.Time + isSet bool +} + +func (v NullableTime) Get() *time.Time { + return v.value +} + +func (v *NullableTime) Set(val *time.Time) { + v.value = val + v.isSet = true +} + +func (v NullableTime) IsSet() bool { + return v.isSet +} + +func (v *NullableTime) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableTime(val *time.Time) *NullableTime { + return &NullableTime{value: val, isSet: true} +} + +func (v NullableTime) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableTime) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +// IsNil checks if an input is nil +func IsNil(i interface{}) bool { + if i == nil { + return true + } + switch reflect.TypeOf(i).Kind() { + case reflect.Chan, reflect.Func, reflect.Map, reflect.Ptr, reflect.UnsafePointer, reflect.Interface, reflect.Slice: + return reflect.ValueOf(i).IsNil() + case reflect.Array: + return reflect.ValueOf(i).IsZero() + } + return false +} + +type MappedNullable interface { + ToMap() (map[string]interface{}, error) +} diff --git a/sdk/templates/openapitools.json b/sdk/templates/openapitools.json new file mode 100644 index 00000000..9841a49b --- /dev/null +++ b/sdk/templates/openapitools.json @@ -0,0 +1,7 @@ +{ + "$schema": "./node_modules/@openapitools/openapi-generator-cli/config.schema.json", + "spaces": 2, + "generator-cli": { + "version": "7.3.0" + } +} diff --git a/sdk/templates/typescript/README.mustache b/sdk/templates/typescript/README.mustache new file mode 100644 index 00000000..f37f214c --- /dev/null +++ b/sdk/templates/typescript/README.mustache @@ -0,0 +1,46 @@ +## {{npmName}}@{{npmVersion}} + +This generator creates TypeScript/JavaScript client that utilizes [axios](https://github.com/axios/axios). The generated Node module can be used in the following environments: + +Environment +* Node.js +* Webpack +* Browserify + +Language level +* ES5 - you must have a Promises/A+ library installed +* ES6 + +Module system +* CommonJS +* ES6 module system + +It can be used in both TypeScript and JavaScript. In TypeScript, the definition will be automatically resolved via `package.json`. ([Reference](https://www.typescriptlang.org/docs/handbook/declaration-files/consumption.html)) + +### Building + +To build and compile the typescript sources to javascript use: +``` +npm install +npm run build +``` + +### Publishing + +First build the package then run `npm publish` + +### Consuming + +navigate to the folder of your consuming project and run one of the following commands. + +_published:_ + +``` +npm install {{npmName}}@{{npmVersion}} --save +``` + +_unPublished (not recommended):_ + +``` +npm install PATH_TO_GENERATED_PACKAGE --save +``` diff --git a/sdk/templates/typescript/api.mustache b/sdk/templates/typescript/api.mustache new file mode 100644 index 00000000..a6a13e31 --- /dev/null +++ b/sdk/templates/typescript/api.mustache @@ -0,0 +1,33 @@ +/* tslint:disable */ +/* eslint-disable */ +{{>licenseInfo}} + +{{^withSeparateModelsAndApi}} +import type { Configuration } from './configuration'; +import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios'; +import globalAxios from 'axios'; +{{#withNodeImports}} +// URLSearchParams not necessarily used +// @ts-ignore +import { URL, URLSearchParams } from 'url'; +{{#multipartFormData}} +import FormData from 'form-data' +{{/multipartFormData}} +{{/withNodeImports}} +// Some imports not used depending on template conditions +// @ts-ignore +import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from './common'; +import type { RequestArgs } from './base'; +// @ts-ignore +import { BASE_PATH, COLLECTION_FORMATS, BaseAPI, RequiredError, operationServerMap } from './base'; + +{{#models}} +{{#model}}{{#isEnum}}{{>modelEnum}}{{/isEnum}}{{#oneOf}}{{#-first}}{{>modelOneOf}}{{/-first}}{{/oneOf}}{{^isEnum}}{{^oneOf}}{{>modelGeneric}}{{/oneOf}}{{/isEnum}}{{/model}} +{{/models}} +{{#apiInfo}}{{#apis}} +{{>apiInner}} +{{/apis}}{{/apiInfo}} +{{/withSeparateModelsAndApi}}{{#withSeparateModelsAndApi}} +{{#apiInfo}}{{#apis}}{{#operations}}export * from './{{tsApiPackage}}/{{classFilename}}'; +{{/operations}}{{/apis}}{{/apiInfo}} +{{/withSeparateModelsAndApi}} diff --git a/sdk/templates/typescript/apiInner.mustache b/sdk/templates/typescript/apiInner.mustache new file mode 100644 index 00000000..ae167c91 --- /dev/null +++ b/sdk/templates/typescript/apiInner.mustache @@ -0,0 +1,452 @@ +{{#withSeparateModelsAndApi}} +/* tslint:disable */ +/* eslint-disable */ +{{>licenseInfo}} + +import type { Configuration } from '{{apiRelativeToRoot}}configuration'; +import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios'; +import globalAxios from 'axios'; +{{#withNodeImports}} +// URLSearchParams not necessarily used +// @ts-ignore +import { URL, URLSearchParams } from 'url'; +{{#multipartFormData}} +import FormData from 'form-data' +{{/multipartFormData}} +{{/withNodeImports}} +// Some imports not used depending on template conditions +// @ts-ignore +import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from '{{apiRelativeToRoot}}common'; +// @ts-ignore +import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError, operationServerMap } from '{{apiRelativeToRoot}}base'; +{{#imports}} +// @ts-ignore +import { {{classname}} } from '{{apiRelativeToRoot}}{{tsModelPackage}}'; +{{/imports}} +{{/withSeparateModelsAndApi}} +{{^withSeparateModelsAndApi}} +{{/withSeparateModelsAndApi}} +{{#operations}} +/** + * {{classname}} - axios parameter creator{{#description}} + * {{&description}}{{/description}} + * @export + */ +export const {{classname}}AxiosParamCreator = function (configuration?: Configuration) { + return { + {{#operation}} + /** + * {{¬es}} + {{#summary}} + * @summary {{&summary}} + {{/summary}} + {{#allParams}} + * @param {{=<% %>=}}{<%#isEnum%><%&datatypeWithEnum%><%/isEnum%><%^isEnum%><%&dataType%><%#isNullable%> | null<%/isNullable%><%/isEnum%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}} + {{/allParams}} + * @param {*} [options] Override http request option.{{#isDeprecated}} + * @deprecated{{/isDeprecated}} + * @throws {RequiredError} + */ + {{nickname}}: async ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}}, {{/allParams}}options: RawAxiosRequestConfig = {}): Promise => { + {{#allParams}} + {{#required}} + // verify required parameter '{{paramName}}' is not null or undefined + assertParamExists('{{nickname}}', '{{paramName}}', {{paramName}}) + {{/required}} + {{/allParams}} + const localVarPath = `{{{path}}}`{{#pathParams}} + .replace(`{${"{{baseName}}"}}`, encodeURIComponent(String({{paramName}}))){{/pathParams}}; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: '{{httpMethod}}', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any;{{#vendorExtensions}}{{#hasFormParams}} + const localVarFormParams = new {{^multipartFormData}}URLSearchParams(){{/multipartFormData}}{{#multipartFormData}}((configuration && configuration.formDataCtor) || FormData)(){{/multipartFormData}};{{/hasFormParams}}{{/vendorExtensions}} + + {{#authMethods}} + // authentication {{name}} required + {{#isApiKey}} + {{#isKeyInHeader}} + await setApiKeyToObject(localVarHeaderParameter, "{{keyParamName}}", configuration) + {{/isKeyInHeader}} + {{#isKeyInQuery}} + await setApiKeyToObject(localVarQueryParameter, "{{keyParamName}}", configuration) + {{/isKeyInQuery}} + {{/isApiKey}} + {{#isBasicBasic}} + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration) + {{/isBasicBasic}} + {{#isBasicBearer}} + // http bearer authentication required + await setBearerAuthToObject(localVarHeaderParameter, configuration) + {{/isBasicBearer}} + {{#isOAuth}} + // oauth required + await setOAuthToObject(localVarHeaderParameter, "{{name}}", [{{#scopes}}"{{{scope}}}"{{^-last}}, {{/-last}}{{/scopes}}], configuration) + {{/isOAuth}} + + {{/authMethods}} + {{#queryParams}} + {{#isArray}} + if ({{paramName}}) { + {{#isCollectionFormatMulti}} + {{#uniqueItems}} + localVarQueryParameter['{{baseName}}'] = Array.from({{paramName}}); + {{/uniqueItems}} + {{^uniqueItems}} + localVarQueryParameter['{{baseName}}'] = {{paramName}}; + {{/uniqueItems}} + {{/isCollectionFormatMulti}} + {{^isCollectionFormatMulti}} + {{#uniqueItems}} + localVarQueryParameter['{{baseName}}'] = Array.from({{paramName}}).join(COLLECTION_FORMATS.{{collectionFormat}}); + {{/uniqueItems}} + {{^uniqueItems}} + localVarQueryParameter['{{baseName}}'] = {{paramName}}.join(COLLECTION_FORMATS.{{collectionFormat}}); + {{/uniqueItems}} + {{/isCollectionFormatMulti}} + } + {{/isArray}} + {{^isArray}} + if ({{paramName}} !== undefined) { + {{#isDateTime}} + localVarQueryParameter['{{baseName}}'] = ({{paramName}} as any instanceof Date) ? + ({{paramName}} as any).toISOString() : + {{paramName}}; + {{/isDateTime}} + {{^isDateTime}} + {{#isDate}} + localVarQueryParameter['{{baseName}}'] = ({{paramName}} as any instanceof Date) ? + ({{paramName}} as any).toISOString().substring(0,10) : + {{paramName}}; + {{/isDate}} + {{^isDate}} + {{#isExplode}} + {{#isPrimitiveType}} + localVarQueryParameter['{{baseName}}'] = {{paramName}}; + {{/isPrimitiveType}} + {{^isPrimitiveType}} + {{^isEnumRef}} + {{^isEnum}} + for (const [key, value] of Object.entries({{paramName}})) { + localVarQueryParameter[key] = value; + } + {{/isEnum}} + {{/isEnumRef}} + {{#isEnum}} + localVarQueryParameter['{{baseName}}'] = {{paramName}}; + {{/isEnum}} + {{#isEnumRef}} + localVarQueryParameter['{{baseName}}'] = {{paramName}}; + {{/isEnumRef}} + {{/isPrimitiveType}} + {{/isExplode}} + {{^isExplode}} + localVarQueryParameter['{{baseName}}'] = {{paramName}}; + {{/isExplode}} + {{/isDate}} + {{/isDateTime}} + } + {{/isArray}} + + {{/queryParams}} + {{#headerParams}} + {{#isArray}} + if ({{paramName}}) { + {{#uniqueItems}} + let mapped = Array.from({{paramName}}).map(value => ("{{{dataType}}}" !== "Set") ? JSON.stringify(value) : (value || "")); + {{/uniqueItems}} + {{^uniqueItems}} + let mapped = {{paramName}}.map(value => ("{{{dataType}}}" !== "Array") ? JSON.stringify(value) : (value || "")); + {{/uniqueItems}} + localVarHeaderParameter['{{baseName}}'] = mapped.join(COLLECTION_FORMATS["{{collectionFormat}}"]); + } + {{/isArray}} + {{^isArray}} + {{! `val == null` covers for both `null` and `undefined`}} + if ({{paramName}} != null) { + {{#isString}} + localVarHeaderParameter['{{baseName}}'] = String({{paramName}}); + {{/isString}} + {{^isString}} + {{! isString is falsy also for $ref that defines a string or enum type}} + localVarHeaderParameter['{{baseName}}'] = typeof {{paramName}} === 'string' + ? {{paramName}} + : JSON.stringify({{paramName}}); + {{/isString}} + } + {{/isArray}} + + {{/headerParams}} + {{#vendorExtensions}} + {{#formParams}} + {{#isArray}} + if ({{paramName}}) { + {{#isCollectionFormatMulti}} + {{paramName}}.forEach((element) => { + localVarFormParams.{{#multipartFormData}}append{{/multipartFormData}}{{^multipartFormData}}set{{/multipartFormData}}('{{baseName}}', element as any); + }) + {{/isCollectionFormatMulti}} + {{^isCollectionFormatMulti}} + localVarFormParams.{{#multipartFormData}}append{{/multipartFormData}}{{^multipartFormData}}set{{/multipartFormData}}('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS.{{collectionFormat}})); + {{/isCollectionFormatMulti}} + }{{/isArray}} + {{^isArray}} + if ({{paramName}} !== undefined) { {{^multipartFormData}} + localVarFormParams.set('{{baseName}}', {{paramName}} as any);{{/multipartFormData}}{{#multipartFormData}}{{#isPrimitiveType}} + localVarFormParams.append('{{baseName}}', {{paramName}} as any);{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isEnumRef}} + localVarFormParams.append('{{baseName}}', {{paramName}} as any);{{/isEnumRef}}{{^isEnumRef}} + localVarFormParams.append('{{baseName}}', new Blob([JSON.stringify({{paramName}})], { type: "application/json", }));{{/isEnumRef}}{{/isPrimitiveType}}{{/multipartFormData}} + }{{/isArray}} + {{/formParams}}{{/vendorExtensions}} + {{#vendorExtensions}}{{#hasFormParams}}{{^multipartFormData}} + localVarHeaderParameter['Content-Type'] = 'application/x-www-form-urlencoded';{{/multipartFormData}}{{#multipartFormData}} + localVarHeaderParameter['Content-Type'] = 'multipart/form-data';{{/multipartFormData}} + {{/hasFormParams}}{{/vendorExtensions}} + {{#bodyParam}} + {{^consumes}} + localVarHeaderParameter['Content-Type'] = 'application/json'; + {{/consumes}} + {{#consumes.0}} + localVarHeaderParameter['Content-Type'] = '{{{mediaType}}}'; + {{/consumes.0}} + + {{/bodyParam}} + setSearchParams(localVarUrlObj, localVarQueryParameter); + localVarHeaderParameter['X-Pulumi-Source'] = 'esc-sdk' + localVarHeaderParameter['User-Agent'] = '{{userAgent}}' + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions,{{#hasFormParams}}{{#multipartFormData}} ...(localVarFormParams as any).getHeaders?.(),{{/multipartFormData}}{{/hasFormParams}} ...options.headers}; + {{#hasFormParams}} + localVarRequestOptions.data = localVarFormParams{{#vendorExtensions}}{{^multipartFormData}}.toString(){{/multipartFormData}}{{/vendorExtensions}}; + {{/hasFormParams}} + {{#bodyParam}} + localVarRequestOptions.data = serializeDataIfNeeded({{paramName}}, localVarRequestOptions, configuration) + {{/bodyParam}} + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + {{/operation}} + } +}; + +/** + * {{classname}} - functional programming interface{{#description}} + * {{{.}}}{{/description}} + * @export + */ +export const {{classname}}Fp = function(configuration?: Configuration) { + const localVarAxiosParamCreator = {{classname}}AxiosParamCreator(configuration) + return { + {{#operation}} + /** + * {{¬es}} + {{#summary}} + * @summary {{&summary}} + {{/summary}} + {{#allParams}} + * @param {{=<% %>=}}{<%#isEnum%><%&datatypeWithEnum%><%/isEnum%><%^isEnum%><%&dataType%><%#isNullable%> | null<%/isNullable%><%/isEnum%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}} + {{/allParams}} + * @param {*} [options] Override http request option.{{#isDeprecated}} + * @deprecated{{/isDeprecated}} + * @throws {RequiredError} + */ + async {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}}, {{/allParams}}options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<{{{returnType}}}{{^returnType}}void{{/returnType}}>> { + const localVarAxiosArgs = await localVarAxiosParamCreator.{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['{{classname}}.{{nickname}}']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + {{/operation}} + } +}; + +/** + * {{classname}} - factory interface{{#description}} + * {{&description}}{{/description}} + * @export + */ +export const {{classname}}Factory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { + const localVarFp = {{classname}}Fp(configuration) + return { + {{#operation}} + /** + * {{¬es}} + {{#summary}} + * @summary {{&summary}} + {{/summary}} + {{#useSingleRequestParameter}} + {{#allParams.0}} + * @param {{=<% %>=}}{<%& classname %><%& operationIdCamelCase %>Request}<%={{ }}=%> requestParameters Request parameters. + {{/allParams.0}} + {{/useSingleRequestParameter}} + {{^useSingleRequestParameter}} + {{#allParams}} + * @param {{=<% %>=}}{<%#isEnum%><%&datatypeWithEnum%><%/isEnum%><%^isEnum%><%&dataType%><%#isNullable%> | null<%/isNullable%><%/isEnum%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}} + {{/allParams}} + {{/useSingleRequestParameter}} + * @param {*} [options] Override http request option.{{#isDeprecated}} + * @deprecated{{/isDeprecated}} + * @throws {RequiredError} + */ + {{#useSingleRequestParameter}} + {{nickname}}({{#allParams.0}}requestParameters: {{classname}}{{operationIdCamelCase}}Request{{^hasRequiredParams}} = {}{{/hasRequiredParams}}, {{/allParams.0}}options?: RawAxiosRequestConfig): AxiosPromise<{{{returnType}}}{{^returnType}}void{{/returnType}}> { + return localVarFp.{{nickname}}({{#allParams.0}}{{#allParams}}requestParameters.{{paramName}}, {{/allParams}}{{/allParams.0}}options).then((request) => request(axios, basePath)); + }, + {{/useSingleRequestParameter}} + {{^useSingleRequestParameter}} + {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}}, {{/allParams}}options?: any): AxiosPromise<{{{returnType}}}{{^returnType}}void{{/returnType}}> { + return localVarFp.{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options).then((request) => request(axios, basePath)); + }, + {{/useSingleRequestParameter}} + {{/operation}} + }; +}; + +{{#withInterfaces}} +/** + * {{classname}} - interface{{#description}} + * {{&description}}{{/description}} + * @export + * @interface {{classname}} + */ +export interface {{classname}}Interface { +{{#operation}} + /** + * {{¬es}} + {{#summary}} + * @summary {{&summary}} + {{/summary}} + {{#allParams}} + * @param {{=<% %>=}}{<%#isEnum%><%&datatypeWithEnum%><%/isEnum%><%^isEnum%><%&dataType%><%#isNullable%> | null<%/isNullable%><%/isEnum%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}} + {{/allParams}} + * @param {*} [options] Override http request option.{{#isDeprecated}} + * @deprecated{{/isDeprecated}} + * @throws {RequiredError} + * @memberof {{classname}}Interface + */ + {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}}, {{/allParams}}options?: RawAxiosRequestConfig): AxiosPromise<{{{returnType}}}{{^returnType}}void{{/returnType}}>; + +{{/operation}} +} + +{{/withInterfaces}} +{{#useSingleRequestParameter}} +{{#operation}} +{{#allParams.0}} +/** + * Request parameters for {{nickname}} operation in {{classname}}. + * @export + * @interface {{classname}}{{operationIdCamelCase}}Request + */ +export interface {{classname}}{{operationIdCamelCase}}Request { + {{#allParams}} + /** + * {{description}} + * @type {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> + * @memberof {{classname}}{{operationIdCamelCase}} + */ + readonly {{paramName}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}} + {{^-last}} + + {{/-last}} + {{/allParams}} +} + +{{/allParams.0}} +{{/operation}} +{{/useSingleRequestParameter}} +/** + * {{classname}} - object-oriented interface{{#description}} + * {{{.}}}{{/description}} + * @export + * @class {{classname}} + * @extends {BaseAPI} + */ +{{#withInterfaces}} +export class {{classname}} extends BaseAPI implements {{classname}}Interface { +{{/withInterfaces}} +{{^withInterfaces}} +export class {{classname}} extends BaseAPI { +{{/withInterfaces}} + {{#operation}} + /** + * {{¬es}} + {{#summary}} + * @summary {{&summary}} + {{/summary}} + {{#useSingleRequestParameter}} + {{#allParams.0}} + * @param {{=<% %>=}}{<%& classname %><%& operationIdCamelCase %>Request}<%={{ }}=%> requestParameters Request parameters. + {{/allParams.0}} + {{/useSingleRequestParameter}} + {{^useSingleRequestParameter}} + {{#allParams}} + * @param {{=<% %>=}}{<%#isEnum%><%&datatypeWithEnum%><%/isEnum%><%^isEnum%><%&dataType%><%#isNullable%> | null<%/isNullable%><%/isEnum%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}} + {{/allParams}} + {{/useSingleRequestParameter}} + * @param {*} [options] Override http request option.{{#isDeprecated}} + * @deprecated{{/isDeprecated}} + * @throws {RequiredError} + * @memberof {{classname}} + */ + {{#useSingleRequestParameter}} + public {{nickname}}({{#allParams.0}}requestParameters: {{classname}}{{operationIdCamelCase}}Request{{^hasRequiredParams}} = {}{{/hasRequiredParams}}, {{/allParams.0}}options?: RawAxiosRequestConfig) { + return {{classname}}Fp(this.configuration).{{nickname}}({{#allParams.0}}{{#allParams}}requestParameters.{{paramName}}, {{/allParams}}{{/allParams.0}}options).then((request) => request(this.axios, this.basePath)); + } + {{/useSingleRequestParameter}} + {{^useSingleRequestParameter}} + public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}}, {{/allParams}}options?: RawAxiosRequestConfig) { + return {{classname}}Fp(this.configuration).{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options).then((request) => request(this.axios, this.basePath)); + } + {{/useSingleRequestParameter}} + {{^-last}} + + {{/-last}} + {{/operation}} +} +{{/operations}} + +{{#operations}} +{{#operation}} +{{#allParams}} +{{#isEnum}} +{{#stringEnums}} +/** + * @export + * @enum {string} + */ +export enum {{operationIdCamelCase}}{{enumName}} { +{{#allowableValues}} + {{#enumVars}} + {{{name}}} = {{{value}}}{{^-last}},{{/-last}} + {{/enumVars}} +{{/allowableValues}} +} +{{/stringEnums}} +{{^stringEnums}} +/** + * @export + */ +export const {{operationIdCamelCase}}{{enumName}} = { +{{#allowableValues}} + {{#enumVars}} + {{{name}}}: {{{value}}}{{^-last}},{{/-last}} + {{/enumVars}} +{{/allowableValues}} +} as const; +export type {{operationIdCamelCase}}{{enumName}} = typeof {{operationIdCamelCase}}{{enumName}}[keyof typeof {{operationIdCamelCase}}{{enumName}}]; +{{/stringEnums}} +{{/isEnum}} +{{/allParams}} +{{/operation}} +{{/operations}} diff --git a/sdk/templates/typescript/baseApi.mustache b/sdk/templates/typescript/baseApi.mustache new file mode 100644 index 00000000..d14b428f --- /dev/null +++ b/sdk/templates/typescript/baseApi.mustache @@ -0,0 +1,116 @@ +/* tslint:disable */ +/* eslint-disable */ +{{>licenseInfo}} + +import type { Configuration } from './configuration'; +// Some imports not used depending on template conditions +// @ts-ignore +import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios'; +import globalAxios from 'axios'; + +export const BASE_PATH = "{{{basePath}}}".replace(/\/+$/, ""); + +/** + * + * @export + */ +export const COLLECTION_FORMATS = { + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|", +}; + +/** + * + * @export + * @interface RequestArgs + */ +export interface RequestArgs { + url: string; + options: RawAxiosRequestConfig; +} + +/** + * + * @export + * @class BaseAPI + */ +export class BaseAPI { + protected configuration: Configuration | undefined; + + constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) { + if (configuration) { + this.configuration = configuration; + this.basePath = configuration.basePath ?? basePath; + } + } +}; + +/** + * + * @export + * @class RequiredError + * @extends {Error} + */ +export class RequiredError extends Error { + constructor(public field: string, msg?: string) { + super(msg); + this.name = "RequiredError" + } +} + +interface ServerMap { + [key: string]: { + url: string, + description: string, + }[]; +} + +/** + * + * @export + */ +export const operationServerMap: ServerMap = { + {{#apiInfo}} + {{#apis}} + {{#operations}} + {{#operation}} + {{#servers}} + {{#-first}} + "{{{classname}}}.{{{nickname}}}": [ + {{/-first}} + { + url: "{{{url}}}", + description: "{{{description}}}{{^description}}No description provided{{/description}}", + {{#variables}} + {{#-first}} + variables: { + {{/-first}} + {{{name}}}: { + description: "{{{description}}}{{^description}}No description provided{{/description}}", + default_value: "{{{defaultValue}}}", + {{#enumValues}} + {{#-first}} + enum_values: [ + {{/-first}} + "{{{.}}}"{{^-last}},{{/-last}} + {{#-last}} + ] + {{/-last}} + {{/enumValues}} + }{{^-last}},{{/-last}} + {{#-last}} + } + {{/-last}} + {{/variables}} + }{{^-last}},{{/-last}} + {{#-last}} + ], + {{/-last}} + {{/servers}} + {{/operation}} + {{/operations}} + {{/apis}} + {{/apiInfo}} +} diff --git a/sdk/templates/typescript/common.mustache b/sdk/templates/typescript/common.mustache new file mode 100644 index 00000000..aa594015 --- /dev/null +++ b/sdk/templates/typescript/common.mustache @@ -0,0 +1,142 @@ +/* tslint:disable */ +/* eslint-disable */ +{{>licenseInfo}} + +import type { Configuration } from "./configuration"; +import type { RequestArgs } from "./base"; +import type { AxiosInstance, AxiosResponse } from 'axios'; +import { RequiredError } from "./base"; +{{#withNodeImports}} +import { URL, URLSearchParams } from 'url'; +{{/withNodeImports}} + +/** + * + * @export + */ +export const DUMMY_BASE_URL = 'https://example.com' + +/** + * + * @throws {RequiredError} + * @export + */ +export const assertParamExists = function (functionName: string, paramName: string, paramValue: unknown) { + if (paramValue === null || paramValue === undefined) { + throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`); + } +} + +/** + * + * @export + */ +export const setApiKeyToObject = async function (object: any, keyParamName: string, configuration?: Configuration) { + if (configuration && configuration.apiKey) { + const localVarApiKeyValue = typeof configuration.apiKey === 'function' + ? await configuration.apiKey(keyParamName) + : await configuration.apiKey; + object[keyParamName] = localVarApiKeyValue; + } +} + +/** + * + * @export + */ +export const setBasicAuthToObject = function (object: any, configuration?: Configuration) { + if (configuration && (configuration.username || configuration.password)) { + object["auth"] = { username: configuration.username, password: configuration.password }; + } +} + +/** + * + * @export + */ +export const setBearerAuthToObject = async function (object: any, configuration?: Configuration) { + if (configuration && configuration.accessToken) { + const accessToken = typeof configuration.accessToken === 'function' + ? await configuration.accessToken() + : await configuration.accessToken; + object["Authorization"] = "Bearer " + accessToken; + } +} + +/** + * + * @export + */ +export const setOAuthToObject = async function (object: any, name: string, scopes: string[], configuration?: Configuration) { + if (configuration && configuration.accessToken) { + const localVarAccessTokenValue = typeof configuration.accessToken === 'function' + ? await configuration.accessToken(name, scopes) + : await configuration.accessToken; + object["Authorization"] = "Bearer " + localVarAccessTokenValue; + } +} + +function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void { + if (parameter == null) return; + if (typeof parameter === "object") { + if (Array.isArray(parameter)) { + (parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key)); + } + else { + Object.keys(parameter).forEach(currentKey => + setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== '' ? '.' : ''}${currentKey}`) + ); + } + } + else { + if (urlSearchParams.has(key)) { + urlSearchParams.append(key, parameter); + } + else { + urlSearchParams.set(key, parameter); + } + } +} + +/** + * + * @export + */ +export const setSearchParams = function (url: URL, ...objects: any[]) { + const searchParams = new URLSearchParams(url.search); + setFlattenedQueryParams(searchParams, objects); + url.search = searchParams.toString(); +} + +/** + * + * @export + */ +export const serializeDataIfNeeded = function (value: any, requestOptions: any, configuration?: Configuration) { + const nonString = typeof value !== 'string'; + const needsSerialization = nonString && configuration && configuration.isJsonMime + ? configuration.isJsonMime(requestOptions.headers['Content-Type']) + : nonString; + return needsSerialization + ? JSON.stringify(value !== undefined ? value : {}) + : (value || ""); +} + +/** + * + * @export + */ +export const toPathString = function (url: URL) { + return url.pathname + url.search + url.hash +} + +/** + * + * @export + */ +export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) { + return >(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { + const axiosRequestArgs = {...axiosArgs.options, url: (axios.defaults.baseURL ? '' : configuration?.basePath ?? basePath) + axiosArgs.url}; + return axios.request(axiosRequestArgs); + }; +} diff --git a/sdk/templates/typescript/configuration.mustache b/sdk/templates/typescript/configuration.mustache new file mode 100644 index 00000000..836f1275 --- /dev/null +++ b/sdk/templates/typescript/configuration.mustache @@ -0,0 +1,99 @@ +/* tslint:disable */ +/* eslint-disable */ +{{>licenseInfo}} + +export interface ConfigurationParameters { + apiKey?: string | Promise | ((name: string) => string) | ((name: string) => Promise); + username?: string; + password?: string; + accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise); + basePath?: string; + serverIndex?: number; + baseOptions?: any; + formDataCtor?: new () => any; +} + +export class Configuration { + /** + * parameter for apiKey security + * @param name security name + * @memberof Configuration + */ + apiKey?: string | Promise | ((name: string) => string) | ((name: string) => Promise); + /** + * parameter for basic security + * + * @type {string} + * @memberof Configuration + */ + username?: string; + /** + * parameter for basic security + * + * @type {string} + * @memberof Configuration + */ + password?: string; + /** + * parameter for oauth2 security + * @param name security name + * @param scopes oauth2 scope + * @memberof Configuration + */ + accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise); + /** + * override base path + * + * @type {string} + * @memberof Configuration + */ + basePath?: string; + /** + * override server index + * + * @type {number} + * @memberof Configuration + */ + serverIndex?: number; + /** + * base options for axios calls + * + * @type {any} + * @memberof Configuration + */ + baseOptions?: any; + /** + * The FormData constructor that will be used to create multipart form data + * requests. You can inject this here so that execution environments that + * do not support the FormData class can still run the generated client. + * + * @type {new () => FormData} + */ + formDataCtor?: new () => any; + + constructor(param: ConfigurationParameters = {}) { + this.apiKey = param.apiKey; + this.username = param.username; + this.password = param.password; + this.accessToken = param.accessToken; + this.basePath = param.basePath; + this.serverIndex = param.serverIndex; + this.baseOptions = param.baseOptions; + this.formDataCtor = param.formDataCtor; + } + + /** + * Check if the given MIME is a JSON MIME. + * JSON MIME examples: + * application/json + * application/json; charset=UTF8 + * APPLICATION/JSON + * application/vnd.company+json + * @param mime - MIME (Multipurpose Internet Mail Extensions) + * @return True if the given MIME is JSON, false otherwise. + */ + public isJsonMime(mime: string): boolean { + const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i'); + return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json'); + } +} diff --git a/sdk/templates/typescript/git_push.sh.mustache b/sdk/templates/typescript/git_push.sh.mustache new file mode 100644 index 00000000..0e3776ae --- /dev/null +++ b/sdk/templates/typescript/git_push.sh.mustache @@ -0,0 +1,57 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="{{{gitHost}}}" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi + +if [ "$git_user_id" = "" ]; then + git_user_id="{{{gitUserId}}}" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="{{{gitRepoId}}}" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="{{{releaseNote}}}" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=$(git remote) +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' diff --git a/sdk/templates/typescript/gitignore b/sdk/templates/typescript/gitignore new file mode 100644 index 00000000..149b5765 --- /dev/null +++ b/sdk/templates/typescript/gitignore @@ -0,0 +1,4 @@ +wwwroot/*.js +node_modules +typings +dist diff --git a/sdk/templates/typescript/index.mustache b/sdk/templates/typescript/index.mustache new file mode 100644 index 00000000..b8e9eb60 --- /dev/null +++ b/sdk/templates/typescript/index.mustache @@ -0,0 +1,7 @@ +/* tslint:disable */ +/* eslint-disable */ +{{>licenseInfo}} + +export * from "./api"; +export * from "./configuration"; +{{#withSeparateModelsAndApi}}export * from "./{{tsModelPackage}}";{{/withSeparateModelsAndApi}} diff --git a/sdk/templates/typescript/licenseInfo.mustache b/sdk/templates/typescript/licenseInfo.mustache new file mode 100644 index 00000000..9d0878e6 --- /dev/null +++ b/sdk/templates/typescript/licenseInfo.mustache @@ -0,0 +1,13 @@ +// Copyright 2024, Pulumi Corporation. All rights reserved. + +/** + * {{{appName}}} + * {{{appDescription}}} + * + * {{#version}}The version of the OpenAPI document: {{{.}}}{{/version}} + * {{#infoEmail}}Contact: {{{.}}}{{/infoEmail}} + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ diff --git a/sdk/templates/typescript/model.mustache b/sdk/templates/typescript/model.mustache new file mode 100644 index 00000000..9e1e8442 --- /dev/null +++ b/sdk/templates/typescript/model.mustache @@ -0,0 +1,16 @@ +/* tslint:disable */ +/* eslint-disable */ +{{>licenseInfo}} +{{#withSeparateModelsAndApi}}{{#hasAllOf}}{{#allOf}} +// May contain unused imports in some cases +// @ts-ignore +import { {{class}} } from './{{filename}}';{{/allOf}}{{/hasAllOf}}{{#hasOneOf}}{{#oneOf}} +// May contain unused imports in some cases +// @ts-ignore +import { {{class}} } from './{{filename}}';{{/oneOf}}{{/hasOneOf}}{{^hasAllOf}}{{^hasOneOf}}{{#imports}} +// May contain unused imports in some cases +// @ts-ignore +import { {{class}} } from './{{filename}}';{{/imports}}{{/hasOneOf}}{{/hasAllOf}}{{/withSeparateModelsAndApi}} +{{#models}}{{#model}} +{{#isEnum}}{{>modelEnum}}{{/isEnum}}{{#oneOf}}{{#-first}}{{>modelOneOf}}{{/-first}}{{/oneOf}}{{#allOf}}{{#-first}}{{>modelAllOf}}{{/-first}}{{/allOf}}{{^isEnum}}{{^oneOf}}{{^allOf}}{{>modelGeneric}}{{/allOf}}{{/oneOf}}{{/isEnum}} +{{/model}}{{/models}} diff --git a/sdk/templates/typescript/modelAllOf.mustache b/sdk/templates/typescript/modelAllOf.mustache new file mode 100644 index 00000000..c1634196 --- /dev/null +++ b/sdk/templates/typescript/modelAllOf.mustache @@ -0,0 +1,6 @@ +/** + * @type {{classname}}{{#description}} + * {{{.}}}{{/description}} + * @export + */ +export type {{classname}} = {{#allOf}}{{{.}}}{{^-last}} & {{/-last}}{{/allOf}}; diff --git a/sdk/templates/typescript/modelEnum.mustache b/sdk/templates/typescript/modelEnum.mustache new file mode 100644 index 00000000..e18f5c09 --- /dev/null +++ b/sdk/templates/typescript/modelEnum.mustache @@ -0,0 +1,17 @@ +/** + * {{{description}}} + * @export + * @enum {string} + */ +{{#isBoolean}} +export type {{classname}} = {{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}} | {{/-last}}{{/enumVars}}{{/allowableValues}} +{{/isBoolean}} + +{{^isBoolean}} +{{^stringEnums}} +{{>modelObjectEnum}} +{{/stringEnums}} +{{#stringEnums}} +{{>modelStringEnum}} +{{/stringEnums}} +{{/isBoolean}} diff --git a/sdk/templates/typescript/modelGeneric.mustache b/sdk/templates/typescript/modelGeneric.mustache new file mode 100644 index 00000000..878383de --- /dev/null +++ b/sdk/templates/typescript/modelGeneric.mustache @@ -0,0 +1,62 @@ +/** + * {{{description}}} + * @export + * @interface {{classname}} + */ +export interface {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{ +{{#additionalPropertiesType}} + [key: string]: {{{additionalPropertiesType}}}{{#additionalPropertiesIsAnyType}}{{#hasVars}} | any{{/hasVars}}{{/additionalPropertiesIsAnyType}}; + +{{/additionalPropertiesType}} +{{#vars}} + /** + * {{{description}}} + * @type {{=<% %>=}}{<%&datatype%>}<%={{ }}=%> + * @memberof {{classname}} + {{#deprecated}} + * @deprecated + {{/deprecated}} + */ + '{{baseName}}'{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#isNullable}} | null{{/isNullable}}; +{{/vars}} +}{{#hasEnums}} + +{{#vars}} +{{#isEnum}} +{{#stringEnums}} +/** + * @export + * @enum {string} + */ +export enum {{enumName}} { +{{#allowableValues}} + {{#enumVars}} + {{#enumDescription}} + /** + * {{.}} + */ + {{/enumDescription}} + {{{name}}} = {{{value}}}{{^-last}},{{/-last}} + {{/enumVars}} +{{/allowableValues}} +} +{{/stringEnums}} +{{^stringEnums}} +export const {{enumName}} = { +{{#allowableValues}} + {{#enumVars}} + {{#enumDescription}} + /** + * {{.}} + */ + {{/enumDescription}} + {{{name}}}: {{{value}}}{{^-last}},{{/-last}} + {{/enumVars}} +{{/allowableValues}} +} as const; + +export type {{enumName}} = typeof {{enumName}}[keyof typeof {{enumName}}]; +{{/stringEnums}} +{{/isEnum}} +{{/vars}} +{{/hasEnums}} diff --git a/sdk/templates/typescript/modelIndex.mustache b/sdk/templates/typescript/modelIndex.mustache new file mode 100644 index 00000000..94711120 --- /dev/null +++ b/sdk/templates/typescript/modelIndex.mustache @@ -0,0 +1,2 @@ +{{#models}}{{#model}}export * from './{{classFilename}}';{{/model}} +{{/models}} \ No newline at end of file diff --git a/sdk/templates/typescript/modelObjectEnum.mustache b/sdk/templates/typescript/modelObjectEnum.mustache new file mode 100644 index 00000000..ce2c8208 --- /dev/null +++ b/sdk/templates/typescript/modelObjectEnum.mustache @@ -0,0 +1,14 @@ +export const {{classname}} = { +{{#allowableValues}} + {{#enumVars}} + {{#enumDescription}} + /** + * {{.}} + */ + {{/enumDescription}} + {{{name}}}: {{{value}}}{{^-last}},{{/-last}} + {{/enumVars}} +{{/allowableValues}} +} as const; + +export type {{classname}} = typeof {{classname}}[keyof typeof {{classname}}]; diff --git a/sdk/templates/typescript/modelOneOf.mustache b/sdk/templates/typescript/modelOneOf.mustache new file mode 100644 index 00000000..bfc9fb0b --- /dev/null +++ b/sdk/templates/typescript/modelOneOf.mustache @@ -0,0 +1,15 @@ +/** + * @type {{classname}}{{#description}} + * {{{.}}}{{/description}} + * @export + */ +export type {{classname}} = {{#discriminator}}{{! + +discriminator with mapped models - TypeScript discriminating union +}}{{#mappedModels}}{ {{discriminator.propertyName}}: '{{mappingName}}' } & {{modelName}}{{^-last}} | {{/-last}}{{/mappedModels}}{{! + +discriminator only - fallback to not use the discriminator. Default model names are available but possibility of having null/nullable values could introduce more edge cases +}}{{^mappedModels}}{{#oneOf}}{{{.}}}{{^-last}} | {{/-last}}{{/oneOf}}{{/mappedModels}}{{/discriminator}}{{! + +plain oneOf +}}{{^discriminator}}{{#oneOf}}{{{.}}}{{^-last}} | {{/-last}}{{/oneOf}}{{/discriminator}}; diff --git a/sdk/templates/typescript/modelStringEnum.mustache b/sdk/templates/typescript/modelStringEnum.mustache new file mode 100644 index 00000000..c2886f75 --- /dev/null +++ b/sdk/templates/typescript/modelStringEnum.mustache @@ -0,0 +1,12 @@ +export enum {{classname}} { +{{#allowableValues}} + {{#enumVars}} + {{#enumDescription}} + /** + * {{.}} + */ + {{/enumDescription}} + {{{name}}} = {{{value}}}{{^-last}},{{/-last}} + {{/enumVars}} +{{/allowableValues}} +} diff --git a/sdk/templates/typescript/npmignore b/sdk/templates/typescript/npmignore new file mode 100644 index 00000000..999d88df --- /dev/null +++ b/sdk/templates/typescript/npmignore @@ -0,0 +1 @@ +# empty npmignore to ensure all required files (e.g., in the dist folder) are published by npm \ No newline at end of file diff --git a/sdk/templates/typescript/package.mustache b/sdk/templates/typescript/package.mustache new file mode 100644 index 00000000..da599f17 --- /dev/null +++ b/sdk/templates/typescript/package.mustache @@ -0,0 +1,40 @@ +{ + "name": "{{npmName}}", + "version": "{{npmVersion}}", + "description": "OpenAPI client for {{npmName}}", + "author": "OpenAPI-Generator Contributors", + "repository": { + "type": "git", + "url": "https://{{gitHost}}/{{gitUserId}}/{{gitRepoId}}.git" + }, + "keywords": [ + "axios", + "typescript", + "openapi-client", + "openapi-generator", + "{{npmName}}" + ], + "license": "Unlicense", + "main": "./dist/index.js", + "typings": "./dist/index.d.ts", +{{#supportsES6}} + "module": "./dist/esm/index.js", + "sideEffects": false, +{{/supportsES6}} + "scripts": { + "build": "tsc{{#supportsES6}} && tsc -p tsconfig.esm.json{{/supportsES6}}", + "prepare": "npm run build" + }, + "dependencies": { + "axios": "^1.6.1" + }, + "devDependencies": { + "@types/node": "^12.11.5", + "typescript": "^4.0" + }{{#npmRepository}},{{/npmRepository}} +{{#npmRepository}} + "publishConfig": { + "registry": "{{npmRepository}}" + } +{{/npmRepository}} +} diff --git a/sdk/templates/typescript/tsconfig.esm.mustache b/sdk/templates/typescript/tsconfig.esm.mustache new file mode 100644 index 00000000..2c0331cc --- /dev/null +++ b/sdk/templates/typescript/tsconfig.esm.mustache @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "esnext", + "outDir": "dist/esm" + } +} diff --git a/sdk/templates/typescript/tsconfig.mustache b/sdk/templates/typescript/tsconfig.mustache new file mode 100644 index 00000000..d0ebbd47 --- /dev/null +++ b/sdk/templates/typescript/tsconfig.mustache @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "declaration": true, + "target": "{{#supportsES6}}ES6{{/supportsES6}}{{^supportsES6}}ES5{{/supportsES6}}", + "module": "commonjs", + "noImplicitAny": true, + "outDir": "dist", + "rootDir": ".", + {{#supportsES6}} + "moduleResolution": "node", + {{/supportsES6}} + {{^supportsES6}} + "lib": [ + "es6", + "dom" + ], + {{/supportsES6}} + "typeRoots": [ + "node_modules/@types" + ] + }, + "exclude": [ + "dist", + "node_modules" + ] +} diff --git a/sdk/typescript/.eslintrc.js b/sdk/typescript/.eslintrc.js new file mode 100644 index 00000000..0fbee882 --- /dev/null +++ b/sdk/typescript/.eslintrc.js @@ -0,0 +1,25 @@ +module.exports = { + env: { + node: true, + es2021: true, + }, + extends: ["eslint:recommended", "plugin:prettier/recommended"], + overrides: [ + { + env: { + node: true, + }, + files: [".eslintrc.{js,cjs}"], + parserOptions: { + sourceType: "script", + }, + }, + ], + parser: "@typescript-eslint/parser", + parserOptions: { + ecmaVersion: "latest", + sourceType: "module", + }, + plugins: ["@typescript-eslint"], + rules: {}, +}; \ No newline at end of file diff --git a/sdk/typescript/esc/index.ts b/sdk/typescript/esc/index.ts new file mode 100644 index 00000000..3b3a2a75 --- /dev/null +++ b/sdk/typescript/esc/index.ts @@ -0,0 +1,262 @@ +// Copyright 2024, Pulumi Corporation. All rights reserved. + +import { + Environment, + EnvironmentDefinitionValues, + OpenEnvironment, + OrgEnvironments, + OrgEnvironment, + EnvironmentDefinition, + EscApi as EscRawApi, + Configuration, + Value, + EnvironmentDiagnostics, + CheckEnvironment, + Pos, + Range, + Trace, +} from "./raw/index"; +import * as yaml from "js-yaml"; +import { AxiosError } from "axios"; + +export { + Configuration, + Environment, + EnvironmentDefinitionValues, + OpenEnvironment, + OrgEnvironments, + OrgEnvironment, + EnvironmentDefinition, + EscRawApi, + Value, + EnvironmentDiagnostics, + CheckEnvironment, + Pos, + Range, + Trace, +}; + +export interface EnvironmentDefinitionResponse { + definition: EnvironmentDefinition; + yaml: string; +} + +export interface EnvironmentResponse { + environment?: Environment; + values?: EnvironmentDefinitionValues; +} + +export interface EnvironmentPropertyResponse { + property: Value; + value: any; +} + +type KeyValueMap = { [key: string]: string }; + +/** + * + * @export + * @class EscApi + */ +export class EscApi { + rawApi: EscRawApi; + config: Configuration; + constructor(config: Configuration) { + this.config = config; + this.rawApi = new EscRawApi(config); + } + async listEnvironments(org: string, continuationToken?: string | undefined): Promise { + const resp = await this.rawApi.listEnvironments(org, continuationToken); + if (resp.status === 200) { + return resp.data; + } + + throw new Error(`Failed to list environments: ${resp.statusText}`); + } + async getEnvironment(org: string, name: string): Promise { + const resp = await this.rawApi.getEnvironment(org, name); + if (resp.status === 200) { + const doc = yaml.load(resp.data as string); + return { + definition: doc as EnvironmentDefinition, + yaml: resp.data as string, + }; + } + + throw new Error(`Failed to get environment: ${resp.statusText}`); + } + + async openEnvironment(org: string, name: string): Promise { + const resp = await this.rawApi.openEnvironment(org, name); + if (resp.status === 200) { + return resp.data; + } + + throw new Error(`Failed to open environment: ${resp.statusText}`); + } + + async readOpenEnvironment( + org: string, + name: string, + openSessionID: string, + ): Promise { + const resp = await this.rawApi.readOpenEnvironment(org, name, openSessionID); + if (resp.status === 200) { + return { + environment: resp.data, + values: convertEnvPropertiesToValues(resp.data.properties), + }; + } + + throw new Error(`Failed to read environment: ${resp.statusText}`); + } + + async openAndReadEnvironment(org: string, name: string): Promise { + const open = await this.openEnvironment(org, name); + if (open?.id) { + return await this.readOpenEnvironment(org, name, open.id); + } + + throw new Error(`Failed to open and read environment: ${open}`); + } + + async readOpenEnvironmentProperty( + org: string, + name: string, + openSessionID: string, + property: string, + ): Promise { + const resp = await this.rawApi.readOpenEnvironmentProperty(org, name, openSessionID, property); + if (resp.status === 200) { + return { + property: resp.data, + value: convertPropertyToValue(resp.data), + }; + } + + throw new Error(`Failed to read environment property: ${resp.statusText}`); + } + + async createEnvironment(org: string, name: string): Promise { + const resp = await this.rawApi.createEnvironment(org, name); + if (resp.status === 200) { + return; + } + + throw new Error(`Failed to create environment: ${resp.statusText}`); + } + + async updateEnvironmentYaml(org: string, name: string, yaml: string): Promise { + const resp = await this.rawApi.updateEnvironmentYaml(org, name, yaml); + if (resp.status === 200) { + return resp.data; + } + + throw new Error(`Failed to update environment: ${resp.statusText}`); + } + + async updateEnvironment( + org: string, + name: string, + values: EnvironmentDefinition, + ): Promise { + const body = yaml.dump(values); + const resp = await this.rawApi.updateEnvironmentYaml(org, name, body); + if (resp.status === 200) { + return resp.data; + } + + throw new Error(`Failed to update environment: ${resp.statusText}`); + } + + async deleteEnvironment(org: string, name: string): Promise { + const resp = await this.rawApi.deleteEnvironment(org, name); + if (resp.status === 200) { + return; + } + + throw new Error(`Failed to delete environment: ${resp.statusText}`); + } + + async checkEnvironmentYaml(org: string, yaml: string): Promise { + try { + const resp = await this.rawApi.checkEnvironmentYaml(org, yaml); + if (resp.status === 200) { + return resp.data; + } + + throw new Error(`Failed to check environment: ${resp.statusText}`); + } catch (err: any) { + if (err instanceof AxiosError) { + if (err.response?.status === 400) { + return err.response?.data; + } + } + throw err; + } + } + + async checkEnvironment(org: string, env: EnvironmentDefinition): Promise { + const body = yaml.dump(env); + return await this.checkEnvironmentYaml(org, body); + } + + async decryptEnvironment(org: string, name: string): Promise { + const resp = await this.rawApi.decryptEnvironment(org, name); + if (resp.status === 200) { + const doc = yaml.load(resp.data as string); + return { + definition: doc as EnvironmentDefinition, + yaml: resp.data as string, + }; + } + + throw new Error(`Failed to decrypt environment: ${resp.statusText}`); + } +} + +function convertEnvPropertiesToValues(env: { [key: string]: Value } | undefined): KeyValueMap { + if (!env) { + return {}; + } + + const values: KeyValueMap = {}; + for (const key in env) { + const value = env[key]; + + values[key] = convertPropertyToValue(value); + } + + return values; +} + +function convertPropertyToValue(property: any): any { + if (!property) { + return property; + } + + let value = property; + if ("value" in property) { + value = convertPropertyToValue(property.value); + } + + if (!value) { + return value; + } + + if (Array.isArray(value)) { + const array = value as Value[]; + return array.map((v) => convertPropertyToValue(v)); + } + + if (typeof value === "object") { + const result: any = {}; + for (const key in value) { + result[key] = convertPropertyToValue(value[key]); + } + + return result; + } + + return value; +} diff --git a/sdk/typescript/esc/raw/.npmignore b/sdk/typescript/esc/raw/.npmignore new file mode 100644 index 00000000..999d88df --- /dev/null +++ b/sdk/typescript/esc/raw/.npmignore @@ -0,0 +1 @@ +# empty npmignore to ensure all required files (e.g., in the dist folder) are published by npm \ No newline at end of file diff --git a/sdk/typescript/esc/raw/.openapi-generator-ignore b/sdk/typescript/esc/raw/.openapi-generator-ignore new file mode 100644 index 00000000..47154ced --- /dev/null +++ b/sdk/typescript/esc/raw/.openapi-generator-ignore @@ -0,0 +1,28 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md + +git_push.sh +.gitignore +package.json +README.md \ No newline at end of file diff --git a/sdk/typescript/esc/raw/.openapi-generator/FILES b/sdk/typescript/esc/raw/.openapi-generator/FILES new file mode 100644 index 00000000..4c5d6211 --- /dev/null +++ b/sdk/typescript/esc/raw/.openapi-generator/FILES @@ -0,0 +1,7 @@ +.npmignore +api.ts +base.ts +common.ts +configuration.ts +index.ts +tsconfig.json diff --git a/sdk/typescript/esc/raw/.openapi-generator/VERSION b/sdk/typescript/esc/raw/.openapi-generator/VERSION new file mode 100644 index 00000000..ba7f754d --- /dev/null +++ b/sdk/typescript/esc/raw/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.4.0 diff --git a/sdk/typescript/esc/raw/api.ts b/sdk/typescript/esc/raw/api.ts new file mode 100644 index 00000000..29f34b4e --- /dev/null +++ b/sdk/typescript/esc/raw/api.ts @@ -0,0 +1,1574 @@ +/* tslint:disable */ +/* eslint-disable */ +// Copyright 2024, Pulumi Corporation. All rights reserved. + +/** + * ESC (Environments, Secrets, Config) API + * Pulumi ESC allows you to compose and manage hierarchical collections of configuration and secrets and consume them in various ways. + * + * The version of the OpenAPI document: 0.1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +import type { Configuration } from './configuration'; +import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios'; +import globalAxios from 'axios'; +// Some imports not used depending on template conditions +// @ts-ignore +import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from './common'; +import type { RequestArgs } from './base'; +// @ts-ignore +import { BASE_PATH, COLLECTION_FORMATS, BaseAPI, RequiredError, operationServerMap } from './base'; + +/** + * + * @export + * @interface Access + */ +export interface Access { + /** + * + * @type {Range} + * @memberof Access + */ + 'receiver'?: Range; + /** + * + * @type {Array} + * @memberof Access + */ + 'accessors'?: Array; +} +/** + * + * @export + * @interface Accessor + */ +export interface Accessor { + /** + * + * @type {number} + * @memberof Accessor + */ + 'index'?: number; + /** + * + * @type {string} + * @memberof Accessor + */ + 'key': string; + /** + * + * @type {Range} + * @memberof Accessor + */ + 'range': Range; +} +/** + * + * @export + * @interface CheckEnvironment + */ +export interface CheckEnvironment { + /** + * + * @type {{ [key: string]: Expr; }} + * @memberof CheckEnvironment + */ + 'exprs'?: { [key: string]: Expr; }; + /** + * + * @type {{ [key: string]: Value; }} + * @memberof CheckEnvironment + */ + 'properties'?: { [key: string]: Value; }; + /** + * + * @type {object} + * @memberof CheckEnvironment + */ + 'schema'?: object; + /** + * + * @type {EvaluatedExecutionContext} + * @memberof CheckEnvironment + */ + 'executionContext'?: EvaluatedExecutionContext; + /** + * + * @type {Array} + * @memberof CheckEnvironment + */ + 'diagnostics'?: Array; +} +/** + * + * @export + * @interface Environment + */ +export interface Environment { + /** + * + * @type {{ [key: string]: Expr; }} + * @memberof Environment + */ + 'exprs'?: { [key: string]: Expr; }; + /** + * + * @type {{ [key: string]: Value; }} + * @memberof Environment + */ + 'properties'?: { [key: string]: Value; }; + /** + * + * @type {any} + * @memberof Environment + */ + 'schema'?: any; + /** + * + * @type {EvaluatedExecutionContext} + * @memberof Environment + */ + 'executionContext'?: EvaluatedExecutionContext; +} +/** + * + * @export + * @interface EnvironmentDefinition + */ +export interface EnvironmentDefinition { + /** + * + * @type {Array} + * @memberof EnvironmentDefinition + */ + 'imports'?: Array; + /** + * + * @type {EnvironmentDefinitionValues} + * @memberof EnvironmentDefinition + */ + 'values'?: EnvironmentDefinitionValues; +} +/** + * + * @export + * @interface EnvironmentDefinitionValues + */ +export interface EnvironmentDefinitionValues { + [key: string]: object | any; + + /** + * + * @type {{ [key: string]: any; }} + * @memberof EnvironmentDefinitionValues + */ + 'pulumiConfig'?: { [key: string]: any; }; + /** + * + * @type {{ [key: string]: string; }} + * @memberof EnvironmentDefinitionValues + */ + 'environmentVariables'?: { [key: string]: string; }; + /** + * + * @type {{ [key: string]: string; }} + * @memberof EnvironmentDefinitionValues + */ + 'files'?: { [key: string]: string; }; +} +/** + * + * @export + * @interface EnvironmentDiagnostic + */ +export interface EnvironmentDiagnostic { + [key: string]: object | any; + + /** + * + * @type {string} + * @memberof EnvironmentDiagnostic + */ + 'summary': string; + /** + * + * @type {string} + * @memberof EnvironmentDiagnostic + */ + 'path'?: string; + /** + * + * @type {Range} + * @memberof EnvironmentDiagnostic + */ + 'range'?: Range; +} +/** + * + * @export + * @interface EnvironmentDiagnostics + */ +export interface EnvironmentDiagnostics { + /** + * + * @type {Array} + * @memberof EnvironmentDiagnostics + */ + 'diagnostics'?: Array; +} +/** + * + * @export + * @interface EvaluatedExecutionContext + */ +export interface EvaluatedExecutionContext { + /** + * + * @type {{ [key: string]: Value; }} + * @memberof EvaluatedExecutionContext + */ + 'properties'?: { [key: string]: Value; }; + /** + * + * @type {any} + * @memberof EvaluatedExecutionContext + */ + 'schema'?: any; +} +/** + * + * @export + * @interface Expr + */ +export interface Expr { + /** + * + * @type {Range} + * @memberof Expr + */ + 'range'?: Range; + /** + * + * @type {Expr} + * @memberof Expr + */ + 'base'?: Expr; + /** + * + * @type {any} + * @memberof Expr + */ + 'schema'?: any; + /** + * + * @type {{ [key: string]: Range; }} + * @memberof Expr + */ + 'keyRanges'?: { [key: string]: Range; }; + /** + * + * @type {any} + * @memberof Expr + */ + 'literal'?: any; + /** + * + * @type {Array} + * @memberof Expr + */ + 'interpolate'?: Array; + /** + * + * @type {Array} + * @memberof Expr + */ + 'symbol'?: Array; + /** + * + * @type {Array} + * @memberof Expr + */ + 'access'?: Array; + /** + * + * @type {Array} + * @memberof Expr + */ + 'list'?: Array; + /** + * + * @type {{ [key: string]: Expr; }} + * @memberof Expr + */ + 'object'?: { [key: string]: Expr; }; + /** + * + * @type {ExprBuiltin} + * @memberof Expr + */ + 'builtin'?: ExprBuiltin; +} +/** + * + * @export + * @interface ExprBuiltin + */ +export interface ExprBuiltin { + /** + * + * @type {string} + * @memberof ExprBuiltin + */ + 'name': string; + /** + * + * @type {Range} + * @memberof ExprBuiltin + */ + 'nameRange'?: Range; + /** + * + * @type {any} + * @memberof ExprBuiltin + */ + 'argSchema'?: any; + /** + * + * @type {Expr} + * @memberof ExprBuiltin + */ + 'arg'?: Expr; +} +/** + * + * @export + * @interface Interpolation + */ +export interface Interpolation { + /** + * + * @type {string} + * @memberof Interpolation + */ + 'text': string; + /** + * + * @type {Array} + * @memberof Interpolation + */ + 'value'?: Array; +} +/** + * + * @export + * @interface ModelError + */ +export interface ModelError { + /** + * + * @type {string} + * @memberof ModelError + */ + 'message': string; + /** + * + * @type {number} + * @memberof ModelError + */ + 'code': number; +} +/** + * + * @export + * @interface OpenEnvironment + */ +export interface OpenEnvironment { + /** + * Open environment session identifier + * @type {string} + * @memberof OpenEnvironment + */ + 'id': string; + /** + * + * @type {EnvironmentDiagnostics} + * @memberof OpenEnvironment + */ + 'diagnostics'?: EnvironmentDiagnostics; +} +/** + * + * @export + * @interface OrgEnvironment + */ +export interface OrgEnvironment { + /** + * + * @type {string} + * @memberof OrgEnvironment + */ + 'organization'?: string; + /** + * + * @type {string} + * @memberof OrgEnvironment + */ + 'name': string; + /** + * + * @type {string} + * @memberof OrgEnvironment + */ + 'created': string; + /** + * + * @type {string} + * @memberof OrgEnvironment + */ + 'modified': string; +} +/** + * + * @export + * @interface OrgEnvironments + */ +export interface OrgEnvironments { + /** + * + * @type {Array} + * @memberof OrgEnvironments + */ + 'environments'?: Array; + /** + * + * @type {string} + * @memberof OrgEnvironments + */ + 'nextToken'?: string; +} +/** + * + * @export + * @interface Pos + */ +export interface Pos { + /** + * Line is the source code line where this position points. Lines are counted starting at 1 and incremented for each newline character encountered. + * @type {number} + * @memberof Pos + */ + 'line': number; + /** + * Column is the source code column where this position points. Columns are counted in visual cells starting at 1, and are incremented roughly per grapheme cluster encountered. + * @type {number} + * @memberof Pos + */ + 'column': number; + /** + * Byte is the byte offset into the file where the indicated position begins. + * @type {number} + * @memberof Pos + */ + 'byte': number; +} +/** + * + * @export + * @interface PropertyAccessor + */ +export interface PropertyAccessor { + /** + * + * @type {number} + * @memberof PropertyAccessor + */ + 'index'?: number; + /** + * + * @type {string} + * @memberof PropertyAccessor + */ + 'key': string; + /** + * + * @type {Range} + * @memberof PropertyAccessor + */ + 'range': Range; + /** + * + * @type {Range} + * @memberof PropertyAccessor + */ + 'value'?: Range; +} +/** + * + * @export + * @interface Range + */ +export interface Range { + /** + * + * @type {string} + * @memberof Range + */ + 'environment': string; + /** + * + * @type {Pos} + * @memberof Range + */ + 'begin': Pos; + /** + * + * @type {Pos} + * @memberof Range + */ + 'end': Pos; +} +/** + * + * @export + * @interface Reference + */ +export interface Reference { + /** + * + * @type {string} + * @memberof Reference + */ + '$ref': string; +} +/** + * + * @export + * @interface Trace + */ +export interface Trace { + /** + * + * @type {Range} + * @memberof Trace + */ + 'def'?: Range; + /** + * + * @type {Value} + * @memberof Trace + */ + 'base'?: Value; +} +/** + * + * @export + * @interface Value + */ +export interface Value { + /** + * + * @type {any} + * @memberof Value + */ + 'value': any; + /** + * + * @type {boolean} + * @memberof Value + */ + 'secret'?: boolean; + /** + * + * @type {boolean} + * @memberof Value + */ + 'unknown'?: boolean; + /** + * + * @type {Trace} + * @memberof Value + */ + 'trace': Trace; +} + +/** + * EscApi - axios parameter creator + * @export + */ +export const EscApiAxiosParamCreator = function (configuration?: Configuration) { + return { + /** + * Checks an environment definition for errors + * @summary Checks an environment definition for errors + * @param {string} orgName Organization name + * @param {string} body Environment Yaml content + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + checkEnvironmentYaml: async (orgName: string, body: string, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'orgName' is not null or undefined + assertParamExists('checkEnvironmentYaml', 'orgName', orgName) + // verify required parameter 'body' is not null or undefined + assertParamExists('checkEnvironmentYaml', 'body', body) + const localVarPath = `/environments/{orgName}/yaml/check` + .replace(`{${"orgName"}}`, encodeURIComponent(String(orgName))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication Authorization required + await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration) + + + + localVarHeaderParameter['Content-Type'] = 'application/x-yaml'; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + localVarHeaderParameter['X-Pulumi-Source'] = 'esc-sdk' + localVarHeaderParameter['User-Agent'] = 'esc-sdk/ts/0.8.3-dev.0' + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(body, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Creates an environment in the given org with the given name. + * @summary Create a new environment + * @param {string} orgName Organization name + * @param {string} envName Environment name + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + createEnvironment: async (orgName: string, envName: string, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'orgName' is not null or undefined + assertParamExists('createEnvironment', 'orgName', orgName) + // verify required parameter 'envName' is not null or undefined + assertParamExists('createEnvironment', 'envName', envName) + const localVarPath = `/environments/{orgName}/{envName}` + .replace(`{${"orgName"}}`, encodeURIComponent(String(orgName))) + .replace(`{${"envName"}}`, encodeURIComponent(String(envName))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication Authorization required + await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration) + + + + setSearchParams(localVarUrlObj, localVarQueryParameter); + localVarHeaderParameter['X-Pulumi-Source'] = 'esc-sdk' + localVarHeaderParameter['User-Agent'] = 'esc-sdk/ts/0.8.3-dev.0' + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Reads the definition for the given environment with static secrets in plaintext + * @summary Reads the definition for the given environment with static secrets in plaintext + * @param {string} orgName Organization name + * @param {string} envName Environment name + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + decryptEnvironment: async (orgName: string, envName: string, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'orgName' is not null or undefined + assertParamExists('decryptEnvironment', 'orgName', orgName) + // verify required parameter 'envName' is not null or undefined + assertParamExists('decryptEnvironment', 'envName', envName) + const localVarPath = `/environments/{orgName}/{envName}/decrypt` + .replace(`{${"orgName"}}`, encodeURIComponent(String(orgName))) + .replace(`{${"envName"}}`, encodeURIComponent(String(envName))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication Authorization required + await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration) + + + + setSearchParams(localVarUrlObj, localVarQueryParameter); + localVarHeaderParameter['X-Pulumi-Source'] = 'esc-sdk' + localVarHeaderParameter['User-Agent'] = 'esc-sdk/ts/0.8.3-dev.0' + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Delete an environment + * @summary Delete an environment + * @param {string} orgName Organization name + * @param {string} envName Environment name + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + deleteEnvironment: async (orgName: string, envName: string, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'orgName' is not null or undefined + assertParamExists('deleteEnvironment', 'orgName', orgName) + // verify required parameter 'envName' is not null or undefined + assertParamExists('deleteEnvironment', 'envName', envName) + const localVarPath = `/environments/{orgName}/{envName}` + .replace(`{${"orgName"}}`, encodeURIComponent(String(orgName))) + .replace(`{${"envName"}}`, encodeURIComponent(String(envName))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'DELETE', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication Authorization required + await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration) + + + + setSearchParams(localVarUrlObj, localVarQueryParameter); + localVarHeaderParameter['X-Pulumi-Source'] = 'esc-sdk' + localVarHeaderParameter['User-Agent'] = 'esc-sdk/ts/0.8.3-dev.0' + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Read an environment + * @summary Read an environment + * @param {string} orgName Organization name + * @param {string} envName Environment name + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getEnvironment: async (orgName: string, envName: string, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'orgName' is not null or undefined + assertParamExists('getEnvironment', 'orgName', orgName) + // verify required parameter 'envName' is not null or undefined + assertParamExists('getEnvironment', 'envName', envName) + const localVarPath = `/environments/{orgName}/{envName}` + .replace(`{${"orgName"}}`, encodeURIComponent(String(orgName))) + .replace(`{${"envName"}}`, encodeURIComponent(String(envName))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication Authorization required + await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration) + + + + setSearchParams(localVarUrlObj, localVarQueryParameter); + localVarHeaderParameter['X-Pulumi-Source'] = 'esc-sdk' + localVarHeaderParameter['User-Agent'] = 'esc-sdk/ts/0.8.3-dev.0' + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Returns the ETag for the given environment if it exists. + * @summary Return an Environment ETag + * @param {string} orgName Organization name + * @param {string} envName Environment name + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getEnvironmentETag: async (orgName: string, envName: string, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'orgName' is not null or undefined + assertParamExists('getEnvironmentETag', 'orgName', orgName) + // verify required parameter 'envName' is not null or undefined + assertParamExists('getEnvironmentETag', 'envName', envName) + const localVarPath = `/environments/{orgName}/{envName}` + .replace(`{${"orgName"}}`, encodeURIComponent(String(orgName))) + .replace(`{${"envName"}}`, encodeURIComponent(String(envName))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'HEAD', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication Authorization required + await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration) + + + + setSearchParams(localVarUrlObj, localVarQueryParameter); + localVarHeaderParameter['X-Pulumi-Source'] = 'esc-sdk' + localVarHeaderParameter['User-Agent'] = 'esc-sdk/ts/0.8.3-dev.0' + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * List environments in the organization available to the current user + * @summary List environments in the organization + * @param {string} orgName Organization name + * @param {string} [continuationToken] continuation Token from previous query to fetch next page of results + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + listEnvironments: async (orgName: string, continuationToken?: string, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'orgName' is not null or undefined + assertParamExists('listEnvironments', 'orgName', orgName) + const localVarPath = `/environments/{orgName}` + .replace(`{${"orgName"}}`, encodeURIComponent(String(orgName))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication Authorization required + await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration) + + if (continuationToken !== undefined) { + localVarQueryParameter['continuationToken'] = continuationToken; + } + + + + setSearchParams(localVarUrlObj, localVarQueryParameter); + localVarHeaderParameter['X-Pulumi-Source'] = 'esc-sdk' + localVarHeaderParameter['User-Agent'] = 'esc-sdk/ts/0.8.3-dev.0' + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Opens a session the given environment for the indicated duration. This returns a session id that can be used to then read values. The default duration is 1 hour. + * @summary Open an environment session + * @param {string} orgName Organization name + * @param {string} envName Environment name + * @param {string} [duration] open duration - A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as “300ms”, “1.5h” or “2h45m”. Valid time units are “ns”, “us” (or “µs”), “ms”, “s”, “m”, “h”. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + openEnvironment: async (orgName: string, envName: string, duration?: string, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'orgName' is not null or undefined + assertParamExists('openEnvironment', 'orgName', orgName) + // verify required parameter 'envName' is not null or undefined + assertParamExists('openEnvironment', 'envName', envName) + const localVarPath = `/environments/{orgName}/{envName}/open` + .replace(`{${"orgName"}}`, encodeURIComponent(String(orgName))) + .replace(`{${"envName"}}`, encodeURIComponent(String(envName))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication Authorization required + await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration) + + if (duration !== undefined) { + localVarQueryParameter['duration'] = duration; + } + + + + setSearchParams(localVarUrlObj, localVarQueryParameter); + localVarHeaderParameter['X-Pulumi-Source'] = 'esc-sdk' + localVarHeaderParameter['User-Agent'] = 'esc-sdk/ts/0.8.3-dev.0' + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Reads and decrypts secrets including retrieving dynamic secrets from providers. + * @summary Read an open environment + * @param {string} orgName Organization name + * @param {string} envName Environment name + * @param {string} openSessionID Open session ID returned from environment open + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + readOpenEnvironment: async (orgName: string, envName: string, openSessionID: string, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'orgName' is not null or undefined + assertParamExists('readOpenEnvironment', 'orgName', orgName) + // verify required parameter 'envName' is not null or undefined + assertParamExists('readOpenEnvironment', 'envName', envName) + // verify required parameter 'openSessionID' is not null or undefined + assertParamExists('readOpenEnvironment', 'openSessionID', openSessionID) + const localVarPath = `/environments/{orgName}/{envName}/open/{openSessionID}` + .replace(`{${"orgName"}}`, encodeURIComponent(String(orgName))) + .replace(`{${"envName"}}`, encodeURIComponent(String(envName))) + .replace(`{${"openSessionID"}}`, encodeURIComponent(String(openSessionID))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication Authorization required + await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration) + + + + setSearchParams(localVarUrlObj, localVarQueryParameter); + localVarHeaderParameter['X-Pulumi-Source'] = 'esc-sdk' + localVarHeaderParameter['User-Agent'] = 'esc-sdk/ts/0.8.3-dev.0' + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Reads and decrypts secrets including retrieving dynamic secrets from providers. + * @summary Read an open environment + * @param {string} orgName Organization name + * @param {string} envName Environment name + * @param {string} openSessionID Open session ID returned from environment open + * @param {string} property Path to a specific property using Pulumi path syntax https://www.pulumi.com/docs/concepts/config/#structured-configuration + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + readOpenEnvironmentProperty: async (orgName: string, envName: string, openSessionID: string, property: string, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'orgName' is not null or undefined + assertParamExists('readOpenEnvironmentProperty', 'orgName', orgName) + // verify required parameter 'envName' is not null or undefined + assertParamExists('readOpenEnvironmentProperty', 'envName', envName) + // verify required parameter 'openSessionID' is not null or undefined + assertParamExists('readOpenEnvironmentProperty', 'openSessionID', openSessionID) + // verify required parameter 'property' is not null or undefined + assertParamExists('readOpenEnvironmentProperty', 'property', property) + const localVarPath = `/environments/{orgName}/{envName}/open//{openSessionID}` + .replace(`{${"orgName"}}`, encodeURIComponent(String(orgName))) + .replace(`{${"envName"}}`, encodeURIComponent(String(envName))) + .replace(`{${"openSessionID"}}`, encodeURIComponent(String(openSessionID))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication Authorization required + await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration) + + if (property !== undefined) { + localVarQueryParameter['property'] = property; + } + + + + setSearchParams(localVarUrlObj, localVarQueryParameter); + localVarHeaderParameter['X-Pulumi-Source'] = 'esc-sdk' + localVarHeaderParameter['User-Agent'] = 'esc-sdk/ts/0.8.3-dev.0' + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Validates and updates the given environment\'s definition. + * @summary Update an existing environment with Yaml file + * @param {string} orgName Organization name + * @param {string} envName Environment name + * @param {string} body Environment Yaml content + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + updateEnvironmentYaml: async (orgName: string, envName: string, body: string, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'orgName' is not null or undefined + assertParamExists('updateEnvironmentYaml', 'orgName', orgName) + // verify required parameter 'envName' is not null or undefined + assertParamExists('updateEnvironmentYaml', 'envName', envName) + // verify required parameter 'body' is not null or undefined + assertParamExists('updateEnvironmentYaml', 'body', body) + const localVarPath = `/environments/{orgName}/{envName}` + .replace(`{${"orgName"}}`, encodeURIComponent(String(orgName))) + .replace(`{${"envName"}}`, encodeURIComponent(String(envName))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'PATCH', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication Authorization required + await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration) + + + + localVarHeaderParameter['Content-Type'] = 'application/x-yaml'; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + localVarHeaderParameter['X-Pulumi-Source'] = 'esc-sdk' + localVarHeaderParameter['User-Agent'] = 'esc-sdk/ts/0.8.3-dev.0' + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(body, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + } +}; + +/** + * EscApi - functional programming interface + * @export + */ +export const EscApiFp = function(configuration?: Configuration) { + const localVarAxiosParamCreator = EscApiAxiosParamCreator(configuration) + return { + /** + * Checks an environment definition for errors + * @summary Checks an environment definition for errors + * @param {string} orgName Organization name + * @param {string} body Environment Yaml content + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async checkEnvironmentYaml(orgName: string, body: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.checkEnvironmentYaml(orgName, body, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['EscApi.checkEnvironmentYaml']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * Creates an environment in the given org with the given name. + * @summary Create a new environment + * @param {string} orgName Organization name + * @param {string} envName Environment name + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async createEnvironment(orgName: string, envName: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.createEnvironment(orgName, envName, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['EscApi.createEnvironment']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * Reads the definition for the given environment with static secrets in plaintext + * @summary Reads the definition for the given environment with static secrets in plaintext + * @param {string} orgName Organization name + * @param {string} envName Environment name + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async decryptEnvironment(orgName: string, envName: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.decryptEnvironment(orgName, envName, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['EscApi.decryptEnvironment']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * Delete an environment + * @summary Delete an environment + * @param {string} orgName Organization name + * @param {string} envName Environment name + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async deleteEnvironment(orgName: string, envName: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.deleteEnvironment(orgName, envName, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['EscApi.deleteEnvironment']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * Read an environment + * @summary Read an environment + * @param {string} orgName Organization name + * @param {string} envName Environment name + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async getEnvironment(orgName: string, envName: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.getEnvironment(orgName, envName, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['EscApi.getEnvironment']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * Returns the ETag for the given environment if it exists. + * @summary Return an Environment ETag + * @param {string} orgName Organization name + * @param {string} envName Environment name + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async getEnvironmentETag(orgName: string, envName: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.getEnvironmentETag(orgName, envName, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['EscApi.getEnvironmentETag']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * List environments in the organization available to the current user + * @summary List environments in the organization + * @param {string} orgName Organization name + * @param {string} [continuationToken] continuation Token from previous query to fetch next page of results + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async listEnvironments(orgName: string, continuationToken?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.listEnvironments(orgName, continuationToken, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['EscApi.listEnvironments']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * Opens a session the given environment for the indicated duration. This returns a session id that can be used to then read values. The default duration is 1 hour. + * @summary Open an environment session + * @param {string} orgName Organization name + * @param {string} envName Environment name + * @param {string} [duration] open duration - A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as “300ms”, “1.5h” or “2h45m”. Valid time units are “ns”, “us” (or “µs”), “ms”, “s”, “m”, “h”. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async openEnvironment(orgName: string, envName: string, duration?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.openEnvironment(orgName, envName, duration, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['EscApi.openEnvironment']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * Reads and decrypts secrets including retrieving dynamic secrets from providers. + * @summary Read an open environment + * @param {string} orgName Organization name + * @param {string} envName Environment name + * @param {string} openSessionID Open session ID returned from environment open + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async readOpenEnvironment(orgName: string, envName: string, openSessionID: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.readOpenEnvironment(orgName, envName, openSessionID, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['EscApi.readOpenEnvironment']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * Reads and decrypts secrets including retrieving dynamic secrets from providers. + * @summary Read an open environment + * @param {string} orgName Organization name + * @param {string} envName Environment name + * @param {string} openSessionID Open session ID returned from environment open + * @param {string} property Path to a specific property using Pulumi path syntax https://www.pulumi.com/docs/concepts/config/#structured-configuration + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async readOpenEnvironmentProperty(orgName: string, envName: string, openSessionID: string, property: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.readOpenEnvironmentProperty(orgName, envName, openSessionID, property, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['EscApi.readOpenEnvironmentProperty']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * Validates and updates the given environment\'s definition. + * @summary Update an existing environment with Yaml file + * @param {string} orgName Organization name + * @param {string} envName Environment name + * @param {string} body Environment Yaml content + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async updateEnvironmentYaml(orgName: string, envName: string, body: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.updateEnvironmentYaml(orgName, envName, body, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['EscApi.updateEnvironmentYaml']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + } +}; + +/** + * EscApi - factory interface + * @export + */ +export const EscApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { + const localVarFp = EscApiFp(configuration) + return { + /** + * Checks an environment definition for errors + * @summary Checks an environment definition for errors + * @param {string} orgName Organization name + * @param {string} body Environment Yaml content + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + checkEnvironmentYaml(orgName: string, body: string, options?: any): AxiosPromise { + return localVarFp.checkEnvironmentYaml(orgName, body, options).then((request) => request(axios, basePath)); + }, + /** + * Creates an environment in the given org with the given name. + * @summary Create a new environment + * @param {string} orgName Organization name + * @param {string} envName Environment name + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + createEnvironment(orgName: string, envName: string, options?: any): AxiosPromise { + return localVarFp.createEnvironment(orgName, envName, options).then((request) => request(axios, basePath)); + }, + /** + * Reads the definition for the given environment with static secrets in plaintext + * @summary Reads the definition for the given environment with static secrets in plaintext + * @param {string} orgName Organization name + * @param {string} envName Environment name + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + decryptEnvironment(orgName: string, envName: string, options?: any): AxiosPromise { + return localVarFp.decryptEnvironment(orgName, envName, options).then((request) => request(axios, basePath)); + }, + /** + * Delete an environment + * @summary Delete an environment + * @param {string} orgName Organization name + * @param {string} envName Environment name + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + deleteEnvironment(orgName: string, envName: string, options?: any): AxiosPromise { + return localVarFp.deleteEnvironment(orgName, envName, options).then((request) => request(axios, basePath)); + }, + /** + * Read an environment + * @summary Read an environment + * @param {string} orgName Organization name + * @param {string} envName Environment name + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getEnvironment(orgName: string, envName: string, options?: any): AxiosPromise { + return localVarFp.getEnvironment(orgName, envName, options).then((request) => request(axios, basePath)); + }, + /** + * Returns the ETag for the given environment if it exists. + * @summary Return an Environment ETag + * @param {string} orgName Organization name + * @param {string} envName Environment name + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getEnvironmentETag(orgName: string, envName: string, options?: any): AxiosPromise { + return localVarFp.getEnvironmentETag(orgName, envName, options).then((request) => request(axios, basePath)); + }, + /** + * List environments in the organization available to the current user + * @summary List environments in the organization + * @param {string} orgName Organization name + * @param {string} [continuationToken] continuation Token from previous query to fetch next page of results + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + listEnvironments(orgName: string, continuationToken?: string, options?: any): AxiosPromise { + return localVarFp.listEnvironments(orgName, continuationToken, options).then((request) => request(axios, basePath)); + }, + /** + * Opens a session the given environment for the indicated duration. This returns a session id that can be used to then read values. The default duration is 1 hour. + * @summary Open an environment session + * @param {string} orgName Organization name + * @param {string} envName Environment name + * @param {string} [duration] open duration - A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as “300ms”, “1.5h” or “2h45m”. Valid time units are “ns”, “us” (or “µs”), “ms”, “s”, “m”, “h”. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + openEnvironment(orgName: string, envName: string, duration?: string, options?: any): AxiosPromise { + return localVarFp.openEnvironment(orgName, envName, duration, options).then((request) => request(axios, basePath)); + }, + /** + * Reads and decrypts secrets including retrieving dynamic secrets from providers. + * @summary Read an open environment + * @param {string} orgName Organization name + * @param {string} envName Environment name + * @param {string} openSessionID Open session ID returned from environment open + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + readOpenEnvironment(orgName: string, envName: string, openSessionID: string, options?: any): AxiosPromise { + return localVarFp.readOpenEnvironment(orgName, envName, openSessionID, options).then((request) => request(axios, basePath)); + }, + /** + * Reads and decrypts secrets including retrieving dynamic secrets from providers. + * @summary Read an open environment + * @param {string} orgName Organization name + * @param {string} envName Environment name + * @param {string} openSessionID Open session ID returned from environment open + * @param {string} property Path to a specific property using Pulumi path syntax https://www.pulumi.com/docs/concepts/config/#structured-configuration + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + readOpenEnvironmentProperty(orgName: string, envName: string, openSessionID: string, property: string, options?: any): AxiosPromise { + return localVarFp.readOpenEnvironmentProperty(orgName, envName, openSessionID, property, options).then((request) => request(axios, basePath)); + }, + /** + * Validates and updates the given environment\'s definition. + * @summary Update an existing environment with Yaml file + * @param {string} orgName Organization name + * @param {string} envName Environment name + * @param {string} body Environment Yaml content + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + updateEnvironmentYaml(orgName: string, envName: string, body: string, options?: any): AxiosPromise { + return localVarFp.updateEnvironmentYaml(orgName, envName, body, options).then((request) => request(axios, basePath)); + }, + }; +}; + +/** + * EscApi - object-oriented interface + * @export + * @class EscApi + * @extends {BaseAPI} + */ +export class EscApi extends BaseAPI { + /** + * Checks an environment definition for errors + * @summary Checks an environment definition for errors + * @param {string} orgName Organization name + * @param {string} body Environment Yaml content + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof EscApi + */ + public checkEnvironmentYaml(orgName: string, body: string, options?: RawAxiosRequestConfig) { + return EscApiFp(this.configuration).checkEnvironmentYaml(orgName, body, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * Creates an environment in the given org with the given name. + * @summary Create a new environment + * @param {string} orgName Organization name + * @param {string} envName Environment name + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof EscApi + */ + public createEnvironment(orgName: string, envName: string, options?: RawAxiosRequestConfig) { + return EscApiFp(this.configuration).createEnvironment(orgName, envName, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * Reads the definition for the given environment with static secrets in plaintext + * @summary Reads the definition for the given environment with static secrets in plaintext + * @param {string} orgName Organization name + * @param {string} envName Environment name + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof EscApi + */ + public decryptEnvironment(orgName: string, envName: string, options?: RawAxiosRequestConfig) { + return EscApiFp(this.configuration).decryptEnvironment(orgName, envName, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * Delete an environment + * @summary Delete an environment + * @param {string} orgName Organization name + * @param {string} envName Environment name + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof EscApi + */ + public deleteEnvironment(orgName: string, envName: string, options?: RawAxiosRequestConfig) { + return EscApiFp(this.configuration).deleteEnvironment(orgName, envName, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * Read an environment + * @summary Read an environment + * @param {string} orgName Organization name + * @param {string} envName Environment name + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof EscApi + */ + public getEnvironment(orgName: string, envName: string, options?: RawAxiosRequestConfig) { + return EscApiFp(this.configuration).getEnvironment(orgName, envName, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * Returns the ETag for the given environment if it exists. + * @summary Return an Environment ETag + * @param {string} orgName Organization name + * @param {string} envName Environment name + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof EscApi + */ + public getEnvironmentETag(orgName: string, envName: string, options?: RawAxiosRequestConfig) { + return EscApiFp(this.configuration).getEnvironmentETag(orgName, envName, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * List environments in the organization available to the current user + * @summary List environments in the organization + * @param {string} orgName Organization name + * @param {string} [continuationToken] continuation Token from previous query to fetch next page of results + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof EscApi + */ + public listEnvironments(orgName: string, continuationToken?: string, options?: RawAxiosRequestConfig) { + return EscApiFp(this.configuration).listEnvironments(orgName, continuationToken, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * Opens a session the given environment for the indicated duration. This returns a session id that can be used to then read values. The default duration is 1 hour. + * @summary Open an environment session + * @param {string} orgName Organization name + * @param {string} envName Environment name + * @param {string} [duration] open duration - A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as “300ms”, “1.5h” or “2h45m”. Valid time units are “ns”, “us” (or “µs”), “ms”, “s”, “m”, “h”. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof EscApi + */ + public openEnvironment(orgName: string, envName: string, duration?: string, options?: RawAxiosRequestConfig) { + return EscApiFp(this.configuration).openEnvironment(orgName, envName, duration, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * Reads and decrypts secrets including retrieving dynamic secrets from providers. + * @summary Read an open environment + * @param {string} orgName Organization name + * @param {string} envName Environment name + * @param {string} openSessionID Open session ID returned from environment open + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof EscApi + */ + public readOpenEnvironment(orgName: string, envName: string, openSessionID: string, options?: RawAxiosRequestConfig) { + return EscApiFp(this.configuration).readOpenEnvironment(orgName, envName, openSessionID, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * Reads and decrypts secrets including retrieving dynamic secrets from providers. + * @summary Read an open environment + * @param {string} orgName Organization name + * @param {string} envName Environment name + * @param {string} openSessionID Open session ID returned from environment open + * @param {string} property Path to a specific property using Pulumi path syntax https://www.pulumi.com/docs/concepts/config/#structured-configuration + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof EscApi + */ + public readOpenEnvironmentProperty(orgName: string, envName: string, openSessionID: string, property: string, options?: RawAxiosRequestConfig) { + return EscApiFp(this.configuration).readOpenEnvironmentProperty(orgName, envName, openSessionID, property, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * Validates and updates the given environment\'s definition. + * @summary Update an existing environment with Yaml file + * @param {string} orgName Organization name + * @param {string} envName Environment name + * @param {string} body Environment Yaml content + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof EscApi + */ + public updateEnvironmentYaml(orgName: string, envName: string, body: string, options?: RawAxiosRequestConfig) { + return EscApiFp(this.configuration).updateEnvironmentYaml(orgName, envName, body, options).then((request) => request(this.axios, this.basePath)); + } +} + + + diff --git a/sdk/typescript/esc/raw/base.ts b/sdk/typescript/esc/raw/base.ts new file mode 100644 index 00000000..864bdda2 --- /dev/null +++ b/sdk/typescript/esc/raw/base.ts @@ -0,0 +1,88 @@ +/* tslint:disable */ +/* eslint-disable */ +// Copyright 2024, Pulumi Corporation. All rights reserved. + +/** + * ESC (Environments, Secrets, Config) API + * Pulumi ESC allows you to compose and manage hierarchical collections of configuration and secrets and consume them in various ways. + * + * The version of the OpenAPI document: 0.1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +import type { Configuration } from './configuration'; +// Some imports not used depending on template conditions +// @ts-ignore +import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios'; +import globalAxios from 'axios'; + +export const BASE_PATH = "https://api.pulumi.com/api/preview".replace(/\/+$/, ""); + +/** + * + * @export + */ +export const COLLECTION_FORMATS = { + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|", +}; + +/** + * + * @export + * @interface RequestArgs + */ +export interface RequestArgs { + url: string; + options: RawAxiosRequestConfig; +} + +/** + * + * @export + * @class BaseAPI + */ +export class BaseAPI { + protected configuration: Configuration | undefined; + + constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) { + if (configuration) { + this.configuration = configuration; + this.basePath = configuration.basePath ?? basePath; + } + } +}; + +/** + * + * @export + * @class RequiredError + * @extends {Error} + */ +export class RequiredError extends Error { + constructor(public field: string, msg?: string) { + super(msg); + this.name = "RequiredError" + } +} + +interface ServerMap { + [key: string]: { + url: string, + description: string, + }[]; +} + +/** + * + * @export + */ +export const operationServerMap: ServerMap = { +} diff --git a/sdk/typescript/esc/raw/common.ts b/sdk/typescript/esc/raw/common.ts new file mode 100644 index 00000000..190ea20f --- /dev/null +++ b/sdk/typescript/esc/raw/common.ts @@ -0,0 +1,152 @@ +/* tslint:disable */ +/* eslint-disable */ +// Copyright 2024, Pulumi Corporation. All rights reserved. + +/** + * ESC (Environments, Secrets, Config) API + * Pulumi ESC allows you to compose and manage hierarchical collections of configuration and secrets and consume them in various ways. + * + * The version of the OpenAPI document: 0.1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +import type { Configuration } from "./configuration"; +import type { RequestArgs } from "./base"; +import type { AxiosInstance, AxiosResponse } from 'axios'; +import { RequiredError } from "./base"; + +/** + * + * @export + */ +export const DUMMY_BASE_URL = 'https://example.com' + +/** + * + * @throws {RequiredError} + * @export + */ +export const assertParamExists = function (functionName: string, paramName: string, paramValue: unknown) { + if (paramValue === null || paramValue === undefined) { + throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`); + } +} + +/** + * + * @export + */ +export const setApiKeyToObject = async function (object: any, keyParamName: string, configuration?: Configuration) { + if (configuration && configuration.apiKey) { + const localVarApiKeyValue = typeof configuration.apiKey === 'function' + ? await configuration.apiKey(keyParamName) + : await configuration.apiKey; + object[keyParamName] = localVarApiKeyValue; + } +} + +/** + * + * @export + */ +export const setBasicAuthToObject = function (object: any, configuration?: Configuration) { + if (configuration && (configuration.username || configuration.password)) { + object["auth"] = { username: configuration.username, password: configuration.password }; + } +} + +/** + * + * @export + */ +export const setBearerAuthToObject = async function (object: any, configuration?: Configuration) { + if (configuration && configuration.accessToken) { + const accessToken = typeof configuration.accessToken === 'function' + ? await configuration.accessToken() + : await configuration.accessToken; + object["Authorization"] = "Bearer " + accessToken; + } +} + +/** + * + * @export + */ +export const setOAuthToObject = async function (object: any, name: string, scopes: string[], configuration?: Configuration) { + if (configuration && configuration.accessToken) { + const localVarAccessTokenValue = typeof configuration.accessToken === 'function' + ? await configuration.accessToken(name, scopes) + : await configuration.accessToken; + object["Authorization"] = "Bearer " + localVarAccessTokenValue; + } +} + +function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void { + if (parameter == null) return; + if (typeof parameter === "object") { + if (Array.isArray(parameter)) { + (parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key)); + } + else { + Object.keys(parameter).forEach(currentKey => + setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== '' ? '.' : ''}${currentKey}`) + ); + } + } + else { + if (urlSearchParams.has(key)) { + urlSearchParams.append(key, parameter); + } + else { + urlSearchParams.set(key, parameter); + } + } +} + +/** + * + * @export + */ +export const setSearchParams = function (url: URL, ...objects: any[]) { + const searchParams = new URLSearchParams(url.search); + setFlattenedQueryParams(searchParams, objects); + url.search = searchParams.toString(); +} + +/** + * + * @export + */ +export const serializeDataIfNeeded = function (value: any, requestOptions: any, configuration?: Configuration) { + const nonString = typeof value !== 'string'; + const needsSerialization = nonString && configuration && configuration.isJsonMime + ? configuration.isJsonMime(requestOptions.headers['Content-Type']) + : nonString; + return needsSerialization + ? JSON.stringify(value !== undefined ? value : {}) + : (value || ""); +} + +/** + * + * @export + */ +export const toPathString = function (url: URL) { + return url.pathname + url.search + url.hash +} + +/** + * + * @export + */ +export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) { + return >(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { + const axiosRequestArgs = {...axiosArgs.options, url: (axios.defaults.baseURL ? '' : configuration?.basePath ?? basePath) + axiosArgs.url}; + return axios.request(axiosRequestArgs); + }; +} diff --git a/sdk/typescript/esc/raw/configuration.ts b/sdk/typescript/esc/raw/configuration.ts new file mode 100644 index 00000000..ed6a91c5 --- /dev/null +++ b/sdk/typescript/esc/raw/configuration.ts @@ -0,0 +1,112 @@ +/* tslint:disable */ +/* eslint-disable */ +// Copyright 2024, Pulumi Corporation. All rights reserved. + +/** + * ESC (Environments, Secrets, Config) API + * Pulumi ESC allows you to compose and manage hierarchical collections of configuration and secrets and consume them in various ways. + * + * The version of the OpenAPI document: 0.1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +export interface ConfigurationParameters { + apiKey?: string | Promise | ((name: string) => string) | ((name: string) => Promise); + username?: string; + password?: string; + accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise); + basePath?: string; + serverIndex?: number; + baseOptions?: any; + formDataCtor?: new () => any; +} + +export class Configuration { + /** + * parameter for apiKey security + * @param name security name + * @memberof Configuration + */ + apiKey?: string | Promise | ((name: string) => string) | ((name: string) => Promise); + /** + * parameter for basic security + * + * @type {string} + * @memberof Configuration + */ + username?: string; + /** + * parameter for basic security + * + * @type {string} + * @memberof Configuration + */ + password?: string; + /** + * parameter for oauth2 security + * @param name security name + * @param scopes oauth2 scope + * @memberof Configuration + */ + accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise); + /** + * override base path + * + * @type {string} + * @memberof Configuration + */ + basePath?: string; + /** + * override server index + * + * @type {number} + * @memberof Configuration + */ + serverIndex?: number; + /** + * base options for axios calls + * + * @type {any} + * @memberof Configuration + */ + baseOptions?: any; + /** + * The FormData constructor that will be used to create multipart form data + * requests. You can inject this here so that execution environments that + * do not support the FormData class can still run the generated client. + * + * @type {new () => FormData} + */ + formDataCtor?: new () => any; + + constructor(param: ConfigurationParameters = {}) { + this.apiKey = param.apiKey; + this.username = param.username; + this.password = param.password; + this.accessToken = param.accessToken; + this.basePath = param.basePath; + this.serverIndex = param.serverIndex; + this.baseOptions = param.baseOptions; + this.formDataCtor = param.formDataCtor; + } + + /** + * Check if the given MIME is a JSON MIME. + * JSON MIME examples: + * application/json + * application/json; charset=UTF8 + * APPLICATION/JSON + * application/vnd.company+json + * @param mime - MIME (Multipurpose Internet Mail Extensions) + * @return True if the given MIME is JSON, false otherwise. + */ + public isJsonMime(mime: string): boolean { + const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i'); + return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json'); + } +} diff --git a/sdk/typescript/esc/raw/index.ts b/sdk/typescript/esc/raw/index.ts new file mode 100644 index 00000000..f2abe205 --- /dev/null +++ b/sdk/typescript/esc/raw/index.ts @@ -0,0 +1,20 @@ +/* tslint:disable */ +/* eslint-disable */ +// Copyright 2024, Pulumi Corporation. All rights reserved. + +/** + * ESC (Environments, Secrets, Config) API + * Pulumi ESC allows you to compose and manage hierarchical collections of configuration and secrets and consume them in various ways. + * + * The version of the OpenAPI document: 0.1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +export * from "./api"; +export * from "./configuration"; + diff --git a/sdk/typescript/esc/raw/tsconfig.json b/sdk/typescript/esc/raw/tsconfig.json new file mode 100644 index 00000000..d953a374 --- /dev/null +++ b/sdk/typescript/esc/raw/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "declaration": true, + "target": "ES5", + "module": "commonjs", + "noImplicitAny": true, + "outDir": "dist", + "rootDir": ".", + "lib": [ + "es6", + "dom" + ], + "typeRoots": [ + "node_modules/@types" + ] + }, + "exclude": [ + "dist", + "node_modules" + ] +} diff --git a/sdk/typescript/jasmine.json b/sdk/typescript/jasmine.json new file mode 100644 index 00000000..cabdac9c --- /dev/null +++ b/sdk/typescript/jasmine.json @@ -0,0 +1,13 @@ +{ + "spec_dir": "spec", + "spec_files": [ + "**/*[sS]pec.?ts" + ], + "helpers": [ + "helpers/**/*.?ts" + ], + "env": { + "stopSpecOnExpectationFailure": false, + "random": true + } +} diff --git a/sdk/typescript/package.json b/sdk/typescript/package.json new file mode 100644 index 00000000..6d6ab48d --- /dev/null +++ b/sdk/typescript/package.json @@ -0,0 +1,46 @@ +{ + "name": "@pulumi/esc-sdk", + "version": "0.0.1", + "description": "NodeJS SDK for Pulumi ESC", + "repository": { + "type": "git", + "url": "https://github.com/pulumi/esc.git", + "directory": "sdk/nodejs" + }, + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/pulumi/esc/issues" + }, + "homepage": "https://github.com/pulumi/esc#readme", + "devDependencies": { + "@types/js-yaml": "^4.0.9", + "@types/node": "^20.10.5", + "@typescript-eslint/eslint-plugin": "^6.15.0", + "@typescript-eslint/parser": "^6.15.0", + "eslint": "^8.56.0", + "eslint-config-prettier": "^9.1.0", + "eslint-plugin-prettier": "^5.1.2", + "jasmine": "^5.1.0", + "prettier": "^3.1.1", + "tsx": "^4.7.0", + "typescript": "^5.4.2" + }, + "dependencies": { + "axios": "^1.6.7", + "js-yaml": "^4.1.0", + "ts-node": "^10.9.2", + "tsc": "^2.0.4", + "yaml": "^2.3.4" + }, + "scripts": { + "format": "prettier --write .", + "lint": "eslint --ext .ts .", + "build": "rm -rf ./bin && tsc", + "test": "tsx --test ./test/*.ts" + }, + "prettier": { + "printWidth": 120, + "tabWidth": 4, + "trailingComma": "all" + } +} diff --git a/sdk/typescript/test/client.spec.ts b/sdk/typescript/test/client.spec.ts new file mode 100644 index 00000000..6abf45d5 --- /dev/null +++ b/sdk/typescript/test/client.spec.ts @@ -0,0 +1,161 @@ +// Copyright 2024, Pulumi Corporation. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import { after, before, describe, it } from "node:test"; +import assert from "assert"; +import * as esc from "../esc"; + +const ENV_PREFIX = "sdk-ts-test"; +describe("ESC", async () => { + + const PULUMI_ACCESS_TOKEN = process.env.PULUMI_ACCESS_TOKEN; + const PULUMI_ORG = process.env.PULUMI_ORG; + if (!PULUMI_ACCESS_TOKEN) { + throw new Error("PULUMI_ACCESS_TOKEN not set"); + } + if (!PULUMI_ORG) { + throw new Error("PULUMI_ORG not set"); + } + let config = new esc.Configuration(); + config.apiKey = `token ${PULUMI_ACCESS_TOKEN}`; + const client = new esc.EscApi(config); + const baseEnvName = `${ENV_PREFIX}-base-${Date.now()}`; + + before(async () => { + + const envDef: esc.EnvironmentDefinition = { + values: { + base: baseEnvName, + }, + } + await removeAllTestEnvs(client, PULUMI_ORG); + await client.createEnvironment(PULUMI_ORG, baseEnvName); + await client.updateEnvironment(PULUMI_ORG, baseEnvName, envDef); + }); + + after(async () => { + await client.deleteEnvironment(PULUMI_ORG, baseEnvName); + }); + + it("should create, list, update, get, decrypt, open and delete an environment", async () => { + const name = `${ENV_PREFIX}-${Date.now()}`; + + await assert.doesNotReject(client.createEnvironment(PULUMI_ORG, name)); + const orgs = await client.listEnvironments(PULUMI_ORG); + assert.notEqual(orgs, undefined); + assert(orgs?.environments?.some((e) => e.name === name)) + + const envDef: esc.EnvironmentDefinition = { + imports: [baseEnvName], + values: { + foo: "bar", + my_secret: { + "fn::secret": "shh! don't tell anyone", + }, + my_array: [1, 2, 3], + pulumiConfig: { + foo: "${foo}", + }, + environmentVariables: { + FOO: "${foo}", + }, + }, + } + const diags = await client.updateEnvironment(PULUMI_ORG, name, envDef) + assert.notEqual(diags, undefined); + assert.equal(diags?.diagnostics, undefined); + + const env = await client.getEnvironment(PULUMI_ORG, name) + + assert.notEqual(env, undefined); + assertEnvDef(env!, baseEnvName); + assert.notEqual(env?.definition?.values?.my_secret, undefined); + + const decryptEnv = await client.decryptEnvironment(PULUMI_ORG, name); + + assert.notEqual(decryptEnv, undefined); + assertEnvDef(decryptEnv!, baseEnvName); + assert.equal(decryptEnv?.definition?.values?.my_secret["fn::secret"], "shh! don't tell anyone"); + + const openEnv = await client.openAndReadEnvironment(PULUMI_ORG, name); + + assert.equal(openEnv?.values?.base, baseEnvName); + assert.equal(openEnv?.values?.foo, "bar"); + assert.deepEqual(openEnv?.values?.my_array, [1, 2, 3]); + assert.deepEqual(openEnv?.values?.my_secret, "shh! don't tell anyone"); + assert.equal(openEnv?.values?.pulumiConfig?.foo, "bar"); + assert.equal(openEnv?.values?.environmentVariables?.FOO, "bar"); + console.log("test"); + + const openInfo = await client.openEnvironment(PULUMI_ORG, name); + assert.notEqual(openInfo, undefined); + + const value = await client.readOpenEnvironmentProperty(PULUMI_ORG, name, openInfo?.id!, "pulumiConfig.foo"); + assert.equal(value?.value, "bar"); + + await client.deleteEnvironment(PULUMI_ORG, name); + }); + + it("check environment valid", async () => { + const envDef: esc.EnvironmentDefinition = { + values: { + foo: "bar", + }, + } + + const diags = await client.checkEnvironment(PULUMI_ORG, envDef) + assert.notEqual(diags, undefined); + assert.equal(diags?.diagnostics?.length, 0); + }); + + it("check environment invalid", async () => { + const envDef: esc.EnvironmentDefinition = { + values: { + foo: "bar", + pulumiConfig: { + foo: "${bad_ref}", + }, + }, + } + const diags = await client.checkEnvironment(PULUMI_ORG, envDef) + assert.notEqual(diags, undefined); + assert.equal(diags?.diagnostics?.length, 1) + assert.equal(diags?.diagnostics?.[0].summary, "unknown property \"bad_ref\"") + }); +}); + +function assertEnvDef(env: esc.EnvironmentDefinitionResponse, baseEnvName: string) { + assert.equal(env.definition?.imports?.length, 1); + assert.equal(env.definition?.imports?.[0], baseEnvName); + assert.equal(env.definition?.values?.foo, "bar"); + assert.deepEqual(env.definition?.values?.my_array, [1, 2, 3]); + assert.equal(env.definition?.values?.pulumiConfig?.foo, "${foo}"); + assert.equal(env.definition?.values?.environmentVariables?.FOO, "${foo}"); +} + +async function removeAllTestEnvs(client: esc.EscApi, orgName: string): Promise { + let continuationToken: string | undefined = undefined; + do { + const orgs: esc.OrgEnvironments | undefined = await client.listEnvironments(orgName, continuationToken); + + assert.notEqual(orgs, undefined); + orgs?.environments?.forEach(async (e: esc.OrgEnvironment) => { + if (e.name.startsWith(ENV_PREFIX)) { + await client.deleteEnvironment(orgName, e.name); + } + }); + + continuationToken = orgs?.nextToken; + } while (continuationToken !== undefined && continuationToken !== ""); +} diff --git a/sdk/typescript/tsconfig.json b/sdk/typescript/tsconfig.json new file mode 100644 index 00000000..1c7a37ff --- /dev/null +++ b/sdk/typescript/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "strict": true, + "outDir": "bin", + "target": "es2016", + "module": "commonjs", + "moduleResolution": "node", + "declaration": true, + "resolveJsonModule": true, + "sourceMap": true, + "stripInternal": true, + "experimentalDecorators": true, + "pretty": true, + "noFallthroughCasesInSwitch": true, + "noImplicitReturns": true, + "forceConsistentCasingInFileNames": true, + "esModuleInterop": true, + "skipLibCheck": true, + "baseUrl": "./esc" + }, + "lib": ["es2017"], + "include": ["src/**/*", "test/**/*"], +} \ No newline at end of file diff --git a/sdk/typescript/yarn.lock b/sdk/typescript/yarn.lock new file mode 100644 index 00000000..d3b42a5e --- /dev/null +++ b/sdk/typescript/yarn.lock @@ -0,0 +1,1456 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@aashutoshrathi/word-wrap@^1.2.3": + version "1.2.6" + resolved "https://registry.yarnpkg.com/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz#bd9154aec9983f77b3a034ecaa015c2e4201f6cf" + integrity sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA== + +"@cspotcode/source-map-support@^0.8.0": + version "0.8.1" + resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz#00629c35a688e05a88b1cda684fb9d5e73f000a1" + integrity sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw== + dependencies: + "@jridgewell/trace-mapping" "0.3.9" + +"@esbuild/aix-ppc64@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/aix-ppc64/-/aix-ppc64-0.19.12.tgz#d1bc06aedb6936b3b6d313bf809a5a40387d2b7f" + integrity sha512-bmoCYyWdEL3wDQIVbcyzRyeKLgk2WtWLTWz1ZIAZF/EGbNOwSA6ew3PftJ1PqMiOOGu0OyFMzG53L0zqIpPeNA== + +"@esbuild/android-arm64@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.19.12.tgz#7ad65a36cfdb7e0d429c353e00f680d737c2aed4" + integrity sha512-P0UVNGIienjZv3f5zq0DP3Nt2IE/3plFzuaS96vihvD0Hd6H/q4WXUGpCxD/E8YrSXfNyRPbpTq+T8ZQioSuPA== + +"@esbuild/android-arm@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.19.12.tgz#b0c26536f37776162ca8bde25e42040c203f2824" + integrity sha512-qg/Lj1mu3CdQlDEEiWrlC4eaPZ1KztwGJ9B6J+/6G+/4ewxJg7gqj8eVYWvao1bXrqGiW2rsBZFSX3q2lcW05w== + +"@esbuild/android-x64@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.19.12.tgz#cb13e2211282012194d89bf3bfe7721273473b3d" + integrity sha512-3k7ZoUW6Q6YqhdhIaq/WZ7HwBpnFBlW905Fa4s4qWJyiNOgT1dOqDiVAQFwBH7gBRZr17gLrlFCRzF6jFh7Kew== + +"@esbuild/darwin-arm64@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.19.12.tgz#cbee41e988020d4b516e9d9e44dd29200996275e" + integrity sha512-B6IeSgZgtEzGC42jsI+YYu9Z3HKRxp8ZT3cqhvliEHovq8HSX2YX8lNocDn79gCKJXOSaEot9MVYky7AKjCs8g== + +"@esbuild/darwin-x64@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.19.12.tgz#e37d9633246d52aecf491ee916ece709f9d5f4cd" + integrity sha512-hKoVkKzFiToTgn+41qGhsUJXFlIjxI/jSYeZf3ugemDYZldIXIxhvwN6erJGlX4t5h417iFuheZ7l+YVn05N3A== + +"@esbuild/freebsd-arm64@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.19.12.tgz#1ee4d8b682ed363b08af74d1ea2b2b4dbba76487" + integrity sha512-4aRvFIXmwAcDBw9AueDQ2YnGmz5L6obe5kmPT8Vd+/+x/JMVKCgdcRwH6APrbpNXsPz+K653Qg8HB/oXvXVukA== + +"@esbuild/freebsd-x64@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.19.12.tgz#37a693553d42ff77cd7126764b535fb6cc28a11c" + integrity sha512-EYoXZ4d8xtBoVN7CEwWY2IN4ho76xjYXqSXMNccFSx2lgqOG/1TBPW0yPx1bJZk94qu3tX0fycJeeQsKovA8gg== + +"@esbuild/linux-arm64@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.19.12.tgz#be9b145985ec6c57470e0e051d887b09dddb2d4b" + integrity sha512-EoTjyYyLuVPfdPLsGVVVC8a0p1BFFvtpQDB/YLEhaXyf/5bczaGeN15QkR+O4S5LeJ92Tqotve7i1jn35qwvdA== + +"@esbuild/linux-arm@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.19.12.tgz#207ecd982a8db95f7b5279207d0ff2331acf5eef" + integrity sha512-J5jPms//KhSNv+LO1S1TX1UWp1ucM6N6XuL6ITdKWElCu8wXP72l9MM0zDTzzeikVyqFE6U8YAV9/tFyj0ti+w== + +"@esbuild/linux-ia32@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.19.12.tgz#d0d86b5ca1562523dc284a6723293a52d5860601" + integrity sha512-Thsa42rrP1+UIGaWz47uydHSBOgTUnwBwNq59khgIwktK6x60Hivfbux9iNR0eHCHzOLjLMLfUMLCypBkZXMHA== + +"@esbuild/linux-loong64@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.19.12.tgz#9a37f87fec4b8408e682b528391fa22afd952299" + integrity sha512-LiXdXA0s3IqRRjm6rV6XaWATScKAXjI4R4LoDlvO7+yQqFdlr1Bax62sRwkVvRIrwXxvtYEHHI4dm50jAXkuAA== + +"@esbuild/linux-mips64el@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.19.12.tgz#4ddebd4e6eeba20b509d8e74c8e30d8ace0b89ec" + integrity sha512-fEnAuj5VGTanfJ07ff0gOA6IPsvrVHLVb6Lyd1g2/ed67oU1eFzL0r9WL7ZzscD+/N6i3dWumGE1Un4f7Amf+w== + +"@esbuild/linux-ppc64@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.19.12.tgz#adb67dadb73656849f63cd522f5ecb351dd8dee8" + integrity sha512-nYJA2/QPimDQOh1rKWedNOe3Gfc8PabU7HT3iXWtNUbRzXS9+vgB0Fjaqr//XNbd82mCxHzik2qotuI89cfixg== + +"@esbuild/linux-riscv64@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.19.12.tgz#11bc0698bf0a2abf8727f1c7ace2112612c15adf" + integrity sha512-2MueBrlPQCw5dVJJpQdUYgeqIzDQgw3QtiAHUC4RBz9FXPrskyyU3VI1hw7C0BSKB9OduwSJ79FTCqtGMWqJHg== + +"@esbuild/linux-s390x@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.19.12.tgz#e86fb8ffba7c5c92ba91fc3b27ed5a70196c3cc8" + integrity sha512-+Pil1Nv3Umes4m3AZKqA2anfhJiVmNCYkPchwFJNEJN5QxmTs1uzyy4TvmDrCRNT2ApwSari7ZIgrPeUx4UZDg== + +"@esbuild/linux-x64@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.19.12.tgz#5f37cfdc705aea687dfe5dfbec086a05acfe9c78" + integrity sha512-B71g1QpxfwBvNrfyJdVDexenDIt1CiDN1TIXLbhOw0KhJzE78KIFGX6OJ9MrtC0oOqMWf+0xop4qEU8JrJTwCg== + +"@esbuild/netbsd-x64@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.19.12.tgz#29da566a75324e0d0dd7e47519ba2f7ef168657b" + integrity sha512-3ltjQ7n1owJgFbuC61Oj++XhtzmymoCihNFgT84UAmJnxJfm4sYCiSLTXZtE00VWYpPMYc+ZQmB6xbSdVh0JWA== + +"@esbuild/openbsd-x64@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.19.12.tgz#306c0acbdb5a99c95be98bdd1d47c916e7dc3ff0" + integrity sha512-RbrfTB9SWsr0kWmb9srfF+L933uMDdu9BIzdA7os2t0TXhCRjrQyCeOt6wVxr79CKD4c+p+YhCj31HBkYcXebw== + +"@esbuild/sunos-x64@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.19.12.tgz#0933eaab9af8b9b2c930236f62aae3fc593faf30" + integrity sha512-HKjJwRrW8uWtCQnQOz9qcU3mUZhTUQvi56Q8DPTLLB+DawoiQdjsYq+j+D3s9I8VFtDr+F9CjgXKKC4ss89IeA== + +"@esbuild/win32-arm64@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.19.12.tgz#773bdbaa1971b36db2f6560088639ccd1e6773ae" + integrity sha512-URgtR1dJnmGvX864pn1B2YUYNzjmXkuJOIqG2HdU62MVS4EHpU2946OZoTMnRUHklGtJdJZ33QfzdjGACXhn1A== + +"@esbuild/win32-ia32@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.19.12.tgz#000516cad06354cc84a73f0943a4aa690ef6fd67" + integrity sha512-+ZOE6pUkMOJfmxmBZElNOx72NKpIa/HFOMGzu8fqzQJ5kgf6aTGrcJaFsNiVMH4JKpMipyK+7k0n2UXN7a8YKQ== + +"@esbuild/win32-x64@0.19.12": + version "0.19.12" + resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.19.12.tgz#c57c8afbb4054a3ab8317591a0b7320360b444ae" + integrity sha512-T1QyPSDCyMXaO3pzBkF96E8xMkiRYbUEZADd29SyPGabqxMViNoii+NcK7eWJAEoU6RZyEm5lVSIjTmcdoB9HA== + +"@eslint-community/eslint-utils@^4.2.0", "@eslint-community/eslint-utils@^4.4.0": + version "4.4.0" + resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz#a23514e8fb9af1269d5f7788aa556798d61c6b59" + integrity sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA== + dependencies: + eslint-visitor-keys "^3.3.0" + +"@eslint-community/regexpp@^4.5.1", "@eslint-community/regexpp@^4.6.1": + version "4.10.0" + resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.10.0.tgz#548f6de556857c8bb73bbee70c35dc82a2e74d63" + integrity sha512-Cu96Sd2By9mCNTx2iyKOmq10v22jUVQv0lQnlGNy16oE9589yE+QADPbrMGCkA51cKZSg3Pu/aTJVTGfL/qjUA== + +"@eslint/eslintrc@^2.1.4": + version "2.1.4" + resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-2.1.4.tgz#388a269f0f25c1b6adc317b5a2c55714894c70ad" + integrity sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ== + dependencies: + ajv "^6.12.4" + debug "^4.3.2" + espree "^9.6.0" + globals "^13.19.0" + ignore "^5.2.0" + import-fresh "^3.2.1" + js-yaml "^4.1.0" + minimatch "^3.1.2" + strip-json-comments "^3.1.1" + +"@eslint/js@8.57.0": + version "8.57.0" + resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.57.0.tgz#a5417ae8427873f1dd08b70b3574b453e67b5f7f" + integrity sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g== + +"@humanwhocodes/config-array@^0.11.14": + version "0.11.14" + resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.14.tgz#d78e481a039f7566ecc9660b4ea7fe6b1fec442b" + integrity sha512-3T8LkOmg45BV5FICb15QQMsyUSWrQ8AygVfC7ZG32zOalnqrilm018ZVCw0eapXux8FtA33q8PSRSstjee3jSg== + dependencies: + "@humanwhocodes/object-schema" "^2.0.2" + debug "^4.3.1" + minimatch "^3.0.5" + +"@humanwhocodes/module-importer@^1.0.1": + version "1.0.1" + resolved "https://registry.yarnpkg.com/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz#af5b2691a22b44be847b0ca81641c5fb6ad0172c" + integrity sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA== + +"@humanwhocodes/object-schema@^2.0.2": + version "2.0.2" + resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-2.0.2.tgz#d9fae00a2d5cb40f92cfe64b47ad749fbc38f917" + integrity sha512-6EwiSjwWYP7pTckG6I5eyFANjPhmPjUX9JRLUSfNPC7FX7zK9gyZAfUEaECL6ALTpGX5AjnBq3C9XmVWPitNpw== + +"@isaacs/cliui@^8.0.2": + version "8.0.2" + resolved "https://registry.yarnpkg.com/@isaacs/cliui/-/cliui-8.0.2.tgz#b37667b7bc181c168782259bab42474fbf52b550" + integrity sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA== + dependencies: + string-width "^5.1.2" + string-width-cjs "npm:string-width@^4.2.0" + strip-ansi "^7.0.1" + strip-ansi-cjs "npm:strip-ansi@^6.0.1" + wrap-ansi "^8.1.0" + wrap-ansi-cjs "npm:wrap-ansi@^7.0.0" + +"@jridgewell/resolve-uri@^3.0.3": + version "3.1.2" + resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz#7a0ee601f60f99a20c7c7c5ff0c80388c1189bd6" + integrity sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw== + +"@jridgewell/sourcemap-codec@^1.4.10": + version "1.4.15" + resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz#d7c6e6755c78567a951e04ab52ef0fd26de59f32" + integrity sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg== + +"@jridgewell/trace-mapping@0.3.9": + version "0.3.9" + resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz#6534fd5933a53ba7cbf3a17615e273a0d1273ff9" + integrity sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ== + dependencies: + "@jridgewell/resolve-uri" "^3.0.3" + "@jridgewell/sourcemap-codec" "^1.4.10" + +"@nodelib/fs.scandir@2.1.5": + version "2.1.5" + resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" + integrity sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g== + dependencies: + "@nodelib/fs.stat" "2.0.5" + run-parallel "^1.1.9" + +"@nodelib/fs.stat@2.0.5", "@nodelib/fs.stat@^2.0.2": + version "2.0.5" + resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz#5bd262af94e9d25bd1e71b05deed44876a222e8b" + integrity sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A== + +"@nodelib/fs.walk@^1.2.3", "@nodelib/fs.walk@^1.2.8": + version "1.2.8" + resolved "https://registry.yarnpkg.com/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz#e95737e8bb6746ddedf69c556953494f196fe69a" + integrity sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg== + dependencies: + "@nodelib/fs.scandir" "2.1.5" + fastq "^1.6.0" + +"@pkgjs/parseargs@^0.11.0": + version "0.11.0" + resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33" + integrity sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg== + +"@pkgr/core@^0.1.0": + version "0.1.1" + resolved "https://registry.yarnpkg.com/@pkgr/core/-/core-0.1.1.tgz#1ec17e2edbec25c8306d424ecfbf13c7de1aaa31" + integrity sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA== + +"@tsconfig/node10@^1.0.7": + version "1.0.9" + resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.9.tgz#df4907fc07a886922637b15e02d4cebc4c0021b2" + integrity sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA== + +"@tsconfig/node12@^1.0.7": + version "1.0.11" + resolved "https://registry.yarnpkg.com/@tsconfig/node12/-/node12-1.0.11.tgz#ee3def1f27d9ed66dac6e46a295cffb0152e058d" + integrity sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag== + +"@tsconfig/node14@^1.0.0": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@tsconfig/node14/-/node14-1.0.3.tgz#e4386316284f00b98435bf40f72f75a09dabf6c1" + integrity sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow== + +"@tsconfig/node16@^1.0.2": + version "1.0.4" + resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.4.tgz#0b92dcc0cc1c81f6f306a381f28e31b1a56536e9" + integrity sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA== + +"@types/js-yaml@^4.0.9": + version "4.0.9" + resolved "https://registry.yarnpkg.com/@types/js-yaml/-/js-yaml-4.0.9.tgz#cd82382c4f902fed9691a2ed79ec68c5898af4c2" + integrity sha512-k4MGaQl5TGo/iipqb2UDG2UwjXziSWkh0uysQelTlJpX1qGlpUZYm8PnO4DxG1qBomtJUdYJ6qR6xdIah10JLg== + +"@types/json-schema@^7.0.12": + version "7.0.15" + resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841" + integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA== + +"@types/node@^20.10.5": + version "20.11.25" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.11.25.tgz#0f50d62f274e54dd7a49f7704cc16bfbcccaf49f" + integrity sha512-TBHyJxk2b7HceLVGFcpAUjsa5zIdsPWlR6XHfyGzd0SFu+/NFgQgMAl96MSDZgQDvJAvV6BKsFOrt6zIL09JDw== + dependencies: + undici-types "~5.26.4" + +"@types/semver@^7.5.0": + version "7.5.8" + resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.5.8.tgz#8268a8c57a3e4abd25c165ecd36237db7948a55e" + integrity sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ== + +"@typescript-eslint/eslint-plugin@^6.15.0": + version "6.21.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.21.0.tgz#30830c1ca81fd5f3c2714e524c4303e0194f9cd3" + integrity sha512-oy9+hTPCUFpngkEZUSzbf9MxI65wbKFoQYsgPdILTfbUldp5ovUuphZVe4i30emU9M/kP+T64Di0mxl7dSw3MA== + dependencies: + "@eslint-community/regexpp" "^4.5.1" + "@typescript-eslint/scope-manager" "6.21.0" + "@typescript-eslint/type-utils" "6.21.0" + "@typescript-eslint/utils" "6.21.0" + "@typescript-eslint/visitor-keys" "6.21.0" + debug "^4.3.4" + graphemer "^1.4.0" + ignore "^5.2.4" + natural-compare "^1.4.0" + semver "^7.5.4" + ts-api-utils "^1.0.1" + +"@typescript-eslint/parser@^6.15.0": + version "6.21.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-6.21.0.tgz#af8fcf66feee2edc86bc5d1cf45e33b0630bf35b" + integrity sha512-tbsV1jPne5CkFQCgPBcDOt30ItF7aJoZL997JSF7MhGQqOeT3svWRYxiqlfA5RUdlHN6Fi+EI9bxqbdyAUZjYQ== + dependencies: + "@typescript-eslint/scope-manager" "6.21.0" + "@typescript-eslint/types" "6.21.0" + "@typescript-eslint/typescript-estree" "6.21.0" + "@typescript-eslint/visitor-keys" "6.21.0" + debug "^4.3.4" + +"@typescript-eslint/scope-manager@6.21.0": + version "6.21.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-6.21.0.tgz#ea8a9bfc8f1504a6ac5d59a6df308d3a0630a2b1" + integrity sha512-OwLUIWZJry80O99zvqXVEioyniJMa+d2GrqpUTqi5/v5D5rOrppJVBPa0yKCblcigC0/aYAzxxqQ1B+DS2RYsg== + dependencies: + "@typescript-eslint/types" "6.21.0" + "@typescript-eslint/visitor-keys" "6.21.0" + +"@typescript-eslint/type-utils@6.21.0": + version "6.21.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-6.21.0.tgz#6473281cfed4dacabe8004e8521cee0bd9d4c01e" + integrity sha512-rZQI7wHfao8qMX3Rd3xqeYSMCL3SoiSQLBATSiVKARdFGCYSRvmViieZjqc58jKgs8Y8i9YvVVhRbHSTA4VBag== + dependencies: + "@typescript-eslint/typescript-estree" "6.21.0" + "@typescript-eslint/utils" "6.21.0" + debug "^4.3.4" + ts-api-utils "^1.0.1" + +"@typescript-eslint/types@6.21.0": + version "6.21.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-6.21.0.tgz#205724c5123a8fef7ecd195075fa6e85bac3436d" + integrity sha512-1kFmZ1rOm5epu9NZEZm1kckCDGj5UJEf7P1kliH4LKu/RkwpsfqqGmY2OOcUs18lSlQBKLDYBOGxRVtrMN5lpg== + +"@typescript-eslint/typescript-estree@6.21.0": + version "6.21.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-6.21.0.tgz#c47ae7901db3b8bddc3ecd73daff2d0895688c46" + integrity sha512-6npJTkZcO+y2/kr+z0hc4HwNfrrP4kNYh57ek7yCNlrBjWQ1Y0OS7jiZTkgumrvkX5HkEKXFZkkdFNkaW2wmUQ== + dependencies: + "@typescript-eslint/types" "6.21.0" + "@typescript-eslint/visitor-keys" "6.21.0" + debug "^4.3.4" + globby "^11.1.0" + is-glob "^4.0.3" + minimatch "9.0.3" + semver "^7.5.4" + ts-api-utils "^1.0.1" + +"@typescript-eslint/utils@6.21.0": + version "6.21.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-6.21.0.tgz#4714e7a6b39e773c1c8e97ec587f520840cd8134" + integrity sha512-NfWVaC8HP9T8cbKQxHcsJBY5YE1O33+jpMwN45qzWWaPDZgLIbo12toGMWnmhvCpd3sIxkpDw3Wv1B3dYrbDQQ== + dependencies: + "@eslint-community/eslint-utils" "^4.4.0" + "@types/json-schema" "^7.0.12" + "@types/semver" "^7.5.0" + "@typescript-eslint/scope-manager" "6.21.0" + "@typescript-eslint/types" "6.21.0" + "@typescript-eslint/typescript-estree" "6.21.0" + semver "^7.5.4" + +"@typescript-eslint/visitor-keys@6.21.0": + version "6.21.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-6.21.0.tgz#87a99d077aa507e20e238b11d56cc26ade45fe47" + integrity sha512-JJtkDduxLi9bivAB+cYOVMtbkqdPOhZ+ZI5LC47MIRrDV4Yn2o+ZnW10Nkmr28xRpSpdJ6Sm42Hjf2+REYXm0A== + dependencies: + "@typescript-eslint/types" "6.21.0" + eslint-visitor-keys "^3.4.1" + +"@ungap/structured-clone@^1.2.0": + version "1.2.0" + resolved "https://registry.yarnpkg.com/@ungap/structured-clone/-/structured-clone-1.2.0.tgz#756641adb587851b5ccb3e095daf27ae581c8406" + integrity sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ== + +acorn-jsx@^5.3.2: + version "5.3.2" + resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937" + integrity sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ== + +acorn-walk@^8.1.1: + version "8.3.2" + resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.3.2.tgz#7703af9415f1b6db9315d6895503862e231d34aa" + integrity sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A== + +acorn@^8.4.1, acorn@^8.9.0: + version "8.11.3" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.11.3.tgz#71e0b14e13a4ec160724b38fb7b0f233b1b81d7a" + integrity sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg== + +ajv@^6.12.4: + version "6.12.6" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" + integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== + dependencies: + fast-deep-equal "^3.1.1" + fast-json-stable-stringify "^2.0.0" + json-schema-traverse "^0.4.1" + uri-js "^4.2.2" + +ansi-regex@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" + integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== + +ansi-regex@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-6.0.1.tgz#3183e38fae9a65d7cb5e53945cd5897d0260a06a" + integrity sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA== + +ansi-styles@^4.0.0, ansi-styles@^4.1.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" + integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== + dependencies: + color-convert "^2.0.1" + +ansi-styles@^6.1.0: + version "6.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-6.2.1.tgz#0e62320cf99c21afff3b3012192546aacbfb05c5" + integrity sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug== + +arg@^4.1.0: + version "4.1.3" + resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089" + integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA== + +argparse@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38" + integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q== + +array-union@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d" + integrity sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw== + +asynckit@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" + integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q== + +axios@^1.6.7: + version "1.6.7" + resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.7.tgz#7b48c2e27c96f9c68a2f8f31e2ab19f59b06b0a7" + integrity sha512-/hDJGff6/c7u0hDkvkGxR/oy6CbCs8ziCsC7SqmhjfozqiJGc8Z11wrv9z9lYfY4K8l+H9TpjcMDX0xOZmx+RA== + dependencies: + follow-redirects "^1.15.4" + form-data "^4.0.0" + proxy-from-env "^1.1.0" + +balanced-match@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" + integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== + +brace-expansion@^1.1.7: + version "1.1.11" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" + integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== + dependencies: + balanced-match "^1.0.0" + concat-map "0.0.1" + +brace-expansion@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-2.0.1.tgz#1edc459e0f0c548486ecf9fc99f2221364b9a0ae" + integrity sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA== + dependencies: + balanced-match "^1.0.0" + +braces@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" + integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== + dependencies: + fill-range "^7.0.1" + +callsites@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73" + integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ== + +chalk@^4.0.0: + version "4.1.2" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" + integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== + dependencies: + ansi-styles "^4.1.0" + supports-color "^7.1.0" + +color-convert@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" + integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== + dependencies: + color-name "~1.1.4" + +color-name@~1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" + integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== + +combined-stream@^1.0.8: + version "1.0.8" + resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" + integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== + dependencies: + delayed-stream "~1.0.0" + +concat-map@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" + integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== + +create-require@^1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333" + integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ== + +cross-spawn@^7.0.0, cross-spawn@^7.0.2: + version "7.0.3" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" + integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== + dependencies: + path-key "^3.1.0" + shebang-command "^2.0.0" + which "^2.0.1" + +debug@^4.3.1, debug@^4.3.2, debug@^4.3.4: + version "4.3.4" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" + integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== + dependencies: + ms "2.1.2" + +deep-is@^0.1.3: + version "0.1.4" + resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.4.tgz#a6f2dce612fadd2ef1f519b73551f17e85199831" + integrity sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ== + +delayed-stream@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" + integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ== + +diff@^4.0.1: + version "4.0.2" + resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" + integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== + +dir-glob@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/dir-glob/-/dir-glob-3.0.1.tgz#56dbf73d992a4a93ba1584f4534063fd2e41717f" + integrity sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA== + dependencies: + path-type "^4.0.0" + +doctrine@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-3.0.0.tgz#addebead72a6574db783639dc87a121773973961" + integrity sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w== + dependencies: + esutils "^2.0.2" + +eastasianwidth@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/eastasianwidth/-/eastasianwidth-0.2.0.tgz#696ce2ec0aa0e6ea93a397ffcf24aa7840c827cb" + integrity sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA== + +emoji-regex@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" + integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== + +emoji-regex@^9.2.2: + version "9.2.2" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-9.2.2.tgz#840c8803b0d8047f4ff0cf963176b32d4ef3ed72" + integrity sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg== + +esbuild@~0.19.10: + version "0.19.12" + resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.19.12.tgz#dc82ee5dc79e82f5a5c3b4323a2a641827db3e04" + integrity sha512-aARqgq8roFBj054KvQr5f1sFu0D65G+miZRCuJyJ0G13Zwx7vRar5Zhn2tkQNzIXcBrNVsv/8stehpj+GAjgbg== + optionalDependencies: + "@esbuild/aix-ppc64" "0.19.12" + "@esbuild/android-arm" "0.19.12" + "@esbuild/android-arm64" "0.19.12" + "@esbuild/android-x64" "0.19.12" + "@esbuild/darwin-arm64" "0.19.12" + "@esbuild/darwin-x64" "0.19.12" + "@esbuild/freebsd-arm64" "0.19.12" + "@esbuild/freebsd-x64" "0.19.12" + "@esbuild/linux-arm" "0.19.12" + "@esbuild/linux-arm64" "0.19.12" + "@esbuild/linux-ia32" "0.19.12" + "@esbuild/linux-loong64" "0.19.12" + "@esbuild/linux-mips64el" "0.19.12" + "@esbuild/linux-ppc64" "0.19.12" + "@esbuild/linux-riscv64" "0.19.12" + "@esbuild/linux-s390x" "0.19.12" + "@esbuild/linux-x64" "0.19.12" + "@esbuild/netbsd-x64" "0.19.12" + "@esbuild/openbsd-x64" "0.19.12" + "@esbuild/sunos-x64" "0.19.12" + "@esbuild/win32-arm64" "0.19.12" + "@esbuild/win32-ia32" "0.19.12" + "@esbuild/win32-x64" "0.19.12" + +escape-string-regexp@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" + integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== + +eslint-config-prettier@^9.1.0: + version "9.1.0" + resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz#31af3d94578645966c082fcb71a5846d3c94867f" + integrity sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw== + +eslint-plugin-prettier@^5.1.2: + version "5.1.3" + resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-5.1.3.tgz#17cfade9e732cef32b5f5be53bd4e07afd8e67e1" + integrity sha512-C9GCVAs4Eq7ZC/XFQHITLiHJxQngdtraXaM+LoUFoFp/lHNl2Zn8f3WQbe9HvTBBQ9YnKFB0/2Ajdqwo5D1EAw== + dependencies: + prettier-linter-helpers "^1.0.0" + synckit "^0.8.6" + +eslint-scope@^7.2.2: + version "7.2.2" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-7.2.2.tgz#deb4f92563390f32006894af62a22dba1c46423f" + integrity sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg== + dependencies: + esrecurse "^4.3.0" + estraverse "^5.2.0" + +eslint-visitor-keys@^3.3.0, eslint-visitor-keys@^3.4.1, eslint-visitor-keys@^3.4.3: + version "3.4.3" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz#0cd72fe8550e3c2eae156a96a4dddcd1c8ac5800" + integrity sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag== + +eslint@^8.56.0: + version "8.57.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.57.0.tgz#c786a6fd0e0b68941aaf624596fb987089195668" + integrity sha512-dZ6+mexnaTIbSBZWgou51U6OmzIhYM2VcNdtiTtI7qPNZm35Akpr0f6vtw3w1Kmn5PYo+tZVfh13WrhpS6oLqQ== + dependencies: + "@eslint-community/eslint-utils" "^4.2.0" + "@eslint-community/regexpp" "^4.6.1" + "@eslint/eslintrc" "^2.1.4" + "@eslint/js" "8.57.0" + "@humanwhocodes/config-array" "^0.11.14" + "@humanwhocodes/module-importer" "^1.0.1" + "@nodelib/fs.walk" "^1.2.8" + "@ungap/structured-clone" "^1.2.0" + ajv "^6.12.4" + chalk "^4.0.0" + cross-spawn "^7.0.2" + debug "^4.3.2" + doctrine "^3.0.0" + escape-string-regexp "^4.0.0" + eslint-scope "^7.2.2" + eslint-visitor-keys "^3.4.3" + espree "^9.6.1" + esquery "^1.4.2" + esutils "^2.0.2" + fast-deep-equal "^3.1.3" + file-entry-cache "^6.0.1" + find-up "^5.0.0" + glob-parent "^6.0.2" + globals "^13.19.0" + graphemer "^1.4.0" + ignore "^5.2.0" + imurmurhash "^0.1.4" + is-glob "^4.0.0" + is-path-inside "^3.0.3" + js-yaml "^4.1.0" + json-stable-stringify-without-jsonify "^1.0.1" + levn "^0.4.1" + lodash.merge "^4.6.2" + minimatch "^3.1.2" + natural-compare "^1.4.0" + optionator "^0.9.3" + strip-ansi "^6.0.1" + text-table "^0.2.0" + +espree@^9.6.0, espree@^9.6.1: + version "9.6.1" + resolved "https://registry.yarnpkg.com/espree/-/espree-9.6.1.tgz#a2a17b8e434690a5432f2f8018ce71d331a48c6f" + integrity sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ== + dependencies: + acorn "^8.9.0" + acorn-jsx "^5.3.2" + eslint-visitor-keys "^3.4.1" + +esquery@^1.4.2: + version "1.5.0" + resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.5.0.tgz#6ce17738de8577694edd7361c57182ac8cb0db0b" + integrity sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg== + dependencies: + estraverse "^5.1.0" + +esrecurse@^4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.3.0.tgz#7ad7964d679abb28bee72cec63758b1c5d2c9921" + integrity sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag== + dependencies: + estraverse "^5.2.0" + +estraverse@^5.1.0, estraverse@^5.2.0: + version "5.3.0" + resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.3.0.tgz#2eea5290702f26ab8fe5370370ff86c965d21123" + integrity sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA== + +esutils@^2.0.2: + version "2.0.3" + resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" + integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== + +fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: + version "3.1.3" + resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" + integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== + +fast-diff@^1.1.2: + version "1.3.0" + resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.3.0.tgz#ece407fa550a64d638536cd727e129c61616e0f0" + integrity sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw== + +fast-glob@^3.2.9: + version "3.3.2" + resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.3.2.tgz#a904501e57cfdd2ffcded45e99a54fef55e46129" + integrity sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow== + dependencies: + "@nodelib/fs.stat" "^2.0.2" + "@nodelib/fs.walk" "^1.2.3" + glob-parent "^5.1.2" + merge2 "^1.3.0" + micromatch "^4.0.4" + +fast-json-stable-stringify@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" + integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== + +fast-levenshtein@^2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" + integrity sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw== + +fastq@^1.6.0: + version "1.17.1" + resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.17.1.tgz#2a523f07a4e7b1e81a42b91b8bf2254107753b47" + integrity sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w== + dependencies: + reusify "^1.0.4" + +file-entry-cache@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-6.0.1.tgz#211b2dd9659cb0394b073e7323ac3c933d522027" + integrity sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg== + dependencies: + flat-cache "^3.0.4" + +fill-range@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" + integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== + dependencies: + to-regex-range "^5.0.1" + +find-up@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-5.0.0.tgz#4c92819ecb7083561e4f4a240a86be5198f536fc" + integrity sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng== + dependencies: + locate-path "^6.0.0" + path-exists "^4.0.0" + +flat-cache@^3.0.4: + version "3.2.0" + resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-3.2.0.tgz#2c0c2d5040c99b1632771a9d105725c0115363ee" + integrity sha512-CYcENa+FtcUKLmhhqyctpclsq7QF38pKjZHsGNiSQF5r4FtoKDWabFDl3hzaEQMvT1LHEysw5twgLvpYYb4vbw== + dependencies: + flatted "^3.2.9" + keyv "^4.5.3" + rimraf "^3.0.2" + +flatted@^3.2.9: + version "3.3.1" + resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.3.1.tgz#21db470729a6734d4997002f439cb308987f567a" + integrity sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw== + +follow-redirects@^1.15.4: + version "1.15.5" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.5.tgz#54d4d6d062c0fa7d9d17feb008461550e3ba8020" + integrity sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw== + +foreground-child@^3.1.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/foreground-child/-/foreground-child-3.1.1.tgz#1d173e776d75d2772fed08efe4a0de1ea1b12d0d" + integrity sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg== + dependencies: + cross-spawn "^7.0.0" + signal-exit "^4.0.1" + +form-data@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452" + integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww== + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.8" + mime-types "^2.1.12" + +fs.realpath@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" + integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== + +fsevents@~2.3.3: + version "2.3.3" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6" + integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== + +get-tsconfig@^4.7.2: + version "4.7.3" + resolved "https://registry.yarnpkg.com/get-tsconfig/-/get-tsconfig-4.7.3.tgz#0498163d98f7b58484dd4906999c0c9d5f103f83" + integrity sha512-ZvkrzoUA0PQZM6fy6+/Hce561s+faD1rsNwhnO5FelNjyy7EMGJ3Rz1AQ8GYDWjhRs/7dBLOEJvhK8MiEJOAFg== + dependencies: + resolve-pkg-maps "^1.0.0" + +glob-parent@^5.1.2: + version "5.1.2" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" + integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== + dependencies: + is-glob "^4.0.1" + +glob-parent@^6.0.2: + version "6.0.2" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-6.0.2.tgz#6d237d99083950c79290f24c7642a3de9a28f9e3" + integrity sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A== + dependencies: + is-glob "^4.0.3" + +glob@^10.2.2: + version "10.3.10" + resolved "https://registry.yarnpkg.com/glob/-/glob-10.3.10.tgz#0351ebb809fd187fe421ab96af83d3a70715df4b" + integrity sha512-fa46+tv1Ak0UPK1TOy/pZrIybNNt4HCv7SDzwyfiOZkvZLEbjsZkJBPtDHVshZjbecAoAGSC20MjLDG/qr679g== + dependencies: + foreground-child "^3.1.0" + jackspeak "^2.3.5" + minimatch "^9.0.1" + minipass "^5.0.0 || ^6.0.2 || ^7.0.0" + path-scurry "^1.10.1" + +glob@^7.1.3: + version "7.2.3" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b" + integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q== + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.1.1" + once "^1.3.0" + path-is-absolute "^1.0.0" + +globals@^13.19.0: + version "13.24.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-13.24.0.tgz#8432a19d78ce0c1e833949c36adb345400bb1171" + integrity sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ== + dependencies: + type-fest "^0.20.2" + +globby@^11.1.0: + version "11.1.0" + resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b" + integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g== + dependencies: + array-union "^2.1.0" + dir-glob "^3.0.1" + fast-glob "^3.2.9" + ignore "^5.2.0" + merge2 "^1.4.1" + slash "^3.0.0" + +graphemer@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/graphemer/-/graphemer-1.4.0.tgz#fb2f1d55e0e3a1849aeffc90c4fa0dd53a0e66c6" + integrity sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag== + +has-flag@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" + integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== + +ignore@^5.2.0, ignore@^5.2.4: + version "5.3.1" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.3.1.tgz#5073e554cd42c5b33b394375f538b8593e34d4ef" + integrity sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw== + +import-fresh@^3.2.1: + version "3.3.0" + resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.3.0.tgz#37162c25fcb9ebaa2e6e53d5b4d88ce17d9e0c2b" + integrity sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw== + dependencies: + parent-module "^1.0.0" + resolve-from "^4.0.0" + +imurmurhash@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" + integrity sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA== + +inflight@^1.0.4: + version "1.0.6" + resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" + integrity sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA== + dependencies: + once "^1.3.0" + wrappy "1" + +inherits@2: + version "2.0.4" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" + integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== + +is-extglob@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" + integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ== + +is-fullwidth-code-point@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" + integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== + +is-glob@^4.0.0, is-glob@^4.0.1, is-glob@^4.0.3: + version "4.0.3" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" + integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== + dependencies: + is-extglob "^2.1.1" + +is-number@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" + integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== + +is-path-inside@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-3.0.3.tgz#d231362e53a07ff2b0e0ea7fed049161ffd16283" + integrity sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ== + +isexe@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" + integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw== + +jackspeak@^2.3.5: + version "2.3.6" + resolved "https://registry.yarnpkg.com/jackspeak/-/jackspeak-2.3.6.tgz#647ecc472238aee4b06ac0e461acc21a8c505ca8" + integrity sha512-N3yCS/NegsOBokc8GAdM8UcmfsKiSS8cipheD/nivzr700H+nsMOxJjQnvwOcRYVuFkdH0wGUvW2WbXGmrZGbQ== + dependencies: + "@isaacs/cliui" "^8.0.2" + optionalDependencies: + "@pkgjs/parseargs" "^0.11.0" + +jasmine-core@~5.1.0: + version "5.1.2" + resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-5.1.2.tgz#8f2789faa79ef1ffad7abab6bff8d4bd661094f7" + integrity sha512-2oIUMGn00FdUiqz6epiiJr7xcFyNYj3rDcfmnzfkBnHyBQ3cBQUs4mmyGsOb7TTLb9kxk7dBcmEmqhDKkBoDyA== + +jasmine@^5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/jasmine/-/jasmine-5.1.0.tgz#a3218fd425ff35aec12f3dc6cf70d8cebbf0042a" + integrity sha512-prmJlC1dbLhti4nE4XAPDWmfJesYO15sjGXVp7Cs7Ym5I9Xtwa/hUHxxJXjnpfLO72+ySttA0Ztf8g/RiVnUKw== + dependencies: + glob "^10.2.2" + jasmine-core "~5.1.0" + +js-yaml@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602" + integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA== + dependencies: + argparse "^2.0.1" + +json-buffer@3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/json-buffer/-/json-buffer-3.0.1.tgz#9338802a30d3b6605fbe0613e094008ca8c05a13" + integrity sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ== + +json-schema-traverse@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" + integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== + +json-stable-stringify-without-jsonify@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651" + integrity sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw== + +keyv@^4.5.3: + version "4.5.4" + resolved "https://registry.yarnpkg.com/keyv/-/keyv-4.5.4.tgz#a879a99e29452f942439f2a405e3af8b31d4de93" + integrity sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw== + dependencies: + json-buffer "3.0.1" + +levn@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/levn/-/levn-0.4.1.tgz#ae4562c007473b932a6200d403268dd2fffc6ade" + integrity sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ== + dependencies: + prelude-ls "^1.2.1" + type-check "~0.4.0" + +locate-path@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-6.0.0.tgz#55321eb309febbc59c4801d931a72452a681d286" + integrity sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw== + dependencies: + p-locate "^5.0.0" + +lodash.merge@^4.6.2: + version "4.6.2" + resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" + integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== + +lru-cache@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" + integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA== + dependencies: + yallist "^4.0.0" + +"lru-cache@^9.1.1 || ^10.0.0": + version "10.2.0" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.2.0.tgz#0bd445ca57363465900f4d1f9bd8db343a4d95c3" + integrity sha512-2bIM8x+VAf6JT4bKAljS1qUWgMsqZRPGJS6FSahIMPVvctcNhyVp7AJu7quxOW9jwkryBReKZY5tY5JYv2n/7Q== + +make-error@^1.1.1: + version "1.3.6" + resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" + integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== + +merge2@^1.3.0, merge2@^1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae" + integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== + +micromatch@^4.0.4: + version "4.0.5" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6" + integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA== + dependencies: + braces "^3.0.2" + picomatch "^2.3.1" + +mime-db@1.52.0: + version "1.52.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" + integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== + +mime-types@^2.1.12: + version "2.1.35" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" + integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== + dependencies: + mime-db "1.52.0" + +minimatch@9.0.3, minimatch@^9.0.1: + version "9.0.3" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-9.0.3.tgz#a6e00c3de44c3a542bfaae70abfc22420a6da825" + integrity sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg== + dependencies: + brace-expansion "^2.0.1" + +minimatch@^3.0.5, minimatch@^3.1.1, minimatch@^3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" + integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== + dependencies: + brace-expansion "^1.1.7" + +"minipass@^5.0.0 || ^6.0.2 || ^7.0.0": + version "7.0.4" + resolved "https://registry.yarnpkg.com/minipass/-/minipass-7.0.4.tgz#dbce03740f50a4786ba994c1fb908844d27b038c" + integrity sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ== + +ms@2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" + integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== + +natural-compare@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" + integrity sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw== + +once@^1.3.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w== + dependencies: + wrappy "1" + +optionator@^0.9.3: + version "0.9.3" + resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.9.3.tgz#007397d44ed1872fdc6ed31360190f81814e2c64" + integrity sha512-JjCoypp+jKn1ttEFExxhetCKeJt9zhAgAve5FXHixTvFDW/5aEktX9bufBKLRRMdU7bNtpLfcGu94B3cdEJgjg== + dependencies: + "@aashutoshrathi/word-wrap" "^1.2.3" + deep-is "^0.1.3" + fast-levenshtein "^2.0.6" + levn "^0.4.1" + prelude-ls "^1.2.1" + type-check "^0.4.0" + +p-limit@^3.0.2: + version "3.1.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.1.0.tgz#e1daccbe78d0d1388ca18c64fea38e3e57e3706b" + integrity sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ== + dependencies: + yocto-queue "^0.1.0" + +p-locate@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-5.0.0.tgz#83c8315c6785005e3bd021839411c9e110e6d834" + integrity sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw== + dependencies: + p-limit "^3.0.2" + +parent-module@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2" + integrity sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g== + dependencies: + callsites "^3.0.0" + +path-exists@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" + integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w== + +path-is-absolute@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" + integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg== + +path-key@^3.1.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" + integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== + +path-scurry@^1.10.1: + version "1.10.1" + resolved "https://registry.yarnpkg.com/path-scurry/-/path-scurry-1.10.1.tgz#9ba6bf5aa8500fe9fd67df4f0d9483b2b0bfc698" + integrity sha512-MkhCqzzBEpPvxxQ71Md0b1Kk51W01lrYvlMzSUaIzNsODdd7mqhiimSZlr+VegAz5Z6Vzt9Xg2ttE//XBhH3EQ== + dependencies: + lru-cache "^9.1.1 || ^10.0.0" + minipass "^5.0.0 || ^6.0.2 || ^7.0.0" + +path-type@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b" + integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw== + +picomatch@^2.3.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" + integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== + +prelude-ls@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" + integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g== + +prettier-linter-helpers@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz#d23d41fe1375646de2d0104d3454a3008802cf7b" + integrity sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w== + dependencies: + fast-diff "^1.1.2" + +prettier@^3.1.1: + version "3.2.5" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.2.5.tgz#e52bc3090586e824964a8813b09aba6233b28368" + integrity sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A== + +proxy-from-env@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" + integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== + +punycode@^2.1.0: + version "2.3.1" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.1.tgz#027422e2faec0b25e1549c3e1bd8309b9133b6e5" + integrity sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg== + +queue-microtask@^1.2.2: + version "1.2.3" + resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243" + integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A== + +resolve-from@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" + integrity sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g== + +resolve-pkg-maps@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz#616b3dc2c57056b5588c31cdf4b3d64db133720f" + integrity sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw== + +reusify@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76" + integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== + +rimraf@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a" + integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA== + dependencies: + glob "^7.1.3" + +run-parallel@^1.1.9: + version "1.2.0" + resolved "https://registry.yarnpkg.com/run-parallel/-/run-parallel-1.2.0.tgz#66d1368da7bdf921eb9d95bd1a9229e7f21a43ee" + integrity sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA== + dependencies: + queue-microtask "^1.2.2" + +semver@^7.5.4: + version "7.6.0" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.0.tgz#1a46a4db4bffcccd97b743b5005c8325f23d4e2d" + integrity sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg== + dependencies: + lru-cache "^6.0.0" + +shebang-command@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea" + integrity sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA== + dependencies: + shebang-regex "^3.0.0" + +shebang-regex@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" + integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== + +signal-exit@^4.0.1: + version "4.1.0" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-4.1.0.tgz#952188c1cbd546070e2dd20d0f41c0ae0530cb04" + integrity sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw== + +slash@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634" + integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q== + +"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0: + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + +string-width@^5.0.1, string-width@^5.1.2: + version "5.1.2" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794" + integrity sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA== + dependencies: + eastasianwidth "^0.2.0" + emoji-regex "^9.2.2" + strip-ansi "^7.0.1" + +"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + +strip-ansi@^7.0.1: + version "7.1.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45" + integrity sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ== + dependencies: + ansi-regex "^6.0.1" + +strip-json-comments@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" + integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== + +supports-color@^7.1.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" + integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== + dependencies: + has-flag "^4.0.0" + +synckit@^0.8.6: + version "0.8.8" + resolved "https://registry.yarnpkg.com/synckit/-/synckit-0.8.8.tgz#fe7fe446518e3d3d49f5e429f443cf08b6edfcd7" + integrity sha512-HwOKAP7Wc5aRGYdKH+dw0PRRpbO841v2DENBtjnR5HFWoiNByAl7vrx3p0G/rCyYXQsrxqtX48TImFtPcIHSpQ== + dependencies: + "@pkgr/core" "^0.1.0" + tslib "^2.6.2" + +text-table@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" + integrity sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw== + +to-regex-range@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" + integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== + dependencies: + is-number "^7.0.0" + +ts-api-utils@^1.0.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/ts-api-utils/-/ts-api-utils-1.2.1.tgz#f716c7e027494629485b21c0df6180f4d08f5e8b" + integrity sha512-RIYA36cJn2WiH9Hy77hdF9r7oEwxAtB/TS9/S4Qd90Ap4z5FSiin5zEiTL44OII1Y3IIlEvxwxFUVgrHSZ/UpA== + +ts-node@^10.9.2: + version "10.9.2" + resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.9.2.tgz#70f021c9e185bccdca820e26dc413805c101c71f" + integrity sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ== + dependencies: + "@cspotcode/source-map-support" "^0.8.0" + "@tsconfig/node10" "^1.0.7" + "@tsconfig/node12" "^1.0.7" + "@tsconfig/node14" "^1.0.0" + "@tsconfig/node16" "^1.0.2" + acorn "^8.4.1" + acorn-walk "^8.1.1" + arg "^4.1.0" + create-require "^1.1.0" + diff "^4.0.1" + make-error "^1.1.1" + v8-compile-cache-lib "^3.0.1" + yn "3.1.1" + +tsc@^2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/tsc/-/tsc-2.0.4.tgz#5f6499146abea5dca4420b451fa4f2f9345238f5" + integrity sha512-fzoSieZI5KKJVBYGvwbVZs/J5za84f2lSTLPYf6AGiIf43tZ3GNrI1QzTLcjtyDDP4aLxd46RTZq1nQxe7+k5Q== + +tslib@^2.6.2: + version "2.6.2" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae" + integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q== + +tsx@^4.7.0: + version "4.7.1" + resolved "https://registry.yarnpkg.com/tsx/-/tsx-4.7.1.tgz#27af6cbf4e1cdfcb9b5425b1c61bb7e668eb5e84" + integrity sha512-8d6VuibXHtlN5E3zFkgY8u4DX7Y3Z27zvvPKVmLon/D4AjuKzarkUBTLDBgj9iTQ0hg5xM7c/mYiRVM+HETf0g== + dependencies: + esbuild "~0.19.10" + get-tsconfig "^4.7.2" + optionalDependencies: + fsevents "~2.3.3" + +type-check@^0.4.0, type-check@~0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.4.0.tgz#07b8203bfa7056c0657050e3ccd2c37730bab8f1" + integrity sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew== + dependencies: + prelude-ls "^1.2.1" + +type-fest@^0.20.2: + version "0.20.2" + resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4" + integrity sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ== + +typescript@^5.4.2: + version "5.4.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.4.2.tgz#0ae9cebcfae970718474fe0da2c090cad6577372" + integrity sha512-+2/g0Fds1ERlP6JsakQQDXjZdZMM+rqpamFZJEKh4kwTIn3iDkgKtby0CeNd5ATNZ4Ry1ax15TMx0W2V+miizQ== + +undici-types@~5.26.4: + version "5.26.5" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617" + integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== + +uri-js@^4.2.2: + version "4.4.1" + resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.1.tgz#9b1a52595225859e55f669d928f88c6c57f2a77e" + integrity sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg== + dependencies: + punycode "^2.1.0" + +v8-compile-cache-lib@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz#6336e8d71965cb3d35a1bbb7868445a7c05264bf" + integrity sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg== + +which@^2.0.1: + version "2.0.2" + resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" + integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA== + dependencies: + isexe "^2.0.0" + +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + +wrap-ansi@^8.1.0: + version "8.1.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214" + integrity sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ== + dependencies: + ansi-styles "^6.1.0" + string-width "^5.0.1" + strip-ansi "^7.0.1" + +wrappy@1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" + integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== + +yallist@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" + integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== + +yaml@^2.3.4: + version "2.4.1" + resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.4.1.tgz#2e57e0b5e995292c25c75d2658f0664765210eed" + integrity sha512-pIXzoImaqmfOrL7teGUBt/T7ZDnyeGBWyXQBvOVhLkWLN37GXv8NMLK406UY6dS51JfcQHsmcW5cJ441bHg6Lg== + +yn@3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50" + integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q== + +yocto-queue@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" + integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==