From da308521a08f4c95e4de0cd4259e9d097229ba82 Mon Sep 17 00:00:00 2001 From: Tzrlk Date: Wed, 14 Aug 2024 13:15:03 +1200 Subject: [PATCH] #16: Simplify openapi client responses. --- .gitignore | 3 - .../templates/additional-properties.go.tmpl | 76 +++ internal/idmc/templates/imports.go.tmpl | 53 +++ internal/idmc/templates/inline.go.tmpl | 91 ++++ internal/idmc/templates/typedef.go.tmpl | 8 + .../union-and-additional-properties.go.tmpl | 74 +++ internal/idmc/templates/union.go.tmpl | 144 ++++++ internal/idmc/v2/api.go | 3 +- internal/idmc/v2/client.gen.go | 414 +---------------- internal/idmc/v2/codegen.yml | 22 +- internal/idmc/v2/types.gen.go | 439 ++++++++++++++++++ internal/idmc/v3/api.go | 3 +- internal/idmc/v3/client.gen.go | 384 +-------------- internal/idmc/v3/codegen.yml | 20 +- internal/idmc/v3/types.gen.go | 399 ++++++++++++++++ 15 files changed, 1315 insertions(+), 818 deletions(-) create mode 100644 internal/idmc/templates/additional-properties.go.tmpl create mode 100644 internal/idmc/templates/imports.go.tmpl create mode 100644 internal/idmc/templates/inline.go.tmpl create mode 100644 internal/idmc/templates/typedef.go.tmpl create mode 100644 internal/idmc/templates/union-and-additional-properties.go.tmpl create mode 100644 internal/idmc/templates/union.go.tmpl create mode 100644 internal/idmc/v2/types.gen.go create mode 100644 internal/idmc/v3/types.gen.go diff --git a/.gitignore b/.gitignore index 5144841..b9212b5 100644 --- a/.gitignore +++ b/.gitignore @@ -8,9 +8,6 @@ dist/ *.dll *.exe -# Keep windows files with windows line endings -*.winfile eol=crlf - # Mac .DS_Store diff --git a/internal/idmc/templates/additional-properties.go.tmpl b/internal/idmc/templates/additional-properties.go.tmpl new file mode 100644 index 0000000..a48b6e6 --- /dev/null +++ b/internal/idmc/templates/additional-properties.go.tmpl @@ -0,0 +1,76 @@ +// ///////// + +{{range .Types}}{{$addType := .Schema.AdditionalPropertiesType.TypeDecl}} + +// Getter for additional properties for {{.TypeName}}. Returns the specified +// element and whether it was found +func (a {{.TypeName}}) Get(fieldName string) (value {{$addType}}, found bool) { + if a.AdditionalProperties != nil { + value, found = a.AdditionalProperties[fieldName] + } + return +} + +// Setter for additional properties for {{.TypeName}} +func (a *{{.TypeName}}) Set(fieldName string, value {{$addType}}) { + if a.AdditionalProperties == nil { + a.AdditionalProperties = make(map[string]{{$addType}}) + } + a.AdditionalProperties[fieldName] = value +} + +{{if eq 0 (len .Schema.UnionElements) -}} +// Override default JSON handling for {{.TypeName}} to handle AdditionalProperties +func (a *{{.TypeName}}) UnmarshalJSON(b []byte) error { + object := make(map[string]json.RawMessage) + err := json.Unmarshal(b, &object) + if err != nil { + return err + } +{{range .Schema.Properties}} + if raw, found := object["{{.JsonFieldName}}"]; found { + err = json.Unmarshal(raw, &a.{{.GoFieldName}}) + if err != nil { + return fmt.Errorf("error reading '{{.JsonFieldName}}': %w", err) + } + delete(object, "{{.JsonFieldName}}") + } +{{end}} + if len(object) != 0 { + a.AdditionalProperties = make(map[string]{{$addType}}) + for fieldName, fieldBuf := range object { + var fieldVal {{$addType}} + err := json.Unmarshal(fieldBuf, &fieldVal) + if err != nil { + return fmt.Errorf("error unmarshaling field %s: %w", fieldName, err) + } + a.AdditionalProperties[fieldName] = fieldVal + } + } + return nil +} + +// Override default JSON handling for {{.TypeName}} to handle AdditionalProperties +func (a {{.TypeName}}) MarshalJSON() ([]byte, error) { + var err error + object := make(map[string]json.RawMessage) +{{range .Schema.Properties}} +{{if not .Required}}if a.{{.GoFieldName}} != nil { {{end}} + object["{{.JsonFieldName}}"], err = json.Marshal(a.{{.GoFieldName}}) + if err != nil { + return nil, fmt.Errorf("error marshaling '{{.JsonFieldName}}': %w", err) + } +{{if not .Required}} }{{end}} +{{end}} + for fieldName, field := range a.AdditionalProperties { + object[fieldName], err = json.Marshal(field) + if err != nil { + return nil, fmt.Errorf("error marshaling '%s': %w", fieldName, err) + } + } + return json.Marshal(object) +} +{{end}} +{{end}} + +// ////////////////////////////////////////////////////////////// diff --git a/internal/idmc/templates/imports.go.tmpl b/internal/idmc/templates/imports.go.tmpl new file mode 100644 index 0000000..2193345 --- /dev/null +++ b/internal/idmc/templates/imports.go.tmpl @@ -0,0 +1,53 @@ +{{- if opts.Generate.StdHTTPServer }}//go:build go1.22 +{{- end }} +// /////////////////////// + +// Package {{.PackageName}} provides primitives to interact with the openapi HTTP API. +// +// Code generated by {{.ModuleName}} version {{.Version}} DO NOT EDIT. +package {{.PackageName}} + +import ( + "bytes" + "compress/gzip" + "context" + "encoding/base64" + "encoding/json" + "encoding/xml" + "errors" + "fmt" + "gopkg.in/yaml.v2" + "io" + "os" + "mime" + "mime/multipart" + "net/http" + "net/url" + "path" + "strings" + "time" + + "github.com/oapi-codegen/runtime" + "github.com/oapi-codegen/nullable" + strictecho "github.com/oapi-codegen/runtime/strictmiddleware/echo" + strictgin "github.com/oapi-codegen/runtime/strictmiddleware/gin" + strictiris "github.com/oapi-codegen/runtime/strictmiddleware/iris" + strictnethttp "github.com/oapi-codegen/runtime/strictmiddleware/nethttp" + openapi_types "github.com/oapi-codegen/runtime/types" + "github.com/getkin/kin-openapi/openapi3" + "github.com/go-chi/chi/v5" + "github.com/labstack/echo/v4" + "github.com/gin-gonic/gin" + "github.com/gofiber/fiber/v2" + "github.com/kataras/iris/v12" + "github.com/kataras/iris/v12/core/router" + "github.com/gorilla/mux" + {{- range .ExternalImports}} + {{ . }} + {{- end}} + {{- range .AdditionalImports}} + {{.Alias}} "{{.Package}}" + {{- end}} +) + +// ////////////////////////////////////////////////////////////// diff --git a/internal/idmc/templates/inline.go.tmpl b/internal/idmc/templates/inline.go.tmpl new file mode 100644 index 0000000..bf201e6 --- /dev/null +++ b/internal/idmc/templates/inline.go.tmpl @@ -0,0 +1,91 @@ +// //////////////////////// + +// Base64 encoded, gzipped, json marshaled Swagger object +var swaggerSpec = []string{ +{{range .SpecParts}} + "{{.}}",{{end}} +} + +// GetSwagger returns the content of the embedded swagger specification file +// or error if failed to decode +func decodeSpec() ([]byte, error) { + zipped, err := base64.StdEncoding.DecodeString(strings.Join(swaggerSpec, "")) + if err != nil { + return nil, fmt.Errorf("error base64 decoding spec: %w", err) + } + zr, err := gzip.NewReader(bytes.NewReader(zipped)) + if err != nil { + return nil, fmt.Errorf("error decompressing spec: %w", err) + } + var buf bytes.Buffer + _, err = buf.ReadFrom(zr) + if err != nil { + return nil, fmt.Errorf("error decompressing spec: %w", err) + } + + return buf.Bytes(), nil +} + +var rawSpec = decodeSpecCached() + +// a naive cached of a decoded swagger spec +func decodeSpecCached() func() ([]byte, error) { + data, err := decodeSpec() + return func() ([]byte, error) { + return data, err + } +} + +// Constructs a synthetic filesystem for resolving external references when loading openapi specifications. +func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error) { + res := make(map[string]func() ([]byte, error)) + if len(pathToFile) > 0 { + res[pathToFile] = rawSpec + } + {{ if .ImportMapping }} + pathPrefix := path.Dir(pathToFile) + {{ end }} + {{ range $key, $value := .ImportMapping }} + for rawPath, rawFunc := range {{ $value.Name }}.PathToRawSpec(path.Join(pathPrefix, "{{ $key }}")) { + if _, ok := res[rawPath]; ok { + // it is not possible to compare functions in golang, so always overwrite the old value + } + res[rawPath] = rawFunc + } + {{- end }} + return res +} + +// GetSwagger returns the Swagger specification corresponding to the generated code +// in this file. The external references of Swagger specification are resolved. +// The logic of resolving external references is tightly connected to "import-mapping" feature. +// Externally referenced files must be embedded in the corresponding golang packages. +// Urls can be supported but this task was out of the scope. +func GetSwagger() (swagger *openapi3.T, err error) { + resolvePath := PathToRawSpec("") + + loader := openapi3.NewLoader() + loader.IsExternalRefsAllowed = true + loader.ReadFromURIFunc = func(loader *openapi3.Loader, url *url.URL) ([]byte, error) { + pathToFile := url.String() + pathToFile = path.Clean(pathToFile) + getSpec, ok := resolvePath[pathToFile] + if !ok { + err1 := fmt.Errorf("path not found: %s", pathToFile) + return nil, err1 + } + return getSpec() + } + var specData []byte + specData, err = rawSpec() + if err != nil { + return + } + swagger, err = loader.LoadFromData(specData) + if err != nil { + return + } + return +} + +// ////////////////////////////////////////////////////////////// diff --git a/internal/idmc/templates/typedef.go.tmpl b/internal/idmc/templates/typedef.go.tmpl new file mode 100644 index 0000000..dd80d26 --- /dev/null +++ b/internal/idmc/templates/typedef.go.tmpl @@ -0,0 +1,8 @@ +// /////////////////////// + +{{range .Types}} +{{ if .Schema.Description }}{{ toGoComment .Schema.Description .TypeName }}{{ else }}// {{.TypeName}} defines model for {{.JsonName}}.{{ end }} +type {{.TypeName}} {{if .IsAlias }}={{end}} {{.Schema.TypeDecl}} +{{end}} + +// ////////////////////////////////////////////////////////////// diff --git a/internal/idmc/templates/union-and-additional-properties.go.tmpl b/internal/idmc/templates/union-and-additional-properties.go.tmpl new file mode 100644 index 0000000..253b5de --- /dev/null +++ b/internal/idmc/templates/union-and-additional-properties.go.tmpl @@ -0,0 +1,74 @@ +{{range .Types}} + +{{$addType := .Schema.AdditionalPropertiesType.TypeDecl}} +{{$typeName := .TypeName -}} +{{$discriminator := .Schema.Discriminator}} +{{$properties := .Schema.Properties -}} + +// Override default JSON handling for {{.TypeName}} to handle AdditionalProperties and union +func (a *{{.TypeName}}) UnmarshalJSON(b []byte) error { + err := a.union.UnmarshalJSON(b) + if err != nil { + return err + } + object := make(map[string]json.RawMessage) + err = json.Unmarshal(b, &object) + if err != nil { + return err + } +{{range .Schema.Properties}} + if raw, found := object["{{.JsonFieldName}}"]; found { + err = json.Unmarshal(raw, &a.{{.GoFieldName}}) + if err != nil { + return fmt.Errorf("error reading '{{.JsonFieldName}}': %w", err) + } + delete(object, "{{.JsonFieldName}}") + } +{{end}} + if len(object) != 0 { + a.AdditionalProperties = make(map[string]{{$addType}}) + for fieldName, fieldBuf := range object { + var fieldVal {{$addType}} + err := json.Unmarshal(fieldBuf, &fieldVal) + if err != nil { + return fmt.Errorf("error unmarshaling field %s: %w", fieldName, err) + } + a.AdditionalProperties[fieldName] = fieldVal + } + } + return nil +} + +// Override default JSON handling for {{.TypeName}} to handle AdditionalProperties and union +func (a {{.TypeName}}) MarshalJSON() ([]byte, error) { + var err error + b, err := a.union.MarshalJSON() + if err != nil { + return nil, err + } + object := make(map[string]json.RawMessage) + if a.union != nil { + err = json.Unmarshal(b, &object) + if err != nil { + return nil, err + } + } +{{range .Schema.Properties}} +{{if not .Required}}if a.{{.GoFieldName}} != nil { {{end}} + object["{{.JsonFieldName}}"], err = json.Marshal(a.{{.GoFieldName}}) + if err != nil { + return nil, fmt.Errorf("error marshaling '{{.JsonFieldName}}': %w", err) + } +{{if not .Required}} }{{end}} +{{end}} + for fieldName, field := range a.AdditionalProperties { + object[fieldName], err = json.Marshal(field) + if err != nil { + return nil, fmt.Errorf("error marshaling '%s': %w", fieldName, err) + } + } + return json.Marshal(object) +} +{{end}} + +// ////////////////////////////////////////////////////////////// diff --git a/internal/idmc/templates/union.go.tmpl b/internal/idmc/templates/union.go.tmpl new file mode 100644 index 0000000..4405567 --- /dev/null +++ b/internal/idmc/templates/union.go.tmpl @@ -0,0 +1,144 @@ +// ///////////////////////// + +{{range .Types}} + {{$typeName := .TypeName -}} + {{$discriminator := .Schema.Discriminator}} + {{$properties := .Schema.Properties -}} + {{range .Schema.UnionElements}} + {{$element := . -}} + // As{{ .Method }} returns the union data inside the {{$typeName}} as a {{.}} + func (t {{$typeName}}) As{{ .Method }}() ({{.}}, error) { + var body {{.}} + err := json.Unmarshal(t.union, &body) + return body, err + } + + // From{{ .Method }} overwrites any union data inside the {{$typeName}} as the provided {{.}} + func (t *{{$typeName}}) From{{ .Method }} (v {{.}}) error { + {{if $discriminator -}} + {{range $value, $type := $discriminator.Mapping -}} + {{if eq $type $element -}} + {{$hasProperty := false -}} + {{range $properties -}} + {{if eq .GoFieldName $discriminator.PropertyName -}} + t.{{$discriminator.PropertyName}} = "{{$value}}" + {{$hasProperty = true -}} + {{end -}} + {{end -}} + {{if not $hasProperty}}v.{{$discriminator.PropertyName}} = "{{$value}}"{{end}} + {{end -}} + {{end -}} + {{end -}} + b, err := json.Marshal(v) + t.union = b + return err + } + + // Merge{{ .Method }} performs a merge with any union data inside the {{$typeName}}, using the provided {{.}} + func (t *{{$typeName}}) Merge{{ .Method }} (v {{.}}) error { + {{if $discriminator -}} + {{range $value, $type := $discriminator.Mapping -}} + {{if eq $type $element -}} + {{$hasProperty := false -}} + {{range $properties -}} + {{if eq .GoFieldName $discriminator.PropertyName -}} + t.{{$discriminator.PropertyName}} = "{{$value}}" + {{$hasProperty = true -}} + {{end -}} + {{end -}} + {{if not $hasProperty}}v.{{$discriminator.PropertyName}} = "{{$value}}"{{end}} + {{end -}} + {{end -}} + {{end -}} + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err + } + {{end}} + + {{if $discriminator}} + func (t {{.TypeName}}) Discriminator() (string, error) { + var discriminator struct { + Discriminator string {{$discriminator.JSONTag}} + } + err := json.Unmarshal(t.union, &discriminator) + return discriminator.Discriminator, err + } + + {{if ne 0 (len $discriminator.Mapping)}} + func (t {{.TypeName}}) ValueByDiscriminator() (interface{}, error) { + discriminator, err := t.Discriminator() + if err != nil { + return nil, err + } + switch discriminator{ + {{range $value, $type := $discriminator.Mapping -}} + case "{{$value}}": + return t.As{{$type}}() + {{end -}} + default: + return nil, errors.New("unknown discriminator value: "+discriminator) + } + } + {{end}} + {{end}} + + {{if not .Schema.HasAdditionalProperties}} + + func (t {{.TypeName}}) MarshalJSON() ([]byte, error) { + b, err := t.union.MarshalJSON() + {{if ne 0 (len .Schema.Properties) -}} + if err != nil { + return nil, err + } + object := make(map[string]json.RawMessage) + if t.union != nil { + err = json.Unmarshal(b, &object) + if err != nil { + return nil, err + } + } + {{range .Schema.Properties}} + {{if not .Required}}if t.{{.GoFieldName}} != nil { {{end}} + object["{{.JsonFieldName}}"], err = json.Marshal(t.{{.GoFieldName}}) + if err != nil { + return nil, fmt.Errorf("error marshaling '{{.JsonFieldName}}': %w", err) + } + {{if not .Required}} }{{end}} + {{end -}} + b, err = json.Marshal(object) + {{end -}} + return b, err + } + + func (t *{{.TypeName}}) UnmarshalJSON(b []byte) error { + err := t.union.UnmarshalJSON(b) + {{if ne 0 (len .Schema.Properties) -}} + if err != nil { + return err + } + object := make(map[string]json.RawMessage) + err = json.Unmarshal(b, &object) + if err != nil { + return err + } + {{range .Schema.Properties}} + if raw, found := object["{{.JsonFieldName}}"]; found { + err = json.Unmarshal(raw, &t.{{.GoFieldName}}) + if err != nil { + return fmt.Errorf("error reading '{{.JsonFieldName}}': %w", err) + } + } + {{end}} + {{end -}} + return err + } + {{end}} +{{end}} + +// ////////////////////////////////////////////////////////////// diff --git a/internal/idmc/v2/api.go b/internal/idmc/v2/api.go index 368209f..1719048 100644 --- a/internal/idmc/v2/api.go +++ b/internal/idmc/v2/api.go @@ -8,7 +8,8 @@ import ( ) //go:generate -command oapi-codegen go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen -//go:generate oapi-codegen -config ./codegen.yml ./openapi.yml +//go:generate oapi-codegen -config ./codegen.yml -generate types -o ./types.gen.go ./openapi.yml +//go:generate oapi-codegen -config ./codegen.yml -generate client -o ./client.gen.go ./openapi.yml type IdmcAdminV2Api struct { Client ClientWithResponses diff --git a/internal/idmc/v2/client.gen.go b/internal/idmc/v2/client.gen.go index 32465d8..02592e8 100644 --- a/internal/idmc/v2/client.gen.go +++ b/internal/idmc/v2/client.gen.go @@ -1,3 +1,5 @@ +// /////////////////////// + // Package v2 provides primitives to interact with the openapi HTTP API. // // Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.3.0 DO NOT EDIT. @@ -14,423 +16,11 @@ import ( "strings" common "terraform-provider-idmc/internal/idmc/common" - externalRef1 "terraform-provider-idmc/internal/idmc/v3" "github.com/oapi-codegen/runtime" ) -// ///////////////////// - -// ////////////////////////////////////////////////////////////// -// ///////////////////// - -// Defines values for ApiErrorResponseBodyType. -const ( - ApiErrorResponseBodyTypeError ApiErrorResponseBodyType = "error" -) - -// Defines values for GetAgentInstallerInfoResponseBodyType. -const ( - GetAgentInstallerInfoResponseBodyTypeAgentInstallerInfo GetAgentInstallerInfoResponseBodyType = "agentInstallerInfo" -) - -// Defines values for LoginRequestBodyType. -const ( - LoginRequestBodyTypeLogin LoginRequestBodyType = "login" -) - -// Defines values for RuntimeEnvironmentType. -const ( - RuntimeEnvironmentTypeRuntimeEnvironment RuntimeEnvironmentType = "runtimeEnvironment" -) - -// Defines values for RuntimeEnvironmentDataMinimalType. -const ( - RuntimeEnvironmentDataMinimalTypeRuntimeEnvironment RuntimeEnvironmentDataMinimalType = "runtimeEnvironment" -) - -// Defines values for UpdateRuntimeEnvironmentRequestBodyType. -const ( - UpdateRuntimeEnvironmentRequestBodyTypeRuntimeEnvironment UpdateRuntimeEnvironmentRequestBodyType = "runtimeEnvironment" -) - -// ////////////////////////////////////////////////////////////// - -// ApiErrorResponse defines model for apiErrorResponse. -type ApiErrorResponse struct { - union json.RawMessage -} - -// ApiErrorResponseBody When the REST API encounters an error, it returns a REST API error object. -type ApiErrorResponseBody struct { - Type ApiErrorResponseBodyType `json:"@type"` - - // Code The internal error code. - Code string `json:"code"` - - // Description The error message. - Description string `json:"description"` - - // StatusCode The http status code of the response. - StatusCode int `json:"statusCode"` -} - -// ApiErrorResponseBodyType defines model for ApiErrorResponseBody.Type. -type ApiErrorResponseBodyType string - -// GetAgentInstallerInfoResponseBody defines model for getAgentInstallerInfoResponseBody. -type GetAgentInstallerInfoResponseBody struct { - Type *GetAgentInstallerInfoResponseBodyType `json:"@type,omitempty"` - - // ChecksumDownloadUrl The url for a checksum file that can be used to verify the installation. - ChecksumDownloadUrl *string `json:"checksumDownloadUrl,omitempty"` - - // DownloadUrl The url to use for downloading the current secure agent version. - DownloadUrl *string `json:"downloadUrl,omitempty"` - - // InstallToken The short-lived token to use when registering a secure agent with the environment. - InstallToken *string `json:"installToken,omitempty"` -} - -// GetAgentInstallerInfoResponseBodyType defines model for GetAgentInstallerInfoResponseBody.Type. -type GetAgentInstallerInfoResponseBodyType string - -// LoginRequestBody defines model for loginRequestBody. -type LoginRequestBody struct { - Type *LoginRequestBodyType `json:"@type,omitempty"` - - // Password Informatica Intelligent Cloud Services password. - Password string `json:"password"` - - // Username Informatica Intelligent Cloud Services user name for the organization that you want to log in to. - Username string `json:"username"` -} - -// LoginRequestBodyType defines model for LoginRequestBody.Type. -type LoginRequestBodyType string - -// LoginResponseBody defines model for loginResponseBody. -type LoginResponseBody struct { - // CreateTime When the user account was created. - CreateTime *string `json:"createTime,omitempty"` - - // CreatedBy Informatica Intelligent Cloud Services user who created the user account. - CreatedBy *string `json:"createdBy,omitempty"` - - // Description Description of the user. - Description *string `json:"description,omitempty"` - - // Emails Email address to be notified when the user changes the account password. - Emails *string `json:"emails,omitempty"` - - // FirstName First name for the user account. - FirstName *string `json:"firstName,omitempty"` - - // ForceChangePassword Determines if the user must reset the password after the user logs in for the first time. Includes the following values: - // True. The user must reset the password. - // False. The user is not forced to reset the password. - ForceChangePassword *bool `json:"forceChangePassword,omitempty"` - - // IcSessionId Informatica Intelligent Cloud Services session ID for version 2 REST API session. - // Use in most version 2 REST API request headers. - IcSessionId *string `json:"icSessionId,omitempty"` - - // Id User ID. - Id *string `json:"id,omitempty"` - - // LastName Last name for the user account. - LastName *string `json:"lastName,omitempty"` - - // Name Informatica Intelligent Cloud Services user name. - Name *string `json:"name,omitempty"` - - // OrgId ID of the organization the user belongs to. 22 characters. - // NOTE: Organizations that were created in legacy Informatica Cloud might have an - // organization ID of 6 characters. - OrgId *string `json:"orgId,omitempty"` - - // OrgUuid Unique identifier for the organization. - OrgUuid *string `json:"orgUuid,omitempty"` - - // Password Salesforce user password. Included when user is configured to authenticate through Salesforce. - Password *string `json:"password,omitempty"` - - // Phone Phone number for the user. - Phone *string `json:"phone,omitempty"` - - // Roles Object that includes a role object for each role assigned to the user. - Roles *struct { - // Description Role description. - Description *string `json:"description,omitempty"` - - // Name Role name. Returns one of the following codes: - // Service Consumer - // Designer - // Admin - Name *string `json:"name,omitempty"` - } `json:"roles,omitempty"` - - // SecurityAnswer Answer to the security question. - SecurityAnswer *string `json:"securityAnswer,omitempty"` - - // SecurityQuestion Security question. Returns one of the following codes: - // SPOUSE_MEETING_CITY - // FIRST_JOB_CITY - // CHILDHOOD_FRIEND - // MOTHER_MAIDEN_NAME - // PET_NAME - // CHILDHOOD_NICKNAME - // CUSTOM_QUESTION:"" - SecurityQuestion *string `json:"securityQuestion,omitempty"` - - // ServerUrl Informatica Intelligent Cloud Services URL for the organization the user belongs - // to. Use the serverUrl as a base for most version 2 REST API resource URIs. - ServerUrl *string `json:"serverUrl,omitempty"` - - // SfUsername Salesforce user name. Included when user is configured to authenticate through Salesforce. - SfUsername *string `json:"sfUsername,omitempty"` - - // SpiUrl This field is no longer applicable and has been deprecated. - // Deprecated: - SpiUrl *string `json:"spiUrl,omitempty"` - - // Timezone Time zone of the user. Time zone honors Daylight Saving Time. - // For more information, see Time zone codes. - Timezone *string `json:"timezone,omitempty"` - - // Title Title of the user. - Title *string `json:"title,omitempty"` - - // UpdateTime When the user account was last updated. - UpdateTime *string `json:"updateTime,omitempty"` - - // UpdatedBy Informatica Intelligent Cloud Services user who last updated the user account. - UpdatedBy *string `json:"updatedBy,omitempty"` - - // UuId Unique identifier for the user. - UuId *string `json:"uuId,omitempty"` -} - -// RuntimeEnvironment defines model for runtimeEnvironment. -type RuntimeEnvironment struct { - Type *RuntimeEnvironmentType `json:"@type,omitempty"` - - // Agents Agents assigned to the Secure Agent group. - Agents *[]RuntimeEnvironmentAgent `json:"agents,omitempty"` - - // CreateTime Date and time the Secure Agent group was created. - CreateTime *string `json:"createTime,omitempty"` - - // CreatedBy User who created the Secure Agent group. - CreatedBy *string `json:"createdBy,omitempty"` - - // Description Description of the Secure Agent group. - Description *string `json:"description,omitempty"` - - // FederatedId Global unique identifier. - FederatedId *string `json:"federatedId,omitempty"` - - // Id Secure Agent group ID. - Id *string `json:"id,omitempty"` - - // IsShared Whether the Secure Agent group can be shared with sub-organizations. - IsShared *bool `json:"isShared,omitempty"` - - // Name Secure Agent group name. - Name string `json:"name"` - - // OrgId Organization ID. - OrgId *string `json:"orgId,omitempty"` - - // ServerlessConfig Attribute that defines serverless runtime environment properties. - ServerlessConfig *map[string]interface{} `json:"serverlessConfig,omitempty"` - - // UpdateTime Date and time that the Secure Agent group was last updated. - UpdateTime *string `json:"updateTime,omitempty"` - - // UpdatedBy User who last updated the Secure Agent group. - UpdatedBy *string `json:"updatedBy,omitempty"` -} - -// RuntimeEnvironmentType defines model for RuntimeEnvironment.Type. -type RuntimeEnvironmentType string - -// RuntimeEnvironmentAgent An agent assigned to a Secure Agent group. -type RuntimeEnvironmentAgent struct { - // Id Agent ID. - Id *string `json:"id,omitempty"` - - // OrgId Organization ID. - OrgId *string `json:"orgId,omitempty"` -} - -// RuntimeEnvironmentDataBulk defines model for runtimeEnvironmentDataBulk. -type RuntimeEnvironmentDataBulk struct { - // Agents Agents assigned to the Secure Agent group. - Agents *[]RuntimeEnvironmentAgent `json:"agents,omitempty"` - - // CreateTime Date and time the Secure Agent group was created. - CreateTime *string `json:"createTime,omitempty"` - - // CreatedBy User who created the Secure Agent group. - CreatedBy *string `json:"createdBy,omitempty"` - - // Description Description of the Secure Agent group. - Description *string `json:"description,omitempty"` - - // FederatedId Global unique identifier. - FederatedId *string `json:"federatedId,omitempty"` - - // Id Secure Agent group ID. - Id *string `json:"id,omitempty"` - - // Name Secure Agent group name. - Name *string `json:"name,omitempty"` - - // OrgId Organization ID. - OrgId *string `json:"orgId,omitempty"` - - // ServerlessConfig Attribute that defines serverless runtime environment properties. - ServerlessConfig *map[string]interface{} `json:"serverlessConfig,omitempty"` - - // UpdateTime Date and time that the Secure Agent group was last updated. - UpdateTime *string `json:"updateTime,omitempty"` - - // UpdatedBy User who last updated the Secure Agent group. - UpdatedBy *string `json:"updatedBy,omitempty"` -} - -// RuntimeEnvironmentDataMinimal defines model for runtimeEnvironmentDataMinimal. -type RuntimeEnvironmentDataMinimal struct { - Type *RuntimeEnvironmentDataMinimalType `json:"@type,omitempty"` - - // IsShared Whether the Secure Agent group can be shared with sub-organizations. - IsShared *bool `json:"isShared,omitempty"` - - // Name Name of the Secure Agent group. - Name string `json:"name"` -} - -// RuntimeEnvironmentDataMinimalType defines model for RuntimeEnvironmentDataMinimal.Type. -type RuntimeEnvironmentDataMinimalType string - -// UpdateRuntimeEnvironmentRequestBody defines model for updateRuntimeEnvironmentRequestBody. -type UpdateRuntimeEnvironmentRequestBody struct { - Type *UpdateRuntimeEnvironmentRequestBodyType `json:"@type,omitempty"` - - // Agents Agents assigned to the Secure Agent group. - Agents *[]RuntimeEnvironmentAgent `json:"agents,omitempty"` - - // IsShared Whether the Secure Agent group can be shared with sub-organizations. - IsShared *bool `json:"isShared,omitempty"` - - // Name Name of the Secure Agent group. - Name string `json:"name"` -} - -// UpdateRuntimeEnvironmentRequestBodyType defines model for UpdateRuntimeEnvironmentRequestBody.Type. -type UpdateRuntimeEnvironmentRequestBodyType string - -// N400 defines model for 400. -type N400 = ApiErrorResponse - -// N401 defines model for 401. -type N401 = ApiErrorResponse - -// N403 defines model for 403. -type N403 = ApiErrorResponse - -// N404 defines model for 404. -type N404 = ApiErrorResponse - -// N500 defines model for 500. -type N500 = ApiErrorResponse - -// N502 defines model for 502. -type N502 = ApiErrorResponse - -// N503 defines model for 503. -type N503 = ApiErrorResponse - -// /////////////////// - -// ////////////////////////////////////////////////////////////// - -// //////////////// - -// CreateRuntimeEnvironmentJSONRequestBody defines body for CreateRuntimeEnvironment for application/json ContentType. -type CreateRuntimeEnvironmentJSONRequestBody = RuntimeEnvironmentDataMinimal - -// UpdateRuntimeEnvironmentJSONRequestBody defines body for UpdateRuntimeEnvironment for application/json ContentType. -type UpdateRuntimeEnvironmentJSONRequestBody = UpdateRuntimeEnvironmentRequestBody - -// LoginJSONRequestBody defines body for Login for application/json ContentType. -type LoginJSONRequestBody = LoginRequestBody - // ////////////////////////////////////////////////////////////// - -// AsApiErrorResponseBody returns the union data inside the ApiErrorResponse as a ApiErrorResponseBody -func (t ApiErrorResponse) AsApiErrorResponseBody() (ApiErrorResponseBody, error) { - var body ApiErrorResponseBody - err := json.Unmarshal(t.union, &body) - return body, err -} - -// FromApiErrorResponseBody overwrites any union data inside the ApiErrorResponse as the provided ApiErrorResponseBody -func (t *ApiErrorResponse) FromApiErrorResponseBody(v ApiErrorResponseBody) error { - b, err := json.Marshal(v) - t.union = b - return err -} - -// MergeApiErrorResponseBody performs a merge with any union data inside the ApiErrorResponse, using the provided ApiErrorResponseBody -func (t *ApiErrorResponse) MergeApiErrorResponseBody(v ApiErrorResponseBody) error { - b, err := json.Marshal(v) - if err != nil { - return err - } - - merged, err := runtime.JSONMerge(t.union, b) - t.union = merged - return err -} - -// AsExternalRef1ApiErrorResponseBody returns the union data inside the ApiErrorResponse as a externalRef1.ApiErrorResponseBody -func (t ApiErrorResponse) AsExternalRef1ApiErrorResponseBody() (externalRef1.ApiErrorResponseBody, error) { - var body externalRef1.ApiErrorResponseBody - err := json.Unmarshal(t.union, &body) - return body, err -} - -// FromExternalRef1ApiErrorResponseBody overwrites any union data inside the ApiErrorResponse as the provided externalRef1.ApiErrorResponseBody -func (t *ApiErrorResponse) FromExternalRef1ApiErrorResponseBody(v externalRef1.ApiErrorResponseBody) error { - b, err := json.Marshal(v) - t.union = b - return err -} - -// MergeExternalRef1ApiErrorResponseBody performs a merge with any union data inside the ApiErrorResponse, using the provided externalRef1.ApiErrorResponseBody -func (t *ApiErrorResponse) MergeExternalRef1ApiErrorResponseBody(v externalRef1.ApiErrorResponseBody) error { - b, err := json.Marshal(v) - if err != nil { - return err - } - - merged, err := runtime.JSONMerge(t.union, b) - t.union = merged - return err -} - -func (t ApiErrorResponse) MarshalJSON() ([]byte, error) { - b, err := t.union.MarshalJSON() - return b, err -} - -func (t *ApiErrorResponse) UnmarshalJSON(b []byte) error { - err := t.union.UnmarshalJSON(b) - return err -} - // //////////////////////// // Client which conforms to the OpenAPI3 specification for this service. diff --git a/internal/idmc/v2/codegen.yml b/internal/idmc/v2/codegen.yml index eb55f10..a1b3815 100644 --- a/internal/idmc/v2/codegen.yml +++ b/internal/idmc/v2/codegen.yml @@ -1,10 +1,6 @@ # yaml-language-server: $schema=https://raw.githubusercontent.com/oapi-codegen/oapi-codegen/HEAD/configuration-schema.json --- -output: ./client.gen.go package: v2 -generate: - client: true - models: true compatibility: always-prefix-enum-values: true additional-imports: @@ -13,11 +9,17 @@ additional-imports: output-options: nullable-type: true user-templates: # https://github.com/oapi-codegen/oapi-codegen/tree/main/pkg/codegen/templates - client-with-responses.tmpl: ../templates/client-with-responses.go.tmpl - client.tmpl: ../templates/client.go.tmpl - constants.tmpl: ../templates/constants.go.tmpl - param-types.tmpl: ../templates/param-types.go.tmpl - request-bodies.tmpl: ../templates/request-bodies.go.tmpl + additional-properties.tmpl: ../templates/additional-properties.go.tmpl + client.tmpl: ../templates/client.go.tmpl + client-with-responses.tmpl: ../templates/client-with-responses.go.tmpl + constants.tmpl: ../templates/constants.go.tmpl + imports.tmpl: ../templates/imports.go.tmpl + inline.tmpl: ../templates/inline.go.tmpl + param-types.tmpl: ../templates/param-types.go.tmpl + request-bodies.tmpl: ../templates/request-bodies.go.tmpl + typedef.tmpl: ../templates/typedef.go.tmpl + union.tmpl: ../templates/union.go.tmpl + union-and-additional-properties.tmpl: ../templates/union-and-additional-properties.go.tmpl import-mapping: ../common/openapi.yml: terraform-provider-idmc/internal/idmc/common - ../v3/openapi.yml: terraform-provider-idmc/internal/idmc/v3 + ../v3/openapi.yml: terraform-provider-idmc/internal/idmc/v3 diff --git a/internal/idmc/v2/types.gen.go b/internal/idmc/v2/types.gen.go new file mode 100644 index 0000000..c189f4d --- /dev/null +++ b/internal/idmc/v2/types.gen.go @@ -0,0 +1,439 @@ +// /////////////////////// + +// Package v2 provides primitives to interact with the openapi HTTP API. +// +// Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.3.0 DO NOT EDIT. +package v2 + +import ( + "encoding/json" + + externalRef1 "terraform-provider-idmc/internal/idmc/v3" + + "github.com/oapi-codegen/runtime" +) + +// ////////////////////////////////////////////////////////////// +// ///////////////////// + +// ////////////////////////////////////////////////////////////// +// ///////////////////// + +// Defines values for ApiErrorResponseBodyType. +const ( + ApiErrorResponseBodyTypeError ApiErrorResponseBodyType = "error" +) + +// Defines values for GetAgentInstallerInfoResponseBodyType. +const ( + GetAgentInstallerInfoResponseBodyTypeAgentInstallerInfo GetAgentInstallerInfoResponseBodyType = "agentInstallerInfo" +) + +// Defines values for LoginRequestBodyType. +const ( + LoginRequestBodyTypeLogin LoginRequestBodyType = "login" +) + +// Defines values for RuntimeEnvironmentType. +const ( + RuntimeEnvironmentTypeRuntimeEnvironment RuntimeEnvironmentType = "runtimeEnvironment" +) + +// Defines values for RuntimeEnvironmentDataMinimalType. +const ( + RuntimeEnvironmentDataMinimalTypeRuntimeEnvironment RuntimeEnvironmentDataMinimalType = "runtimeEnvironment" +) + +// Defines values for UpdateRuntimeEnvironmentRequestBodyType. +const ( + UpdateRuntimeEnvironmentRequestBodyTypeRuntimeEnvironment UpdateRuntimeEnvironmentRequestBodyType = "runtimeEnvironment" +) + +// ////////////////////////////////////////////////////////////// +// /////////////////////// + +// ApiErrorResponse defines model for apiErrorResponse. +type ApiErrorResponse struct { + union json.RawMessage +} + +// ApiErrorResponseBody When the REST API encounters an error, it returns a REST API error object. +type ApiErrorResponseBody struct { + Type ApiErrorResponseBodyType `json:"@type"` + + // Code The internal error code. + Code string `json:"code"` + + // Description The error message. + Description string `json:"description"` + + // StatusCode The http status code of the response. + StatusCode int `json:"statusCode"` +} + +// ApiErrorResponseBodyType defines model for ApiErrorResponseBody.Type. +type ApiErrorResponseBodyType string + +// GetAgentInstallerInfoResponseBody defines model for getAgentInstallerInfoResponseBody. +type GetAgentInstallerInfoResponseBody struct { + Type *GetAgentInstallerInfoResponseBodyType `json:"@type,omitempty"` + + // ChecksumDownloadUrl The url for a checksum file that can be used to verify the installation. + ChecksumDownloadUrl *string `json:"checksumDownloadUrl,omitempty"` + + // DownloadUrl The url to use for downloading the current secure agent version. + DownloadUrl *string `json:"downloadUrl,omitempty"` + + // InstallToken The short-lived token to use when registering a secure agent with the environment. + InstallToken *string `json:"installToken,omitempty"` +} + +// GetAgentInstallerInfoResponseBodyType defines model for GetAgentInstallerInfoResponseBody.Type. +type GetAgentInstallerInfoResponseBodyType string + +// LoginRequestBody defines model for loginRequestBody. +type LoginRequestBody struct { + Type *LoginRequestBodyType `json:"@type,omitempty"` + + // Password Informatica Intelligent Cloud Services password. + Password string `json:"password"` + + // Username Informatica Intelligent Cloud Services user name for the organization that you want to log in to. + Username string `json:"username"` +} + +// LoginRequestBodyType defines model for LoginRequestBody.Type. +type LoginRequestBodyType string + +// LoginResponseBody defines model for loginResponseBody. +type LoginResponseBody struct { + // CreateTime When the user account was created. + CreateTime *string `json:"createTime,omitempty"` + + // CreatedBy Informatica Intelligent Cloud Services user who created the user account. + CreatedBy *string `json:"createdBy,omitempty"` + + // Description Description of the user. + Description *string `json:"description,omitempty"` + + // Emails Email address to be notified when the user changes the account password. + Emails *string `json:"emails,omitempty"` + + // FirstName First name for the user account. + FirstName *string `json:"firstName,omitempty"` + + // ForceChangePassword Determines if the user must reset the password after the user logs in for the first time. Includes the following values: + // True. The user must reset the password. + // False. The user is not forced to reset the password. + ForceChangePassword *bool `json:"forceChangePassword,omitempty"` + + // IcSessionId Informatica Intelligent Cloud Services session ID for version 2 REST API session. + // Use in most version 2 REST API request headers. + IcSessionId *string `json:"icSessionId,omitempty"` + + // Id User ID. + Id *string `json:"id,omitempty"` + + // LastName Last name for the user account. + LastName *string `json:"lastName,omitempty"` + + // Name Informatica Intelligent Cloud Services user name. + Name *string `json:"name,omitempty"` + + // OrgId ID of the organization the user belongs to. 22 characters. + // NOTE: Organizations that were created in legacy Informatica Cloud might have an + // organization ID of 6 characters. + OrgId *string `json:"orgId,omitempty"` + + // OrgUuid Unique identifier for the organization. + OrgUuid *string `json:"orgUuid,omitempty"` + + // Password Salesforce user password. Included when user is configured to authenticate through Salesforce. + Password *string `json:"password,omitempty"` + + // Phone Phone number for the user. + Phone *string `json:"phone,omitempty"` + + // Roles Object that includes a role object for each role assigned to the user. + Roles *struct { + // Description Role description. + Description *string `json:"description,omitempty"` + + // Name Role name. Returns one of the following codes: + // Service Consumer + // Designer + // Admin + Name *string `json:"name,omitempty"` + } `json:"roles,omitempty"` + + // SecurityAnswer Answer to the security question. + SecurityAnswer *string `json:"securityAnswer,omitempty"` + + // SecurityQuestion Security question. Returns one of the following codes: + // SPOUSE_MEETING_CITY + // FIRST_JOB_CITY + // CHILDHOOD_FRIEND + // MOTHER_MAIDEN_NAME + // PET_NAME + // CHILDHOOD_NICKNAME + // CUSTOM_QUESTION:"" + SecurityQuestion *string `json:"securityQuestion,omitempty"` + + // ServerUrl Informatica Intelligent Cloud Services URL for the organization the user belongs + // to. Use the serverUrl as a base for most version 2 REST API resource URIs. + ServerUrl *string `json:"serverUrl,omitempty"` + + // SfUsername Salesforce user name. Included when user is configured to authenticate through Salesforce. + SfUsername *string `json:"sfUsername,omitempty"` + + // SpiUrl This field is no longer applicable and has been deprecated. + // Deprecated: + SpiUrl *string `json:"spiUrl,omitempty"` + + // Timezone Time zone of the user. Time zone honors Daylight Saving Time. + // For more information, see Time zone codes. + Timezone *string `json:"timezone,omitempty"` + + // Title Title of the user. + Title *string `json:"title,omitempty"` + + // UpdateTime When the user account was last updated. + UpdateTime *string `json:"updateTime,omitempty"` + + // UpdatedBy Informatica Intelligent Cloud Services user who last updated the user account. + UpdatedBy *string `json:"updatedBy,omitempty"` + + // UuId Unique identifier for the user. + UuId *string `json:"uuId,omitempty"` +} + +// RuntimeEnvironment defines model for runtimeEnvironment. +type RuntimeEnvironment struct { + Type *RuntimeEnvironmentType `json:"@type,omitempty"` + + // Agents Agents assigned to the Secure Agent group. + Agents *[]RuntimeEnvironmentAgent `json:"agents,omitempty"` + + // CreateTime Date and time the Secure Agent group was created. + CreateTime *string `json:"createTime,omitempty"` + + // CreatedBy User who created the Secure Agent group. + CreatedBy *string `json:"createdBy,omitempty"` + + // Description Description of the Secure Agent group. + Description *string `json:"description,omitempty"` + + // FederatedId Global unique identifier. + FederatedId *string `json:"federatedId,omitempty"` + + // Id Secure Agent group ID. + Id *string `json:"id,omitempty"` + + // IsShared Whether the Secure Agent group can be shared with sub-organizations. + IsShared *bool `json:"isShared,omitempty"` + + // Name Secure Agent group name. + Name string `json:"name"` + + // OrgId Organization ID. + OrgId *string `json:"orgId,omitempty"` + + // ServerlessConfig Attribute that defines serverless runtime environment properties. + ServerlessConfig *map[string]interface{} `json:"serverlessConfig,omitempty"` + + // UpdateTime Date and time that the Secure Agent group was last updated. + UpdateTime *string `json:"updateTime,omitempty"` + + // UpdatedBy User who last updated the Secure Agent group. + UpdatedBy *string `json:"updatedBy,omitempty"` +} + +// RuntimeEnvironmentType defines model for RuntimeEnvironment.Type. +type RuntimeEnvironmentType string + +// RuntimeEnvironmentAgent An agent assigned to a Secure Agent group. +type RuntimeEnvironmentAgent struct { + // Id Agent ID. + Id *string `json:"id,omitempty"` + + // OrgId Organization ID. + OrgId *string `json:"orgId,omitempty"` +} + +// RuntimeEnvironmentDataBulk defines model for runtimeEnvironmentDataBulk. +type RuntimeEnvironmentDataBulk struct { + // Agents Agents assigned to the Secure Agent group. + Agents *[]RuntimeEnvironmentAgent `json:"agents,omitempty"` + + // CreateTime Date and time the Secure Agent group was created. + CreateTime *string `json:"createTime,omitempty"` + + // CreatedBy User who created the Secure Agent group. + CreatedBy *string `json:"createdBy,omitempty"` + + // Description Description of the Secure Agent group. + Description *string `json:"description,omitempty"` + + // FederatedId Global unique identifier. + FederatedId *string `json:"federatedId,omitempty"` + + // Id Secure Agent group ID. + Id *string `json:"id,omitempty"` + + // Name Secure Agent group name. + Name *string `json:"name,omitempty"` + + // OrgId Organization ID. + OrgId *string `json:"orgId,omitempty"` + + // ServerlessConfig Attribute that defines serverless runtime environment properties. + ServerlessConfig *map[string]interface{} `json:"serverlessConfig,omitempty"` + + // UpdateTime Date and time that the Secure Agent group was last updated. + UpdateTime *string `json:"updateTime,omitempty"` + + // UpdatedBy User who last updated the Secure Agent group. + UpdatedBy *string `json:"updatedBy,omitempty"` +} + +// RuntimeEnvironmentDataMinimal defines model for runtimeEnvironmentDataMinimal. +type RuntimeEnvironmentDataMinimal struct { + Type *RuntimeEnvironmentDataMinimalType `json:"@type,omitempty"` + + // IsShared Whether the Secure Agent group can be shared with sub-organizations. + IsShared *bool `json:"isShared,omitempty"` + + // Name Name of the Secure Agent group. + Name string `json:"name"` +} + +// RuntimeEnvironmentDataMinimalType defines model for RuntimeEnvironmentDataMinimal.Type. +type RuntimeEnvironmentDataMinimalType string + +// UpdateRuntimeEnvironmentRequestBody defines model for updateRuntimeEnvironmentRequestBody. +type UpdateRuntimeEnvironmentRequestBody struct { + Type *UpdateRuntimeEnvironmentRequestBodyType `json:"@type,omitempty"` + + // Agents Agents assigned to the Secure Agent group. + Agents *[]RuntimeEnvironmentAgent `json:"agents,omitempty"` + + // IsShared Whether the Secure Agent group can be shared with sub-organizations. + IsShared *bool `json:"isShared,omitempty"` + + // Name Name of the Secure Agent group. + Name string `json:"name"` +} + +// UpdateRuntimeEnvironmentRequestBodyType defines model for UpdateRuntimeEnvironmentRequestBody.Type. +type UpdateRuntimeEnvironmentRequestBodyType string + +// N400 defines model for 400. +type N400 = ApiErrorResponse + +// N401 defines model for 401. +type N401 = ApiErrorResponse + +// N403 defines model for 403. +type N403 = ApiErrorResponse + +// N404 defines model for 404. +type N404 = ApiErrorResponse + +// N500 defines model for 500. +type N500 = ApiErrorResponse + +// N502 defines model for 502. +type N502 = ApiErrorResponse + +// N503 defines model for 503. +type N503 = ApiErrorResponse + +// ////////////////////////////////////////////////////////////// +// /////////////////// + +// ////////////////////////////////////////////////////////////// + +// //////////////// + +// CreateRuntimeEnvironmentJSONRequestBody defines body for CreateRuntimeEnvironment for application/json ContentType. +type CreateRuntimeEnvironmentJSONRequestBody = RuntimeEnvironmentDataMinimal + +// UpdateRuntimeEnvironmentJSONRequestBody defines body for UpdateRuntimeEnvironment for application/json ContentType. +type UpdateRuntimeEnvironmentJSONRequestBody = UpdateRuntimeEnvironmentRequestBody + +// LoginJSONRequestBody defines body for Login for application/json ContentType. +type LoginJSONRequestBody = LoginRequestBody + +// ////////////////////////////////////////////////////////////// + +// ///////// + +// ////////////////////////////////////////////////////////////// +// ///////// + +// ////////////////////////////////////////////////////////////// +// ///////////////////////// + +// AsApiErrorResponseBody returns the union data inside the ApiErrorResponse as a ApiErrorResponseBody +func (t ApiErrorResponse) AsApiErrorResponseBody() (ApiErrorResponseBody, error) { + var body ApiErrorResponseBody + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromApiErrorResponseBody overwrites any union data inside the ApiErrorResponse as the provided ApiErrorResponseBody +func (t *ApiErrorResponse) FromApiErrorResponseBody(v ApiErrorResponseBody) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeApiErrorResponseBody performs a merge with any union data inside the ApiErrorResponse, using the provided ApiErrorResponseBody +func (t *ApiErrorResponse) MergeApiErrorResponseBody(v ApiErrorResponseBody) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +// AsExternalRef1ApiErrorResponseBody returns the union data inside the ApiErrorResponse as a externalRef1.ApiErrorResponseBody +func (t ApiErrorResponse) AsExternalRef1ApiErrorResponseBody() (externalRef1.ApiErrorResponseBody, error) { + var body externalRef1.ApiErrorResponseBody + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromExternalRef1ApiErrorResponseBody overwrites any union data inside the ApiErrorResponse as the provided externalRef1.ApiErrorResponseBody +func (t *ApiErrorResponse) FromExternalRef1ApiErrorResponseBody(v externalRef1.ApiErrorResponseBody) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeExternalRef1ApiErrorResponseBody performs a merge with any union data inside the ApiErrorResponse, using the provided externalRef1.ApiErrorResponseBody +func (t *ApiErrorResponse) MergeExternalRef1ApiErrorResponseBody(v externalRef1.ApiErrorResponseBody) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +func (t ApiErrorResponse) MarshalJSON() ([]byte, error) { + b, err := t.union.MarshalJSON() + return b, err +} + +func (t *ApiErrorResponse) UnmarshalJSON(b []byte) error { + err := t.union.UnmarshalJSON(b) + return err +} + +// ////////////////////////////////////////////////////////////// diff --git a/internal/idmc/v3/api.go b/internal/idmc/v3/api.go index a01327f..e0d374e 100644 --- a/internal/idmc/v3/api.go +++ b/internal/idmc/v3/api.go @@ -10,7 +10,8 @@ import ( ) //go:generate -command oapi-codegen go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen -//go:generate oapi-codegen -config ./codegen.yml ./openapi.yml +//go:generate oapi-codegen -config ./codegen.yml -generate types -o ./types.gen.go ./openapi.yml +//go:generate oapi-codegen -config ./codegen.yml -generate client -o ./client.gen.go ./openapi.yml type IdmcAdminV3Api struct { Client ClientWithResponses diff --git a/internal/idmc/v3/client.gen.go b/internal/idmc/v3/client.gen.go index bd5f3f1..1d3a164 100644 --- a/internal/idmc/v3/client.gen.go +++ b/internal/idmc/v3/client.gen.go @@ -1,3 +1,5 @@ +// /////////////////////// + // Package v3 provides primitives to interact with the openapi HTTP API. // // Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.3.0 DO NOT EDIT. @@ -18,389 +20,7 @@ import ( "github.com/oapi-codegen/runtime" ) -// ///////////////////// - -// ////////////////////////////////////////////////////////////// -// ///////////////////// - -// Defines values for LoginResponseBodyUserInfoStatus. -const ( - LoginResponseBodyUserInfoStatusActive LoginResponseBodyUserInfoStatus = "Active" - LoginResponseBodyUserInfoStatusInactive LoginResponseBodyUserInfoStatus = "Inactive" -) - -// Defines values for RolePrivilegeItemStatus. -const ( - RolePrivilegeItemStatusDefault RolePrivilegeItemStatus = "Default" - RolePrivilegeItemStatusDisabled RolePrivilegeItemStatus = "Disabled" - RolePrivilegeItemStatusEnabled RolePrivilegeItemStatus = "Enabled" - RolePrivilegeItemStatusUnassigned RolePrivilegeItemStatus = "Unassigned" -) - -// Defines values for RoleStatus. -const ( - RoleStatusDisabled RoleStatus = "Disabled" - RoleStatusEnabled RoleStatus = "Enabled" -) - -// Defines values for GetRolesParamsExpand. -const ( - GetRolesParamsExpandPrivileges GetRolesParamsExpand = "privileges" -) - -// ////////////////////////////////////////////////////////////// - -// ApiError defines model for apiError. -type ApiError struct { - Code string `json:"code"` - DebugMessage *string `json:"debugMessage,omitempty"` - Details *[]ApiErrorDetail `json:"details,omitempty"` - Message string `json:"message"` - RequestId string `json:"requestId"` -} - -// ApiErrorDetail defines model for apiErrorDetail. -type ApiErrorDetail struct { - Code string `json:"code"` - DebugMessage *string `json:"debugMessage,omitempty"` - Message string `json:"message"` -} - -// ApiErrorResponseBody When the REST API encounters an error, it returns a REST API error object. -type ApiErrorResponseBody struct { - Error ApiError `json:"error"` -} - -// CreateRoleRequestBody defines model for createRoleRequestBody. -type CreateRoleRequestBody struct { - // Description Description of the role. - Description *string `json:"description,omitempty"` - - // Name Name of the role. - Name *string `json:"name,omitempty"` - - // Privileges IDs of the privileges to assign to the role. - // A role must have at least one privilege assigned to it. - Privileges *[]string `json:"privileges,omitempty"` -} - -// CreateRoleResponseBody defines model for createRoleResponseBody. -type CreateRoleResponseBody struct { - // CreateTime Date and time the role was created. - CreateTime *string `json:"createTime,omitempty"` - - // CreatedBy User who created the role. - CreatedBy *string `json:"createdBy,omitempty"` - - // Description Description of the role. - Description *string `json:"description,omitempty"` - - // DisplayDescription Description displayed in the user interface. - DisplayDescription *string `json:"displayDescription,omitempty"` - - // DisplayName Role name displayed in the user interface. - DisplayName *string `json:"displayName,omitempty"` - - // Id Role ID. - Id *string `json:"id,omitempty"` - - // OrgId ID of the organization the role belongs to. - OrgId *string `json:"orgId,omitempty"` - Privileges *[]RolePrivilegeItem `json:"privileges,omitempty"` - - // RoleName Name of the role. - RoleName *string `json:"roleName,omitempty"` - - // Status Whether the organization's license to use the role is valid or has expired. - Status *RoleStatus `json:"status,omitempty"` - - // SystemRole Whether the role is a system-defined role. - SystemRole *bool `json:"systemRole,omitempty"` - - // UpdateTime Date and time the role was last updated. - UpdateTime *string `json:"updateTime,omitempty"` - - // UpdatedBy User who last updated the role. - UpdatedBy *string `json:"updatedBy,omitempty"` -} - -// GetRolesResponseBody defines model for getRolesResponseBody. -type GetRolesResponseBody = []GetRolesResponseBodyItem - -// GetRolesResponseBodyItem defines model for getRolesResponseBodyItem. -type GetRolesResponseBodyItem struct { - // CreateTime Date and time the role was created. - CreateTime *string `json:"createTime,omitempty"` - - // CreatedBy User who created the role. - CreatedBy *string `json:"createdBy,omitempty"` - - // Description Description of the role. - Description *string `json:"description,omitempty"` - - // DisplayDescription Description displayed in the user interface. - DisplayDescription *string `json:"displayDescription,omitempty"` - - // DisplayName Role name displayed in the user interface. - DisplayName *string `json:"displayName,omitempty"` - - // Id Role ID. - Id *string `json:"id,omitempty"` - - // OrgId ID of the organization the role belongs to. - OrgId *string `json:"orgId,omitempty"` - Privileges *[]RolePrivilegeItem `json:"privileges,omitempty"` - - // RoleName Name of the role. - RoleName *string `json:"roleName,omitempty"` - - // Status Whether the organization's license to use the role is valid or has expired. - Status *RoleStatus `json:"status,omitempty"` - - // SystemRole Whether the role is a system-defined role. - SystemRole *bool `json:"systemRole,omitempty"` - - // UpdateTime Date and time the role was last updated. - UpdateTime *string `json:"updateTime,omitempty"` - - // UpdatedBy User who last updated the role. - UpdatedBy *string `json:"updatedBy,omitempty"` -} - -// LoginRequestBody defines model for loginRequestBody. -type LoginRequestBody struct { - // Password Informatica Intelligent Cloud Services password. - Password string `json:"password"` - - // Username Informatica Intelligent Cloud Services user name for the organization that you want to log in to. - Username string `json:"username"` -} - -// LoginResponseBody defines model for loginResponseBody. -type LoginResponseBody struct { - // Products Subscribed Informatica products. - Products *[]LoginResponseBodyProduct `json:"products,omitempty"` - UserInfo *LoginResponseBodyUserInfo `json:"userInfo,omitempty"` -} - -// LoginResponseBodyProduct defines model for loginResponseBodyProduct. -type LoginResponseBodyProduct struct { - // BaseApiUrl Base API URL for the product. Use in REST API requests. - BaseApiUrl *string `json:"baseApiUrl,omitempty"` - - // Name Product name. - Name *string `json:"name,omitempty"` -} - -// LoginResponseBodyUserInfo defines model for loginResponseBodyUserInfo. -type LoginResponseBodyUserInfo struct { - // Groups User group information for the user. - Groups *map[string]interface{} `json:"groups,omitempty"` - - // Id User ID. - Id *string `json:"id,omitempty"` - - // Name User name. - Name *string `json:"name,omitempty"` - - // OrgId ID of the organization the user belongs to. - OrgId *string `json:"orgId,omitempty"` - - // OrgName Organization name. - OrgName *string `json:"orgName,omitempty"` - - // ParentOrgId Organization ID for the parent. - ParentOrgId *string `json:"parentOrgId,omitempty"` - - // SessionId REST API session ID for the current session. Use in most REST API request headers. - SessionId *string `json:"sessionId,omitempty"` - - // Status Status of the user. - Status *LoginResponseBodyUserInfoStatus `json:"status,omitempty"` -} - -// LoginResponseBodyUserInfoStatus Status of the user. -type LoginResponseBodyUserInfoStatus string - -// RoleInfo defines model for roleInfo. -type RoleInfo struct { - // CreateTime Date and time the role was created. - CreateTime *string `json:"createTime,omitempty"` - - // CreatedBy User who created the role. - CreatedBy *string `json:"createdBy,omitempty"` - - // Description Description of the role. - Description *string `json:"description,omitempty"` - - // DisplayDescription Description displayed in the user interface. - DisplayDescription *string `json:"displayDescription,omitempty"` - - // DisplayName Role name displayed in the user interface. - DisplayName *string `json:"displayName,omitempty"` - - // Id Role ID. - Id *string `json:"id,omitempty"` - - // OrgId ID of the organization the role belongs to. - OrgId *string `json:"orgId,omitempty"` - - // RoleName Name of the role. - RoleName *string `json:"roleName,omitempty"` - - // Status Whether the organization's license to use the role is valid or has expired. - Status *RoleStatus `json:"status,omitempty"` - - // SystemRole Whether the role is a system-defined role. - SystemRole *bool `json:"systemRole,omitempty"` - - // UpdateTime Date and time the role was last updated. - UpdateTime *string `json:"updateTime,omitempty"` - - // UpdatedBy User who last updated the role. - UpdatedBy *string `json:"updatedBy,omitempty"` -} - -// RolePrivilegeItem defines model for rolePrivilegeItem. -type RolePrivilegeItem struct { - // Description Description of the privilege. - Description *string `json:"description,omitempty"` - - // Id Privilege ID. - Id string `json:"id"` - - // Name Name of the privilege. - Name string `json:"name"` - - // Service The Informatica Intelligent Cloud Services service that applies to the privilege. - Service string `json:"service"` - - // Status Status of the privilege. Returns one of the following values: - // * Enabled: License to use the privilege is valid. - // * Disabled: License to use the privilege has expired. - // * Unassigned: No license to use this privilege. - // * Default: Privilege included by default. - Status RolePrivilegeItemStatus `json:"status"` -} - -// RolePrivilegeItemStatus Status of the privilege. Returns one of the following values: -// * Enabled: License to use the privilege is valid. -// * Disabled: License to use the privilege has expired. -// * Unassigned: No license to use this privilege. -// * Default: Privilege included by default. -type RolePrivilegeItemStatus string - -// RoleStatus Whether the organization's license to use the role is valid or has expired. -type RoleStatus string - -// UpdateRoleRequestBody defines model for updateRoleRequestBody. -type UpdateRoleRequestBody struct { - // Privileges IDs of the privileges to assign to the role. - // A role must have at least one privilege assigned to it. - Privileges []string `json:"privileges"` -} - -// WithPrivilegeItems defines model for withPrivilegeItems. -type WithPrivilegeItems struct { - Privileges *[]RolePrivilegeItem `json:"privileges,omitempty"` -} - -// WithPrivilegeRefs defines model for withPrivilegeRefs. -type WithPrivilegeRefs struct { - // Privileges IDs of the privileges to assign to the role. - // A role must have at least one privilege assigned to it. - Privileges *[]string `json:"privileges,omitempty"` -} - -// HeaderSession defines model for headerSession. -type HeaderSession = string - -// PathRole defines model for pathRole. -type PathRole = string - -// N204 When the REST API encounters an error, it returns a REST API error object. -type N204 = ApiErrorResponseBody - -// N400 When the REST API encounters an error, it returns a REST API error object. -type N400 = ApiErrorResponseBody - -// N401 When the REST API encounters an error, it returns a REST API error object. -type N401 = ApiErrorResponseBody - -// N403 When the REST API encounters an error, it returns a REST API error object. -type N403 = ApiErrorResponseBody - -// N404 When the REST API encounters an error, it returns a REST API error object. -type N404 = ApiErrorResponseBody - -// N500 When the REST API encounters an error, it returns a REST API error object. -type N500 = ApiErrorResponseBody - -// N502 When the REST API encounters an error, it returns a REST API error object. -type N502 = ApiErrorResponseBody - -// N503 When the REST API encounters an error, it returns a REST API error object. -type N503 = ApiErrorResponseBody - -// RolePrivileges defines model for rolePrivileges. -type RolePrivileges = UpdateRoleRequestBody - -// /////////////////// - -// ListPrivilegesParams defines parameters for ListPrivileges. -type ListPrivilegesParams struct { - // Q The query string used to filter results. - Q *string `json:"q,omitempty"` -} - -// GetRolesParams defines parameters for GetRoles. -type GetRolesParams struct { - // Q Query filter. You can filter using one of the following fields: - // * roleId. Unique identifier for the role. - // * roleName. Name of the role. - Q *string `form:"q,omitempty" json:"q,omitempty"` - - // Expand Returns the privileges associated with the role specified in the query filter. - Expand *GetRolesParamsExpand `form:"expand,omitempty" json:"expand,omitempty"` - INFASESSIONID HeaderSession `json:"INFA-SESSION-ID"` -} - -// GetRolesParamsExpand defines parameters for GetRoles. -type GetRolesParamsExpand string - -// DeleteRoleParams defines parameters for DeleteRole. -type DeleteRoleParams struct { - INFASESSIONID HeaderSession `json:"INFA-SESSION-ID"` -} - -// AddRolePrivilegesParams defines parameters for AddRolePrivileges. -type AddRolePrivilegesParams struct { - INFASESSIONID HeaderSession `json:"INFA-SESSION-ID"` -} - -// RemoveRolePrivilegesParams defines parameters for RemoveRolePrivileges. -type RemoveRolePrivilegesParams struct { - INFASESSIONID HeaderSession `json:"INFA-SESSION-ID"` -} - // ////////////////////////////////////////////////////////////// - -// //////////////// - -// LoginJSONRequestBody defines body for Login for application/json ContentType. -type LoginJSONRequestBody = LoginRequestBody - -// CreateRoleJSONRequestBody defines body for CreateRole for application/json ContentType. -type CreateRoleJSONRequestBody = CreateRoleRequestBody - -// AddRolePrivilegesJSONRequestBody defines body for AddRolePrivileges for application/json ContentType. -type AddRolePrivilegesJSONRequestBody = UpdateRoleRequestBody - -// RemoveRolePrivilegesJSONRequestBody defines body for RemoveRolePrivileges for application/json ContentType. -type RemoveRolePrivilegesJSONRequestBody = UpdateRoleRequestBody - -// ////////////////////////////////////////////////////////////// - // //////////////////////// // Client which conforms to the OpenAPI3 specification for this service. diff --git a/internal/idmc/v3/codegen.yml b/internal/idmc/v3/codegen.yml index abe436e..7078d65 100644 --- a/internal/idmc/v3/codegen.yml +++ b/internal/idmc/v3/codegen.yml @@ -1,10 +1,6 @@ # yaml-language-server: $schema=https://raw.githubusercontent.com/oapi-codegen/oapi-codegen/HEAD/configuration-schema.json --- -output: ./client.gen.go package: v3 -generate: - client: true - models: true compatibility: always-prefix-enum-values: true additional-imports: @@ -13,10 +9,16 @@ additional-imports: output-options: nullable-type: true user-templates: # https://github.com/oapi-codegen/oapi-codegen/tree/main/pkg/codegen/templates - client-with-responses.tmpl: ../templates/client-with-responses.go.tmpl - client.tmpl: ../templates/client.go.tmpl - constants.tmpl: ../templates/constants.go.tmpl - param-types.tmpl: ../templates/param-types.go.tmpl - request-bodies.tmpl: ../templates/request-bodies.go.tmpl + additional-properties.tmpl: ../templates/additional-properties.go.tmpl + client.tmpl: ../templates/client.go.tmpl + client-with-responses.tmpl: ../templates/client-with-responses.go.tmpl + constants.tmpl: ../templates/constants.go.tmpl + imports.tmpl: ../templates/imports.go.tmpl + inline.tmpl: ../templates/inline.go.tmpl + param-types.tmpl: ../templates/param-types.go.tmpl + request-bodies.tmpl: ../templates/request-bodies.go.tmpl + typedef.tmpl: ../templates/typedef.go.tmpl + union.tmpl: ../templates/union.go.tmpl + union-and-additional-properties.tmpl: ../templates/union-and-additional-properties.go.tmpl import-mapping: ../common/openapi.yml: terraform-provider-idmc/internal/idmc/common diff --git a/internal/idmc/v3/types.gen.go b/internal/idmc/v3/types.gen.go new file mode 100644 index 0000000..7b6822e --- /dev/null +++ b/internal/idmc/v3/types.gen.go @@ -0,0 +1,399 @@ +// /////////////////////// + +// Package v3 provides primitives to interact with the openapi HTTP API. +// +// Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.3.0 DO NOT EDIT. +package v3 + +// ////////////////////////////////////////////////////////////// +// ///////////////////// + +// ////////////////////////////////////////////////////////////// +// ///////////////////// + +// Defines values for LoginResponseBodyUserInfoStatus. +const ( + LoginResponseBodyUserInfoStatusActive LoginResponseBodyUserInfoStatus = "Active" + LoginResponseBodyUserInfoStatusInactive LoginResponseBodyUserInfoStatus = "Inactive" +) + +// Defines values for RolePrivilegeItemStatus. +const ( + RolePrivilegeItemStatusDefault RolePrivilegeItemStatus = "Default" + RolePrivilegeItemStatusDisabled RolePrivilegeItemStatus = "Disabled" + RolePrivilegeItemStatusEnabled RolePrivilegeItemStatus = "Enabled" + RolePrivilegeItemStatusUnassigned RolePrivilegeItemStatus = "Unassigned" +) + +// Defines values for RoleStatus. +const ( + RoleStatusDisabled RoleStatus = "Disabled" + RoleStatusEnabled RoleStatus = "Enabled" +) + +// Defines values for GetRolesParamsExpand. +const ( + GetRolesParamsExpandPrivileges GetRolesParamsExpand = "privileges" +) + +// ////////////////////////////////////////////////////////////// +// /////////////////////// + +// ApiError defines model for apiError. +type ApiError struct { + Code string `json:"code"` + DebugMessage *string `json:"debugMessage,omitempty"` + Details *[]ApiErrorDetail `json:"details,omitempty"` + Message string `json:"message"` + RequestId string `json:"requestId"` +} + +// ApiErrorDetail defines model for apiErrorDetail. +type ApiErrorDetail struct { + Code string `json:"code"` + DebugMessage *string `json:"debugMessage,omitempty"` + Message string `json:"message"` +} + +// ApiErrorResponseBody When the REST API encounters an error, it returns a REST API error object. +type ApiErrorResponseBody struct { + Error ApiError `json:"error"` +} + +// CreateRoleRequestBody defines model for createRoleRequestBody. +type CreateRoleRequestBody struct { + // Description Description of the role. + Description *string `json:"description,omitempty"` + + // Name Name of the role. + Name *string `json:"name,omitempty"` + + // Privileges IDs of the privileges to assign to the role. + // A role must have at least one privilege assigned to it. + Privileges *[]string `json:"privileges,omitempty"` +} + +// CreateRoleResponseBody defines model for createRoleResponseBody. +type CreateRoleResponseBody struct { + // CreateTime Date and time the role was created. + CreateTime *string `json:"createTime,omitempty"` + + // CreatedBy User who created the role. + CreatedBy *string `json:"createdBy,omitempty"` + + // Description Description of the role. + Description *string `json:"description,omitempty"` + + // DisplayDescription Description displayed in the user interface. + DisplayDescription *string `json:"displayDescription,omitempty"` + + // DisplayName Role name displayed in the user interface. + DisplayName *string `json:"displayName,omitempty"` + + // Id Role ID. + Id *string `json:"id,omitempty"` + + // OrgId ID of the organization the role belongs to. + OrgId *string `json:"orgId,omitempty"` + Privileges *[]RolePrivilegeItem `json:"privileges,omitempty"` + + // RoleName Name of the role. + RoleName *string `json:"roleName,omitempty"` + + // Status Whether the organization's license to use the role is valid or has expired. + Status *RoleStatus `json:"status,omitempty"` + + // SystemRole Whether the role is a system-defined role. + SystemRole *bool `json:"systemRole,omitempty"` + + // UpdateTime Date and time the role was last updated. + UpdateTime *string `json:"updateTime,omitempty"` + + // UpdatedBy User who last updated the role. + UpdatedBy *string `json:"updatedBy,omitempty"` +} + +// GetRolesResponseBody defines model for getRolesResponseBody. +type GetRolesResponseBody = []GetRolesResponseBodyItem + +// GetRolesResponseBodyItem defines model for getRolesResponseBodyItem. +type GetRolesResponseBodyItem struct { + // CreateTime Date and time the role was created. + CreateTime *string `json:"createTime,omitempty"` + + // CreatedBy User who created the role. + CreatedBy *string `json:"createdBy,omitempty"` + + // Description Description of the role. + Description *string `json:"description,omitempty"` + + // DisplayDescription Description displayed in the user interface. + DisplayDescription *string `json:"displayDescription,omitempty"` + + // DisplayName Role name displayed in the user interface. + DisplayName *string `json:"displayName,omitempty"` + + // Id Role ID. + Id *string `json:"id,omitempty"` + + // OrgId ID of the organization the role belongs to. + OrgId *string `json:"orgId,omitempty"` + Privileges *[]RolePrivilegeItem `json:"privileges,omitempty"` + + // RoleName Name of the role. + RoleName *string `json:"roleName,omitempty"` + + // Status Whether the organization's license to use the role is valid or has expired. + Status *RoleStatus `json:"status,omitempty"` + + // SystemRole Whether the role is a system-defined role. + SystemRole *bool `json:"systemRole,omitempty"` + + // UpdateTime Date and time the role was last updated. + UpdateTime *string `json:"updateTime,omitempty"` + + // UpdatedBy User who last updated the role. + UpdatedBy *string `json:"updatedBy,omitempty"` +} + +// LoginRequestBody defines model for loginRequestBody. +type LoginRequestBody struct { + // Password Informatica Intelligent Cloud Services password. + Password string `json:"password"` + + // Username Informatica Intelligent Cloud Services user name for the organization that you want to log in to. + Username string `json:"username"` +} + +// LoginResponseBody defines model for loginResponseBody. +type LoginResponseBody struct { + // Products Subscribed Informatica products. + Products *[]LoginResponseBodyProduct `json:"products,omitempty"` + UserInfo *LoginResponseBodyUserInfo `json:"userInfo,omitempty"` +} + +// LoginResponseBodyProduct defines model for loginResponseBodyProduct. +type LoginResponseBodyProduct struct { + // BaseApiUrl Base API URL for the product. Use in REST API requests. + BaseApiUrl *string `json:"baseApiUrl,omitempty"` + + // Name Product name. + Name *string `json:"name,omitempty"` +} + +// LoginResponseBodyUserInfo defines model for loginResponseBodyUserInfo. +type LoginResponseBodyUserInfo struct { + // Groups User group information for the user. + Groups *map[string]interface{} `json:"groups,omitempty"` + + // Id User ID. + Id *string `json:"id,omitempty"` + + // Name User name. + Name *string `json:"name,omitempty"` + + // OrgId ID of the organization the user belongs to. + OrgId *string `json:"orgId,omitempty"` + + // OrgName Organization name. + OrgName *string `json:"orgName,omitempty"` + + // ParentOrgId Organization ID for the parent. + ParentOrgId *string `json:"parentOrgId,omitempty"` + + // SessionId REST API session ID for the current session. Use in most REST API request headers. + SessionId *string `json:"sessionId,omitempty"` + + // Status Status of the user. + Status *LoginResponseBodyUserInfoStatus `json:"status,omitempty"` +} + +// LoginResponseBodyUserInfoStatus Status of the user. +type LoginResponseBodyUserInfoStatus string + +// RoleInfo defines model for roleInfo. +type RoleInfo struct { + // CreateTime Date and time the role was created. + CreateTime *string `json:"createTime,omitempty"` + + // CreatedBy User who created the role. + CreatedBy *string `json:"createdBy,omitempty"` + + // Description Description of the role. + Description *string `json:"description,omitempty"` + + // DisplayDescription Description displayed in the user interface. + DisplayDescription *string `json:"displayDescription,omitempty"` + + // DisplayName Role name displayed in the user interface. + DisplayName *string `json:"displayName,omitempty"` + + // Id Role ID. + Id *string `json:"id,omitempty"` + + // OrgId ID of the organization the role belongs to. + OrgId *string `json:"orgId,omitempty"` + + // RoleName Name of the role. + RoleName *string `json:"roleName,omitempty"` + + // Status Whether the organization's license to use the role is valid or has expired. + Status *RoleStatus `json:"status,omitempty"` + + // SystemRole Whether the role is a system-defined role. + SystemRole *bool `json:"systemRole,omitempty"` + + // UpdateTime Date and time the role was last updated. + UpdateTime *string `json:"updateTime,omitempty"` + + // UpdatedBy User who last updated the role. + UpdatedBy *string `json:"updatedBy,omitempty"` +} + +// RolePrivilegeItem defines model for rolePrivilegeItem. +type RolePrivilegeItem struct { + // Description Description of the privilege. + Description *string `json:"description,omitempty"` + + // Id Privilege ID. + Id string `json:"id"` + + // Name Name of the privilege. + Name string `json:"name"` + + // Service The Informatica Intelligent Cloud Services service that applies to the privilege. + Service string `json:"service"` + + // Status Status of the privilege. Returns one of the following values: + // * Enabled: License to use the privilege is valid. + // * Disabled: License to use the privilege has expired. + // * Unassigned: No license to use this privilege. + // * Default: Privilege included by default. + Status RolePrivilegeItemStatus `json:"status"` +} + +// RolePrivilegeItemStatus Status of the privilege. Returns one of the following values: +// * Enabled: License to use the privilege is valid. +// * Disabled: License to use the privilege has expired. +// * Unassigned: No license to use this privilege. +// * Default: Privilege included by default. +type RolePrivilegeItemStatus string + +// RoleStatus Whether the organization's license to use the role is valid or has expired. +type RoleStatus string + +// UpdateRoleRequestBody defines model for updateRoleRequestBody. +type UpdateRoleRequestBody struct { + // Privileges IDs of the privileges to assign to the role. + // A role must have at least one privilege assigned to it. + Privileges []string `json:"privileges"` +} + +// WithPrivilegeItems defines model for withPrivilegeItems. +type WithPrivilegeItems struct { + Privileges *[]RolePrivilegeItem `json:"privileges,omitempty"` +} + +// WithPrivilegeRefs defines model for withPrivilegeRefs. +type WithPrivilegeRefs struct { + // Privileges IDs of the privileges to assign to the role. + // A role must have at least one privilege assigned to it. + Privileges *[]string `json:"privileges,omitempty"` +} + +// HeaderSession defines model for headerSession. +type HeaderSession = string + +// PathRole defines model for pathRole. +type PathRole = string + +// N204 When the REST API encounters an error, it returns a REST API error object. +type N204 = ApiErrorResponseBody + +// N400 When the REST API encounters an error, it returns a REST API error object. +type N400 = ApiErrorResponseBody + +// N401 When the REST API encounters an error, it returns a REST API error object. +type N401 = ApiErrorResponseBody + +// N403 When the REST API encounters an error, it returns a REST API error object. +type N403 = ApiErrorResponseBody + +// N404 When the REST API encounters an error, it returns a REST API error object. +type N404 = ApiErrorResponseBody + +// N500 When the REST API encounters an error, it returns a REST API error object. +type N500 = ApiErrorResponseBody + +// N502 When the REST API encounters an error, it returns a REST API error object. +type N502 = ApiErrorResponseBody + +// N503 When the REST API encounters an error, it returns a REST API error object. +type N503 = ApiErrorResponseBody + +// RolePrivileges defines model for rolePrivileges. +type RolePrivileges = UpdateRoleRequestBody + +// ////////////////////////////////////////////////////////////// +// /////////////////// + +// ListPrivilegesParams defines parameters for ListPrivileges. +type ListPrivilegesParams struct { + // Q The query string used to filter results. + Q *string `json:"q,omitempty"` +} + +// GetRolesParams defines parameters for GetRoles. +type GetRolesParams struct { + // Q Query filter. You can filter using one of the following fields: + // * roleId. Unique identifier for the role. + // * roleName. Name of the role. + Q *string `form:"q,omitempty" json:"q,omitempty"` + + // Expand Returns the privileges associated with the role specified in the query filter. + Expand *GetRolesParamsExpand `form:"expand,omitempty" json:"expand,omitempty"` + INFASESSIONID HeaderSession `json:"INFA-SESSION-ID"` +} + +// GetRolesParamsExpand defines parameters for GetRoles. +type GetRolesParamsExpand string + +// DeleteRoleParams defines parameters for DeleteRole. +type DeleteRoleParams struct { + INFASESSIONID HeaderSession `json:"INFA-SESSION-ID"` +} + +// AddRolePrivilegesParams defines parameters for AddRolePrivileges. +type AddRolePrivilegesParams struct { + INFASESSIONID HeaderSession `json:"INFA-SESSION-ID"` +} + +// RemoveRolePrivilegesParams defines parameters for RemoveRolePrivileges. +type RemoveRolePrivilegesParams struct { + INFASESSIONID HeaderSession `json:"INFA-SESSION-ID"` +} + +// ////////////////////////////////////////////////////////////// + +// //////////////// + +// LoginJSONRequestBody defines body for Login for application/json ContentType. +type LoginJSONRequestBody = LoginRequestBody + +// CreateRoleJSONRequestBody defines body for CreateRole for application/json ContentType. +type CreateRoleJSONRequestBody = CreateRoleRequestBody + +// AddRolePrivilegesJSONRequestBody defines body for AddRolePrivileges for application/json ContentType. +type AddRolePrivilegesJSONRequestBody = UpdateRoleRequestBody + +// RemoveRolePrivilegesJSONRequestBody defines body for RemoveRolePrivileges for application/json ContentType. +type RemoveRolePrivilegesJSONRequestBody = UpdateRoleRequestBody + +// ////////////////////////////////////////////////////////////// + +// ///////// + +// ////////////////////////////////////////////////////////////// +// ///////// + +// //////////////////////////////////////////////////////////////