diff --git a/go.work b/go.work index 94f06ff1b..456c29cc7 100644 --- a/go.work +++ b/go.work @@ -38,6 +38,7 @@ use ( ./services/dns ./services/iaas ./services/iaasalpha + ./services/kms ./services/lbapplication ./services/loadbalancer ./services/logme diff --git a/services/kms/.openapi-generator/VERSION b/services/kms/.openapi-generator/VERSION new file mode 100644 index 000000000..cd802a1ec --- /dev/null +++ b/services/kms/.openapi-generator/VERSION @@ -0,0 +1 @@ +6.6.0 \ No newline at end of file diff --git a/services/kms/api_default.go b/services/kms/api_default.go new file mode 100644 index 000000000..91eeb5857 --- /dev/null +++ b/services/kms/api_default.go @@ -0,0 +1,3463 @@ +/* +STACKIT Key Management Service API + +This API provides endpoints for managing keys and key rings. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package kms + +import ( + "bytes" + "context" + "fmt" + "io" + "net/http" + "net/url" + "strings" + + "github.com/stackitcloud/stackit-sdk-go/core/config" + "github.com/stackitcloud/stackit-sdk-go/core/oapierror" +) + +// DefaultApiService DefaultApi service +type DefaultApiService service + +type ApiCreateKeyRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + regionId string + keyRingId string + createKeyPayload *CreateKeyPayload +} + +func (r ApiCreateKeyRequest) CreateKeyPayload(createKeyPayload CreateKeyPayload) ApiCreateKeyRequest { + r.createKeyPayload = &createKeyPayload + return r +} + +func (r ApiCreateKeyRequest) Execute() (*Key, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *Key + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.CreateKey") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(r.regionId, "regionId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(r.keyRingId, "keyRingId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.createKeyPayload == nil { + return localVarReturnValue, fmt.Errorf("createKeyPayload is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // 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 + } + // body params + localVarPostBody = r.createKeyPayload + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 401 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + } + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +/* +CreateKey: Create key + +Creates a new key for the given key ring. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the key ring is part of. + @param regionId The STACKIT region name the key ring is located in. + @param keyRingId The key ring UUID. + @return ApiCreateKeyRequest +*/ +func (a *APIClient) CreateKey(ctx context.Context, projectId string, regionId string, keyRingId string) ApiCreateKeyRequest { + return ApiCreateKeyRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + regionId: regionId, + keyRingId: keyRingId, + } +} + +func (a *APIClient) CreateKeyExecute(ctx context.Context, projectId string, regionId string, keyRingId string) (*Key, error) { + r := ApiCreateKeyRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + regionId: regionId, + keyRingId: keyRingId, + } + return r.Execute() +} + +type ApiCreateKeyRingRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + regionId string + createKeyRingPayload *CreateKeyRingPayload +} + +func (r ApiCreateKeyRingRequest) CreateKeyRingPayload(createKeyRingPayload CreateKeyRingPayload) ApiCreateKeyRingRequest { + r.createKeyRingPayload = &createKeyRingPayload + return r +} + +func (r ApiCreateKeyRingRequest) Execute() (*KeyRing, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *KeyRing + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.CreateKeyRing") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1beta/projects/{projectId}/regions/{regionId}/keyrings" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(r.regionId, "regionId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.createKeyRingPayload == nil { + return localVarReturnValue, fmt.Errorf("createKeyRingPayload is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // 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 + } + // body params + localVarPostBody = r.createKeyRingPayload + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 401 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + } + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +/* +CreateKeyRing: Create key ring + +Creates a new key ring within the project. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the key ring is part of. + @param regionId The STACKIT region name the key ring is located in. + @return ApiCreateKeyRingRequest +*/ +func (a *APIClient) CreateKeyRing(ctx context.Context, projectId string, regionId string) ApiCreateKeyRingRequest { + return ApiCreateKeyRingRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + regionId: regionId, + } +} + +func (a *APIClient) CreateKeyRingExecute(ctx context.Context, projectId string, regionId string) (*KeyRing, error) { + r := ApiCreateKeyRingRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + regionId: regionId, + } + return r.Execute() +} + +type ApiCreateWrappingKeyRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + regionId string + keyRingId string + createWrappingKeyPayload *CreateWrappingKeyPayload +} + +func (r ApiCreateWrappingKeyRequest) CreateWrappingKeyPayload(createWrappingKeyPayload CreateWrappingKeyPayload) ApiCreateWrappingKeyRequest { + r.createWrappingKeyPayload = &createWrappingKeyPayload + return r +} + +func (r ApiCreateWrappingKeyRequest) Execute() (*WrappingKey, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *WrappingKey + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.CreateWrappingKey") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/wrappingkeys" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(r.regionId, "regionId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(r.keyRingId, "keyRingId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.createWrappingKeyPayload == nil { + return localVarReturnValue, fmt.Errorf("createWrappingKeyPayload is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // 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 + } + // body params + localVarPostBody = r.createWrappingKeyPayload + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 401 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + } + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +/* +CreateWrappingKey: Create wrapping key + +Creates a new wrapping key for the given key ring. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the key ring is part of. + @param regionId The STACKIT region name the key ring is located in. + @param keyRingId The key ring UUID. + @return ApiCreateWrappingKeyRequest +*/ +func (a *APIClient) CreateWrappingKey(ctx context.Context, projectId string, regionId string, keyRingId string) ApiCreateWrappingKeyRequest { + return ApiCreateWrappingKeyRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + regionId: regionId, + keyRingId: keyRingId, + } +} + +func (a *APIClient) CreateWrappingKeyExecute(ctx context.Context, projectId string, regionId string, keyRingId string) (*WrappingKey, error) { + r := ApiCreateWrappingKeyRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + regionId: regionId, + keyRingId: keyRingId, + } + return r.Execute() +} + +type ApiDecryptRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + regionId string + keyRingId string + keyId string + versionNumber int64 + decryptPayload *DecryptPayload +} + +func (r ApiDecryptRequest) DecryptPayload(decryptPayload DecryptPayload) ApiDecryptRequest { + r.decryptPayload = &decryptPayload + return r +} + +func (r ApiDecryptRequest) Execute() (*DecryptedData, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *DecryptedData + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.Decrypt") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions/{versionNumber}/decrypt" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(r.regionId, "regionId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(r.keyRingId, "keyRingId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"keyId"+"}", url.PathEscape(ParameterValueToString(r.keyId, "keyId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"versionNumber"+"}", url.PathEscape(ParameterValueToString(r.versionNumber, "versionNumber")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.decryptPayload == nil { + return localVarReturnValue, fmt.Errorf("decryptPayload is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // 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 + } + // body params + localVarPostBody = r.decryptPayload + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 401 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 409 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + } + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +/* +Decrypt: Decrypt + +Decrypts data using the given key version. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the key ring is part of. + @param regionId The STACKIT region name the key ring is located in. + @param keyRingId The key ring UUID. + @param keyId The key UUID. + @param versionNumber The version number. + @return ApiDecryptRequest +*/ +func (a *APIClient) Decrypt(ctx context.Context, projectId string, regionId string, keyRingId string, keyId string, versionNumber int64) ApiDecryptRequest { + return ApiDecryptRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + regionId: regionId, + keyRingId: keyRingId, + keyId: keyId, + versionNumber: versionNumber, + } +} + +func (a *APIClient) DecryptExecute(ctx context.Context, projectId string, regionId string, keyRingId string, keyId string, versionNumber int64) (*DecryptedData, error) { + r := ApiDecryptRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + regionId: regionId, + keyRingId: keyRingId, + keyId: keyId, + versionNumber: versionNumber, + } + return r.Execute() +} + +type ApiDisableVersionRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + regionId string + keyRingId string + keyId string + versionNumber int64 +} + +func (r ApiDisableVersionRequest) Execute() error { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.DisableVersion") + if err != nil { + return &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions/{versionNumber}/disable" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(r.regionId, "regionId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(r.keyRingId, "keyRingId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"keyId"+"}", url.PathEscape(ParameterValueToString(r.keyId, "keyId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"versionNumber"+"}", url.PathEscape(ParameterValueToString(r.versionNumber, "versionNumber")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return newErr + } + if localVarHTTPResponse.StatusCode == 401 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + } + return newErr + } + + return nil +} + +/* +DisableVersion: Disable version + +Disables the given version. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the key ring is part of. + @param regionId The STACKIT region name the key ring is located in. + @param keyRingId The key ring UUID. + @param keyId The key UUID. + @param versionNumber The version number. + @return ApiDisableVersionRequest +*/ +func (a *APIClient) DisableVersion(ctx context.Context, projectId string, regionId string, keyRingId string, keyId string, versionNumber int64) ApiDisableVersionRequest { + return ApiDisableVersionRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + regionId: regionId, + keyRingId: keyRingId, + keyId: keyId, + versionNumber: versionNumber, + } +} + +func (a *APIClient) DisableVersionExecute(ctx context.Context, projectId string, regionId string, keyRingId string, keyId string, versionNumber int64) error { + r := ApiDisableVersionRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + regionId: regionId, + keyRingId: keyRingId, + keyId: keyId, + versionNumber: versionNumber, + } + return r.Execute() +} + +type ApiEnableVersionRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + regionId string + keyRingId string + keyId string + versionNumber int64 +} + +func (r ApiEnableVersionRequest) Execute() error { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.EnableVersion") + if err != nil { + return &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions/{versionNumber}/enable" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(r.regionId, "regionId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(r.keyRingId, "keyRingId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"keyId"+"}", url.PathEscape(ParameterValueToString(r.keyId, "keyId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"versionNumber"+"}", url.PathEscape(ParameterValueToString(r.versionNumber, "versionNumber")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return newErr + } + if localVarHTTPResponse.StatusCode == 401 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + } + return newErr + } + + return nil +} + +/* +EnableVersion: Enable version + +Enables the given version. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the key ring is part of. + @param regionId The STACKIT region name the key ring is located in. + @param keyRingId The key ring UUID. + @param keyId The key UUID. + @param versionNumber The version number. + @return ApiEnableVersionRequest +*/ +func (a *APIClient) EnableVersion(ctx context.Context, projectId string, regionId string, keyRingId string, keyId string, versionNumber int64) ApiEnableVersionRequest { + return ApiEnableVersionRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + regionId: regionId, + keyRingId: keyRingId, + keyId: keyId, + versionNumber: versionNumber, + } +} + +func (a *APIClient) EnableVersionExecute(ctx context.Context, projectId string, regionId string, keyRingId string, keyId string, versionNumber int64) error { + r := ApiEnableVersionRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + regionId: regionId, + keyRingId: keyRingId, + keyId: keyId, + versionNumber: versionNumber, + } + return r.Execute() +} + +type ApiEncryptRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + regionId string + keyRingId string + keyId string + versionNumber int64 + encryptPayload *EncryptPayload +} + +func (r ApiEncryptRequest) EncryptPayload(encryptPayload EncryptPayload) ApiEncryptRequest { + r.encryptPayload = &encryptPayload + return r +} + +func (r ApiEncryptRequest) Execute() (*EncryptedData, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *EncryptedData + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.Encrypt") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions/{versionNumber}/encrypt" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(r.regionId, "regionId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(r.keyRingId, "keyRingId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"keyId"+"}", url.PathEscape(ParameterValueToString(r.keyId, "keyId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"versionNumber"+"}", url.PathEscape(ParameterValueToString(r.versionNumber, "versionNumber")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.encryptPayload == nil { + return localVarReturnValue, fmt.Errorf("encryptPayload is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // 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 + } + // body params + localVarPostBody = r.encryptPayload + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 401 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 409 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + } + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +/* +Encrypt: Encrypt + +Encrypts data using the given key version. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the key ring is part of. + @param regionId The STACKIT region name the key ring is located in. + @param keyRingId The key ring UUID. + @param keyId The key UUID. + @param versionNumber The version number. + @return ApiEncryptRequest +*/ +func (a *APIClient) Encrypt(ctx context.Context, projectId string, regionId string, keyRingId string, keyId string, versionNumber int64) ApiEncryptRequest { + return ApiEncryptRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + regionId: regionId, + keyRingId: keyRingId, + keyId: keyId, + versionNumber: versionNumber, + } +} + +func (a *APIClient) EncryptExecute(ctx context.Context, projectId string, regionId string, keyRingId string, keyId string, versionNumber int64) (*EncryptedData, error) { + r := ApiEncryptRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + regionId: regionId, + keyRingId: keyRingId, + keyId: keyId, + versionNumber: versionNumber, + } + return r.Execute() +} + +type ApiGetKeyRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + regionId string + keyRingId string + keyId string +} + +func (r ApiGetKeyRequest) Execute() (*Key, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *Key + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.GetKey") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(r.regionId, "regionId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(r.keyRingId, "keyRingId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"keyId"+"}", url.PathEscape(ParameterValueToString(r.keyId, "keyId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 401 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + } + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +/* +GetKey: Get key + +Returns the details for the given key. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the key ring is part of. + @param regionId The STACKIT region name the key ring is located in. + @param keyRingId The key ring UUID. + @param keyId The key UUID. + @return ApiGetKeyRequest +*/ +func (a *APIClient) GetKey(ctx context.Context, projectId string, regionId string, keyRingId string, keyId string) ApiGetKeyRequest { + return ApiGetKeyRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + regionId: regionId, + keyRingId: keyRingId, + keyId: keyId, + } +} + +func (a *APIClient) GetKeyExecute(ctx context.Context, projectId string, regionId string, keyRingId string, keyId string) (*Key, error) { + r := ApiGetKeyRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + regionId: regionId, + keyRingId: keyRingId, + keyId: keyId, + } + return r.Execute() +} + +type ApiGetKeyRingRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + regionId string + keyRingId string +} + +func (r ApiGetKeyRingRequest) Execute() (*KeyRing, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *KeyRing + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.GetKeyRing") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(r.regionId, "regionId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(r.keyRingId, "keyRingId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 401 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + } + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +/* +GetKeyRing: Get key ring + +Returns the details for the given key ring. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the key ring is part of. + @param regionId The STACKIT region name the key ring is located in. + @param keyRingId The key ring UUID. + @return ApiGetKeyRingRequest +*/ +func (a *APIClient) GetKeyRing(ctx context.Context, projectId string, regionId string, keyRingId string) ApiGetKeyRingRequest { + return ApiGetKeyRingRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + regionId: regionId, + keyRingId: keyRingId, + } +} + +func (a *APIClient) GetKeyRingExecute(ctx context.Context, projectId string, regionId string, keyRingId string) (*KeyRing, error) { + r := ApiGetKeyRingRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + regionId: regionId, + keyRingId: keyRingId, + } + return r.Execute() +} + +type ApiGetVersionRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + regionId string + keyRingId string + keyId string + versionNumber int64 +} + +func (r ApiGetVersionRequest) Execute() (*Version, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *Version + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.GetVersion") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions/{versionNumber}" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(r.regionId, "regionId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(r.keyRingId, "keyRingId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"keyId"+"}", url.PathEscape(ParameterValueToString(r.keyId, "keyId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"versionNumber"+"}", url.PathEscape(ParameterValueToString(r.versionNumber, "versionNumber")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 401 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + } + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +/* +GetVersion: Get version + +Returns the details for the given version. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the key ring is part of. + @param regionId The STACKIT region name the key ring is located in. + @param keyRingId The key ring UUID. + @param keyId The key UUID. + @param versionNumber The version number. + @return ApiGetVersionRequest +*/ +func (a *APIClient) GetVersion(ctx context.Context, projectId string, regionId string, keyRingId string, keyId string, versionNumber int64) ApiGetVersionRequest { + return ApiGetVersionRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + regionId: regionId, + keyRingId: keyRingId, + keyId: keyId, + versionNumber: versionNumber, + } +} + +func (a *APIClient) GetVersionExecute(ctx context.Context, projectId string, regionId string, keyRingId string, keyId string, versionNumber int64) (*Version, error) { + r := ApiGetVersionRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + regionId: regionId, + keyRingId: keyRingId, + keyId: keyId, + versionNumber: versionNumber, + } + return r.Execute() +} + +type ApiGetWrappingKeyRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + regionId string + keyRingId string + wrappingKeyId string +} + +func (r ApiGetWrappingKeyRequest) Execute() (*WrappingKey, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *WrappingKey + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.GetWrappingKey") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/wrappingkeys/{wrappingKeyId}" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(r.regionId, "regionId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(r.keyRingId, "keyRingId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"wrappingKeyId"+"}", url.PathEscape(ParameterValueToString(r.wrappingKeyId, "wrappingKeyId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 401 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + } + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +/* +GetWrappingKey: Get wrapping key + +Returns the details for the given wrapping key. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the key ring is part of. + @param regionId The STACKIT region name the key ring is located in. + @param keyRingId The key ring UUID. + @param wrappingKeyId The wrapping key UUID. + @return ApiGetWrappingKeyRequest +*/ +func (a *APIClient) GetWrappingKey(ctx context.Context, projectId string, regionId string, keyRingId string, wrappingKeyId string) ApiGetWrappingKeyRequest { + return ApiGetWrappingKeyRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + regionId: regionId, + keyRingId: keyRingId, + wrappingKeyId: wrappingKeyId, + } +} + +func (a *APIClient) GetWrappingKeyExecute(ctx context.Context, projectId string, regionId string, keyRingId string, wrappingKeyId string) (*WrappingKey, error) { + r := ApiGetWrappingKeyRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + regionId: regionId, + keyRingId: keyRingId, + wrappingKeyId: wrappingKeyId, + } + return r.Execute() +} + +type ApiImportKeyRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + regionId string + keyRingId string + keyId string + importKeyPayload *ImportKeyPayload +} + +func (r ApiImportKeyRequest) ImportKeyPayload(importKeyPayload ImportKeyPayload) ApiImportKeyRequest { + r.importKeyPayload = &importKeyPayload + return r +} + +func (r ApiImportKeyRequest) Execute() (*Key, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *Key + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ImportKey") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/import" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(r.regionId, "regionId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(r.keyRingId, "keyRingId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"keyId"+"}", url.PathEscape(ParameterValueToString(r.keyId, "keyId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.importKeyPayload == nil { + return localVarReturnValue, fmt.Errorf("importKeyPayload is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // 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 + } + // body params + localVarPostBody = r.importKeyPayload + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 401 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 409 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + } + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +/* +ImportKey: Import key + +Imports a new version to the given key. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the key ring is part of. + @param regionId The STACKIT region name the key ring is located in. + @param keyRingId The key ring UUID. + @param keyId The key UUID. + @return ApiImportKeyRequest +*/ +func (a *APIClient) ImportKey(ctx context.Context, projectId string, regionId string, keyRingId string, keyId string) ApiImportKeyRequest { + return ApiImportKeyRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + regionId: regionId, + keyRingId: keyRingId, + keyId: keyId, + } +} + +func (a *APIClient) ImportKeyExecute(ctx context.Context, projectId string, regionId string, keyRingId string, keyId string) (*Key, error) { + r := ApiImportKeyRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + regionId: regionId, + keyRingId: keyRingId, + keyId: keyId, + } + return r.Execute() +} + +type ApiListKeyRingsRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + regionId string +} + +func (r ApiListKeyRingsRequest) Execute() (*KeyRingList, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *KeyRingList + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ListKeyRings") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1beta/projects/{projectId}/regions/{regionId}/keyrings" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(r.regionId, "regionId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 401 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + } + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +/* +ListKeyRings: List key rings + +Returns a list of all key rings within the project. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the key ring is part of. + @param regionId The STACKIT region name the key ring is located in. + @return ApiListKeyRingsRequest +*/ +func (a *APIClient) ListKeyRings(ctx context.Context, projectId string, regionId string) ApiListKeyRingsRequest { + return ApiListKeyRingsRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + regionId: regionId, + } +} + +func (a *APIClient) ListKeyRingsExecute(ctx context.Context, projectId string, regionId string) (*KeyRingList, error) { + r := ApiListKeyRingsRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + regionId: regionId, + } + return r.Execute() +} + +type ApiListKeysRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + regionId string + keyRingId string +} + +func (r ApiListKeysRequest) Execute() (*KeyList, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *KeyList + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ListKeys") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(r.regionId, "regionId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(r.keyRingId, "keyRingId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 401 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + } + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +/* +ListKeys: List keys + +Returns the keys for the given key ring. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the key ring is part of. + @param regionId The STACKIT region name the key ring is located in. + @param keyRingId The key ring UUID. + @return ApiListKeysRequest +*/ +func (a *APIClient) ListKeys(ctx context.Context, projectId string, regionId string, keyRingId string) ApiListKeysRequest { + return ApiListKeysRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + regionId: regionId, + keyRingId: keyRingId, + } +} + +func (a *APIClient) ListKeysExecute(ctx context.Context, projectId string, regionId string, keyRingId string) (*KeyList, error) { + r := ApiListKeysRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + regionId: regionId, + keyRingId: keyRingId, + } + return r.Execute() +} + +type ApiListVersionsRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + regionId string + keyRingId string + keyId string +} + +func (r ApiListVersionsRequest) Execute() (*VersionList, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *VersionList + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ListVersions") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(r.regionId, "regionId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(r.keyRingId, "keyRingId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"keyId"+"}", url.PathEscape(ParameterValueToString(r.keyId, "keyId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 401 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + } + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +/* +ListVersions: List versions + +Returns a list of all versions of a given key. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the key ring is part of. + @param regionId The STACKIT region name the key ring is located in. + @param keyRingId The key ring UUID. + @param keyId The key UUID. + @return ApiListVersionsRequest +*/ +func (a *APIClient) ListVersions(ctx context.Context, projectId string, regionId string, keyRingId string, keyId string) ApiListVersionsRequest { + return ApiListVersionsRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + regionId: regionId, + keyRingId: keyRingId, + keyId: keyId, + } +} + +func (a *APIClient) ListVersionsExecute(ctx context.Context, projectId string, regionId string, keyRingId string, keyId string) (*VersionList, error) { + r := ApiListVersionsRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + regionId: regionId, + keyRingId: keyRingId, + keyId: keyId, + } + return r.Execute() +} + +type ApiListWrappingKeysRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + regionId string + keyRingId string +} + +func (r ApiListWrappingKeysRequest) Execute() (*WrappingKeyList, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *WrappingKeyList + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ListWrappingKeys") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/wrappingkeys" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(r.regionId, "regionId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(r.keyRingId, "keyRingId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 401 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + } + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +/* +ListWrappingKeys: List wrapping keys + +Returns the wrapping keys for the given key ring. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the key ring is part of. + @param regionId The STACKIT region name the key ring is located in. + @param keyRingId The key ring UUID. + @return ApiListWrappingKeysRequest +*/ +func (a *APIClient) ListWrappingKeys(ctx context.Context, projectId string, regionId string, keyRingId string) ApiListWrappingKeysRequest { + return ApiListWrappingKeysRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + regionId: regionId, + keyRingId: keyRingId, + } +} + +func (a *APIClient) ListWrappingKeysExecute(ctx context.Context, projectId string, regionId string, keyRingId string) (*WrappingKeyList, error) { + r := ApiListWrappingKeysRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + regionId: regionId, + keyRingId: keyRingId, + } + return r.Execute() +} + +type ApiRotateKeyRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + regionId string + keyRingId string + keyId string +} + +func (r ApiRotateKeyRequest) Execute() (*Key, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *Key + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.RotateKey") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/rotate" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(r.regionId, "regionId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(r.keyRingId, "keyRingId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"keyId"+"}", url.PathEscape(ParameterValueToString(r.keyId, "keyId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 401 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 403 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 409 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + } + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +/* +RotateKey: Rotate key + +Rotates the given key. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the key ring is part of. + @param regionId The STACKIT region name the key ring is located in. + @param keyRingId The key ring UUID. + @param keyId The key UUID. + @return ApiRotateKeyRequest +*/ +func (a *APIClient) RotateKey(ctx context.Context, projectId string, regionId string, keyRingId string, keyId string) ApiRotateKeyRequest { + return ApiRotateKeyRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + regionId: regionId, + keyRingId: keyRingId, + keyId: keyId, + } +} + +func (a *APIClient) RotateKeyExecute(ctx context.Context, projectId string, regionId string, keyRingId string, keyId string) (*Key, error) { + r := ApiRotateKeyRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + regionId: regionId, + keyRingId: keyRingId, + keyId: keyId, + } + return r.Execute() +} + +type ApiSignRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + regionId string + keyRingId string + keyId string + versionNumber int64 + signPayload *SignPayload +} + +func (r ApiSignRequest) SignPayload(signPayload SignPayload) ApiSignRequest { + r.signPayload = &signPayload + return r +} + +func (r ApiSignRequest) Execute() (*SignedData, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *SignedData + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.Sign") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions/{versionNumber}/sign" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(r.regionId, "regionId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(r.keyRingId, "keyRingId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"keyId"+"}", url.PathEscape(ParameterValueToString(r.keyId, "keyId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"versionNumber"+"}", url.PathEscape(ParameterValueToString(r.versionNumber, "versionNumber")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.signPayload == nil { + return localVarReturnValue, fmt.Errorf("signPayload is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // 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 + } + // body params + localVarPostBody = r.signPayload + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 401 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 409 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + } + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +/* +Sign: Sign + +Sign data using the given key version as secret. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the key ring is part of. + @param regionId The STACKIT region name the key ring is located in. + @param keyRingId The key ring UUID. + @param keyId The key UUID. + @param versionNumber The version number. + @return ApiSignRequest +*/ +func (a *APIClient) Sign(ctx context.Context, projectId string, regionId string, keyRingId string, keyId string, versionNumber int64) ApiSignRequest { + return ApiSignRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + regionId: regionId, + keyRingId: keyRingId, + keyId: keyId, + versionNumber: versionNumber, + } +} + +func (a *APIClient) SignExecute(ctx context.Context, projectId string, regionId string, keyRingId string, keyId string, versionNumber int64) (*SignedData, error) { + r := ApiSignRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + regionId: regionId, + keyRingId: keyRingId, + keyId: keyId, + versionNumber: versionNumber, + } + return r.Execute() +} + +type ApiVerifyRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + regionId string + keyRingId string + keyId string + versionNumber int64 + verifyPayload *VerifyPayload +} + +func (r ApiVerifyRequest) VerifyPayload(verifyPayload VerifyPayload) ApiVerifyRequest { + r.verifyPayload = &verifyPayload + return r +} + +func (r ApiVerifyRequest) Execute() (*VerifiedData, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *VerifiedData + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.Verify") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions/{versionNumber}/verify" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(r.regionId, "regionId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(r.keyRingId, "keyRingId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"keyId"+"}", url.PathEscape(ParameterValueToString(r.keyId, "keyId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"versionNumber"+"}", url.PathEscape(ParameterValueToString(r.versionNumber, "versionNumber")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.verifyPayload == nil { + return localVarReturnValue, fmt.Errorf("verifyPayload is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // 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 + } + // body params + localVarPostBody = r.verifyPayload + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 401 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 409 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v HttpError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + } + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +/* +Verify: Verify + +Verify data using the given key version as secret. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the key ring is part of. + @param regionId The STACKIT region name the key ring is located in. + @param keyRingId The key ring UUID. + @param keyId The key UUID. + @param versionNumber The version number. + @return ApiVerifyRequest +*/ +func (a *APIClient) Verify(ctx context.Context, projectId string, regionId string, keyRingId string, keyId string, versionNumber int64) ApiVerifyRequest { + return ApiVerifyRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + regionId: regionId, + keyRingId: keyRingId, + keyId: keyId, + versionNumber: versionNumber, + } +} + +func (a *APIClient) VerifyExecute(ctx context.Context, projectId string, regionId string, keyRingId string, keyId string, versionNumber int64) (*VerifiedData, error) { + r := ApiVerifyRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + regionId: regionId, + keyRingId: keyRingId, + keyId: keyId, + versionNumber: versionNumber, + } + return r.Execute() +} diff --git a/services/kms/api_default_test.go b/services/kms/api_default_test.go new file mode 100644 index 000000000..48be45645 --- /dev/null +++ b/services/kms/api_default_test.go @@ -0,0 +1,1176 @@ +/* +STACKIT Key Management Service API + +Testing DefaultApiService + +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); + +package kms + +import ( + "context" + "encoding/json" + "net/http" + "net/http/httptest" + "net/url" + "strings" + "testing" + + "github.com/google/uuid" + "github.com/stackitcloud/stackit-sdk-go/core/config" +) + +func Test_kms_DefaultApiService(t *testing.T) { + + t.Run("Test DefaultApiService CreateKey", func(t *testing.T) { + _apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys" + projectIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) + regionIdValue := "regionId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1) + keyRingIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(keyRingIdValue, "keyRingId")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + data := Key{} + w.Header().Add("Content-Type", "application/json") + json.NewEncoder(w).Encode(data) + }) + testServer := httptest.NewServer(testDefaultApiServeMux) + defer testServer.Close() + + configuration := &config.Configuration{ + DefaultHeader: make(map[string]string), + UserAgent: "OpenAPI-Generator/1.0.0/go", + Debug: false, + Region: "test_region", + Servers: config.ServerConfigurations{ + { + URL: testServer.URL, + Description: "Localhost for kms_DefaultApi", + Variables: map[string]config.ServerVariable{ + "region": { + DefaultValue: "test_region.", + EnumValues: []string{ + "test_region.", + }, + }, + }, + }, + }, + OperationServers: map[string]config.ServerConfigurations{}, + } + apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication()) + if err != nil { + t.Fatalf("creating API client: %v", err) + } + + projectId := projectIdValue + regionId := regionIdValue + keyRingId := keyRingIdValue + createKeyPayload := CreateKeyPayload{} + + resp, reqErr := apiClient.CreateKey(context.Background(), projectId, regionId, keyRingId).CreateKeyPayload(createKeyPayload).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if IsNil(resp) { + t.Fatalf("response not present") + } + }) + + t.Run("Test DefaultApiService CreateKeyRing", func(t *testing.T) { + _apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings" + projectIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) + regionIdValue := "regionId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + data := KeyRing{} + w.Header().Add("Content-Type", "application/json") + json.NewEncoder(w).Encode(data) + }) + testServer := httptest.NewServer(testDefaultApiServeMux) + defer testServer.Close() + + configuration := &config.Configuration{ + DefaultHeader: make(map[string]string), + UserAgent: "OpenAPI-Generator/1.0.0/go", + Debug: false, + Region: "test_region", + Servers: config.ServerConfigurations{ + { + URL: testServer.URL, + Description: "Localhost for kms_DefaultApi", + Variables: map[string]config.ServerVariable{ + "region": { + DefaultValue: "test_region.", + EnumValues: []string{ + "test_region.", + }, + }, + }, + }, + }, + OperationServers: map[string]config.ServerConfigurations{}, + } + apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication()) + if err != nil { + t.Fatalf("creating API client: %v", err) + } + + projectId := projectIdValue + regionId := regionIdValue + createKeyRingPayload := CreateKeyRingPayload{} + + resp, reqErr := apiClient.CreateKeyRing(context.Background(), projectId, regionId).CreateKeyRingPayload(createKeyRingPayload).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if IsNil(resp) { + t.Fatalf("response not present") + } + }) + + t.Run("Test DefaultApiService CreateWrappingKey", func(t *testing.T) { + _apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/wrappingkeys" + projectIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) + regionIdValue := "regionId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1) + keyRingIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(keyRingIdValue, "keyRingId")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + data := WrappingKey{} + w.Header().Add("Content-Type", "application/json") + json.NewEncoder(w).Encode(data) + }) + testServer := httptest.NewServer(testDefaultApiServeMux) + defer testServer.Close() + + configuration := &config.Configuration{ + DefaultHeader: make(map[string]string), + UserAgent: "OpenAPI-Generator/1.0.0/go", + Debug: false, + Region: "test_region", + Servers: config.ServerConfigurations{ + { + URL: testServer.URL, + Description: "Localhost for kms_DefaultApi", + Variables: map[string]config.ServerVariable{ + "region": { + DefaultValue: "test_region.", + EnumValues: []string{ + "test_region.", + }, + }, + }, + }, + }, + OperationServers: map[string]config.ServerConfigurations{}, + } + apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication()) + if err != nil { + t.Fatalf("creating API client: %v", err) + } + + projectId := projectIdValue + regionId := regionIdValue + keyRingId := keyRingIdValue + createWrappingKeyPayload := CreateWrappingKeyPayload{} + + resp, reqErr := apiClient.CreateWrappingKey(context.Background(), projectId, regionId, keyRingId).CreateWrappingKeyPayload(createWrappingKeyPayload).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if IsNil(resp) { + t.Fatalf("response not present") + } + }) + + t.Run("Test DefaultApiService Decrypt", func(t *testing.T) { + _apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions/{versionNumber}/decrypt" + projectIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) + regionIdValue := "regionId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1) + keyRingIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(keyRingIdValue, "keyRingId")), -1) + keyIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyId"+"}", url.PathEscape(ParameterValueToString(keyIdValue, "keyId")), -1) + versionNumberValue := int64(123) + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"versionNumber"+"}", url.PathEscape(ParameterValueToString(versionNumberValue, "versionNumber")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + data := DecryptedData{} + w.Header().Add("Content-Type", "application/json") + json.NewEncoder(w).Encode(data) + }) + testServer := httptest.NewServer(testDefaultApiServeMux) + defer testServer.Close() + + configuration := &config.Configuration{ + DefaultHeader: make(map[string]string), + UserAgent: "OpenAPI-Generator/1.0.0/go", + Debug: false, + Region: "test_region", + Servers: config.ServerConfigurations{ + { + URL: testServer.URL, + Description: "Localhost for kms_DefaultApi", + Variables: map[string]config.ServerVariable{ + "region": { + DefaultValue: "test_region.", + EnumValues: []string{ + "test_region.", + }, + }, + }, + }, + }, + OperationServers: map[string]config.ServerConfigurations{}, + } + apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication()) + if err != nil { + t.Fatalf("creating API client: %v", err) + } + + projectId := projectIdValue + regionId := regionIdValue + keyRingId := keyRingIdValue + keyId := keyIdValue + versionNumber := versionNumberValue + decryptPayload := DecryptPayload{} + + resp, reqErr := apiClient.Decrypt(context.Background(), projectId, regionId, keyRingId, keyId, versionNumber).DecryptPayload(decryptPayload).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if IsNil(resp) { + t.Fatalf("response not present") + } + }) + + t.Run("Test DefaultApiService DisableVersion", func(t *testing.T) { + _apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions/{versionNumber}/disable" + projectIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) + regionIdValue := "regionId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1) + keyRingIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(keyRingIdValue, "keyRingId")), -1) + keyIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyId"+"}", url.PathEscape(ParameterValueToString(keyIdValue, "keyId")), -1) + versionNumberValue := int64(123) + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"versionNumber"+"}", url.PathEscape(ParameterValueToString(versionNumberValue, "versionNumber")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + }) + testServer := httptest.NewServer(testDefaultApiServeMux) + defer testServer.Close() + + configuration := &config.Configuration{ + DefaultHeader: make(map[string]string), + UserAgent: "OpenAPI-Generator/1.0.0/go", + Debug: false, + Region: "test_region", + Servers: config.ServerConfigurations{ + { + URL: testServer.URL, + Description: "Localhost for kms_DefaultApi", + Variables: map[string]config.ServerVariable{ + "region": { + DefaultValue: "test_region.", + EnumValues: []string{ + "test_region.", + }, + }, + }, + }, + }, + OperationServers: map[string]config.ServerConfigurations{}, + } + apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication()) + if err != nil { + t.Fatalf("creating API client: %v", err) + } + + projectId := projectIdValue + regionId := regionIdValue + keyRingId := keyRingIdValue + keyId := keyIdValue + versionNumber := versionNumberValue + + reqErr := apiClient.DisableVersion(context.Background(), projectId, regionId, keyRingId, keyId, versionNumber).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + }) + + t.Run("Test DefaultApiService EnableVersion", func(t *testing.T) { + _apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions/{versionNumber}/enable" + projectIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) + regionIdValue := "regionId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1) + keyRingIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(keyRingIdValue, "keyRingId")), -1) + keyIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyId"+"}", url.PathEscape(ParameterValueToString(keyIdValue, "keyId")), -1) + versionNumberValue := int64(123) + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"versionNumber"+"}", url.PathEscape(ParameterValueToString(versionNumberValue, "versionNumber")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + }) + testServer := httptest.NewServer(testDefaultApiServeMux) + defer testServer.Close() + + configuration := &config.Configuration{ + DefaultHeader: make(map[string]string), + UserAgent: "OpenAPI-Generator/1.0.0/go", + Debug: false, + Region: "test_region", + Servers: config.ServerConfigurations{ + { + URL: testServer.URL, + Description: "Localhost for kms_DefaultApi", + Variables: map[string]config.ServerVariable{ + "region": { + DefaultValue: "test_region.", + EnumValues: []string{ + "test_region.", + }, + }, + }, + }, + }, + OperationServers: map[string]config.ServerConfigurations{}, + } + apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication()) + if err != nil { + t.Fatalf("creating API client: %v", err) + } + + projectId := projectIdValue + regionId := regionIdValue + keyRingId := keyRingIdValue + keyId := keyIdValue + versionNumber := versionNumberValue + + reqErr := apiClient.EnableVersion(context.Background(), projectId, regionId, keyRingId, keyId, versionNumber).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + }) + + t.Run("Test DefaultApiService Encrypt", func(t *testing.T) { + _apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions/{versionNumber}/encrypt" + projectIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) + regionIdValue := "regionId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1) + keyRingIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(keyRingIdValue, "keyRingId")), -1) + keyIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyId"+"}", url.PathEscape(ParameterValueToString(keyIdValue, "keyId")), -1) + versionNumberValue := int64(123) + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"versionNumber"+"}", url.PathEscape(ParameterValueToString(versionNumberValue, "versionNumber")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + data := EncryptedData{} + w.Header().Add("Content-Type", "application/json") + json.NewEncoder(w).Encode(data) + }) + testServer := httptest.NewServer(testDefaultApiServeMux) + defer testServer.Close() + + configuration := &config.Configuration{ + DefaultHeader: make(map[string]string), + UserAgent: "OpenAPI-Generator/1.0.0/go", + Debug: false, + Region: "test_region", + Servers: config.ServerConfigurations{ + { + URL: testServer.URL, + Description: "Localhost for kms_DefaultApi", + Variables: map[string]config.ServerVariable{ + "region": { + DefaultValue: "test_region.", + EnumValues: []string{ + "test_region.", + }, + }, + }, + }, + }, + OperationServers: map[string]config.ServerConfigurations{}, + } + apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication()) + if err != nil { + t.Fatalf("creating API client: %v", err) + } + + projectId := projectIdValue + regionId := regionIdValue + keyRingId := keyRingIdValue + keyId := keyIdValue + versionNumber := versionNumberValue + encryptPayload := EncryptPayload{} + + resp, reqErr := apiClient.Encrypt(context.Background(), projectId, regionId, keyRingId, keyId, versionNumber).EncryptPayload(encryptPayload).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if IsNil(resp) { + t.Fatalf("response not present") + } + }) + + t.Run("Test DefaultApiService GetKey", func(t *testing.T) { + _apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}" + projectIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) + regionIdValue := "regionId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1) + keyRingIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(keyRingIdValue, "keyRingId")), -1) + keyIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyId"+"}", url.PathEscape(ParameterValueToString(keyIdValue, "keyId")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + data := Key{} + w.Header().Add("Content-Type", "application/json") + json.NewEncoder(w).Encode(data) + }) + testServer := httptest.NewServer(testDefaultApiServeMux) + defer testServer.Close() + + configuration := &config.Configuration{ + DefaultHeader: make(map[string]string), + UserAgent: "OpenAPI-Generator/1.0.0/go", + Debug: false, + Region: "test_region", + Servers: config.ServerConfigurations{ + { + URL: testServer.URL, + Description: "Localhost for kms_DefaultApi", + Variables: map[string]config.ServerVariable{ + "region": { + DefaultValue: "test_region.", + EnumValues: []string{ + "test_region.", + }, + }, + }, + }, + }, + OperationServers: map[string]config.ServerConfigurations{}, + } + apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication()) + if err != nil { + t.Fatalf("creating API client: %v", err) + } + + projectId := projectIdValue + regionId := regionIdValue + keyRingId := keyRingIdValue + keyId := keyIdValue + + resp, reqErr := apiClient.GetKey(context.Background(), projectId, regionId, keyRingId, keyId).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if IsNil(resp) { + t.Fatalf("response not present") + } + }) + + t.Run("Test DefaultApiService GetKeyRing", func(t *testing.T) { + _apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}" + projectIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) + regionIdValue := "regionId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1) + keyRingIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(keyRingIdValue, "keyRingId")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + data := KeyRing{} + w.Header().Add("Content-Type", "application/json") + json.NewEncoder(w).Encode(data) + }) + testServer := httptest.NewServer(testDefaultApiServeMux) + defer testServer.Close() + + configuration := &config.Configuration{ + DefaultHeader: make(map[string]string), + UserAgent: "OpenAPI-Generator/1.0.0/go", + Debug: false, + Region: "test_region", + Servers: config.ServerConfigurations{ + { + URL: testServer.URL, + Description: "Localhost for kms_DefaultApi", + Variables: map[string]config.ServerVariable{ + "region": { + DefaultValue: "test_region.", + EnumValues: []string{ + "test_region.", + }, + }, + }, + }, + }, + OperationServers: map[string]config.ServerConfigurations{}, + } + apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication()) + if err != nil { + t.Fatalf("creating API client: %v", err) + } + + projectId := projectIdValue + regionId := regionIdValue + keyRingId := keyRingIdValue + + resp, reqErr := apiClient.GetKeyRing(context.Background(), projectId, regionId, keyRingId).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if IsNil(resp) { + t.Fatalf("response not present") + } + }) + + t.Run("Test DefaultApiService GetVersion", func(t *testing.T) { + _apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions/{versionNumber}" + projectIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) + regionIdValue := "regionId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1) + keyRingIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(keyRingIdValue, "keyRingId")), -1) + keyIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyId"+"}", url.PathEscape(ParameterValueToString(keyIdValue, "keyId")), -1) + versionNumberValue := int64(123) + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"versionNumber"+"}", url.PathEscape(ParameterValueToString(versionNumberValue, "versionNumber")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + data := Version{} + w.Header().Add("Content-Type", "application/json") + json.NewEncoder(w).Encode(data) + }) + testServer := httptest.NewServer(testDefaultApiServeMux) + defer testServer.Close() + + configuration := &config.Configuration{ + DefaultHeader: make(map[string]string), + UserAgent: "OpenAPI-Generator/1.0.0/go", + Debug: false, + Region: "test_region", + Servers: config.ServerConfigurations{ + { + URL: testServer.URL, + Description: "Localhost for kms_DefaultApi", + Variables: map[string]config.ServerVariable{ + "region": { + DefaultValue: "test_region.", + EnumValues: []string{ + "test_region.", + }, + }, + }, + }, + }, + OperationServers: map[string]config.ServerConfigurations{}, + } + apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication()) + if err != nil { + t.Fatalf("creating API client: %v", err) + } + + projectId := projectIdValue + regionId := regionIdValue + keyRingId := keyRingIdValue + keyId := keyIdValue + versionNumber := versionNumberValue + + resp, reqErr := apiClient.GetVersion(context.Background(), projectId, regionId, keyRingId, keyId, versionNumber).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if IsNil(resp) { + t.Fatalf("response not present") + } + }) + + t.Run("Test DefaultApiService GetWrappingKey", func(t *testing.T) { + _apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/wrappingkeys/{wrappingKeyId}" + projectIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) + regionIdValue := "regionId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1) + keyRingIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(keyRingIdValue, "keyRingId")), -1) + wrappingKeyIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"wrappingKeyId"+"}", url.PathEscape(ParameterValueToString(wrappingKeyIdValue, "wrappingKeyId")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + data := WrappingKey{} + w.Header().Add("Content-Type", "application/json") + json.NewEncoder(w).Encode(data) + }) + testServer := httptest.NewServer(testDefaultApiServeMux) + defer testServer.Close() + + configuration := &config.Configuration{ + DefaultHeader: make(map[string]string), + UserAgent: "OpenAPI-Generator/1.0.0/go", + Debug: false, + Region: "test_region", + Servers: config.ServerConfigurations{ + { + URL: testServer.URL, + Description: "Localhost for kms_DefaultApi", + Variables: map[string]config.ServerVariable{ + "region": { + DefaultValue: "test_region.", + EnumValues: []string{ + "test_region.", + }, + }, + }, + }, + }, + OperationServers: map[string]config.ServerConfigurations{}, + } + apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication()) + if err != nil { + t.Fatalf("creating API client: %v", err) + } + + projectId := projectIdValue + regionId := regionIdValue + keyRingId := keyRingIdValue + wrappingKeyId := wrappingKeyIdValue + + resp, reqErr := apiClient.GetWrappingKey(context.Background(), projectId, regionId, keyRingId, wrappingKeyId).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if IsNil(resp) { + t.Fatalf("response not present") + } + }) + + t.Run("Test DefaultApiService ImportKey", func(t *testing.T) { + _apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/import" + projectIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) + regionIdValue := "regionId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1) + keyRingIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(keyRingIdValue, "keyRingId")), -1) + keyIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyId"+"}", url.PathEscape(ParameterValueToString(keyIdValue, "keyId")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + data := Key{} + w.Header().Add("Content-Type", "application/json") + json.NewEncoder(w).Encode(data) + }) + testServer := httptest.NewServer(testDefaultApiServeMux) + defer testServer.Close() + + configuration := &config.Configuration{ + DefaultHeader: make(map[string]string), + UserAgent: "OpenAPI-Generator/1.0.0/go", + Debug: false, + Region: "test_region", + Servers: config.ServerConfigurations{ + { + URL: testServer.URL, + Description: "Localhost for kms_DefaultApi", + Variables: map[string]config.ServerVariable{ + "region": { + DefaultValue: "test_region.", + EnumValues: []string{ + "test_region.", + }, + }, + }, + }, + }, + OperationServers: map[string]config.ServerConfigurations{}, + } + apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication()) + if err != nil { + t.Fatalf("creating API client: %v", err) + } + + projectId := projectIdValue + regionId := regionIdValue + keyRingId := keyRingIdValue + keyId := keyIdValue + importKeyPayload := ImportKeyPayload{} + + resp, reqErr := apiClient.ImportKey(context.Background(), projectId, regionId, keyRingId, keyId).ImportKeyPayload(importKeyPayload).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if IsNil(resp) { + t.Fatalf("response not present") + } + }) + + t.Run("Test DefaultApiService ListKeyRings", func(t *testing.T) { + _apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings" + projectIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) + regionIdValue := "regionId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + data := KeyRingList{} + w.Header().Add("Content-Type", "application/json") + json.NewEncoder(w).Encode(data) + }) + testServer := httptest.NewServer(testDefaultApiServeMux) + defer testServer.Close() + + configuration := &config.Configuration{ + DefaultHeader: make(map[string]string), + UserAgent: "OpenAPI-Generator/1.0.0/go", + Debug: false, + Region: "test_region", + Servers: config.ServerConfigurations{ + { + URL: testServer.URL, + Description: "Localhost for kms_DefaultApi", + Variables: map[string]config.ServerVariable{ + "region": { + DefaultValue: "test_region.", + EnumValues: []string{ + "test_region.", + }, + }, + }, + }, + }, + OperationServers: map[string]config.ServerConfigurations{}, + } + apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication()) + if err != nil { + t.Fatalf("creating API client: %v", err) + } + + projectId := projectIdValue + regionId := regionIdValue + + resp, reqErr := apiClient.ListKeyRings(context.Background(), projectId, regionId).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if IsNil(resp) { + t.Fatalf("response not present") + } + }) + + t.Run("Test DefaultApiService ListKeys", func(t *testing.T) { + _apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys" + projectIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) + regionIdValue := "regionId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1) + keyRingIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(keyRingIdValue, "keyRingId")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + data := KeyList{} + w.Header().Add("Content-Type", "application/json") + json.NewEncoder(w).Encode(data) + }) + testServer := httptest.NewServer(testDefaultApiServeMux) + defer testServer.Close() + + configuration := &config.Configuration{ + DefaultHeader: make(map[string]string), + UserAgent: "OpenAPI-Generator/1.0.0/go", + Debug: false, + Region: "test_region", + Servers: config.ServerConfigurations{ + { + URL: testServer.URL, + Description: "Localhost for kms_DefaultApi", + Variables: map[string]config.ServerVariable{ + "region": { + DefaultValue: "test_region.", + EnumValues: []string{ + "test_region.", + }, + }, + }, + }, + }, + OperationServers: map[string]config.ServerConfigurations{}, + } + apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication()) + if err != nil { + t.Fatalf("creating API client: %v", err) + } + + projectId := projectIdValue + regionId := regionIdValue + keyRingId := keyRingIdValue + + resp, reqErr := apiClient.ListKeys(context.Background(), projectId, regionId, keyRingId).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if IsNil(resp) { + t.Fatalf("response not present") + } + }) + + t.Run("Test DefaultApiService ListVersions", func(t *testing.T) { + _apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions" + projectIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) + regionIdValue := "regionId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1) + keyRingIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(keyRingIdValue, "keyRingId")), -1) + keyIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyId"+"}", url.PathEscape(ParameterValueToString(keyIdValue, "keyId")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + data := VersionList{} + w.Header().Add("Content-Type", "application/json") + json.NewEncoder(w).Encode(data) + }) + testServer := httptest.NewServer(testDefaultApiServeMux) + defer testServer.Close() + + configuration := &config.Configuration{ + DefaultHeader: make(map[string]string), + UserAgent: "OpenAPI-Generator/1.0.0/go", + Debug: false, + Region: "test_region", + Servers: config.ServerConfigurations{ + { + URL: testServer.URL, + Description: "Localhost for kms_DefaultApi", + Variables: map[string]config.ServerVariable{ + "region": { + DefaultValue: "test_region.", + EnumValues: []string{ + "test_region.", + }, + }, + }, + }, + }, + OperationServers: map[string]config.ServerConfigurations{}, + } + apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication()) + if err != nil { + t.Fatalf("creating API client: %v", err) + } + + projectId := projectIdValue + regionId := regionIdValue + keyRingId := keyRingIdValue + keyId := keyIdValue + + resp, reqErr := apiClient.ListVersions(context.Background(), projectId, regionId, keyRingId, keyId).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if IsNil(resp) { + t.Fatalf("response not present") + } + }) + + t.Run("Test DefaultApiService ListWrappingKeys", func(t *testing.T) { + _apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/wrappingkeys" + projectIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) + regionIdValue := "regionId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1) + keyRingIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(keyRingIdValue, "keyRingId")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + data := WrappingKeyList{} + w.Header().Add("Content-Type", "application/json") + json.NewEncoder(w).Encode(data) + }) + testServer := httptest.NewServer(testDefaultApiServeMux) + defer testServer.Close() + + configuration := &config.Configuration{ + DefaultHeader: make(map[string]string), + UserAgent: "OpenAPI-Generator/1.0.0/go", + Debug: false, + Region: "test_region", + Servers: config.ServerConfigurations{ + { + URL: testServer.URL, + Description: "Localhost for kms_DefaultApi", + Variables: map[string]config.ServerVariable{ + "region": { + DefaultValue: "test_region.", + EnumValues: []string{ + "test_region.", + }, + }, + }, + }, + }, + OperationServers: map[string]config.ServerConfigurations{}, + } + apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication()) + if err != nil { + t.Fatalf("creating API client: %v", err) + } + + projectId := projectIdValue + regionId := regionIdValue + keyRingId := keyRingIdValue + + resp, reqErr := apiClient.ListWrappingKeys(context.Background(), projectId, regionId, keyRingId).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if IsNil(resp) { + t.Fatalf("response not present") + } + }) + + t.Run("Test DefaultApiService RotateKey", func(t *testing.T) { + _apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/rotate" + projectIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) + regionIdValue := "regionId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1) + keyRingIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(keyRingIdValue, "keyRingId")), -1) + keyIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyId"+"}", url.PathEscape(ParameterValueToString(keyIdValue, "keyId")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + data := Key{} + w.Header().Add("Content-Type", "application/json") + json.NewEncoder(w).Encode(data) + }) + testServer := httptest.NewServer(testDefaultApiServeMux) + defer testServer.Close() + + configuration := &config.Configuration{ + DefaultHeader: make(map[string]string), + UserAgent: "OpenAPI-Generator/1.0.0/go", + Debug: false, + Region: "test_region", + Servers: config.ServerConfigurations{ + { + URL: testServer.URL, + Description: "Localhost for kms_DefaultApi", + Variables: map[string]config.ServerVariable{ + "region": { + DefaultValue: "test_region.", + EnumValues: []string{ + "test_region.", + }, + }, + }, + }, + }, + OperationServers: map[string]config.ServerConfigurations{}, + } + apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication()) + if err != nil { + t.Fatalf("creating API client: %v", err) + } + + projectId := projectIdValue + regionId := regionIdValue + keyRingId := keyRingIdValue + keyId := keyIdValue + + resp, reqErr := apiClient.RotateKey(context.Background(), projectId, regionId, keyRingId, keyId).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if IsNil(resp) { + t.Fatalf("response not present") + } + }) + + t.Run("Test DefaultApiService Sign", func(t *testing.T) { + _apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions/{versionNumber}/sign" + projectIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) + regionIdValue := "regionId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1) + keyRingIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(keyRingIdValue, "keyRingId")), -1) + keyIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyId"+"}", url.PathEscape(ParameterValueToString(keyIdValue, "keyId")), -1) + versionNumberValue := int64(123) + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"versionNumber"+"}", url.PathEscape(ParameterValueToString(versionNumberValue, "versionNumber")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + data := SignedData{} + w.Header().Add("Content-Type", "application/json") + json.NewEncoder(w).Encode(data) + }) + testServer := httptest.NewServer(testDefaultApiServeMux) + defer testServer.Close() + + configuration := &config.Configuration{ + DefaultHeader: make(map[string]string), + UserAgent: "OpenAPI-Generator/1.0.0/go", + Debug: false, + Region: "test_region", + Servers: config.ServerConfigurations{ + { + URL: testServer.URL, + Description: "Localhost for kms_DefaultApi", + Variables: map[string]config.ServerVariable{ + "region": { + DefaultValue: "test_region.", + EnumValues: []string{ + "test_region.", + }, + }, + }, + }, + }, + OperationServers: map[string]config.ServerConfigurations{}, + } + apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication()) + if err != nil { + t.Fatalf("creating API client: %v", err) + } + + projectId := projectIdValue + regionId := regionIdValue + keyRingId := keyRingIdValue + keyId := keyIdValue + versionNumber := versionNumberValue + signPayload := SignPayload{} + + resp, reqErr := apiClient.Sign(context.Background(), projectId, regionId, keyRingId, keyId, versionNumber).SignPayload(signPayload).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if IsNil(resp) { + t.Fatalf("response not present") + } + }) + + t.Run("Test DefaultApiService Verify", func(t *testing.T) { + _apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions/{versionNumber}/verify" + projectIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) + regionIdValue := "regionId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1) + keyRingIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(keyRingIdValue, "keyRingId")), -1) + keyIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyId"+"}", url.PathEscape(ParameterValueToString(keyIdValue, "keyId")), -1) + versionNumberValue := int64(123) + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"versionNumber"+"}", url.PathEscape(ParameterValueToString(versionNumberValue, "versionNumber")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + data := VerifiedData{} + w.Header().Add("Content-Type", "application/json") + json.NewEncoder(w).Encode(data) + }) + testServer := httptest.NewServer(testDefaultApiServeMux) + defer testServer.Close() + + configuration := &config.Configuration{ + DefaultHeader: make(map[string]string), + UserAgent: "OpenAPI-Generator/1.0.0/go", + Debug: false, + Region: "test_region", + Servers: config.ServerConfigurations{ + { + URL: testServer.URL, + Description: "Localhost for kms_DefaultApi", + Variables: map[string]config.ServerVariable{ + "region": { + DefaultValue: "test_region.", + EnumValues: []string{ + "test_region.", + }, + }, + }, + }, + }, + OperationServers: map[string]config.ServerConfigurations{}, + } + apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication()) + if err != nil { + t.Fatalf("creating API client: %v", err) + } + + projectId := projectIdValue + regionId := regionIdValue + keyRingId := keyRingIdValue + keyId := keyIdValue + versionNumber := versionNumberValue + verifyPayload := VerifyPayload{} + + resp, reqErr := apiClient.Verify(context.Background(), projectId, regionId, keyRingId, keyId, versionNumber).VerifyPayload(verifyPayload).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if IsNil(resp) { + t.Fatalf("response not present") + } + }) + +} diff --git a/services/kms/client.go b/services/kms/client.go new file mode 100644 index 000000000..ba026a0cb --- /dev/null +++ b/services/kms/client.go @@ -0,0 +1,631 @@ +/* +STACKIT Key Management Service API + +This API provides endpoints for managing keys and key rings. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package kms + +import ( + "bytes" + "context" + "encoding/json" + "encoding/xml" + "fmt" + "io" + "log" + "mime/multipart" + "net/http" + "net/http/httputil" + "net/url" + "os" + "path/filepath" + "reflect" + "regexp" + "strconv" + "strings" + "time" + "unicode/utf8" + + "github.com/stackitcloud/stackit-sdk-go/core/auth" + "github.com/stackitcloud/stackit-sdk-go/core/config" +) + +var ( + jsonCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:vnd\.[^;]+\+)?json)`) + xmlCheck = regexp.MustCompile(`(?i:(?:application|text)/xml)`) + queryParamSplit = regexp.MustCompile(`(^|&)([^&]+)`) + queryDescape = strings.NewReplacer("%5B", "[", "%5D", "]") +) + +// APIClient manages communication with the STACKIT Key Management Service API API v1beta.0.0 +// In most cases there should be only one, shared, APIClient. +type APIClient struct { + cfg *config.Configuration + common service // Reuse a single struct instead of allocating one for each service on the heap. + defaultApi *DefaultApiService +} + +type service struct { + client *APIClient +} + +// NewAPIClient creates a new API client. +// Optionally receives configuration options +func NewAPIClient(opts ...config.ConfigurationOption) (*APIClient, error) { + cfg := NewConfiguration() + + for _, option := range opts { + err := option(cfg) + if err != nil { + return nil, fmt.Errorf("configuring the client: %w", err) + } + } + + err := config.ConfigureRegion(cfg) + if err != nil { + return nil, fmt.Errorf("configuring region: %w", err) + } + + if cfg.HTTPClient == nil { + cfg.HTTPClient = &http.Client{} + } + + authRoundTripper, err := auth.SetupAuth(cfg) + if err != nil { + return nil, fmt.Errorf("setting up authentication: %w", err) + } + + roundTripper := authRoundTripper + if cfg.Middleware != nil { + roundTripper = config.ChainMiddleware(roundTripper, cfg.Middleware...) + } + + cfg.HTTPClient.Transport = roundTripper + + c := &APIClient{} + c.cfg = cfg + c.common.client = c + c.defaultApi = (*DefaultApiService)(&c.common) + + return c, nil +} + +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 < lenIndValue; i++ { + var arrayValue = indValue.Index(i) + parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, arrayValue.Interface(), collectionType) + } + return + + case reflect.Map: + var indValue = reflect.ValueOf(obj) + if indValue == reflect.ValueOf(nil) { + return + } + iter := indValue.MapRange() + for iter.Next() { + k, v := iter.Key(), iter.Value() + parameterAddToHeaderOrQuery(headerOrQueryParams, fmt.Sprintf("%s[%s]", keyPrefix, k.String()), v.Interface(), collectionType) + } + return + + case reflect.Interface: + fallthrough + case reflect.Ptr: + parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, v.Elem().Interface(), collectionType) + return + + case reflect.Int, reflect.Int8, reflect.Int16, + reflect.Int32, reflect.Int64: + value = strconv.FormatInt(v.Int(), 10) + case reflect.Uint, reflect.Uint8, reflect.Uint16, + reflect.Uint32, reflect.Uint64, reflect.Uintptr: + value = strconv.FormatUint(v.Uint(), 10) + case reflect.Float32, reflect.Float64: + value = strconv.FormatFloat(v.Float(), 'g', -1, 32) + case reflect.Bool: + value = strconv.FormatBool(v.Bool()) + case reflect.String: + value = v.String() + default: + value = v.Type().String() + " value" + } + } + + switch valuesMap := headerOrQueryParams.(type) { + case url.Values: + if collectionType == "csv" && valuesMap.Get(keyPrefix) != "" { + valuesMap.Set(keyPrefix, valuesMap.Get(keyPrefix)+","+value) + } else { + valuesMap.Add(keyPrefix, value) + } + break + case map[string]string: + valuesMap[keyPrefix] = value + break + } +} + +// helper for converting interface{} parameters to json strings +func parameterToJson(obj interface{}) (string, error) { + jsonBuf, err := json.Marshal(obj) + if err != nil { + return "", err + } + return string(jsonBuf), err +} + +// callAPI do the request. +func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) { + if c.cfg.Debug { + dump, err := httputil.DumpRequestOut(request, true) + if err != nil { + return nil, err + } + log.Printf("\n%s\n", string(dump)) + } + + resp, err := c.cfg.HTTPClient.Do(request) + if err != nil { + return resp, err + } + + if c.cfg.Debug { + dump, err := httputil.DumpResponse(resp, true) + if err != nil { + return resp, err + } + log.Printf("\n%s\n", string(dump)) + } + return resp, err +} + +// Allow modification of underlying config for alternate implementations and testing +// Caution: modifying the configuration while live can cause data races and potentially unwanted behavior +func (c *APIClient) GetConfig() *config.Configuration { + return c.cfg +} + +type formFile struct { + fileBytes []byte + fileName string + formFileName string +} + +// prepareRequest build the request +func (c *APIClient) prepareRequest( + ctx context.Context, + path string, method string, + postBody interface{}, + headerParams map[string]string, + queryParams url.Values, + formParams url.Values, + formFiles []formFile) (localVarRequest *http.Request, err error) { + + var body *bytes.Buffer + + // Detect postBody type and post. + if postBody != nil { + contentType := headerParams["Content-Type"] + if contentType == "" { + contentType = detectContentType(postBody) + headerParams["Content-Type"] = contentType + } + + body, err = setBody(postBody, contentType) + if err != nil { + return nil, err + } + } + + // add form parameters and file if available. + if strings.HasPrefix(headerParams["Content-Type"], "multipart/form-data") && len(formParams) > 0 || (len(formFiles) > 0) { + if body != nil { + return nil, fmt.Errorf("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, fmt.Errorf("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 *APIClient) 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 fmt.Errorf("unknown type with GetActualInstance but no unmarshalObj.UnmarshalJSON defined") + } + } else if err = json.Unmarshal(b, v); err != nil { // simple model + return err + } + return nil + } + return fmt.Errorf("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 +} + +// 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) { + if bodyBuf == nil { + 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) { + err = xml.NewEncoder(bodyBuf).Encode(body) + } + + if err != nil { + return nil, err + } + + if bodyBuf.Len() == 0 { + err = fmt.Errorf("invalid body type %s", 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) +} diff --git a/services/kms/configuration.go b/services/kms/configuration.go new file mode 100644 index 000000000..117e2933c --- /dev/null +++ b/services/kms/configuration.go @@ -0,0 +1,41 @@ +/* +STACKIT Key Management Service API + +This API provides endpoints for managing keys and key rings. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package kms + +import ( + "github.com/stackitcloud/stackit-sdk-go/core/config" +) + +// NewConfiguration returns a new Configuration object +func NewConfiguration() *config.Configuration { + cfg := &config.Configuration{ + DefaultHeader: make(map[string]string), + UserAgent: "OpenAPI-Generator/1.0.0/go", + Debug: false, + Servers: config.ServerConfigurations{ + { + URL: "https://kms.api.{region}stackit.cloud", + Description: "No description provided", + Variables: map[string]config.ServerVariable{ + "region": { + Description: "No description provided", + DefaultValue: "eu01.", + EnumValues: []string{ + "eu01.", + }, + }, + }, + }, + }, + OperationServers: map[string]config.ServerConfigurations{}, + } + return cfg +} diff --git a/services/kms/go.mod b/services/kms/go.mod new file mode 100644 index 000000000..d5a29b169 --- /dev/null +++ b/services/kms/go.mod @@ -0,0 +1,10 @@ +module github.com/stackitcloud/stackit-sdk-go/services/kms + +go 1.21 + +require ( + github.com/google/uuid v1.6.0 + github.com/stackitcloud/stackit-sdk-go/core v0.16.2 +) + +require github.com/golang-jwt/jwt/v5 v5.2.2 // indirect diff --git a/services/kms/go.sum b/services/kms/go.sum new file mode 100644 index 000000000..93bc53c57 --- /dev/null +++ b/services/kms/go.sum @@ -0,0 +1,8 @@ +github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8= +github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/stackitcloud/stackit-sdk-go/core v0.16.2 h1:F8A4P/LLlQSbz0S0+G3m8rb3BUOK6EcR/CKx5UQY5jQ= +github.com/stackitcloud/stackit-sdk-go/core v0.16.2/go.mod h1:8KIw3czdNJ9sdil9QQimxjR6vHjeINFrRv0iZ67wfn0= diff --git a/services/kms/model_algorithm.go b/services/kms/model_algorithm.go new file mode 100644 index 000000000..f5a94f97c --- /dev/null +++ b/services/kms/model_algorithm.go @@ -0,0 +1,133 @@ +/* +STACKIT Key Management Service API + +This API provides endpoints for managing keys and key rings. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package kms + +import ( + "encoding/json" + "fmt" +) + +// Algorithm The algorithm the key material uses. +type Algorithm string + +// List of algorithm +const ( + ALGORITHM_AES_256_GCM Algorithm = "aes_256_gcm" + ALGORITHM_RSA_2048_OAEP_SHA256 Algorithm = "rsa_2048_oaep_sha256" + ALGORITHM_RSA_3072_OAEP_SHA256 Algorithm = "rsa_3072_oaep_sha256" + ALGORITHM_RSA_4096_OAEP_SHA256 Algorithm = "rsa_4096_oaep_sha256" + ALGORITHM_RSA_4096_OAEP_SHA512 Algorithm = "rsa_4096_oaep_sha512" + ALGORITHM_HMAC_SHA256 Algorithm = "hmac_sha256" + ALGORITHM_HMAC_SHA384 Algorithm = "hmac_sha384" + ALGORITHM_HMAC_SHA512 Algorithm = "hmac_sha512" + ALGORITHM_ECDSA_P256_SHA256 Algorithm = "ecdsa_p256_sha256" + ALGORITHM_ECDSA_P384_SHA384 Algorithm = "ecdsa_p384_sha384" + ALGORITHM_ECDSA_P521_SHA512 Algorithm = "ecdsa_p521_sha512" +) + +// All allowed values of Algorithm enum +var AllowedAlgorithmEnumValues = []Algorithm{ + "aes_256_gcm", + "rsa_2048_oaep_sha256", + "rsa_3072_oaep_sha256", + "rsa_4096_oaep_sha256", + "rsa_4096_oaep_sha512", + "hmac_sha256", + "hmac_sha384", + "hmac_sha512", + "ecdsa_p256_sha256", + "ecdsa_p384_sha384", + "ecdsa_p521_sha512", +} + +func (v *Algorithm) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + // Allow unmarshalling zero value for testing purposes + var zeroValue string + if value == zeroValue { + return nil + } + enumTypeValue := Algorithm(value) + for _, existing := range AllowedAlgorithmEnumValues { + if existing == enumTypeValue { + *v = enumTypeValue + return nil + } + } + + return fmt.Errorf("%+v is not a valid Algorithm", value) +} + +// NewAlgorithmFromValue returns a pointer to a valid Algorithm +// for the value passed as argument, or an error if the value passed is not allowed by the enum +func NewAlgorithmFromValue(v string) (*Algorithm, error) { + ev := Algorithm(v) + if ev.IsValid() { + return &ev, nil + } else { + return nil, fmt.Errorf("invalid value '%v' for Algorithm: valid values are %v", v, AllowedAlgorithmEnumValues) + } +} + +// IsValid return true if the value is valid for the enum, false otherwise +func (v Algorithm) IsValid() bool { + for _, existing := range AllowedAlgorithmEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to algorithm value +func (v Algorithm) Ptr() *Algorithm { + return &v +} + +type NullableAlgorithm struct { + value *Algorithm + isSet bool +} + +func (v NullableAlgorithm) Get() *Algorithm { + return v.value +} + +func (v *NullableAlgorithm) Set(val *Algorithm) { + v.value = val + v.isSet = true +} + +func (v NullableAlgorithm) IsSet() bool { + return v.isSet +} + +func (v *NullableAlgorithm) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableAlgorithm(val *Algorithm) *NullableAlgorithm { + return &NullableAlgorithm{value: val, isSet: true} +} + +func (v NullableAlgorithm) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableAlgorithm) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/kms/model_backend.go b/services/kms/model_backend.go new file mode 100644 index 000000000..4e36f3834 --- /dev/null +++ b/services/kms/model_backend.go @@ -0,0 +1,113 @@ +/* +STACKIT Key Management Service API + +This API provides endpoints for managing keys and key rings. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package kms + +import ( + "encoding/json" + "fmt" +) + +// Backend The backend that is responsible for maintaining this key. +type Backend string + +// List of backend +const ( + BACKEND_SOFTWARE Backend = "software" +) + +// All allowed values of Backend enum +var AllowedBackendEnumValues = []Backend{ + "software", +} + +func (v *Backend) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + // Allow unmarshalling zero value for testing purposes + var zeroValue string + if value == zeroValue { + return nil + } + enumTypeValue := Backend(value) + for _, existing := range AllowedBackendEnumValues { + if existing == enumTypeValue { + *v = enumTypeValue + return nil + } + } + + return fmt.Errorf("%+v is not a valid Backend", value) +} + +// NewBackendFromValue returns a pointer to a valid Backend +// for the value passed as argument, or an error if the value passed is not allowed by the enum +func NewBackendFromValue(v string) (*Backend, error) { + ev := Backend(v) + if ev.IsValid() { + return &ev, nil + } else { + return nil, fmt.Errorf("invalid value '%v' for Backend: valid values are %v", v, AllowedBackendEnumValues) + } +} + +// IsValid return true if the value is valid for the enum, false otherwise +func (v Backend) IsValid() bool { + for _, existing := range AllowedBackendEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to backend value +func (v Backend) Ptr() *Backend { + return &v +} + +type NullableBackend struct { + value *Backend + isSet bool +} + +func (v NullableBackend) Get() *Backend { + return v.value +} + +func (v *NullableBackend) Set(val *Backend) { + v.value = val + v.isSet = true +} + +func (v NullableBackend) IsSet() bool { + return v.isSet +} + +func (v *NullableBackend) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableBackend(val *Backend) *NullableBackend { + return &NullableBackend{value: val, isSet: true} +} + +func (v NullableBackend) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableBackend) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/kms/model_create_key_payload.go b/services/kms/model_create_key_payload.go new file mode 100644 index 000000000..9e77cb333 --- /dev/null +++ b/services/kms/model_create_key_payload.go @@ -0,0 +1,355 @@ +/* +STACKIT Key Management Service API + +This API provides endpoints for managing keys and key rings. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package kms + +import ( + "encoding/json" +) + +// checks if the CreateKeyPayload type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &CreateKeyPayload{} + +/* + types and functions for algorithm +*/ + +// isEnumRef +type CreateKeyPayloadGetAlgorithmAttributeType = *Algorithm +type CreateKeyPayloadGetAlgorithmArgType = Algorithm +type CreateKeyPayloadGetAlgorithmRetType = Algorithm + +func getCreateKeyPayloadGetAlgorithmAttributeTypeOk(arg CreateKeyPayloadGetAlgorithmAttributeType) (ret CreateKeyPayloadGetAlgorithmRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setCreateKeyPayloadGetAlgorithmAttributeType(arg *CreateKeyPayloadGetAlgorithmAttributeType, val CreateKeyPayloadGetAlgorithmRetType) { + *arg = &val +} + +/* + types and functions for backend +*/ + +// isEnumRef +type CreateKeyPayloadGetBackendAttributeType = *Backend +type CreateKeyPayloadGetBackendArgType = Backend +type CreateKeyPayloadGetBackendRetType = Backend + +func getCreateKeyPayloadGetBackendAttributeTypeOk(arg CreateKeyPayloadGetBackendAttributeType) (ret CreateKeyPayloadGetBackendRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setCreateKeyPayloadGetBackendAttributeType(arg *CreateKeyPayloadGetBackendAttributeType, val CreateKeyPayloadGetBackendRetType) { + *arg = &val +} + +/* + types and functions for description +*/ + +// isNotNullableString +type CreateKeyPayloadGetDescriptionAttributeType = *string + +func getCreateKeyPayloadGetDescriptionAttributeTypeOk(arg CreateKeyPayloadGetDescriptionAttributeType) (ret CreateKeyPayloadGetDescriptionRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setCreateKeyPayloadGetDescriptionAttributeType(arg *CreateKeyPayloadGetDescriptionAttributeType, val CreateKeyPayloadGetDescriptionRetType) { + *arg = &val +} + +type CreateKeyPayloadGetDescriptionArgType = string +type CreateKeyPayloadGetDescriptionRetType = string + +/* + types and functions for displayName +*/ + +// isNotNullableString +type CreateKeyPayloadGetDisplayNameAttributeType = *string + +func getCreateKeyPayloadGetDisplayNameAttributeTypeOk(arg CreateKeyPayloadGetDisplayNameAttributeType) (ret CreateKeyPayloadGetDisplayNameRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setCreateKeyPayloadGetDisplayNameAttributeType(arg *CreateKeyPayloadGetDisplayNameAttributeType, val CreateKeyPayloadGetDisplayNameRetType) { + *arg = &val +} + +type CreateKeyPayloadGetDisplayNameArgType = string +type CreateKeyPayloadGetDisplayNameRetType = string + +/* + types and functions for importOnly +*/ + +// isBoolean +type CreateKeyPayloadgetImportOnlyAttributeType = *bool +type CreateKeyPayloadgetImportOnlyArgType = bool +type CreateKeyPayloadgetImportOnlyRetType = bool + +func getCreateKeyPayloadgetImportOnlyAttributeTypeOk(arg CreateKeyPayloadgetImportOnlyAttributeType) (ret CreateKeyPayloadgetImportOnlyRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setCreateKeyPayloadgetImportOnlyAttributeType(arg *CreateKeyPayloadgetImportOnlyAttributeType, val CreateKeyPayloadgetImportOnlyRetType) { + *arg = &val +} + +/* + types and functions for purpose +*/ + +// isEnumRef +type CreateKeyPayloadGetPurposeAttributeType = *Purpose +type CreateKeyPayloadGetPurposeArgType = Purpose +type CreateKeyPayloadGetPurposeRetType = Purpose + +func getCreateKeyPayloadGetPurposeAttributeTypeOk(arg CreateKeyPayloadGetPurposeAttributeType) (ret CreateKeyPayloadGetPurposeRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setCreateKeyPayloadGetPurposeAttributeType(arg *CreateKeyPayloadGetPurposeAttributeType, val CreateKeyPayloadGetPurposeRetType) { + *arg = &val +} + +// CreateKeyPayload struct for CreateKeyPayload +type CreateKeyPayload struct { + // REQUIRED + Algorithm CreateKeyPayloadGetAlgorithmAttributeType `json:"algorithm"` + // REQUIRED + Backend CreateKeyPayloadGetBackendAttributeType `json:"backend"` + // A user chosen description to distinguish multiple keys. + Description CreateKeyPayloadGetDescriptionAttributeType `json:"description,omitempty"` + // The display name to distinguish multiple keys. + // REQUIRED + DisplayName CreateKeyPayloadGetDisplayNameAttributeType `json:"displayName"` + // States whether versions can be created or only imported. + ImportOnly CreateKeyPayloadgetImportOnlyAttributeType `json:"importOnly,omitempty"` + // REQUIRED + Purpose CreateKeyPayloadGetPurposeAttributeType `json:"purpose"` +} + +type _CreateKeyPayload CreateKeyPayload + +// NewCreateKeyPayload instantiates a new CreateKeyPayload 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 NewCreateKeyPayload(algorithm CreateKeyPayloadGetAlgorithmArgType, backend CreateKeyPayloadGetBackendArgType, displayName CreateKeyPayloadGetDisplayNameArgType, purpose CreateKeyPayloadGetPurposeArgType) *CreateKeyPayload { + this := CreateKeyPayload{} + setCreateKeyPayloadGetAlgorithmAttributeType(&this.Algorithm, algorithm) + setCreateKeyPayloadGetBackendAttributeType(&this.Backend, backend) + setCreateKeyPayloadGetDisplayNameAttributeType(&this.DisplayName, displayName) + setCreateKeyPayloadGetPurposeAttributeType(&this.Purpose, purpose) + return &this +} + +// NewCreateKeyPayloadWithDefaults instantiates a new CreateKeyPayload 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 NewCreateKeyPayloadWithDefaults() *CreateKeyPayload { + this := CreateKeyPayload{} + var importOnly bool = false + this.ImportOnly = &importOnly + return &this +} + +// GetAlgorithm returns the Algorithm field value +func (o *CreateKeyPayload) GetAlgorithm() (ret CreateKeyPayloadGetAlgorithmRetType) { + ret, _ = o.GetAlgorithmOk() + return ret +} + +// GetAlgorithmOk returns a tuple with the Algorithm field value +// and a boolean to check if the value has been set. +func (o *CreateKeyPayload) GetAlgorithmOk() (ret CreateKeyPayloadGetAlgorithmRetType, ok bool) { + return getCreateKeyPayloadGetAlgorithmAttributeTypeOk(o.Algorithm) +} + +// SetAlgorithm sets field value +func (o *CreateKeyPayload) SetAlgorithm(v CreateKeyPayloadGetAlgorithmRetType) { + setCreateKeyPayloadGetAlgorithmAttributeType(&o.Algorithm, v) +} + +// GetBackend returns the Backend field value +func (o *CreateKeyPayload) GetBackend() (ret CreateKeyPayloadGetBackendRetType) { + ret, _ = o.GetBackendOk() + return ret +} + +// GetBackendOk returns a tuple with the Backend field value +// and a boolean to check if the value has been set. +func (o *CreateKeyPayload) GetBackendOk() (ret CreateKeyPayloadGetBackendRetType, ok bool) { + return getCreateKeyPayloadGetBackendAttributeTypeOk(o.Backend) +} + +// SetBackend sets field value +func (o *CreateKeyPayload) SetBackend(v CreateKeyPayloadGetBackendRetType) { + setCreateKeyPayloadGetBackendAttributeType(&o.Backend, v) +} + +// GetDescription returns the Description field value if set, zero value otherwise. +func (o *CreateKeyPayload) GetDescription() (res CreateKeyPayloadGetDescriptionRetType) { + res, _ = o.GetDescriptionOk() + return +} + +// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateKeyPayload) GetDescriptionOk() (ret CreateKeyPayloadGetDescriptionRetType, ok bool) { + return getCreateKeyPayloadGetDescriptionAttributeTypeOk(o.Description) +} + +// HasDescription returns a boolean if a field has been set. +func (o *CreateKeyPayload) HasDescription() bool { + _, ok := o.GetDescriptionOk() + return ok +} + +// SetDescription gets a reference to the given string and assigns it to the Description field. +func (o *CreateKeyPayload) SetDescription(v CreateKeyPayloadGetDescriptionRetType) { + setCreateKeyPayloadGetDescriptionAttributeType(&o.Description, v) +} + +// GetDisplayName returns the DisplayName field value +func (o *CreateKeyPayload) GetDisplayName() (ret CreateKeyPayloadGetDisplayNameRetType) { + ret, _ = o.GetDisplayNameOk() + return ret +} + +// GetDisplayNameOk returns a tuple with the DisplayName field value +// and a boolean to check if the value has been set. +func (o *CreateKeyPayload) GetDisplayNameOk() (ret CreateKeyPayloadGetDisplayNameRetType, ok bool) { + return getCreateKeyPayloadGetDisplayNameAttributeTypeOk(o.DisplayName) +} + +// SetDisplayName sets field value +func (o *CreateKeyPayload) SetDisplayName(v CreateKeyPayloadGetDisplayNameRetType) { + setCreateKeyPayloadGetDisplayNameAttributeType(&o.DisplayName, v) +} + +// GetImportOnly returns the ImportOnly field value if set, zero value otherwise. +func (o *CreateKeyPayload) GetImportOnly() (res CreateKeyPayloadgetImportOnlyRetType) { + res, _ = o.GetImportOnlyOk() + return +} + +// GetImportOnlyOk returns a tuple with the ImportOnly field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateKeyPayload) GetImportOnlyOk() (ret CreateKeyPayloadgetImportOnlyRetType, ok bool) { + return getCreateKeyPayloadgetImportOnlyAttributeTypeOk(o.ImportOnly) +} + +// HasImportOnly returns a boolean if a field has been set. +func (o *CreateKeyPayload) HasImportOnly() bool { + _, ok := o.GetImportOnlyOk() + return ok +} + +// SetImportOnly gets a reference to the given bool and assigns it to the ImportOnly field. +func (o *CreateKeyPayload) SetImportOnly(v CreateKeyPayloadgetImportOnlyRetType) { + setCreateKeyPayloadgetImportOnlyAttributeType(&o.ImportOnly, v) +} + +// GetPurpose returns the Purpose field value +func (o *CreateKeyPayload) GetPurpose() (ret CreateKeyPayloadGetPurposeRetType) { + ret, _ = o.GetPurposeOk() + return ret +} + +// GetPurposeOk returns a tuple with the Purpose field value +// and a boolean to check if the value has been set. +func (o *CreateKeyPayload) GetPurposeOk() (ret CreateKeyPayloadGetPurposeRetType, ok bool) { + return getCreateKeyPayloadGetPurposeAttributeTypeOk(o.Purpose) +} + +// SetPurpose sets field value +func (o *CreateKeyPayload) SetPurpose(v CreateKeyPayloadGetPurposeRetType) { + setCreateKeyPayloadGetPurposeAttributeType(&o.Purpose, v) +} + +func (o CreateKeyPayload) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getCreateKeyPayloadGetAlgorithmAttributeTypeOk(o.Algorithm); ok { + toSerialize["Algorithm"] = val + } + if val, ok := getCreateKeyPayloadGetBackendAttributeTypeOk(o.Backend); ok { + toSerialize["Backend"] = val + } + if val, ok := getCreateKeyPayloadGetDescriptionAttributeTypeOk(o.Description); ok { + toSerialize["Description"] = val + } + if val, ok := getCreateKeyPayloadGetDisplayNameAttributeTypeOk(o.DisplayName); ok { + toSerialize["DisplayName"] = val + } + if val, ok := getCreateKeyPayloadgetImportOnlyAttributeTypeOk(o.ImportOnly); ok { + toSerialize["ImportOnly"] = val + } + if val, ok := getCreateKeyPayloadGetPurposeAttributeTypeOk(o.Purpose); ok { + toSerialize["Purpose"] = val + } + return toSerialize, nil +} + +type NullableCreateKeyPayload struct { + value *CreateKeyPayload + isSet bool +} + +func (v NullableCreateKeyPayload) Get() *CreateKeyPayload { + return v.value +} + +func (v *NullableCreateKeyPayload) Set(val *CreateKeyPayload) { + v.value = val + v.isSet = true +} + +func (v NullableCreateKeyPayload) IsSet() bool { + return v.isSet +} + +func (v *NullableCreateKeyPayload) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableCreateKeyPayload(val *CreateKeyPayload) *NullableCreateKeyPayload { + return &NullableCreateKeyPayload{value: val, isSet: true} +} + +func (v NullableCreateKeyPayload) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableCreateKeyPayload) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/kms/model_create_key_ring_payload.go b/services/kms/model_create_key_ring_payload.go new file mode 100644 index 000000000..948c78f40 --- /dev/null +++ b/services/kms/model_create_key_ring_payload.go @@ -0,0 +1,176 @@ +/* +STACKIT Key Management Service API + +This API provides endpoints for managing keys and key rings. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package kms + +import ( + "encoding/json" +) + +// checks if the CreateKeyRingPayload type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &CreateKeyRingPayload{} + +/* + types and functions for description +*/ + +// isNotNullableString +type CreateKeyRingPayloadGetDescriptionAttributeType = *string + +func getCreateKeyRingPayloadGetDescriptionAttributeTypeOk(arg CreateKeyRingPayloadGetDescriptionAttributeType) (ret CreateKeyRingPayloadGetDescriptionRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setCreateKeyRingPayloadGetDescriptionAttributeType(arg *CreateKeyRingPayloadGetDescriptionAttributeType, val CreateKeyRingPayloadGetDescriptionRetType) { + *arg = &val +} + +type CreateKeyRingPayloadGetDescriptionArgType = string +type CreateKeyRingPayloadGetDescriptionRetType = string + +/* + types and functions for displayName +*/ + +// isNotNullableString +type CreateKeyRingPayloadGetDisplayNameAttributeType = *string + +func getCreateKeyRingPayloadGetDisplayNameAttributeTypeOk(arg CreateKeyRingPayloadGetDisplayNameAttributeType) (ret CreateKeyRingPayloadGetDisplayNameRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setCreateKeyRingPayloadGetDisplayNameAttributeType(arg *CreateKeyRingPayloadGetDisplayNameAttributeType, val CreateKeyRingPayloadGetDisplayNameRetType) { + *arg = &val +} + +type CreateKeyRingPayloadGetDisplayNameArgType = string +type CreateKeyRingPayloadGetDisplayNameRetType = string + +// CreateKeyRingPayload struct for CreateKeyRingPayload +type CreateKeyRingPayload struct { + // A user chosen description to distinguish multiple key rings. + Description CreateKeyRingPayloadGetDescriptionAttributeType `json:"description,omitempty"` + // The display name to distinguish multiple key rings. + // REQUIRED + DisplayName CreateKeyRingPayloadGetDisplayNameAttributeType `json:"displayName"` +} + +type _CreateKeyRingPayload CreateKeyRingPayload + +// NewCreateKeyRingPayload instantiates a new CreateKeyRingPayload 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 NewCreateKeyRingPayload(displayName CreateKeyRingPayloadGetDisplayNameArgType) *CreateKeyRingPayload { + this := CreateKeyRingPayload{} + setCreateKeyRingPayloadGetDisplayNameAttributeType(&this.DisplayName, displayName) + return &this +} + +// NewCreateKeyRingPayloadWithDefaults instantiates a new CreateKeyRingPayload 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 NewCreateKeyRingPayloadWithDefaults() *CreateKeyRingPayload { + this := CreateKeyRingPayload{} + return &this +} + +// GetDescription returns the Description field value if set, zero value otherwise. +func (o *CreateKeyRingPayload) GetDescription() (res CreateKeyRingPayloadGetDescriptionRetType) { + res, _ = o.GetDescriptionOk() + return +} + +// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateKeyRingPayload) GetDescriptionOk() (ret CreateKeyRingPayloadGetDescriptionRetType, ok bool) { + return getCreateKeyRingPayloadGetDescriptionAttributeTypeOk(o.Description) +} + +// HasDescription returns a boolean if a field has been set. +func (o *CreateKeyRingPayload) HasDescription() bool { + _, ok := o.GetDescriptionOk() + return ok +} + +// SetDescription gets a reference to the given string and assigns it to the Description field. +func (o *CreateKeyRingPayload) SetDescription(v CreateKeyRingPayloadGetDescriptionRetType) { + setCreateKeyRingPayloadGetDescriptionAttributeType(&o.Description, v) +} + +// GetDisplayName returns the DisplayName field value +func (o *CreateKeyRingPayload) GetDisplayName() (ret CreateKeyRingPayloadGetDisplayNameRetType) { + ret, _ = o.GetDisplayNameOk() + return ret +} + +// GetDisplayNameOk returns a tuple with the DisplayName field value +// and a boolean to check if the value has been set. +func (o *CreateKeyRingPayload) GetDisplayNameOk() (ret CreateKeyRingPayloadGetDisplayNameRetType, ok bool) { + return getCreateKeyRingPayloadGetDisplayNameAttributeTypeOk(o.DisplayName) +} + +// SetDisplayName sets field value +func (o *CreateKeyRingPayload) SetDisplayName(v CreateKeyRingPayloadGetDisplayNameRetType) { + setCreateKeyRingPayloadGetDisplayNameAttributeType(&o.DisplayName, v) +} + +func (o CreateKeyRingPayload) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getCreateKeyRingPayloadGetDescriptionAttributeTypeOk(o.Description); ok { + toSerialize["Description"] = val + } + if val, ok := getCreateKeyRingPayloadGetDisplayNameAttributeTypeOk(o.DisplayName); ok { + toSerialize["DisplayName"] = val + } + return toSerialize, nil +} + +type NullableCreateKeyRingPayload struct { + value *CreateKeyRingPayload + isSet bool +} + +func (v NullableCreateKeyRingPayload) Get() *CreateKeyRingPayload { + return v.value +} + +func (v *NullableCreateKeyRingPayload) Set(val *CreateKeyRingPayload) { + v.value = val + v.isSet = true +} + +func (v NullableCreateKeyRingPayload) IsSet() bool { + return v.isSet +} + +func (v *NullableCreateKeyRingPayload) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableCreateKeyRingPayload(val *CreateKeyRingPayload) *NullableCreateKeyRingPayload { + return &NullableCreateKeyRingPayload{value: val, isSet: true} +} + +func (v NullableCreateKeyRingPayload) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableCreateKeyRingPayload) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/kms/model_create_wrapping_key_payload.go b/services/kms/model_create_wrapping_key_payload.go new file mode 100644 index 000000000..6afdacec7 --- /dev/null +++ b/services/kms/model_create_wrapping_key_payload.go @@ -0,0 +1,305 @@ +/* +STACKIT Key Management Service API + +This API provides endpoints for managing keys and key rings. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package kms + +import ( + "encoding/json" +) + +// checks if the CreateWrappingKeyPayload type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &CreateWrappingKeyPayload{} + +/* + types and functions for algorithm +*/ + +// isEnumRef +type CreateWrappingKeyPayloadGetAlgorithmAttributeType = *WrappingAlgorithm +type CreateWrappingKeyPayloadGetAlgorithmArgType = WrappingAlgorithm +type CreateWrappingKeyPayloadGetAlgorithmRetType = WrappingAlgorithm + +func getCreateWrappingKeyPayloadGetAlgorithmAttributeTypeOk(arg CreateWrappingKeyPayloadGetAlgorithmAttributeType) (ret CreateWrappingKeyPayloadGetAlgorithmRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setCreateWrappingKeyPayloadGetAlgorithmAttributeType(arg *CreateWrappingKeyPayloadGetAlgorithmAttributeType, val CreateWrappingKeyPayloadGetAlgorithmRetType) { + *arg = &val +} + +/* + types and functions for backend +*/ + +// isEnumRef +type CreateWrappingKeyPayloadGetBackendAttributeType = *Backend +type CreateWrappingKeyPayloadGetBackendArgType = Backend +type CreateWrappingKeyPayloadGetBackendRetType = Backend + +func getCreateWrappingKeyPayloadGetBackendAttributeTypeOk(arg CreateWrappingKeyPayloadGetBackendAttributeType) (ret CreateWrappingKeyPayloadGetBackendRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setCreateWrappingKeyPayloadGetBackendAttributeType(arg *CreateWrappingKeyPayloadGetBackendAttributeType, val CreateWrappingKeyPayloadGetBackendRetType) { + *arg = &val +} + +/* + types and functions for description +*/ + +// isNotNullableString +type CreateWrappingKeyPayloadGetDescriptionAttributeType = *string + +func getCreateWrappingKeyPayloadGetDescriptionAttributeTypeOk(arg CreateWrappingKeyPayloadGetDescriptionAttributeType) (ret CreateWrappingKeyPayloadGetDescriptionRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setCreateWrappingKeyPayloadGetDescriptionAttributeType(arg *CreateWrappingKeyPayloadGetDescriptionAttributeType, val CreateWrappingKeyPayloadGetDescriptionRetType) { + *arg = &val +} + +type CreateWrappingKeyPayloadGetDescriptionArgType = string +type CreateWrappingKeyPayloadGetDescriptionRetType = string + +/* + types and functions for displayName +*/ + +// isNotNullableString +type CreateWrappingKeyPayloadGetDisplayNameAttributeType = *string + +func getCreateWrappingKeyPayloadGetDisplayNameAttributeTypeOk(arg CreateWrappingKeyPayloadGetDisplayNameAttributeType) (ret CreateWrappingKeyPayloadGetDisplayNameRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setCreateWrappingKeyPayloadGetDisplayNameAttributeType(arg *CreateWrappingKeyPayloadGetDisplayNameAttributeType, val CreateWrappingKeyPayloadGetDisplayNameRetType) { + *arg = &val +} + +type CreateWrappingKeyPayloadGetDisplayNameArgType = string +type CreateWrappingKeyPayloadGetDisplayNameRetType = string + +/* + types and functions for purpose +*/ + +// isEnumRef +type CreateWrappingKeyPayloadGetPurposeAttributeType = *WrappingPurpose +type CreateWrappingKeyPayloadGetPurposeArgType = WrappingPurpose +type CreateWrappingKeyPayloadGetPurposeRetType = WrappingPurpose + +func getCreateWrappingKeyPayloadGetPurposeAttributeTypeOk(arg CreateWrappingKeyPayloadGetPurposeAttributeType) (ret CreateWrappingKeyPayloadGetPurposeRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setCreateWrappingKeyPayloadGetPurposeAttributeType(arg *CreateWrappingKeyPayloadGetPurposeAttributeType, val CreateWrappingKeyPayloadGetPurposeRetType) { + *arg = &val +} + +// CreateWrappingKeyPayload struct for CreateWrappingKeyPayload +type CreateWrappingKeyPayload struct { + // REQUIRED + Algorithm CreateWrappingKeyPayloadGetAlgorithmAttributeType `json:"algorithm"` + // REQUIRED + Backend CreateWrappingKeyPayloadGetBackendAttributeType `json:"backend"` + // A user chosen description to distinguish multiple wrapping keys. + Description CreateWrappingKeyPayloadGetDescriptionAttributeType `json:"description,omitempty"` + // The display name to distinguish multiple wrapping keys. + // REQUIRED + DisplayName CreateWrappingKeyPayloadGetDisplayNameAttributeType `json:"displayName"` + // REQUIRED + Purpose CreateWrappingKeyPayloadGetPurposeAttributeType `json:"purpose"` +} + +type _CreateWrappingKeyPayload CreateWrappingKeyPayload + +// NewCreateWrappingKeyPayload instantiates a new CreateWrappingKeyPayload 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 NewCreateWrappingKeyPayload(algorithm CreateWrappingKeyPayloadGetAlgorithmArgType, backend CreateWrappingKeyPayloadGetBackendArgType, displayName CreateWrappingKeyPayloadGetDisplayNameArgType, purpose CreateWrappingKeyPayloadGetPurposeArgType) *CreateWrappingKeyPayload { + this := CreateWrappingKeyPayload{} + setCreateWrappingKeyPayloadGetAlgorithmAttributeType(&this.Algorithm, algorithm) + setCreateWrappingKeyPayloadGetBackendAttributeType(&this.Backend, backend) + setCreateWrappingKeyPayloadGetDisplayNameAttributeType(&this.DisplayName, displayName) + setCreateWrappingKeyPayloadGetPurposeAttributeType(&this.Purpose, purpose) + return &this +} + +// NewCreateWrappingKeyPayloadWithDefaults instantiates a new CreateWrappingKeyPayload 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 NewCreateWrappingKeyPayloadWithDefaults() *CreateWrappingKeyPayload { + this := CreateWrappingKeyPayload{} + return &this +} + +// GetAlgorithm returns the Algorithm field value +func (o *CreateWrappingKeyPayload) GetAlgorithm() (ret CreateWrappingKeyPayloadGetAlgorithmRetType) { + ret, _ = o.GetAlgorithmOk() + return ret +} + +// GetAlgorithmOk returns a tuple with the Algorithm field value +// and a boolean to check if the value has been set. +func (o *CreateWrappingKeyPayload) GetAlgorithmOk() (ret CreateWrappingKeyPayloadGetAlgorithmRetType, ok bool) { + return getCreateWrappingKeyPayloadGetAlgorithmAttributeTypeOk(o.Algorithm) +} + +// SetAlgorithm sets field value +func (o *CreateWrappingKeyPayload) SetAlgorithm(v CreateWrappingKeyPayloadGetAlgorithmRetType) { + setCreateWrappingKeyPayloadGetAlgorithmAttributeType(&o.Algorithm, v) +} + +// GetBackend returns the Backend field value +func (o *CreateWrappingKeyPayload) GetBackend() (ret CreateWrappingKeyPayloadGetBackendRetType) { + ret, _ = o.GetBackendOk() + return ret +} + +// GetBackendOk returns a tuple with the Backend field value +// and a boolean to check if the value has been set. +func (o *CreateWrappingKeyPayload) GetBackendOk() (ret CreateWrappingKeyPayloadGetBackendRetType, ok bool) { + return getCreateWrappingKeyPayloadGetBackendAttributeTypeOk(o.Backend) +} + +// SetBackend sets field value +func (o *CreateWrappingKeyPayload) SetBackend(v CreateWrappingKeyPayloadGetBackendRetType) { + setCreateWrappingKeyPayloadGetBackendAttributeType(&o.Backend, v) +} + +// GetDescription returns the Description field value if set, zero value otherwise. +func (o *CreateWrappingKeyPayload) GetDescription() (res CreateWrappingKeyPayloadGetDescriptionRetType) { + res, _ = o.GetDescriptionOk() + return +} + +// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateWrappingKeyPayload) GetDescriptionOk() (ret CreateWrappingKeyPayloadGetDescriptionRetType, ok bool) { + return getCreateWrappingKeyPayloadGetDescriptionAttributeTypeOk(o.Description) +} + +// HasDescription returns a boolean if a field has been set. +func (o *CreateWrappingKeyPayload) HasDescription() bool { + _, ok := o.GetDescriptionOk() + return ok +} + +// SetDescription gets a reference to the given string and assigns it to the Description field. +func (o *CreateWrappingKeyPayload) SetDescription(v CreateWrappingKeyPayloadGetDescriptionRetType) { + setCreateWrappingKeyPayloadGetDescriptionAttributeType(&o.Description, v) +} + +// GetDisplayName returns the DisplayName field value +func (o *CreateWrappingKeyPayload) GetDisplayName() (ret CreateWrappingKeyPayloadGetDisplayNameRetType) { + ret, _ = o.GetDisplayNameOk() + return ret +} + +// GetDisplayNameOk returns a tuple with the DisplayName field value +// and a boolean to check if the value has been set. +func (o *CreateWrappingKeyPayload) GetDisplayNameOk() (ret CreateWrappingKeyPayloadGetDisplayNameRetType, ok bool) { + return getCreateWrappingKeyPayloadGetDisplayNameAttributeTypeOk(o.DisplayName) +} + +// SetDisplayName sets field value +func (o *CreateWrappingKeyPayload) SetDisplayName(v CreateWrappingKeyPayloadGetDisplayNameRetType) { + setCreateWrappingKeyPayloadGetDisplayNameAttributeType(&o.DisplayName, v) +} + +// GetPurpose returns the Purpose field value +func (o *CreateWrappingKeyPayload) GetPurpose() (ret CreateWrappingKeyPayloadGetPurposeRetType) { + ret, _ = o.GetPurposeOk() + return ret +} + +// GetPurposeOk returns a tuple with the Purpose field value +// and a boolean to check if the value has been set. +func (o *CreateWrappingKeyPayload) GetPurposeOk() (ret CreateWrappingKeyPayloadGetPurposeRetType, ok bool) { + return getCreateWrappingKeyPayloadGetPurposeAttributeTypeOk(o.Purpose) +} + +// SetPurpose sets field value +func (o *CreateWrappingKeyPayload) SetPurpose(v CreateWrappingKeyPayloadGetPurposeRetType) { + setCreateWrappingKeyPayloadGetPurposeAttributeType(&o.Purpose, v) +} + +func (o CreateWrappingKeyPayload) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getCreateWrappingKeyPayloadGetAlgorithmAttributeTypeOk(o.Algorithm); ok { + toSerialize["Algorithm"] = val + } + if val, ok := getCreateWrappingKeyPayloadGetBackendAttributeTypeOk(o.Backend); ok { + toSerialize["Backend"] = val + } + if val, ok := getCreateWrappingKeyPayloadGetDescriptionAttributeTypeOk(o.Description); ok { + toSerialize["Description"] = val + } + if val, ok := getCreateWrappingKeyPayloadGetDisplayNameAttributeTypeOk(o.DisplayName); ok { + toSerialize["DisplayName"] = val + } + if val, ok := getCreateWrappingKeyPayloadGetPurposeAttributeTypeOk(o.Purpose); ok { + toSerialize["Purpose"] = val + } + return toSerialize, nil +} + +type NullableCreateWrappingKeyPayload struct { + value *CreateWrappingKeyPayload + isSet bool +} + +func (v NullableCreateWrappingKeyPayload) Get() *CreateWrappingKeyPayload { + return v.value +} + +func (v *NullableCreateWrappingKeyPayload) Set(val *CreateWrappingKeyPayload) { + v.value = val + v.isSet = true +} + +func (v NullableCreateWrappingKeyPayload) IsSet() bool { + return v.isSet +} + +func (v *NullableCreateWrappingKeyPayload) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableCreateWrappingKeyPayload(val *CreateWrappingKeyPayload) *NullableCreateWrappingKeyPayload { + return &NullableCreateWrappingKeyPayload{value: val, isSet: true} +} + +func (v NullableCreateWrappingKeyPayload) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableCreateWrappingKeyPayload) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/kms/model_decrypt_payload.go b/services/kms/model_decrypt_payload.go new file mode 100644 index 000000000..24ce6cbad --- /dev/null +++ b/services/kms/model_decrypt_payload.go @@ -0,0 +1,126 @@ +/* +STACKIT Key Management Service API + +This API provides endpoints for managing keys and key rings. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package kms + +import ( + "encoding/json" +) + +// checks if the DecryptPayload type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &DecryptPayload{} + +/* + types and functions for data +*/ + +// isByteArray +type DecryptPayloadGetDataAttributeType = *[]byte +type DecryptPayloadGetDataArgType = []byte +type DecryptPayloadGetDataRetType = []byte + +func getDecryptPayloadGetDataAttributeTypeOk(arg DecryptPayloadGetDataAttributeType) (ret DecryptPayloadGetDataRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDecryptPayloadGetDataAttributeType(arg *DecryptPayloadGetDataAttributeType, val DecryptPayloadGetDataRetType) { + *arg = &val +} + +// DecryptPayload struct for DecryptPayload +type DecryptPayload struct { + // The data that has to be decrypted. Encoded in base64. + // REQUIRED + Data DecryptPayloadGetDataAttributeType `json:"data"` +} + +type _DecryptPayload DecryptPayload + +// NewDecryptPayload instantiates a new DecryptPayload 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 NewDecryptPayload(data DecryptPayloadGetDataArgType) *DecryptPayload { + this := DecryptPayload{} + setDecryptPayloadGetDataAttributeType(&this.Data, data) + return &this +} + +// NewDecryptPayloadWithDefaults instantiates a new DecryptPayload 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 NewDecryptPayloadWithDefaults() *DecryptPayload { + this := DecryptPayload{} + return &this +} + +// GetData returns the Data field value +func (o *DecryptPayload) GetData() (ret DecryptPayloadGetDataRetType) { + ret, _ = o.GetDataOk() + return ret +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *DecryptPayload) GetDataOk() (ret DecryptPayloadGetDataRetType, ok bool) { + return getDecryptPayloadGetDataAttributeTypeOk(o.Data) +} + +// SetData sets field value +func (o *DecryptPayload) SetData(v DecryptPayloadGetDataRetType) { + setDecryptPayloadGetDataAttributeType(&o.Data, v) +} + +func (o DecryptPayload) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getDecryptPayloadGetDataAttributeTypeOk(o.Data); ok { + toSerialize["Data"] = val + } + return toSerialize, nil +} + +type NullableDecryptPayload struct { + value *DecryptPayload + isSet bool +} + +func (v NullableDecryptPayload) Get() *DecryptPayload { + return v.value +} + +func (v *NullableDecryptPayload) Set(val *DecryptPayload) { + v.value = val + v.isSet = true +} + +func (v NullableDecryptPayload) IsSet() bool { + return v.isSet +} + +func (v *NullableDecryptPayload) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableDecryptPayload(val *DecryptPayload) *NullableDecryptPayload { + return &NullableDecryptPayload{value: val, isSet: true} +} + +func (v NullableDecryptPayload) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableDecryptPayload) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/kms/model_decrypted_data.go b/services/kms/model_decrypted_data.go new file mode 100644 index 000000000..caa1adfac --- /dev/null +++ b/services/kms/model_decrypted_data.go @@ -0,0 +1,126 @@ +/* +STACKIT Key Management Service API + +This API provides endpoints for managing keys and key rings. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package kms + +import ( + "encoding/json" +) + +// checks if the DecryptedData type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &DecryptedData{} + +/* + types and functions for data +*/ + +// isByteArray +type DecryptedDataGetDataAttributeType = *[]byte +type DecryptedDataGetDataArgType = []byte +type DecryptedDataGetDataRetType = []byte + +func getDecryptedDataGetDataAttributeTypeOk(arg DecryptedDataGetDataAttributeType) (ret DecryptedDataGetDataRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDecryptedDataGetDataAttributeType(arg *DecryptedDataGetDataAttributeType, val DecryptedDataGetDataRetType) { + *arg = &val +} + +// DecryptedData struct for DecryptedData +type DecryptedData struct { + // The decrypted data. Encoded in base64. + // REQUIRED + Data DecryptedDataGetDataAttributeType `json:"data"` +} + +type _DecryptedData DecryptedData + +// NewDecryptedData instantiates a new DecryptedData 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 NewDecryptedData(data DecryptedDataGetDataArgType) *DecryptedData { + this := DecryptedData{} + setDecryptedDataGetDataAttributeType(&this.Data, data) + return &this +} + +// NewDecryptedDataWithDefaults instantiates a new DecryptedData 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 NewDecryptedDataWithDefaults() *DecryptedData { + this := DecryptedData{} + return &this +} + +// GetData returns the Data field value +func (o *DecryptedData) GetData() (ret DecryptedDataGetDataRetType) { + ret, _ = o.GetDataOk() + return ret +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *DecryptedData) GetDataOk() (ret DecryptedDataGetDataRetType, ok bool) { + return getDecryptedDataGetDataAttributeTypeOk(o.Data) +} + +// SetData sets field value +func (o *DecryptedData) SetData(v DecryptedDataGetDataRetType) { + setDecryptedDataGetDataAttributeType(&o.Data, v) +} + +func (o DecryptedData) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getDecryptedDataGetDataAttributeTypeOk(o.Data); ok { + toSerialize["Data"] = val + } + return toSerialize, nil +} + +type NullableDecryptedData struct { + value *DecryptedData + isSet bool +} + +func (v NullableDecryptedData) Get() *DecryptedData { + return v.value +} + +func (v *NullableDecryptedData) Set(val *DecryptedData) { + v.value = val + v.isSet = true +} + +func (v NullableDecryptedData) IsSet() bool { + return v.isSet +} + +func (v *NullableDecryptedData) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableDecryptedData(val *DecryptedData) *NullableDecryptedData { + return &NullableDecryptedData{value: val, isSet: true} +} + +func (v NullableDecryptedData) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableDecryptedData) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/kms/model_encrypt_payload.go b/services/kms/model_encrypt_payload.go new file mode 100644 index 000000000..9c83701ea --- /dev/null +++ b/services/kms/model_encrypt_payload.go @@ -0,0 +1,126 @@ +/* +STACKIT Key Management Service API + +This API provides endpoints for managing keys and key rings. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package kms + +import ( + "encoding/json" +) + +// checks if the EncryptPayload type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &EncryptPayload{} + +/* + types and functions for data +*/ + +// isByteArray +type EncryptPayloadGetDataAttributeType = *[]byte +type EncryptPayloadGetDataArgType = []byte +type EncryptPayloadGetDataRetType = []byte + +func getEncryptPayloadGetDataAttributeTypeOk(arg EncryptPayloadGetDataAttributeType) (ret EncryptPayloadGetDataRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setEncryptPayloadGetDataAttributeType(arg *EncryptPayloadGetDataAttributeType, val EncryptPayloadGetDataRetType) { + *arg = &val +} + +// EncryptPayload struct for EncryptPayload +type EncryptPayload struct { + // The data that has to be encrypted. Encoded in base64. + // REQUIRED + Data EncryptPayloadGetDataAttributeType `json:"data"` +} + +type _EncryptPayload EncryptPayload + +// NewEncryptPayload instantiates a new EncryptPayload 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 NewEncryptPayload(data EncryptPayloadGetDataArgType) *EncryptPayload { + this := EncryptPayload{} + setEncryptPayloadGetDataAttributeType(&this.Data, data) + return &this +} + +// NewEncryptPayloadWithDefaults instantiates a new EncryptPayload 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 NewEncryptPayloadWithDefaults() *EncryptPayload { + this := EncryptPayload{} + return &this +} + +// GetData returns the Data field value +func (o *EncryptPayload) GetData() (ret EncryptPayloadGetDataRetType) { + ret, _ = o.GetDataOk() + return ret +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *EncryptPayload) GetDataOk() (ret EncryptPayloadGetDataRetType, ok bool) { + return getEncryptPayloadGetDataAttributeTypeOk(o.Data) +} + +// SetData sets field value +func (o *EncryptPayload) SetData(v EncryptPayloadGetDataRetType) { + setEncryptPayloadGetDataAttributeType(&o.Data, v) +} + +func (o EncryptPayload) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getEncryptPayloadGetDataAttributeTypeOk(o.Data); ok { + toSerialize["Data"] = val + } + return toSerialize, nil +} + +type NullableEncryptPayload struct { + value *EncryptPayload + isSet bool +} + +func (v NullableEncryptPayload) Get() *EncryptPayload { + return v.value +} + +func (v *NullableEncryptPayload) Set(val *EncryptPayload) { + v.value = val + v.isSet = true +} + +func (v NullableEncryptPayload) IsSet() bool { + return v.isSet +} + +func (v *NullableEncryptPayload) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableEncryptPayload(val *EncryptPayload) *NullableEncryptPayload { + return &NullableEncryptPayload{value: val, isSet: true} +} + +func (v NullableEncryptPayload) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableEncryptPayload) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/kms/model_encrypted_data.go b/services/kms/model_encrypted_data.go new file mode 100644 index 000000000..5b8713ad6 --- /dev/null +++ b/services/kms/model_encrypted_data.go @@ -0,0 +1,126 @@ +/* +STACKIT Key Management Service API + +This API provides endpoints for managing keys and key rings. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package kms + +import ( + "encoding/json" +) + +// checks if the EncryptedData type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &EncryptedData{} + +/* + types and functions for data +*/ + +// isByteArray +type EncryptedDataGetDataAttributeType = *[]byte +type EncryptedDataGetDataArgType = []byte +type EncryptedDataGetDataRetType = []byte + +func getEncryptedDataGetDataAttributeTypeOk(arg EncryptedDataGetDataAttributeType) (ret EncryptedDataGetDataRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setEncryptedDataGetDataAttributeType(arg *EncryptedDataGetDataAttributeType, val EncryptedDataGetDataRetType) { + *arg = &val +} + +// EncryptedData struct for EncryptedData +type EncryptedData struct { + // The encrypted data. Encoded in base64. + // REQUIRED + Data EncryptedDataGetDataAttributeType `json:"data"` +} + +type _EncryptedData EncryptedData + +// NewEncryptedData instantiates a new EncryptedData 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 NewEncryptedData(data EncryptedDataGetDataArgType) *EncryptedData { + this := EncryptedData{} + setEncryptedDataGetDataAttributeType(&this.Data, data) + return &this +} + +// NewEncryptedDataWithDefaults instantiates a new EncryptedData 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 NewEncryptedDataWithDefaults() *EncryptedData { + this := EncryptedData{} + return &this +} + +// GetData returns the Data field value +func (o *EncryptedData) GetData() (ret EncryptedDataGetDataRetType) { + ret, _ = o.GetDataOk() + return ret +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *EncryptedData) GetDataOk() (ret EncryptedDataGetDataRetType, ok bool) { + return getEncryptedDataGetDataAttributeTypeOk(o.Data) +} + +// SetData sets field value +func (o *EncryptedData) SetData(v EncryptedDataGetDataRetType) { + setEncryptedDataGetDataAttributeType(&o.Data, v) +} + +func (o EncryptedData) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getEncryptedDataGetDataAttributeTypeOk(o.Data); ok { + toSerialize["Data"] = val + } + return toSerialize, nil +} + +type NullableEncryptedData struct { + value *EncryptedData + isSet bool +} + +func (v NullableEncryptedData) Get() *EncryptedData { + return v.value +} + +func (v *NullableEncryptedData) Set(val *EncryptedData) { + v.value = val + v.isSet = true +} + +func (v NullableEncryptedData) IsSet() bool { + return v.isSet +} + +func (v *NullableEncryptedData) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableEncryptedData(val *EncryptedData) *NullableEncryptedData { + return &NullableEncryptedData{value: val, isSet: true} +} + +func (v NullableEncryptedData) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableEncryptedData) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/kms/model_http_error.go b/services/kms/model_http_error.go new file mode 100644 index 000000000..3eff4b023 --- /dev/null +++ b/services/kms/model_http_error.go @@ -0,0 +1,127 @@ +/* +STACKIT Key Management Service API + +This API provides endpoints for managing keys and key rings. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package kms + +import ( + "encoding/json" +) + +// checks if the HttpError type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &HttpError{} + +/* + types and functions for message +*/ + +// isNotNullableString +type HttpErrorGetMessageAttributeType = *string + +func getHttpErrorGetMessageAttributeTypeOk(arg HttpErrorGetMessageAttributeType) (ret HttpErrorGetMessageRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setHttpErrorGetMessageAttributeType(arg *HttpErrorGetMessageAttributeType, val HttpErrorGetMessageRetType) { + *arg = &val +} + +type HttpErrorGetMessageArgType = string +type HttpErrorGetMessageRetType = string + +// HttpError struct for HttpError +type HttpError struct { + // A string that gives a short information about what went wrong. + // REQUIRED + Message HttpErrorGetMessageAttributeType `json:"message"` +} + +type _HttpError HttpError + +// NewHttpError instantiates a new HttpError 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 NewHttpError(message HttpErrorGetMessageArgType) *HttpError { + this := HttpError{} + setHttpErrorGetMessageAttributeType(&this.Message, message) + return &this +} + +// NewHttpErrorWithDefaults instantiates a new HttpError 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 NewHttpErrorWithDefaults() *HttpError { + this := HttpError{} + return &this +} + +// GetMessage returns the Message field value +func (o *HttpError) GetMessage() (ret HttpErrorGetMessageRetType) { + ret, _ = o.GetMessageOk() + return ret +} + +// GetMessageOk returns a tuple with the Message field value +// and a boolean to check if the value has been set. +func (o *HttpError) GetMessageOk() (ret HttpErrorGetMessageRetType, ok bool) { + return getHttpErrorGetMessageAttributeTypeOk(o.Message) +} + +// SetMessage sets field value +func (o *HttpError) SetMessage(v HttpErrorGetMessageRetType) { + setHttpErrorGetMessageAttributeType(&o.Message, v) +} + +func (o HttpError) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getHttpErrorGetMessageAttributeTypeOk(o.Message); ok { + toSerialize["Message"] = val + } + return toSerialize, nil +} + +type NullableHttpError struct { + value *HttpError + isSet bool +} + +func (v NullableHttpError) Get() *HttpError { + return v.value +} + +func (v *NullableHttpError) Set(val *HttpError) { + v.value = val + v.isSet = true +} + +func (v NullableHttpError) IsSet() bool { + return v.isSet +} + +func (v *NullableHttpError) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableHttpError(val *HttpError) *NullableHttpError { + return &NullableHttpError{value: val, isSet: true} +} + +func (v NullableHttpError) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableHttpError) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/kms/model_import_key_payload.go b/services/kms/model_import_key_payload.go new file mode 100644 index 000000000..72db06822 --- /dev/null +++ b/services/kms/model_import_key_payload.go @@ -0,0 +1,172 @@ +/* +STACKIT Key Management Service API + +This API provides endpoints for managing keys and key rings. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package kms + +import ( + "encoding/json" +) + +// checks if the ImportKeyPayload type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ImportKeyPayload{} + +/* + types and functions for wrappedKey +*/ + +// isNotNullableString +type ImportKeyPayloadGetWrappedKeyAttributeType = *string + +func getImportKeyPayloadGetWrappedKeyAttributeTypeOk(arg ImportKeyPayloadGetWrappedKeyAttributeType) (ret ImportKeyPayloadGetWrappedKeyRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setImportKeyPayloadGetWrappedKeyAttributeType(arg *ImportKeyPayloadGetWrappedKeyAttributeType, val ImportKeyPayloadGetWrappedKeyRetType) { + *arg = &val +} + +type ImportKeyPayloadGetWrappedKeyArgType = string +type ImportKeyPayloadGetWrappedKeyRetType = string + +/* + types and functions for wrappingKeyId +*/ + +// isNotNullableString +type ImportKeyPayloadGetWrappingKeyIdAttributeType = *string + +func getImportKeyPayloadGetWrappingKeyIdAttributeTypeOk(arg ImportKeyPayloadGetWrappingKeyIdAttributeType) (ret ImportKeyPayloadGetWrappingKeyIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setImportKeyPayloadGetWrappingKeyIdAttributeType(arg *ImportKeyPayloadGetWrappingKeyIdAttributeType, val ImportKeyPayloadGetWrappingKeyIdRetType) { + *arg = &val +} + +type ImportKeyPayloadGetWrappingKeyIdArgType = string +type ImportKeyPayloadGetWrappingKeyIdRetType = string + +// ImportKeyPayload struct for ImportKeyPayload +type ImportKeyPayload struct { + // The wrapped key material that has to be imported. Encoded in base64. + // REQUIRED + WrappedKey ImportKeyPayloadGetWrappedKeyAttributeType `json:"wrappedKey"` + // The unique id of the wrapping key the key material has been wrapped with. + // REQUIRED + WrappingKeyId ImportKeyPayloadGetWrappingKeyIdAttributeType `json:"wrappingKeyId"` +} + +type _ImportKeyPayload ImportKeyPayload + +// NewImportKeyPayload instantiates a new ImportKeyPayload 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 NewImportKeyPayload(wrappedKey ImportKeyPayloadGetWrappedKeyArgType, wrappingKeyId ImportKeyPayloadGetWrappingKeyIdArgType) *ImportKeyPayload { + this := ImportKeyPayload{} + setImportKeyPayloadGetWrappedKeyAttributeType(&this.WrappedKey, wrappedKey) + setImportKeyPayloadGetWrappingKeyIdAttributeType(&this.WrappingKeyId, wrappingKeyId) + return &this +} + +// NewImportKeyPayloadWithDefaults instantiates a new ImportKeyPayload 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 NewImportKeyPayloadWithDefaults() *ImportKeyPayload { + this := ImportKeyPayload{} + return &this +} + +// GetWrappedKey returns the WrappedKey field value +func (o *ImportKeyPayload) GetWrappedKey() (ret ImportKeyPayloadGetWrappedKeyRetType) { + ret, _ = o.GetWrappedKeyOk() + return ret +} + +// GetWrappedKeyOk returns a tuple with the WrappedKey field value +// and a boolean to check if the value has been set. +func (o *ImportKeyPayload) GetWrappedKeyOk() (ret ImportKeyPayloadGetWrappedKeyRetType, ok bool) { + return getImportKeyPayloadGetWrappedKeyAttributeTypeOk(o.WrappedKey) +} + +// SetWrappedKey sets field value +func (o *ImportKeyPayload) SetWrappedKey(v ImportKeyPayloadGetWrappedKeyRetType) { + setImportKeyPayloadGetWrappedKeyAttributeType(&o.WrappedKey, v) +} + +// GetWrappingKeyId returns the WrappingKeyId field value +func (o *ImportKeyPayload) GetWrappingKeyId() (ret ImportKeyPayloadGetWrappingKeyIdRetType) { + ret, _ = o.GetWrappingKeyIdOk() + return ret +} + +// GetWrappingKeyIdOk returns a tuple with the WrappingKeyId field value +// and a boolean to check if the value has been set. +func (o *ImportKeyPayload) GetWrappingKeyIdOk() (ret ImportKeyPayloadGetWrappingKeyIdRetType, ok bool) { + return getImportKeyPayloadGetWrappingKeyIdAttributeTypeOk(o.WrappingKeyId) +} + +// SetWrappingKeyId sets field value +func (o *ImportKeyPayload) SetWrappingKeyId(v ImportKeyPayloadGetWrappingKeyIdRetType) { + setImportKeyPayloadGetWrappingKeyIdAttributeType(&o.WrappingKeyId, v) +} + +func (o ImportKeyPayload) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getImportKeyPayloadGetWrappedKeyAttributeTypeOk(o.WrappedKey); ok { + toSerialize["WrappedKey"] = val + } + if val, ok := getImportKeyPayloadGetWrappingKeyIdAttributeTypeOk(o.WrappingKeyId); ok { + toSerialize["WrappingKeyId"] = val + } + return toSerialize, nil +} + +type NullableImportKeyPayload struct { + value *ImportKeyPayload + isSet bool +} + +func (v NullableImportKeyPayload) Get() *ImportKeyPayload { + return v.value +} + +func (v *NullableImportKeyPayload) Set(val *ImportKeyPayload) { + v.value = val + v.isSet = true +} + +func (v NullableImportKeyPayload) IsSet() bool { + return v.isSet +} + +func (v *NullableImportKeyPayload) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableImportKeyPayload(val *ImportKeyPayload) *NullableImportKeyPayload { + return &NullableImportKeyPayload{value: val, isSet: true} +} + +func (v NullableImportKeyPayload) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableImportKeyPayload) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/kms/model_key.go b/services/kms/model_key.go new file mode 100644 index 000000000..b067ae42b --- /dev/null +++ b/services/kms/model_key.go @@ -0,0 +1,534 @@ +/* +STACKIT Key Management Service API + +This API provides endpoints for managing keys and key rings. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package kms + +import ( + "encoding/json" + "time" +) + +// checks if the Key type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &Key{} + +/* + types and functions for algorithm +*/ + +// isEnumRef +type KeyGetAlgorithmAttributeType = *Algorithm +type KeyGetAlgorithmArgType = Algorithm +type KeyGetAlgorithmRetType = Algorithm + +func getKeyGetAlgorithmAttributeTypeOk(arg KeyGetAlgorithmAttributeType) (ret KeyGetAlgorithmRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setKeyGetAlgorithmAttributeType(arg *KeyGetAlgorithmAttributeType, val KeyGetAlgorithmRetType) { + *arg = &val +} + +/* + types and functions for backend +*/ + +// isEnumRef +type KeyGetBackendAttributeType = *Backend +type KeyGetBackendArgType = Backend +type KeyGetBackendRetType = Backend + +func getKeyGetBackendAttributeTypeOk(arg KeyGetBackendAttributeType) (ret KeyGetBackendRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setKeyGetBackendAttributeType(arg *KeyGetBackendAttributeType, val KeyGetBackendRetType) { + *arg = &val +} + +/* + types and functions for createdAt +*/ + +// isDateTime +type KeyGetCreatedAtAttributeType = *time.Time +type KeyGetCreatedAtArgType = time.Time +type KeyGetCreatedAtRetType = time.Time + +func getKeyGetCreatedAtAttributeTypeOk(arg KeyGetCreatedAtAttributeType) (ret KeyGetCreatedAtRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setKeyGetCreatedAtAttributeType(arg *KeyGetCreatedAtAttributeType, val KeyGetCreatedAtRetType) { + *arg = &val +} + +/* + types and functions for description +*/ + +// isNotNullableString +type KeyGetDescriptionAttributeType = *string + +func getKeyGetDescriptionAttributeTypeOk(arg KeyGetDescriptionAttributeType) (ret KeyGetDescriptionRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setKeyGetDescriptionAttributeType(arg *KeyGetDescriptionAttributeType, val KeyGetDescriptionRetType) { + *arg = &val +} + +type KeyGetDescriptionArgType = string +type KeyGetDescriptionRetType = string + +/* + types and functions for displayName +*/ + +// isNotNullableString +type KeyGetDisplayNameAttributeType = *string + +func getKeyGetDisplayNameAttributeTypeOk(arg KeyGetDisplayNameAttributeType) (ret KeyGetDisplayNameRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setKeyGetDisplayNameAttributeType(arg *KeyGetDisplayNameAttributeType, val KeyGetDisplayNameRetType) { + *arg = &val +} + +type KeyGetDisplayNameArgType = string +type KeyGetDisplayNameRetType = string + +/* + types and functions for id +*/ + +// isNotNullableString +type KeyGetIdAttributeType = *string + +func getKeyGetIdAttributeTypeOk(arg KeyGetIdAttributeType) (ret KeyGetIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setKeyGetIdAttributeType(arg *KeyGetIdAttributeType, val KeyGetIdRetType) { + *arg = &val +} + +type KeyGetIdArgType = string +type KeyGetIdRetType = string + +/* + types and functions for importOnly +*/ + +// isBoolean +type KeygetImportOnlyAttributeType = *bool +type KeygetImportOnlyArgType = bool +type KeygetImportOnlyRetType = bool + +func getKeygetImportOnlyAttributeTypeOk(arg KeygetImportOnlyAttributeType) (ret KeygetImportOnlyRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setKeygetImportOnlyAttributeType(arg *KeygetImportOnlyAttributeType, val KeygetImportOnlyRetType) { + *arg = &val +} + +/* + types and functions for keyRingId +*/ + +// isNotNullableString +type KeyGetKeyRingIdAttributeType = *string + +func getKeyGetKeyRingIdAttributeTypeOk(arg KeyGetKeyRingIdAttributeType) (ret KeyGetKeyRingIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setKeyGetKeyRingIdAttributeType(arg *KeyGetKeyRingIdAttributeType, val KeyGetKeyRingIdRetType) { + *arg = &val +} + +type KeyGetKeyRingIdArgType = string +type KeyGetKeyRingIdRetType = string + +/* + types and functions for purpose +*/ + +// isEnumRef +type KeyGetPurposeAttributeType = *Purpose +type KeyGetPurposeArgType = Purpose +type KeyGetPurposeRetType = Purpose + +func getKeyGetPurposeAttributeTypeOk(arg KeyGetPurposeAttributeType) (ret KeyGetPurposeRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setKeyGetPurposeAttributeType(arg *KeyGetPurposeAttributeType, val KeyGetPurposeRetType) { + *arg = &val +} + +/* + types and functions for state +*/ + +// isEnumRef +type KeyGetStateAttributeType = *string +type KeyGetStateArgType = string +type KeyGetStateRetType = string + +func getKeyGetStateAttributeTypeOk(arg KeyGetStateAttributeType) (ret KeyGetStateRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setKeyGetStateAttributeType(arg *KeyGetStateAttributeType, val KeyGetStateRetType) { + *arg = &val +} + +// Key struct for Key +type Key struct { + // REQUIRED + Algorithm KeyGetAlgorithmAttributeType `json:"algorithm"` + // REQUIRED + Backend KeyGetBackendAttributeType `json:"backend"` + // The date and time the creation of the key was triggered. + // REQUIRED + CreatedAt KeyGetCreatedAtAttributeType `json:"createdAt"` + // A user chosen description to distinguish multiple keys. + Description KeyGetDescriptionAttributeType `json:"description,omitempty"` + // The display name to distinguish multiple keys. + // REQUIRED + DisplayName KeyGetDisplayNameAttributeType `json:"displayName"` + // A auto generated unique id which identifies the keys. + // REQUIRED + Id KeyGetIdAttributeType `json:"id"` + // States whether versions can be created or only imported. + ImportOnly KeygetImportOnlyAttributeType `json:"importOnly,omitempty"` + // The unique id of the key ring this key is assigned to. + // REQUIRED + KeyRingId KeyGetKeyRingIdAttributeType `json:"keyRingId"` + // REQUIRED + Purpose KeyGetPurposeAttributeType `json:"purpose"` + // The current state of the key. + // REQUIRED + State KeyGetStateAttributeType `json:"state"` +} + +type _Key Key + +// NewKey instantiates a new Key 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 NewKey(algorithm KeyGetAlgorithmArgType, backend KeyGetBackendArgType, createdAt KeyGetCreatedAtArgType, displayName KeyGetDisplayNameArgType, id KeyGetIdArgType, keyRingId KeyGetKeyRingIdArgType, purpose KeyGetPurposeArgType, state KeyGetStateArgType) *Key { + this := Key{} + setKeyGetAlgorithmAttributeType(&this.Algorithm, algorithm) + setKeyGetBackendAttributeType(&this.Backend, backend) + setKeyGetCreatedAtAttributeType(&this.CreatedAt, createdAt) + setKeyGetDisplayNameAttributeType(&this.DisplayName, displayName) + setKeyGetIdAttributeType(&this.Id, id) + setKeyGetKeyRingIdAttributeType(&this.KeyRingId, keyRingId) + setKeyGetPurposeAttributeType(&this.Purpose, purpose) + setKeyGetStateAttributeType(&this.State, state) + return &this +} + +// NewKeyWithDefaults instantiates a new Key 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 NewKeyWithDefaults() *Key { + this := Key{} + var importOnly bool = false + this.ImportOnly = &importOnly + return &this +} + +// GetAlgorithm returns the Algorithm field value +func (o *Key) GetAlgorithm() (ret KeyGetAlgorithmRetType) { + ret, _ = o.GetAlgorithmOk() + return ret +} + +// GetAlgorithmOk returns a tuple with the Algorithm field value +// and a boolean to check if the value has been set. +func (o *Key) GetAlgorithmOk() (ret KeyGetAlgorithmRetType, ok bool) { + return getKeyGetAlgorithmAttributeTypeOk(o.Algorithm) +} + +// SetAlgorithm sets field value +func (o *Key) SetAlgorithm(v KeyGetAlgorithmRetType) { + setKeyGetAlgorithmAttributeType(&o.Algorithm, v) +} + +// GetBackend returns the Backend field value +func (o *Key) GetBackend() (ret KeyGetBackendRetType) { + ret, _ = o.GetBackendOk() + return ret +} + +// GetBackendOk returns a tuple with the Backend field value +// and a boolean to check if the value has been set. +func (o *Key) GetBackendOk() (ret KeyGetBackendRetType, ok bool) { + return getKeyGetBackendAttributeTypeOk(o.Backend) +} + +// SetBackend sets field value +func (o *Key) SetBackend(v KeyGetBackendRetType) { + setKeyGetBackendAttributeType(&o.Backend, v) +} + +// GetCreatedAt returns the CreatedAt field value +func (o *Key) GetCreatedAt() (ret KeyGetCreatedAtRetType) { + ret, _ = o.GetCreatedAtOk() + return ret +} + +// GetCreatedAtOk returns a tuple with the CreatedAt field value +// and a boolean to check if the value has been set. +func (o *Key) GetCreatedAtOk() (ret KeyGetCreatedAtRetType, ok bool) { + return getKeyGetCreatedAtAttributeTypeOk(o.CreatedAt) +} + +// SetCreatedAt sets field value +func (o *Key) SetCreatedAt(v KeyGetCreatedAtRetType) { + setKeyGetCreatedAtAttributeType(&o.CreatedAt, v) +} + +// GetDescription returns the Description field value if set, zero value otherwise. +func (o *Key) GetDescription() (res KeyGetDescriptionRetType) { + res, _ = o.GetDescriptionOk() + return +} + +// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Key) GetDescriptionOk() (ret KeyGetDescriptionRetType, ok bool) { + return getKeyGetDescriptionAttributeTypeOk(o.Description) +} + +// HasDescription returns a boolean if a field has been set. +func (o *Key) HasDescription() bool { + _, ok := o.GetDescriptionOk() + return ok +} + +// SetDescription gets a reference to the given string and assigns it to the Description field. +func (o *Key) SetDescription(v KeyGetDescriptionRetType) { + setKeyGetDescriptionAttributeType(&o.Description, v) +} + +// GetDisplayName returns the DisplayName field value +func (o *Key) GetDisplayName() (ret KeyGetDisplayNameRetType) { + ret, _ = o.GetDisplayNameOk() + return ret +} + +// GetDisplayNameOk returns a tuple with the DisplayName field value +// and a boolean to check if the value has been set. +func (o *Key) GetDisplayNameOk() (ret KeyGetDisplayNameRetType, ok bool) { + return getKeyGetDisplayNameAttributeTypeOk(o.DisplayName) +} + +// SetDisplayName sets field value +func (o *Key) SetDisplayName(v KeyGetDisplayNameRetType) { + setKeyGetDisplayNameAttributeType(&o.DisplayName, v) +} + +// GetId returns the Id field value +func (o *Key) GetId() (ret KeyGetIdRetType) { + ret, _ = o.GetIdOk() + return ret +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *Key) GetIdOk() (ret KeyGetIdRetType, ok bool) { + return getKeyGetIdAttributeTypeOk(o.Id) +} + +// SetId sets field value +func (o *Key) SetId(v KeyGetIdRetType) { + setKeyGetIdAttributeType(&o.Id, v) +} + +// GetImportOnly returns the ImportOnly field value if set, zero value otherwise. +func (o *Key) GetImportOnly() (res KeygetImportOnlyRetType) { + res, _ = o.GetImportOnlyOk() + return +} + +// GetImportOnlyOk returns a tuple with the ImportOnly field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Key) GetImportOnlyOk() (ret KeygetImportOnlyRetType, ok bool) { + return getKeygetImportOnlyAttributeTypeOk(o.ImportOnly) +} + +// HasImportOnly returns a boolean if a field has been set. +func (o *Key) HasImportOnly() bool { + _, ok := o.GetImportOnlyOk() + return ok +} + +// SetImportOnly gets a reference to the given bool and assigns it to the ImportOnly field. +func (o *Key) SetImportOnly(v KeygetImportOnlyRetType) { + setKeygetImportOnlyAttributeType(&o.ImportOnly, v) +} + +// GetKeyRingId returns the KeyRingId field value +func (o *Key) GetKeyRingId() (ret KeyGetKeyRingIdRetType) { + ret, _ = o.GetKeyRingIdOk() + return ret +} + +// GetKeyRingIdOk returns a tuple with the KeyRingId field value +// and a boolean to check if the value has been set. +func (o *Key) GetKeyRingIdOk() (ret KeyGetKeyRingIdRetType, ok bool) { + return getKeyGetKeyRingIdAttributeTypeOk(o.KeyRingId) +} + +// SetKeyRingId sets field value +func (o *Key) SetKeyRingId(v KeyGetKeyRingIdRetType) { + setKeyGetKeyRingIdAttributeType(&o.KeyRingId, v) +} + +// GetPurpose returns the Purpose field value +func (o *Key) GetPurpose() (ret KeyGetPurposeRetType) { + ret, _ = o.GetPurposeOk() + return ret +} + +// GetPurposeOk returns a tuple with the Purpose field value +// and a boolean to check if the value has been set. +func (o *Key) GetPurposeOk() (ret KeyGetPurposeRetType, ok bool) { + return getKeyGetPurposeAttributeTypeOk(o.Purpose) +} + +// SetPurpose sets field value +func (o *Key) SetPurpose(v KeyGetPurposeRetType) { + setKeyGetPurposeAttributeType(&o.Purpose, v) +} + +// GetState returns the State field value +func (o *Key) GetState() (ret KeyGetStateRetType) { + ret, _ = o.GetStateOk() + return ret +} + +// GetStateOk returns a tuple with the State field value +// and a boolean to check if the value has been set. +func (o *Key) GetStateOk() (ret KeyGetStateRetType, ok bool) { + return getKeyGetStateAttributeTypeOk(o.State) +} + +// SetState sets field value +func (o *Key) SetState(v KeyGetStateRetType) { + setKeyGetStateAttributeType(&o.State, v) +} + +func (o Key) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getKeyGetAlgorithmAttributeTypeOk(o.Algorithm); ok { + toSerialize["Algorithm"] = val + } + if val, ok := getKeyGetBackendAttributeTypeOk(o.Backend); ok { + toSerialize["Backend"] = val + } + if val, ok := getKeyGetCreatedAtAttributeTypeOk(o.CreatedAt); ok { + toSerialize["CreatedAt"] = val + } + if val, ok := getKeyGetDescriptionAttributeTypeOk(o.Description); ok { + toSerialize["Description"] = val + } + if val, ok := getKeyGetDisplayNameAttributeTypeOk(o.DisplayName); ok { + toSerialize["DisplayName"] = val + } + if val, ok := getKeyGetIdAttributeTypeOk(o.Id); ok { + toSerialize["Id"] = val + } + if val, ok := getKeygetImportOnlyAttributeTypeOk(o.ImportOnly); ok { + toSerialize["ImportOnly"] = val + } + if val, ok := getKeyGetKeyRingIdAttributeTypeOk(o.KeyRingId); ok { + toSerialize["KeyRingId"] = val + } + if val, ok := getKeyGetPurposeAttributeTypeOk(o.Purpose); ok { + toSerialize["Purpose"] = val + } + if val, ok := getKeyGetStateAttributeTypeOk(o.State); ok { + toSerialize["State"] = val + } + return toSerialize, nil +} + +type NullableKey struct { + value *Key + isSet bool +} + +func (v NullableKey) Get() *Key { + return v.value +} + +func (v *NullableKey) Set(val *Key) { + v.value = val + v.isSet = true +} + +func (v NullableKey) IsSet() bool { + return v.isSet +} + +func (v *NullableKey) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableKey(val *Key) *NullableKey { + return &NullableKey{value: val, isSet: true} +} + +func (v NullableKey) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableKey) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/kms/model_key_list.go b/services/kms/model_key_list.go new file mode 100644 index 000000000..c61bd607c --- /dev/null +++ b/services/kms/model_key_list.go @@ -0,0 +1,125 @@ +/* +STACKIT Key Management Service API + +This API provides endpoints for managing keys and key rings. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package kms + +import ( + "encoding/json" +) + +// checks if the KeyList type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &KeyList{} + +/* + types and functions for keys +*/ + +// isArray +type KeyListGetKeysAttributeType = *[]Key +type KeyListGetKeysArgType = []Key +type KeyListGetKeysRetType = []Key + +func getKeyListGetKeysAttributeTypeOk(arg KeyListGetKeysAttributeType) (ret KeyListGetKeysRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setKeyListGetKeysAttributeType(arg *KeyListGetKeysAttributeType, val KeyListGetKeysRetType) { + *arg = &val +} + +// KeyList struct for KeyList +type KeyList struct { + // REQUIRED + Keys KeyListGetKeysAttributeType `json:"keys"` +} + +type _KeyList KeyList + +// NewKeyList instantiates a new KeyList 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 NewKeyList(keys KeyListGetKeysArgType) *KeyList { + this := KeyList{} + setKeyListGetKeysAttributeType(&this.Keys, keys) + return &this +} + +// NewKeyListWithDefaults instantiates a new KeyList 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 NewKeyListWithDefaults() *KeyList { + this := KeyList{} + return &this +} + +// GetKeys returns the Keys field value +func (o *KeyList) GetKeys() (ret KeyListGetKeysRetType) { + ret, _ = o.GetKeysOk() + return ret +} + +// GetKeysOk returns a tuple with the Keys field value +// and a boolean to check if the value has been set. +func (o *KeyList) GetKeysOk() (ret KeyListGetKeysRetType, ok bool) { + return getKeyListGetKeysAttributeTypeOk(o.Keys) +} + +// SetKeys sets field value +func (o *KeyList) SetKeys(v KeyListGetKeysRetType) { + setKeyListGetKeysAttributeType(&o.Keys, v) +} + +func (o KeyList) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getKeyListGetKeysAttributeTypeOk(o.Keys); ok { + toSerialize["Keys"] = val + } + return toSerialize, nil +} + +type NullableKeyList struct { + value *KeyList + isSet bool +} + +func (v NullableKeyList) Get() *KeyList { + return v.value +} + +func (v *NullableKeyList) Set(val *KeyList) { + v.value = val + v.isSet = true +} + +func (v NullableKeyList) IsSet() bool { + return v.isSet +} + +func (v *NullableKeyList) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableKeyList(val *KeyList) *NullableKeyList { + return &NullableKeyList{value: val, isSet: true} +} + +func (v NullableKeyList) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableKeyList) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/kms/model_key_ring.go b/services/kms/model_key_ring.go new file mode 100644 index 000000000..aaf10ac55 --- /dev/null +++ b/services/kms/model_key_ring.go @@ -0,0 +1,310 @@ +/* +STACKIT Key Management Service API + +This API provides endpoints for managing keys and key rings. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package kms + +import ( + "encoding/json" + "time" +) + +// checks if the KeyRing type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &KeyRing{} + +/* + types and functions for createdAt +*/ + +// isDateTime +type KeyRingGetCreatedAtAttributeType = *time.Time +type KeyRingGetCreatedAtArgType = time.Time +type KeyRingGetCreatedAtRetType = time.Time + +func getKeyRingGetCreatedAtAttributeTypeOk(arg KeyRingGetCreatedAtAttributeType) (ret KeyRingGetCreatedAtRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setKeyRingGetCreatedAtAttributeType(arg *KeyRingGetCreatedAtAttributeType, val KeyRingGetCreatedAtRetType) { + *arg = &val +} + +/* + types and functions for description +*/ + +// isNotNullableString +type KeyRingGetDescriptionAttributeType = *string + +func getKeyRingGetDescriptionAttributeTypeOk(arg KeyRingGetDescriptionAttributeType) (ret KeyRingGetDescriptionRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setKeyRingGetDescriptionAttributeType(arg *KeyRingGetDescriptionAttributeType, val KeyRingGetDescriptionRetType) { + *arg = &val +} + +type KeyRingGetDescriptionArgType = string +type KeyRingGetDescriptionRetType = string + +/* + types and functions for displayName +*/ + +// isNotNullableString +type KeyRingGetDisplayNameAttributeType = *string + +func getKeyRingGetDisplayNameAttributeTypeOk(arg KeyRingGetDisplayNameAttributeType) (ret KeyRingGetDisplayNameRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setKeyRingGetDisplayNameAttributeType(arg *KeyRingGetDisplayNameAttributeType, val KeyRingGetDisplayNameRetType) { + *arg = &val +} + +type KeyRingGetDisplayNameArgType = string +type KeyRingGetDisplayNameRetType = string + +/* + types and functions for id +*/ + +// isNotNullableString +type KeyRingGetIdAttributeType = *string + +func getKeyRingGetIdAttributeTypeOk(arg KeyRingGetIdAttributeType) (ret KeyRingGetIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setKeyRingGetIdAttributeType(arg *KeyRingGetIdAttributeType, val KeyRingGetIdRetType) { + *arg = &val +} + +type KeyRingGetIdArgType = string +type KeyRingGetIdRetType = string + +/* + types and functions for state +*/ + +// isEnumRef +type KeyRingGetStateAttributeType = *string +type KeyRingGetStateArgType = string +type KeyRingGetStateRetType = string + +func getKeyRingGetStateAttributeTypeOk(arg KeyRingGetStateAttributeType) (ret KeyRingGetStateRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setKeyRingGetStateAttributeType(arg *KeyRingGetStateAttributeType, val KeyRingGetStateRetType) { + *arg = &val +} + +// KeyRing struct for KeyRing +type KeyRing struct { + // The date and time the creation of the key ring was triggered. + // REQUIRED + CreatedAt KeyRingGetCreatedAtAttributeType `json:"createdAt"` + // A user chosen description to distinguish multiple key rings. + Description KeyRingGetDescriptionAttributeType `json:"description,omitempty"` + // The display name to distinguish multiple key rings. + // REQUIRED + DisplayName KeyRingGetDisplayNameAttributeType `json:"displayName"` + // A auto generated unique id which identifies the key ring. + // REQUIRED + Id KeyRingGetIdAttributeType `json:"id"` + // The current state of the key ring. + // REQUIRED + State KeyRingGetStateAttributeType `json:"state"` +} + +type _KeyRing KeyRing + +// NewKeyRing instantiates a new KeyRing 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 NewKeyRing(createdAt KeyRingGetCreatedAtArgType, displayName KeyRingGetDisplayNameArgType, id KeyRingGetIdArgType, state KeyRingGetStateArgType) *KeyRing { + this := KeyRing{} + setKeyRingGetCreatedAtAttributeType(&this.CreatedAt, createdAt) + setKeyRingGetDisplayNameAttributeType(&this.DisplayName, displayName) + setKeyRingGetIdAttributeType(&this.Id, id) + setKeyRingGetStateAttributeType(&this.State, state) + return &this +} + +// NewKeyRingWithDefaults instantiates a new KeyRing 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 NewKeyRingWithDefaults() *KeyRing { + this := KeyRing{} + return &this +} + +// GetCreatedAt returns the CreatedAt field value +func (o *KeyRing) GetCreatedAt() (ret KeyRingGetCreatedAtRetType) { + ret, _ = o.GetCreatedAtOk() + return ret +} + +// GetCreatedAtOk returns a tuple with the CreatedAt field value +// and a boolean to check if the value has been set. +func (o *KeyRing) GetCreatedAtOk() (ret KeyRingGetCreatedAtRetType, ok bool) { + return getKeyRingGetCreatedAtAttributeTypeOk(o.CreatedAt) +} + +// SetCreatedAt sets field value +func (o *KeyRing) SetCreatedAt(v KeyRingGetCreatedAtRetType) { + setKeyRingGetCreatedAtAttributeType(&o.CreatedAt, v) +} + +// GetDescription returns the Description field value if set, zero value otherwise. +func (o *KeyRing) GetDescription() (res KeyRingGetDescriptionRetType) { + res, _ = o.GetDescriptionOk() + return +} + +// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *KeyRing) GetDescriptionOk() (ret KeyRingGetDescriptionRetType, ok bool) { + return getKeyRingGetDescriptionAttributeTypeOk(o.Description) +} + +// HasDescription returns a boolean if a field has been set. +func (o *KeyRing) HasDescription() bool { + _, ok := o.GetDescriptionOk() + return ok +} + +// SetDescription gets a reference to the given string and assigns it to the Description field. +func (o *KeyRing) SetDescription(v KeyRingGetDescriptionRetType) { + setKeyRingGetDescriptionAttributeType(&o.Description, v) +} + +// GetDisplayName returns the DisplayName field value +func (o *KeyRing) GetDisplayName() (ret KeyRingGetDisplayNameRetType) { + ret, _ = o.GetDisplayNameOk() + return ret +} + +// GetDisplayNameOk returns a tuple with the DisplayName field value +// and a boolean to check if the value has been set. +func (o *KeyRing) GetDisplayNameOk() (ret KeyRingGetDisplayNameRetType, ok bool) { + return getKeyRingGetDisplayNameAttributeTypeOk(o.DisplayName) +} + +// SetDisplayName sets field value +func (o *KeyRing) SetDisplayName(v KeyRingGetDisplayNameRetType) { + setKeyRingGetDisplayNameAttributeType(&o.DisplayName, v) +} + +// GetId returns the Id field value +func (o *KeyRing) GetId() (ret KeyRingGetIdRetType) { + ret, _ = o.GetIdOk() + return ret +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *KeyRing) GetIdOk() (ret KeyRingGetIdRetType, ok bool) { + return getKeyRingGetIdAttributeTypeOk(o.Id) +} + +// SetId sets field value +func (o *KeyRing) SetId(v KeyRingGetIdRetType) { + setKeyRingGetIdAttributeType(&o.Id, v) +} + +// GetState returns the State field value +func (o *KeyRing) GetState() (ret KeyRingGetStateRetType) { + ret, _ = o.GetStateOk() + return ret +} + +// GetStateOk returns a tuple with the State field value +// and a boolean to check if the value has been set. +func (o *KeyRing) GetStateOk() (ret KeyRingGetStateRetType, ok bool) { + return getKeyRingGetStateAttributeTypeOk(o.State) +} + +// SetState sets field value +func (o *KeyRing) SetState(v KeyRingGetStateRetType) { + setKeyRingGetStateAttributeType(&o.State, v) +} + +func (o KeyRing) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getKeyRingGetCreatedAtAttributeTypeOk(o.CreatedAt); ok { + toSerialize["CreatedAt"] = val + } + if val, ok := getKeyRingGetDescriptionAttributeTypeOk(o.Description); ok { + toSerialize["Description"] = val + } + if val, ok := getKeyRingGetDisplayNameAttributeTypeOk(o.DisplayName); ok { + toSerialize["DisplayName"] = val + } + if val, ok := getKeyRingGetIdAttributeTypeOk(o.Id); ok { + toSerialize["Id"] = val + } + if val, ok := getKeyRingGetStateAttributeTypeOk(o.State); ok { + toSerialize["State"] = val + } + return toSerialize, nil +} + +type NullableKeyRing struct { + value *KeyRing + isSet bool +} + +func (v NullableKeyRing) Get() *KeyRing { + return v.value +} + +func (v *NullableKeyRing) Set(val *KeyRing) { + v.value = val + v.isSet = true +} + +func (v NullableKeyRing) IsSet() bool { + return v.isSet +} + +func (v *NullableKeyRing) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableKeyRing(val *KeyRing) *NullableKeyRing { + return &NullableKeyRing{value: val, isSet: true} +} + +func (v NullableKeyRing) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableKeyRing) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/kms/model_key_ring_list.go b/services/kms/model_key_ring_list.go new file mode 100644 index 000000000..0a136e625 --- /dev/null +++ b/services/kms/model_key_ring_list.go @@ -0,0 +1,125 @@ +/* +STACKIT Key Management Service API + +This API provides endpoints for managing keys and key rings. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package kms + +import ( + "encoding/json" +) + +// checks if the KeyRingList type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &KeyRingList{} + +/* + types and functions for keyRings +*/ + +// isArray +type KeyRingListGetKeyRingsAttributeType = *[]KeyRing +type KeyRingListGetKeyRingsArgType = []KeyRing +type KeyRingListGetKeyRingsRetType = []KeyRing + +func getKeyRingListGetKeyRingsAttributeTypeOk(arg KeyRingListGetKeyRingsAttributeType) (ret KeyRingListGetKeyRingsRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setKeyRingListGetKeyRingsAttributeType(arg *KeyRingListGetKeyRingsAttributeType, val KeyRingListGetKeyRingsRetType) { + *arg = &val +} + +// KeyRingList struct for KeyRingList +type KeyRingList struct { + // REQUIRED + KeyRings KeyRingListGetKeyRingsAttributeType `json:"keyRings"` +} + +type _KeyRingList KeyRingList + +// NewKeyRingList instantiates a new KeyRingList 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 NewKeyRingList(keyRings KeyRingListGetKeyRingsArgType) *KeyRingList { + this := KeyRingList{} + setKeyRingListGetKeyRingsAttributeType(&this.KeyRings, keyRings) + return &this +} + +// NewKeyRingListWithDefaults instantiates a new KeyRingList 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 NewKeyRingListWithDefaults() *KeyRingList { + this := KeyRingList{} + return &this +} + +// GetKeyRings returns the KeyRings field value +func (o *KeyRingList) GetKeyRings() (ret KeyRingListGetKeyRingsRetType) { + ret, _ = o.GetKeyRingsOk() + return ret +} + +// GetKeyRingsOk returns a tuple with the KeyRings field value +// and a boolean to check if the value has been set. +func (o *KeyRingList) GetKeyRingsOk() (ret KeyRingListGetKeyRingsRetType, ok bool) { + return getKeyRingListGetKeyRingsAttributeTypeOk(o.KeyRings) +} + +// SetKeyRings sets field value +func (o *KeyRingList) SetKeyRings(v KeyRingListGetKeyRingsRetType) { + setKeyRingListGetKeyRingsAttributeType(&o.KeyRings, v) +} + +func (o KeyRingList) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getKeyRingListGetKeyRingsAttributeTypeOk(o.KeyRings); ok { + toSerialize["KeyRings"] = val + } + return toSerialize, nil +} + +type NullableKeyRingList struct { + value *KeyRingList + isSet bool +} + +func (v NullableKeyRingList) Get() *KeyRingList { + return v.value +} + +func (v *NullableKeyRingList) Set(val *KeyRingList) { + v.value = val + v.isSet = true +} + +func (v NullableKeyRingList) IsSet() bool { + return v.isSet +} + +func (v *NullableKeyRingList) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableKeyRingList(val *KeyRingList) *NullableKeyRingList { + return &NullableKeyRingList{value: val, isSet: true} +} + +func (v NullableKeyRingList) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableKeyRingList) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/kms/model_purpose.go b/services/kms/model_purpose.go new file mode 100644 index 000000000..34ef82800 --- /dev/null +++ b/services/kms/model_purpose.go @@ -0,0 +1,119 @@ +/* +STACKIT Key Management Service API + +This API provides endpoints for managing keys and key rings. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package kms + +import ( + "encoding/json" + "fmt" +) + +// Purpose The purpose of the key. +type Purpose string + +// List of purpose +const ( + PURPOSE_SYMMETRIC_ENCRYPT_DECRYPT Purpose = "symmetric_encrypt_decrypt" + PURPOSE_ASYMMETRIC_ENCRYPT_DECRYPT Purpose = "asymmetric_encrypt_decrypt" + PURPOSE_MESSAGE_AUTHENTICATION_CODE Purpose = "message_authentication_code" + PURPOSE_ASYMMETRIC_SIGN_VERIFY Purpose = "asymmetric_sign_verify" +) + +// All allowed values of Purpose enum +var AllowedPurposeEnumValues = []Purpose{ + "symmetric_encrypt_decrypt", + "asymmetric_encrypt_decrypt", + "message_authentication_code", + "asymmetric_sign_verify", +} + +func (v *Purpose) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + // Allow unmarshalling zero value for testing purposes + var zeroValue string + if value == zeroValue { + return nil + } + enumTypeValue := Purpose(value) + for _, existing := range AllowedPurposeEnumValues { + if existing == enumTypeValue { + *v = enumTypeValue + return nil + } + } + + return fmt.Errorf("%+v is not a valid Purpose", value) +} + +// NewPurposeFromValue returns a pointer to a valid Purpose +// for the value passed as argument, or an error if the value passed is not allowed by the enum +func NewPurposeFromValue(v string) (*Purpose, error) { + ev := Purpose(v) + if ev.IsValid() { + return &ev, nil + } else { + return nil, fmt.Errorf("invalid value '%v' for Purpose: valid values are %v", v, AllowedPurposeEnumValues) + } +} + +// IsValid return true if the value is valid for the enum, false otherwise +func (v Purpose) IsValid() bool { + for _, existing := range AllowedPurposeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to purpose value +func (v Purpose) Ptr() *Purpose { + return &v +} + +type NullablePurpose struct { + value *Purpose + isSet bool +} + +func (v NullablePurpose) Get() *Purpose { + return v.value +} + +func (v *NullablePurpose) Set(val *Purpose) { + v.value = val + v.isSet = true +} + +func (v NullablePurpose) IsSet() bool { + return v.isSet +} + +func (v *NullablePurpose) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullablePurpose(val *Purpose) *NullablePurpose { + return &NullablePurpose{value: val, isSet: true} +} + +func (v NullablePurpose) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullablePurpose) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/kms/model_sign_payload.go b/services/kms/model_sign_payload.go new file mode 100644 index 000000000..811901474 --- /dev/null +++ b/services/kms/model_sign_payload.go @@ -0,0 +1,126 @@ +/* +STACKIT Key Management Service API + +This API provides endpoints for managing keys and key rings. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package kms + +import ( + "encoding/json" +) + +// checks if the SignPayload type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &SignPayload{} + +/* + types and functions for data +*/ + +// isByteArray +type SignPayloadGetDataAttributeType = *[]byte +type SignPayloadGetDataArgType = []byte +type SignPayloadGetDataRetType = []byte + +func getSignPayloadGetDataAttributeTypeOk(arg SignPayloadGetDataAttributeType) (ret SignPayloadGetDataRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setSignPayloadGetDataAttributeType(arg *SignPayloadGetDataAttributeType, val SignPayloadGetDataRetType) { + *arg = &val +} + +// SignPayload struct for SignPayload +type SignPayload struct { + // The data that has to be signed. Encoded in base64. + // REQUIRED + Data SignPayloadGetDataAttributeType `json:"data"` +} + +type _SignPayload SignPayload + +// NewSignPayload instantiates a new SignPayload 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 NewSignPayload(data SignPayloadGetDataArgType) *SignPayload { + this := SignPayload{} + setSignPayloadGetDataAttributeType(&this.Data, data) + return &this +} + +// NewSignPayloadWithDefaults instantiates a new SignPayload 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 NewSignPayloadWithDefaults() *SignPayload { + this := SignPayload{} + return &this +} + +// GetData returns the Data field value +func (o *SignPayload) GetData() (ret SignPayloadGetDataRetType) { + ret, _ = o.GetDataOk() + return ret +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *SignPayload) GetDataOk() (ret SignPayloadGetDataRetType, ok bool) { + return getSignPayloadGetDataAttributeTypeOk(o.Data) +} + +// SetData sets field value +func (o *SignPayload) SetData(v SignPayloadGetDataRetType) { + setSignPayloadGetDataAttributeType(&o.Data, v) +} + +func (o SignPayload) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getSignPayloadGetDataAttributeTypeOk(o.Data); ok { + toSerialize["Data"] = val + } + return toSerialize, nil +} + +type NullableSignPayload struct { + value *SignPayload + isSet bool +} + +func (v NullableSignPayload) Get() *SignPayload { + return v.value +} + +func (v *NullableSignPayload) Set(val *SignPayload) { + v.value = val + v.isSet = true +} + +func (v NullableSignPayload) IsSet() bool { + return v.isSet +} + +func (v *NullableSignPayload) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableSignPayload(val *SignPayload) *NullableSignPayload { + return &NullableSignPayload{value: val, isSet: true} +} + +func (v NullableSignPayload) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableSignPayload) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/kms/model_signed_data.go b/services/kms/model_signed_data.go new file mode 100644 index 000000000..c5ab0219c --- /dev/null +++ b/services/kms/model_signed_data.go @@ -0,0 +1,170 @@ +/* +STACKIT Key Management Service API + +This API provides endpoints for managing keys and key rings. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package kms + +import ( + "encoding/json" +) + +// checks if the SignedData type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &SignedData{} + +/* + types and functions for data +*/ + +// isByteArray +type SignedDataGetDataAttributeType = *[]byte +type SignedDataGetDataArgType = []byte +type SignedDataGetDataRetType = []byte + +func getSignedDataGetDataAttributeTypeOk(arg SignedDataGetDataAttributeType) (ret SignedDataGetDataRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setSignedDataGetDataAttributeType(arg *SignedDataGetDataAttributeType, val SignedDataGetDataRetType) { + *arg = &val +} + +/* + types and functions for signature +*/ + +// isByteArray +type SignedDataGetSignatureAttributeType = *[]byte +type SignedDataGetSignatureArgType = []byte +type SignedDataGetSignatureRetType = []byte + +func getSignedDataGetSignatureAttributeTypeOk(arg SignedDataGetSignatureAttributeType) (ret SignedDataGetSignatureRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setSignedDataGetSignatureAttributeType(arg *SignedDataGetSignatureAttributeType, val SignedDataGetSignatureRetType) { + *arg = &val +} + +// SignedData struct for SignedData +type SignedData struct { + // The data that was signed. Encoded in base64. + // REQUIRED + Data SignedDataGetDataAttributeType `json:"data"` + // The signature of the data. Encoded in base64. + // REQUIRED + Signature SignedDataGetSignatureAttributeType `json:"signature"` +} + +type _SignedData SignedData + +// NewSignedData instantiates a new SignedData 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 NewSignedData(data SignedDataGetDataArgType, signature SignedDataGetSignatureArgType) *SignedData { + this := SignedData{} + setSignedDataGetDataAttributeType(&this.Data, data) + setSignedDataGetSignatureAttributeType(&this.Signature, signature) + return &this +} + +// NewSignedDataWithDefaults instantiates a new SignedData 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 NewSignedDataWithDefaults() *SignedData { + this := SignedData{} + return &this +} + +// GetData returns the Data field value +func (o *SignedData) GetData() (ret SignedDataGetDataRetType) { + ret, _ = o.GetDataOk() + return ret +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *SignedData) GetDataOk() (ret SignedDataGetDataRetType, ok bool) { + return getSignedDataGetDataAttributeTypeOk(o.Data) +} + +// SetData sets field value +func (o *SignedData) SetData(v SignedDataGetDataRetType) { + setSignedDataGetDataAttributeType(&o.Data, v) +} + +// GetSignature returns the Signature field value +func (o *SignedData) GetSignature() (ret SignedDataGetSignatureRetType) { + ret, _ = o.GetSignatureOk() + return ret +} + +// GetSignatureOk returns a tuple with the Signature field value +// and a boolean to check if the value has been set. +func (o *SignedData) GetSignatureOk() (ret SignedDataGetSignatureRetType, ok bool) { + return getSignedDataGetSignatureAttributeTypeOk(o.Signature) +} + +// SetSignature sets field value +func (o *SignedData) SetSignature(v SignedDataGetSignatureRetType) { + setSignedDataGetSignatureAttributeType(&o.Signature, v) +} + +func (o SignedData) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getSignedDataGetDataAttributeTypeOk(o.Data); ok { + toSerialize["Data"] = val + } + if val, ok := getSignedDataGetSignatureAttributeTypeOk(o.Signature); ok { + toSerialize["Signature"] = val + } + return toSerialize, nil +} + +type NullableSignedData struct { + value *SignedData + isSet bool +} + +func (v NullableSignedData) Get() *SignedData { + return v.value +} + +func (v *NullableSignedData) Set(val *SignedData) { + v.value = val + v.isSet = true +} + +func (v NullableSignedData) IsSet() bool { + return v.isSet +} + +func (v *NullableSignedData) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableSignedData(val *SignedData) *NullableSignedData { + return &NullableSignedData{value: val, isSet: true} +} + +func (v NullableSignedData) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableSignedData) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/kms/model_verified_data.go b/services/kms/model_verified_data.go new file mode 100644 index 000000000..14b68839e --- /dev/null +++ b/services/kms/model_verified_data.go @@ -0,0 +1,126 @@ +/* +STACKIT Key Management Service API + +This API provides endpoints for managing keys and key rings. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package kms + +import ( + "encoding/json" +) + +// checks if the VerifiedData type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &VerifiedData{} + +/* + types and functions for valid +*/ + +// isBoolean +type VerifiedDatagetValidAttributeType = *bool +type VerifiedDatagetValidArgType = bool +type VerifiedDatagetValidRetType = bool + +func getVerifiedDatagetValidAttributeTypeOk(arg VerifiedDatagetValidAttributeType) (ret VerifiedDatagetValidRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setVerifiedDatagetValidAttributeType(arg *VerifiedDatagetValidAttributeType, val VerifiedDatagetValidRetType) { + *arg = &val +} + +// VerifiedData struct for VerifiedData +type VerifiedData struct { + // Whether or not the data has a valid signature. + // REQUIRED + Valid VerifiedDatagetValidAttributeType `json:"valid"` +} + +type _VerifiedData VerifiedData + +// NewVerifiedData instantiates a new VerifiedData 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 NewVerifiedData(valid VerifiedDatagetValidArgType) *VerifiedData { + this := VerifiedData{} + setVerifiedDatagetValidAttributeType(&this.Valid, valid) + return &this +} + +// NewVerifiedDataWithDefaults instantiates a new VerifiedData 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 NewVerifiedDataWithDefaults() *VerifiedData { + this := VerifiedData{} + return &this +} + +// GetValid returns the Valid field value +func (o *VerifiedData) GetValid() (ret VerifiedDatagetValidRetType) { + ret, _ = o.GetValidOk() + return ret +} + +// GetValidOk returns a tuple with the Valid field value +// and a boolean to check if the value has been set. +func (o *VerifiedData) GetValidOk() (ret VerifiedDatagetValidRetType, ok bool) { + return getVerifiedDatagetValidAttributeTypeOk(o.Valid) +} + +// SetValid sets field value +func (o *VerifiedData) SetValid(v VerifiedDatagetValidRetType) { + setVerifiedDatagetValidAttributeType(&o.Valid, v) +} + +func (o VerifiedData) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getVerifiedDatagetValidAttributeTypeOk(o.Valid); ok { + toSerialize["Valid"] = val + } + return toSerialize, nil +} + +type NullableVerifiedData struct { + value *VerifiedData + isSet bool +} + +func (v NullableVerifiedData) Get() *VerifiedData { + return v.value +} + +func (v *NullableVerifiedData) Set(val *VerifiedData) { + v.value = val + v.isSet = true +} + +func (v NullableVerifiedData) IsSet() bool { + return v.isSet +} + +func (v *NullableVerifiedData) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableVerifiedData(val *VerifiedData) *NullableVerifiedData { + return &NullableVerifiedData{value: val, isSet: true} +} + +func (v NullableVerifiedData) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableVerifiedData) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/kms/model_verify_payload.go b/services/kms/model_verify_payload.go new file mode 100644 index 000000000..fa4035a0e --- /dev/null +++ b/services/kms/model_verify_payload.go @@ -0,0 +1,170 @@ +/* +STACKIT Key Management Service API + +This API provides endpoints for managing keys and key rings. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package kms + +import ( + "encoding/json" +) + +// checks if the VerifyPayload type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &VerifyPayload{} + +/* + types and functions for data +*/ + +// isByteArray +type VerifyPayloadGetDataAttributeType = *[]byte +type VerifyPayloadGetDataArgType = []byte +type VerifyPayloadGetDataRetType = []byte + +func getVerifyPayloadGetDataAttributeTypeOk(arg VerifyPayloadGetDataAttributeType) (ret VerifyPayloadGetDataRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setVerifyPayloadGetDataAttributeType(arg *VerifyPayloadGetDataAttributeType, val VerifyPayloadGetDataRetType) { + *arg = &val +} + +/* + types and functions for signature +*/ + +// isByteArray +type VerifyPayloadGetSignatureAttributeType = *[]byte +type VerifyPayloadGetSignatureArgType = []byte +type VerifyPayloadGetSignatureRetType = []byte + +func getVerifyPayloadGetSignatureAttributeTypeOk(arg VerifyPayloadGetSignatureAttributeType) (ret VerifyPayloadGetSignatureRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setVerifyPayloadGetSignatureAttributeType(arg *VerifyPayloadGetSignatureAttributeType, val VerifyPayloadGetSignatureRetType) { + *arg = &val +} + +// VerifyPayload struct for VerifyPayload +type VerifyPayload struct { + // The data to be verified. Encoded in base64. + // REQUIRED + Data VerifyPayloadGetDataAttributeType `json:"data"` + // The signature of the data. Encoded in base64. + // REQUIRED + Signature VerifyPayloadGetSignatureAttributeType `json:"signature"` +} + +type _VerifyPayload VerifyPayload + +// NewVerifyPayload instantiates a new VerifyPayload 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 NewVerifyPayload(data VerifyPayloadGetDataArgType, signature VerifyPayloadGetSignatureArgType) *VerifyPayload { + this := VerifyPayload{} + setVerifyPayloadGetDataAttributeType(&this.Data, data) + setVerifyPayloadGetSignatureAttributeType(&this.Signature, signature) + return &this +} + +// NewVerifyPayloadWithDefaults instantiates a new VerifyPayload 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 NewVerifyPayloadWithDefaults() *VerifyPayload { + this := VerifyPayload{} + return &this +} + +// GetData returns the Data field value +func (o *VerifyPayload) GetData() (ret VerifyPayloadGetDataRetType) { + ret, _ = o.GetDataOk() + return ret +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *VerifyPayload) GetDataOk() (ret VerifyPayloadGetDataRetType, ok bool) { + return getVerifyPayloadGetDataAttributeTypeOk(o.Data) +} + +// SetData sets field value +func (o *VerifyPayload) SetData(v VerifyPayloadGetDataRetType) { + setVerifyPayloadGetDataAttributeType(&o.Data, v) +} + +// GetSignature returns the Signature field value +func (o *VerifyPayload) GetSignature() (ret VerifyPayloadGetSignatureRetType) { + ret, _ = o.GetSignatureOk() + return ret +} + +// GetSignatureOk returns a tuple with the Signature field value +// and a boolean to check if the value has been set. +func (o *VerifyPayload) GetSignatureOk() (ret VerifyPayloadGetSignatureRetType, ok bool) { + return getVerifyPayloadGetSignatureAttributeTypeOk(o.Signature) +} + +// SetSignature sets field value +func (o *VerifyPayload) SetSignature(v VerifyPayloadGetSignatureRetType) { + setVerifyPayloadGetSignatureAttributeType(&o.Signature, v) +} + +func (o VerifyPayload) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getVerifyPayloadGetDataAttributeTypeOk(o.Data); ok { + toSerialize["Data"] = val + } + if val, ok := getVerifyPayloadGetSignatureAttributeTypeOk(o.Signature); ok { + toSerialize["Signature"] = val + } + return toSerialize, nil +} + +type NullableVerifyPayload struct { + value *VerifyPayload + isSet bool +} + +func (v NullableVerifyPayload) Get() *VerifyPayload { + return v.value +} + +func (v *NullableVerifyPayload) Set(val *VerifyPayload) { + v.value = val + v.isSet = true +} + +func (v NullableVerifyPayload) IsSet() bool { + return v.isSet +} + +func (v *NullableVerifyPayload) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableVerifyPayload(val *VerifyPayload) *NullableVerifyPayload { + return &NullableVerifyPayload{value: val, isSet: true} +} + +func (v NullableVerifyPayload) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableVerifyPayload) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/kms/model_version.go b/services/kms/model_version.go new file mode 100644 index 000000000..87e0aea05 --- /dev/null +++ b/services/kms/model_version.go @@ -0,0 +1,404 @@ +/* +STACKIT Key Management Service API + +This API provides endpoints for managing keys and key rings. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package kms + +import ( + "encoding/json" + "time" +) + +// checks if the Version type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &Version{} + +/* + types and functions for createdAt +*/ + +// isDateTime +type VersionGetCreatedAtAttributeType = *time.Time +type VersionGetCreatedAtArgType = time.Time +type VersionGetCreatedAtRetType = time.Time + +func getVersionGetCreatedAtAttributeTypeOk(arg VersionGetCreatedAtAttributeType) (ret VersionGetCreatedAtRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setVersionGetCreatedAtAttributeType(arg *VersionGetCreatedAtAttributeType, val VersionGetCreatedAtRetType) { + *arg = &val +} + +/* + types and functions for disabled +*/ + +// isBoolean +type VersiongetDisabledAttributeType = *bool +type VersiongetDisabledArgType = bool +type VersiongetDisabledRetType = bool + +func getVersiongetDisabledAttributeTypeOk(arg VersiongetDisabledAttributeType) (ret VersiongetDisabledRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setVersiongetDisabledAttributeType(arg *VersiongetDisabledAttributeType, val VersiongetDisabledRetType) { + *arg = &val +} + +/* + types and functions for keyId +*/ + +// isNotNullableString +type VersionGetKeyIdAttributeType = *string + +func getVersionGetKeyIdAttributeTypeOk(arg VersionGetKeyIdAttributeType) (ret VersionGetKeyIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setVersionGetKeyIdAttributeType(arg *VersionGetKeyIdAttributeType, val VersionGetKeyIdRetType) { + *arg = &val +} + +type VersionGetKeyIdArgType = string +type VersionGetKeyIdRetType = string + +/* + types and functions for keyRingId +*/ + +// isNotNullableString +type VersionGetKeyRingIdAttributeType = *string + +func getVersionGetKeyRingIdAttributeTypeOk(arg VersionGetKeyRingIdAttributeType) (ret VersionGetKeyRingIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setVersionGetKeyRingIdAttributeType(arg *VersionGetKeyRingIdAttributeType, val VersionGetKeyRingIdRetType) { + *arg = &val +} + +type VersionGetKeyRingIdArgType = string +type VersionGetKeyRingIdRetType = string + +/* + types and functions for number +*/ + +// isLong +type VersionGetNumberAttributeType = *int64 +type VersionGetNumberArgType = int64 +type VersionGetNumberRetType = int64 + +func getVersionGetNumberAttributeTypeOk(arg VersionGetNumberAttributeType) (ret VersionGetNumberRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setVersionGetNumberAttributeType(arg *VersionGetNumberAttributeType, val VersionGetNumberRetType) { + *arg = &val +} + +/* + types and functions for publicKey +*/ + +// isNotNullableString +type VersionGetPublicKeyAttributeType = *string + +func getVersionGetPublicKeyAttributeTypeOk(arg VersionGetPublicKeyAttributeType) (ret VersionGetPublicKeyRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setVersionGetPublicKeyAttributeType(arg *VersionGetPublicKeyAttributeType, val VersionGetPublicKeyRetType) { + *arg = &val +} + +type VersionGetPublicKeyArgType = string +type VersionGetPublicKeyRetType = string + +/* + types and functions for state +*/ + +// isEnumRef +type VersionGetStateAttributeType = *string +type VersionGetStateArgType = string +type VersionGetStateRetType = string + +func getVersionGetStateAttributeTypeOk(arg VersionGetStateAttributeType) (ret VersionGetStateRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setVersionGetStateAttributeType(arg *VersionGetStateAttributeType, val VersionGetStateRetType) { + *arg = &val +} + +// Version struct for Version +type Version struct { + // The date and time the creation of the key was triggered. + // REQUIRED + CreatedAt VersionGetCreatedAtAttributeType `json:"createdAt"` + // States whether versions is enabled or disabled. + Disabled VersiongetDisabledAttributeType `json:"disabled,omitempty"` + // The unique id of the key this version is assigned to. + // REQUIRED + KeyId VersionGetKeyIdAttributeType `json:"keyId"` + // The unique id of the key ring the key of this version is assigned to. + // REQUIRED + KeyRingId VersionGetKeyRingIdAttributeType `json:"keyRingId"` + // A sequential number which identifies the key versions. + // REQUIRED + Number VersionGetNumberAttributeType `json:"number"` + // The public key of the key version. Only present in asymmetric keys. + PublicKey VersionGetPublicKeyAttributeType `json:"publicKey,omitempty"` + // The current state of the key. + // REQUIRED + State VersionGetStateAttributeType `json:"state"` +} + +type _Version Version + +// NewVersion instantiates a new Version 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 NewVersion(createdAt VersionGetCreatedAtArgType, keyId VersionGetKeyIdArgType, keyRingId VersionGetKeyRingIdArgType, number VersionGetNumberArgType, state VersionGetStateArgType) *Version { + this := Version{} + setVersionGetCreatedAtAttributeType(&this.CreatedAt, createdAt) + setVersionGetKeyIdAttributeType(&this.KeyId, keyId) + setVersionGetKeyRingIdAttributeType(&this.KeyRingId, keyRingId) + setVersionGetNumberAttributeType(&this.Number, number) + setVersionGetStateAttributeType(&this.State, state) + return &this +} + +// NewVersionWithDefaults instantiates a new Version 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 NewVersionWithDefaults() *Version { + this := Version{} + var disabled bool = false + this.Disabled = &disabled + return &this +} + +// GetCreatedAt returns the CreatedAt field value +func (o *Version) GetCreatedAt() (ret VersionGetCreatedAtRetType) { + ret, _ = o.GetCreatedAtOk() + return ret +} + +// GetCreatedAtOk returns a tuple with the CreatedAt field value +// and a boolean to check if the value has been set. +func (o *Version) GetCreatedAtOk() (ret VersionGetCreatedAtRetType, ok bool) { + return getVersionGetCreatedAtAttributeTypeOk(o.CreatedAt) +} + +// SetCreatedAt sets field value +func (o *Version) SetCreatedAt(v VersionGetCreatedAtRetType) { + setVersionGetCreatedAtAttributeType(&o.CreatedAt, v) +} + +// GetDisabled returns the Disabled field value if set, zero value otherwise. +func (o *Version) GetDisabled() (res VersiongetDisabledRetType) { + res, _ = o.GetDisabledOk() + return +} + +// GetDisabledOk returns a tuple with the Disabled field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Version) GetDisabledOk() (ret VersiongetDisabledRetType, ok bool) { + return getVersiongetDisabledAttributeTypeOk(o.Disabled) +} + +// HasDisabled returns a boolean if a field has been set. +func (o *Version) HasDisabled() bool { + _, ok := o.GetDisabledOk() + return ok +} + +// SetDisabled gets a reference to the given bool and assigns it to the Disabled field. +func (o *Version) SetDisabled(v VersiongetDisabledRetType) { + setVersiongetDisabledAttributeType(&o.Disabled, v) +} + +// GetKeyId returns the KeyId field value +func (o *Version) GetKeyId() (ret VersionGetKeyIdRetType) { + ret, _ = o.GetKeyIdOk() + return ret +} + +// GetKeyIdOk returns a tuple with the KeyId field value +// and a boolean to check if the value has been set. +func (o *Version) GetKeyIdOk() (ret VersionGetKeyIdRetType, ok bool) { + return getVersionGetKeyIdAttributeTypeOk(o.KeyId) +} + +// SetKeyId sets field value +func (o *Version) SetKeyId(v VersionGetKeyIdRetType) { + setVersionGetKeyIdAttributeType(&o.KeyId, v) +} + +// GetKeyRingId returns the KeyRingId field value +func (o *Version) GetKeyRingId() (ret VersionGetKeyRingIdRetType) { + ret, _ = o.GetKeyRingIdOk() + return ret +} + +// GetKeyRingIdOk returns a tuple with the KeyRingId field value +// and a boolean to check if the value has been set. +func (o *Version) GetKeyRingIdOk() (ret VersionGetKeyRingIdRetType, ok bool) { + return getVersionGetKeyRingIdAttributeTypeOk(o.KeyRingId) +} + +// SetKeyRingId sets field value +func (o *Version) SetKeyRingId(v VersionGetKeyRingIdRetType) { + setVersionGetKeyRingIdAttributeType(&o.KeyRingId, v) +} + +// GetNumber returns the Number field value +func (o *Version) GetNumber() (ret VersionGetNumberRetType) { + ret, _ = o.GetNumberOk() + return ret +} + +// GetNumberOk returns a tuple with the Number field value +// and a boolean to check if the value has been set. +func (o *Version) GetNumberOk() (ret VersionGetNumberRetType, ok bool) { + return getVersionGetNumberAttributeTypeOk(o.Number) +} + +// SetNumber sets field value +func (o *Version) SetNumber(v VersionGetNumberRetType) { + setVersionGetNumberAttributeType(&o.Number, v) +} + +// GetPublicKey returns the PublicKey field value if set, zero value otherwise. +func (o *Version) GetPublicKey() (res VersionGetPublicKeyRetType) { + res, _ = o.GetPublicKeyOk() + return +} + +// GetPublicKeyOk returns a tuple with the PublicKey field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Version) GetPublicKeyOk() (ret VersionGetPublicKeyRetType, ok bool) { + return getVersionGetPublicKeyAttributeTypeOk(o.PublicKey) +} + +// HasPublicKey returns a boolean if a field has been set. +func (o *Version) HasPublicKey() bool { + _, ok := o.GetPublicKeyOk() + return ok +} + +// SetPublicKey gets a reference to the given string and assigns it to the PublicKey field. +func (o *Version) SetPublicKey(v VersionGetPublicKeyRetType) { + setVersionGetPublicKeyAttributeType(&o.PublicKey, v) +} + +// GetState returns the State field value +func (o *Version) GetState() (ret VersionGetStateRetType) { + ret, _ = o.GetStateOk() + return ret +} + +// GetStateOk returns a tuple with the State field value +// and a boolean to check if the value has been set. +func (o *Version) GetStateOk() (ret VersionGetStateRetType, ok bool) { + return getVersionGetStateAttributeTypeOk(o.State) +} + +// SetState sets field value +func (o *Version) SetState(v VersionGetStateRetType) { + setVersionGetStateAttributeType(&o.State, v) +} + +func (o Version) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getVersionGetCreatedAtAttributeTypeOk(o.CreatedAt); ok { + toSerialize["CreatedAt"] = val + } + if val, ok := getVersiongetDisabledAttributeTypeOk(o.Disabled); ok { + toSerialize["Disabled"] = val + } + if val, ok := getVersionGetKeyIdAttributeTypeOk(o.KeyId); ok { + toSerialize["KeyId"] = val + } + if val, ok := getVersionGetKeyRingIdAttributeTypeOk(o.KeyRingId); ok { + toSerialize["KeyRingId"] = val + } + if val, ok := getVersionGetNumberAttributeTypeOk(o.Number); ok { + toSerialize["Number"] = val + } + if val, ok := getVersionGetPublicKeyAttributeTypeOk(o.PublicKey); ok { + toSerialize["PublicKey"] = val + } + if val, ok := getVersionGetStateAttributeTypeOk(o.State); ok { + toSerialize["State"] = val + } + return toSerialize, nil +} + +type NullableVersion struct { + value *Version + isSet bool +} + +func (v NullableVersion) Get() *Version { + return v.value +} + +func (v *NullableVersion) Set(val *Version) { + v.value = val + v.isSet = true +} + +func (v NullableVersion) IsSet() bool { + return v.isSet +} + +func (v *NullableVersion) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableVersion(val *Version) *NullableVersion { + return &NullableVersion{value: val, isSet: true} +} + +func (v NullableVersion) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableVersion) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/kms/model_version_list.go b/services/kms/model_version_list.go new file mode 100644 index 000000000..a8d54f8ed --- /dev/null +++ b/services/kms/model_version_list.go @@ -0,0 +1,125 @@ +/* +STACKIT Key Management Service API + +This API provides endpoints for managing keys and key rings. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package kms + +import ( + "encoding/json" +) + +// checks if the VersionList type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &VersionList{} + +/* + types and functions for versions +*/ + +// isArray +type VersionListGetVersionsAttributeType = *[]Version +type VersionListGetVersionsArgType = []Version +type VersionListGetVersionsRetType = []Version + +func getVersionListGetVersionsAttributeTypeOk(arg VersionListGetVersionsAttributeType) (ret VersionListGetVersionsRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setVersionListGetVersionsAttributeType(arg *VersionListGetVersionsAttributeType, val VersionListGetVersionsRetType) { + *arg = &val +} + +// VersionList struct for VersionList +type VersionList struct { + // REQUIRED + Versions VersionListGetVersionsAttributeType `json:"versions"` +} + +type _VersionList VersionList + +// NewVersionList instantiates a new VersionList 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 NewVersionList(versions VersionListGetVersionsArgType) *VersionList { + this := VersionList{} + setVersionListGetVersionsAttributeType(&this.Versions, versions) + return &this +} + +// NewVersionListWithDefaults instantiates a new VersionList 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 NewVersionListWithDefaults() *VersionList { + this := VersionList{} + return &this +} + +// GetVersions returns the Versions field value +func (o *VersionList) GetVersions() (ret VersionListGetVersionsRetType) { + ret, _ = o.GetVersionsOk() + return ret +} + +// GetVersionsOk returns a tuple with the Versions field value +// and a boolean to check if the value has been set. +func (o *VersionList) GetVersionsOk() (ret VersionListGetVersionsRetType, ok bool) { + return getVersionListGetVersionsAttributeTypeOk(o.Versions) +} + +// SetVersions sets field value +func (o *VersionList) SetVersions(v VersionListGetVersionsRetType) { + setVersionListGetVersionsAttributeType(&o.Versions, v) +} + +func (o VersionList) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getVersionListGetVersionsAttributeTypeOk(o.Versions); ok { + toSerialize["Versions"] = val + } + return toSerialize, nil +} + +type NullableVersionList struct { + value *VersionList + isSet bool +} + +func (v NullableVersionList) Get() *VersionList { + return v.value +} + +func (v *NullableVersionList) Set(val *VersionList) { + v.value = val + v.isSet = true +} + +func (v NullableVersionList) IsSet() bool { + return v.isSet +} + +func (v *NullableVersionList) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableVersionList(val *VersionList) *NullableVersionList { + return &NullableVersionList{value: val, isSet: true} +} + +func (v NullableVersionList) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableVersionList) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/kms/model_wrapping_algorithm.go b/services/kms/model_wrapping_algorithm.go new file mode 100644 index 000000000..cd9ca9034 --- /dev/null +++ b/services/kms/model_wrapping_algorithm.go @@ -0,0 +1,127 @@ +/* +STACKIT Key Management Service API + +This API provides endpoints for managing keys and key rings. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package kms + +import ( + "encoding/json" + "fmt" +) + +// WrappingAlgorithm The wrapping algorithm used to wrap the key to import. +type WrappingAlgorithm string + +// List of wrappingAlgorithm +const ( + WRAPPINGALGORITHM__2048_OAEP_SHA256 WrappingAlgorithm = "rsa_2048_oaep_sha256" + WRAPPINGALGORITHM__3072_OAEP_SHA256 WrappingAlgorithm = "rsa_3072_oaep_sha256" + WRAPPINGALGORITHM__4096_OAEP_SHA256 WrappingAlgorithm = "rsa_4096_oaep_sha256" + WRAPPINGALGORITHM__4096_OAEP_SHA512 WrappingAlgorithm = "rsa_4096_oaep_sha512" + WRAPPINGALGORITHM__2048_OAEP_SHA256_AES_256_KEY_WRAP WrappingAlgorithm = "rsa_2048_oaep_sha256_aes_256_key_wrap" + WRAPPINGALGORITHM__3072_OAEP_SHA256_AES_256_KEY_WRAP WrappingAlgorithm = "rsa_3072_oaep_sha256_aes_256_key_wrap" + WRAPPINGALGORITHM__4096_OAEP_SHA256_AES_256_KEY_WRAP WrappingAlgorithm = "rsa_4096_oaep_sha256_aes_256_key_wrap" + WRAPPINGALGORITHM__4096_OAEP_SHA512_AES_256_KEY_WRAP WrappingAlgorithm = "rsa_4096_oaep_sha512_aes_256_key_wrap" +) + +// All allowed values of WrappingAlgorithm enum +var AllowedWrappingAlgorithmEnumValues = []WrappingAlgorithm{ + "rsa_2048_oaep_sha256", + "rsa_3072_oaep_sha256", + "rsa_4096_oaep_sha256", + "rsa_4096_oaep_sha512", + "rsa_2048_oaep_sha256_aes_256_key_wrap", + "rsa_3072_oaep_sha256_aes_256_key_wrap", + "rsa_4096_oaep_sha256_aes_256_key_wrap", + "rsa_4096_oaep_sha512_aes_256_key_wrap", +} + +func (v *WrappingAlgorithm) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + // Allow unmarshalling zero value for testing purposes + var zeroValue string + if value == zeroValue { + return nil + } + enumTypeValue := WrappingAlgorithm(value) + for _, existing := range AllowedWrappingAlgorithmEnumValues { + if existing == enumTypeValue { + *v = enumTypeValue + return nil + } + } + + return fmt.Errorf("%+v is not a valid WrappingAlgorithm", value) +} + +// NewWrappingAlgorithmFromValue returns a pointer to a valid WrappingAlgorithm +// for the value passed as argument, or an error if the value passed is not allowed by the enum +func NewWrappingAlgorithmFromValue(v string) (*WrappingAlgorithm, error) { + ev := WrappingAlgorithm(v) + if ev.IsValid() { + return &ev, nil + } else { + return nil, fmt.Errorf("invalid value '%v' for WrappingAlgorithm: valid values are %v", v, AllowedWrappingAlgorithmEnumValues) + } +} + +// IsValid return true if the value is valid for the enum, false otherwise +func (v WrappingAlgorithm) IsValid() bool { + for _, existing := range AllowedWrappingAlgorithmEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to wrappingAlgorithm value +func (v WrappingAlgorithm) Ptr() *WrappingAlgorithm { + return &v +} + +type NullableWrappingAlgorithm struct { + value *WrappingAlgorithm + isSet bool +} + +func (v NullableWrappingAlgorithm) Get() *WrappingAlgorithm { + return v.value +} + +func (v *NullableWrappingAlgorithm) Set(val *WrappingAlgorithm) { + v.value = val + v.isSet = true +} + +func (v NullableWrappingAlgorithm) IsSet() bool { + return v.isSet +} + +func (v *NullableWrappingAlgorithm) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableWrappingAlgorithm(val *WrappingAlgorithm) *NullableWrappingAlgorithm { + return &NullableWrappingAlgorithm{value: val, isSet: true} +} + +func (v NullableWrappingAlgorithm) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableWrappingAlgorithm) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/kms/model_wrapping_key.go b/services/kms/model_wrapping_key.go new file mode 100644 index 000000000..df845ac16 --- /dev/null +++ b/services/kms/model_wrapping_key.go @@ -0,0 +1,577 @@ +/* +STACKIT Key Management Service API + +This API provides endpoints for managing keys and key rings. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package kms + +import ( + "encoding/json" + "time" +) + +// checks if the WrappingKey type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &WrappingKey{} + +/* + types and functions for algorithm +*/ + +// isEnumRef +type WrappingKeyGetAlgorithmAttributeType = *WrappingAlgorithm +type WrappingKeyGetAlgorithmArgType = WrappingAlgorithm +type WrappingKeyGetAlgorithmRetType = WrappingAlgorithm + +func getWrappingKeyGetAlgorithmAttributeTypeOk(arg WrappingKeyGetAlgorithmAttributeType) (ret WrappingKeyGetAlgorithmRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setWrappingKeyGetAlgorithmAttributeType(arg *WrappingKeyGetAlgorithmAttributeType, val WrappingKeyGetAlgorithmRetType) { + *arg = &val +} + +/* + types and functions for backend +*/ + +// isEnumRef +type WrappingKeyGetBackendAttributeType = *Backend +type WrappingKeyGetBackendArgType = Backend +type WrappingKeyGetBackendRetType = Backend + +func getWrappingKeyGetBackendAttributeTypeOk(arg WrappingKeyGetBackendAttributeType) (ret WrappingKeyGetBackendRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setWrappingKeyGetBackendAttributeType(arg *WrappingKeyGetBackendAttributeType, val WrappingKeyGetBackendRetType) { + *arg = &val +} + +/* + types and functions for createdAt +*/ + +// isDateTime +type WrappingKeyGetCreatedAtAttributeType = *time.Time +type WrappingKeyGetCreatedAtArgType = time.Time +type WrappingKeyGetCreatedAtRetType = time.Time + +func getWrappingKeyGetCreatedAtAttributeTypeOk(arg WrappingKeyGetCreatedAtAttributeType) (ret WrappingKeyGetCreatedAtRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setWrappingKeyGetCreatedAtAttributeType(arg *WrappingKeyGetCreatedAtAttributeType, val WrappingKeyGetCreatedAtRetType) { + *arg = &val +} + +/* + types and functions for description +*/ + +// isNotNullableString +type WrappingKeyGetDescriptionAttributeType = *string + +func getWrappingKeyGetDescriptionAttributeTypeOk(arg WrappingKeyGetDescriptionAttributeType) (ret WrappingKeyGetDescriptionRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setWrappingKeyGetDescriptionAttributeType(arg *WrappingKeyGetDescriptionAttributeType, val WrappingKeyGetDescriptionRetType) { + *arg = &val +} + +type WrappingKeyGetDescriptionArgType = string +type WrappingKeyGetDescriptionRetType = string + +/* + types and functions for displayName +*/ + +// isNotNullableString +type WrappingKeyGetDisplayNameAttributeType = *string + +func getWrappingKeyGetDisplayNameAttributeTypeOk(arg WrappingKeyGetDisplayNameAttributeType) (ret WrappingKeyGetDisplayNameRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setWrappingKeyGetDisplayNameAttributeType(arg *WrappingKeyGetDisplayNameAttributeType, val WrappingKeyGetDisplayNameRetType) { + *arg = &val +} + +type WrappingKeyGetDisplayNameArgType = string +type WrappingKeyGetDisplayNameRetType = string + +/* + types and functions for expiresAt +*/ + +// isDateTime +type WrappingKeyGetExpiresAtAttributeType = *time.Time +type WrappingKeyGetExpiresAtArgType = time.Time +type WrappingKeyGetExpiresAtRetType = time.Time + +func getWrappingKeyGetExpiresAtAttributeTypeOk(arg WrappingKeyGetExpiresAtAttributeType) (ret WrappingKeyGetExpiresAtRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setWrappingKeyGetExpiresAtAttributeType(arg *WrappingKeyGetExpiresAtAttributeType, val WrappingKeyGetExpiresAtRetType) { + *arg = &val +} + +/* + types and functions for id +*/ + +// isNotNullableString +type WrappingKeyGetIdAttributeType = *string + +func getWrappingKeyGetIdAttributeTypeOk(arg WrappingKeyGetIdAttributeType) (ret WrappingKeyGetIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setWrappingKeyGetIdAttributeType(arg *WrappingKeyGetIdAttributeType, val WrappingKeyGetIdRetType) { + *arg = &val +} + +type WrappingKeyGetIdArgType = string +type WrappingKeyGetIdRetType = string + +/* + types and functions for keyRingId +*/ + +// isNotNullableString +type WrappingKeyGetKeyRingIdAttributeType = *string + +func getWrappingKeyGetKeyRingIdAttributeTypeOk(arg WrappingKeyGetKeyRingIdAttributeType) (ret WrappingKeyGetKeyRingIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setWrappingKeyGetKeyRingIdAttributeType(arg *WrappingKeyGetKeyRingIdAttributeType, val WrappingKeyGetKeyRingIdRetType) { + *arg = &val +} + +type WrappingKeyGetKeyRingIdArgType = string +type WrappingKeyGetKeyRingIdRetType = string + +/* + types and functions for publicKey +*/ + +// isNotNullableString +type WrappingKeyGetPublicKeyAttributeType = *string + +func getWrappingKeyGetPublicKeyAttributeTypeOk(arg WrappingKeyGetPublicKeyAttributeType) (ret WrappingKeyGetPublicKeyRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setWrappingKeyGetPublicKeyAttributeType(arg *WrappingKeyGetPublicKeyAttributeType, val WrappingKeyGetPublicKeyRetType) { + *arg = &val +} + +type WrappingKeyGetPublicKeyArgType = string +type WrappingKeyGetPublicKeyRetType = string + +/* + types and functions for purpose +*/ + +// isEnumRef +type WrappingKeyGetPurposeAttributeType = *WrappingPurpose +type WrappingKeyGetPurposeArgType = WrappingPurpose +type WrappingKeyGetPurposeRetType = WrappingPurpose + +func getWrappingKeyGetPurposeAttributeTypeOk(arg WrappingKeyGetPurposeAttributeType) (ret WrappingKeyGetPurposeRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setWrappingKeyGetPurposeAttributeType(arg *WrappingKeyGetPurposeAttributeType, val WrappingKeyGetPurposeRetType) { + *arg = &val +} + +/* + types and functions for state +*/ + +// isEnumRef +type WrappingKeyGetStateAttributeType = *string +type WrappingKeyGetStateArgType = string +type WrappingKeyGetStateRetType = string + +func getWrappingKeyGetStateAttributeTypeOk(arg WrappingKeyGetStateAttributeType) (ret WrappingKeyGetStateRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setWrappingKeyGetStateAttributeType(arg *WrappingKeyGetStateAttributeType, val WrappingKeyGetStateRetType) { + *arg = &val +} + +// WrappingKey struct for WrappingKey +type WrappingKey struct { + // REQUIRED + Algorithm WrappingKeyGetAlgorithmAttributeType `json:"algorithm"` + // REQUIRED + Backend WrappingKeyGetBackendAttributeType `json:"backend"` + // The date and time the creation of the wrapping key was triggered. + // REQUIRED + CreatedAt WrappingKeyGetCreatedAtAttributeType `json:"createdAt"` + // A user chosen description to distinguish multiple wrapping keys. + Description WrappingKeyGetDescriptionAttributeType `json:"description,omitempty"` + // The display name to distinguish multiple wrapping keys. + // REQUIRED + DisplayName WrappingKeyGetDisplayNameAttributeType `json:"displayName"` + // The date and time the wrapping key will expire. + // REQUIRED + ExpiresAt WrappingKeyGetExpiresAtAttributeType `json:"expiresAt"` + // A auto generated unique id which identifies the wrapping keys. + // REQUIRED + Id WrappingKeyGetIdAttributeType `json:"id"` + // The unique id of the key ring this wrapping key is assigned to. + // REQUIRED + KeyRingId WrappingKeyGetKeyRingIdAttributeType `json:"keyRingId"` + // The public key of the wrapping key. + PublicKey WrappingKeyGetPublicKeyAttributeType `json:"publicKey,omitempty"` + // REQUIRED + Purpose WrappingKeyGetPurposeAttributeType `json:"purpose"` + // The current state of the wrapping key. + // REQUIRED + State WrappingKeyGetStateAttributeType `json:"state"` +} + +type _WrappingKey WrappingKey + +// NewWrappingKey instantiates a new WrappingKey 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 NewWrappingKey(algorithm WrappingKeyGetAlgorithmArgType, backend WrappingKeyGetBackendArgType, createdAt WrappingKeyGetCreatedAtArgType, displayName WrappingKeyGetDisplayNameArgType, expiresAt WrappingKeyGetExpiresAtArgType, id WrappingKeyGetIdArgType, keyRingId WrappingKeyGetKeyRingIdArgType, purpose WrappingKeyGetPurposeArgType, state WrappingKeyGetStateArgType) *WrappingKey { + this := WrappingKey{} + setWrappingKeyGetAlgorithmAttributeType(&this.Algorithm, algorithm) + setWrappingKeyGetBackendAttributeType(&this.Backend, backend) + setWrappingKeyGetCreatedAtAttributeType(&this.CreatedAt, createdAt) + setWrappingKeyGetDisplayNameAttributeType(&this.DisplayName, displayName) + setWrappingKeyGetExpiresAtAttributeType(&this.ExpiresAt, expiresAt) + setWrappingKeyGetIdAttributeType(&this.Id, id) + setWrappingKeyGetKeyRingIdAttributeType(&this.KeyRingId, keyRingId) + setWrappingKeyGetPurposeAttributeType(&this.Purpose, purpose) + setWrappingKeyGetStateAttributeType(&this.State, state) + return &this +} + +// NewWrappingKeyWithDefaults instantiates a new WrappingKey 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 NewWrappingKeyWithDefaults() *WrappingKey { + this := WrappingKey{} + return &this +} + +// GetAlgorithm returns the Algorithm field value +func (o *WrappingKey) GetAlgorithm() (ret WrappingKeyGetAlgorithmRetType) { + ret, _ = o.GetAlgorithmOk() + return ret +} + +// GetAlgorithmOk returns a tuple with the Algorithm field value +// and a boolean to check if the value has been set. +func (o *WrappingKey) GetAlgorithmOk() (ret WrappingKeyGetAlgorithmRetType, ok bool) { + return getWrappingKeyGetAlgorithmAttributeTypeOk(o.Algorithm) +} + +// SetAlgorithm sets field value +func (o *WrappingKey) SetAlgorithm(v WrappingKeyGetAlgorithmRetType) { + setWrappingKeyGetAlgorithmAttributeType(&o.Algorithm, v) +} + +// GetBackend returns the Backend field value +func (o *WrappingKey) GetBackend() (ret WrappingKeyGetBackendRetType) { + ret, _ = o.GetBackendOk() + return ret +} + +// GetBackendOk returns a tuple with the Backend field value +// and a boolean to check if the value has been set. +func (o *WrappingKey) GetBackendOk() (ret WrappingKeyGetBackendRetType, ok bool) { + return getWrappingKeyGetBackendAttributeTypeOk(o.Backend) +} + +// SetBackend sets field value +func (o *WrappingKey) SetBackend(v WrappingKeyGetBackendRetType) { + setWrappingKeyGetBackendAttributeType(&o.Backend, v) +} + +// GetCreatedAt returns the CreatedAt field value +func (o *WrappingKey) GetCreatedAt() (ret WrappingKeyGetCreatedAtRetType) { + ret, _ = o.GetCreatedAtOk() + return ret +} + +// GetCreatedAtOk returns a tuple with the CreatedAt field value +// and a boolean to check if the value has been set. +func (o *WrappingKey) GetCreatedAtOk() (ret WrappingKeyGetCreatedAtRetType, ok bool) { + return getWrappingKeyGetCreatedAtAttributeTypeOk(o.CreatedAt) +} + +// SetCreatedAt sets field value +func (o *WrappingKey) SetCreatedAt(v WrappingKeyGetCreatedAtRetType) { + setWrappingKeyGetCreatedAtAttributeType(&o.CreatedAt, v) +} + +// GetDescription returns the Description field value if set, zero value otherwise. +func (o *WrappingKey) GetDescription() (res WrappingKeyGetDescriptionRetType) { + res, _ = o.GetDescriptionOk() + return +} + +// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *WrappingKey) GetDescriptionOk() (ret WrappingKeyGetDescriptionRetType, ok bool) { + return getWrappingKeyGetDescriptionAttributeTypeOk(o.Description) +} + +// HasDescription returns a boolean if a field has been set. +func (o *WrappingKey) HasDescription() bool { + _, ok := o.GetDescriptionOk() + return ok +} + +// SetDescription gets a reference to the given string and assigns it to the Description field. +func (o *WrappingKey) SetDescription(v WrappingKeyGetDescriptionRetType) { + setWrappingKeyGetDescriptionAttributeType(&o.Description, v) +} + +// GetDisplayName returns the DisplayName field value +func (o *WrappingKey) GetDisplayName() (ret WrappingKeyGetDisplayNameRetType) { + ret, _ = o.GetDisplayNameOk() + return ret +} + +// GetDisplayNameOk returns a tuple with the DisplayName field value +// and a boolean to check if the value has been set. +func (o *WrappingKey) GetDisplayNameOk() (ret WrappingKeyGetDisplayNameRetType, ok bool) { + return getWrappingKeyGetDisplayNameAttributeTypeOk(o.DisplayName) +} + +// SetDisplayName sets field value +func (o *WrappingKey) SetDisplayName(v WrappingKeyGetDisplayNameRetType) { + setWrappingKeyGetDisplayNameAttributeType(&o.DisplayName, v) +} + +// GetExpiresAt returns the ExpiresAt field value +func (o *WrappingKey) GetExpiresAt() (ret WrappingKeyGetExpiresAtRetType) { + ret, _ = o.GetExpiresAtOk() + return ret +} + +// GetExpiresAtOk returns a tuple with the ExpiresAt field value +// and a boolean to check if the value has been set. +func (o *WrappingKey) GetExpiresAtOk() (ret WrappingKeyGetExpiresAtRetType, ok bool) { + return getWrappingKeyGetExpiresAtAttributeTypeOk(o.ExpiresAt) +} + +// SetExpiresAt sets field value +func (o *WrappingKey) SetExpiresAt(v WrappingKeyGetExpiresAtRetType) { + setWrappingKeyGetExpiresAtAttributeType(&o.ExpiresAt, v) +} + +// GetId returns the Id field value +func (o *WrappingKey) GetId() (ret WrappingKeyGetIdRetType) { + ret, _ = o.GetIdOk() + return ret +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *WrappingKey) GetIdOk() (ret WrappingKeyGetIdRetType, ok bool) { + return getWrappingKeyGetIdAttributeTypeOk(o.Id) +} + +// SetId sets field value +func (o *WrappingKey) SetId(v WrappingKeyGetIdRetType) { + setWrappingKeyGetIdAttributeType(&o.Id, v) +} + +// GetKeyRingId returns the KeyRingId field value +func (o *WrappingKey) GetKeyRingId() (ret WrappingKeyGetKeyRingIdRetType) { + ret, _ = o.GetKeyRingIdOk() + return ret +} + +// GetKeyRingIdOk returns a tuple with the KeyRingId field value +// and a boolean to check if the value has been set. +func (o *WrappingKey) GetKeyRingIdOk() (ret WrappingKeyGetKeyRingIdRetType, ok bool) { + return getWrappingKeyGetKeyRingIdAttributeTypeOk(o.KeyRingId) +} + +// SetKeyRingId sets field value +func (o *WrappingKey) SetKeyRingId(v WrappingKeyGetKeyRingIdRetType) { + setWrappingKeyGetKeyRingIdAttributeType(&o.KeyRingId, v) +} + +// GetPublicKey returns the PublicKey field value if set, zero value otherwise. +func (o *WrappingKey) GetPublicKey() (res WrappingKeyGetPublicKeyRetType) { + res, _ = o.GetPublicKeyOk() + return +} + +// GetPublicKeyOk returns a tuple with the PublicKey field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *WrappingKey) GetPublicKeyOk() (ret WrappingKeyGetPublicKeyRetType, ok bool) { + return getWrappingKeyGetPublicKeyAttributeTypeOk(o.PublicKey) +} + +// HasPublicKey returns a boolean if a field has been set. +func (o *WrappingKey) HasPublicKey() bool { + _, ok := o.GetPublicKeyOk() + return ok +} + +// SetPublicKey gets a reference to the given string and assigns it to the PublicKey field. +func (o *WrappingKey) SetPublicKey(v WrappingKeyGetPublicKeyRetType) { + setWrappingKeyGetPublicKeyAttributeType(&o.PublicKey, v) +} + +// GetPurpose returns the Purpose field value +func (o *WrappingKey) GetPurpose() (ret WrappingKeyGetPurposeRetType) { + ret, _ = o.GetPurposeOk() + return ret +} + +// GetPurposeOk returns a tuple with the Purpose field value +// and a boolean to check if the value has been set. +func (o *WrappingKey) GetPurposeOk() (ret WrappingKeyGetPurposeRetType, ok bool) { + return getWrappingKeyGetPurposeAttributeTypeOk(o.Purpose) +} + +// SetPurpose sets field value +func (o *WrappingKey) SetPurpose(v WrappingKeyGetPurposeRetType) { + setWrappingKeyGetPurposeAttributeType(&o.Purpose, v) +} + +// GetState returns the State field value +func (o *WrappingKey) GetState() (ret WrappingKeyGetStateRetType) { + ret, _ = o.GetStateOk() + return ret +} + +// GetStateOk returns a tuple with the State field value +// and a boolean to check if the value has been set. +func (o *WrappingKey) GetStateOk() (ret WrappingKeyGetStateRetType, ok bool) { + return getWrappingKeyGetStateAttributeTypeOk(o.State) +} + +// SetState sets field value +func (o *WrappingKey) SetState(v WrappingKeyGetStateRetType) { + setWrappingKeyGetStateAttributeType(&o.State, v) +} + +func (o WrappingKey) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getWrappingKeyGetAlgorithmAttributeTypeOk(o.Algorithm); ok { + toSerialize["Algorithm"] = val + } + if val, ok := getWrappingKeyGetBackendAttributeTypeOk(o.Backend); ok { + toSerialize["Backend"] = val + } + if val, ok := getWrappingKeyGetCreatedAtAttributeTypeOk(o.CreatedAt); ok { + toSerialize["CreatedAt"] = val + } + if val, ok := getWrappingKeyGetDescriptionAttributeTypeOk(o.Description); ok { + toSerialize["Description"] = val + } + if val, ok := getWrappingKeyGetDisplayNameAttributeTypeOk(o.DisplayName); ok { + toSerialize["DisplayName"] = val + } + if val, ok := getWrappingKeyGetExpiresAtAttributeTypeOk(o.ExpiresAt); ok { + toSerialize["ExpiresAt"] = val + } + if val, ok := getWrappingKeyGetIdAttributeTypeOk(o.Id); ok { + toSerialize["Id"] = val + } + if val, ok := getWrappingKeyGetKeyRingIdAttributeTypeOk(o.KeyRingId); ok { + toSerialize["KeyRingId"] = val + } + if val, ok := getWrappingKeyGetPublicKeyAttributeTypeOk(o.PublicKey); ok { + toSerialize["PublicKey"] = val + } + if val, ok := getWrappingKeyGetPurposeAttributeTypeOk(o.Purpose); ok { + toSerialize["Purpose"] = val + } + if val, ok := getWrappingKeyGetStateAttributeTypeOk(o.State); ok { + toSerialize["State"] = val + } + return toSerialize, nil +} + +type NullableWrappingKey struct { + value *WrappingKey + isSet bool +} + +func (v NullableWrappingKey) Get() *WrappingKey { + return v.value +} + +func (v *NullableWrappingKey) Set(val *WrappingKey) { + v.value = val + v.isSet = true +} + +func (v NullableWrappingKey) IsSet() bool { + return v.isSet +} + +func (v *NullableWrappingKey) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableWrappingKey(val *WrappingKey) *NullableWrappingKey { + return &NullableWrappingKey{value: val, isSet: true} +} + +func (v NullableWrappingKey) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableWrappingKey) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/kms/model_wrapping_key_list.go b/services/kms/model_wrapping_key_list.go new file mode 100644 index 000000000..746228ab8 --- /dev/null +++ b/services/kms/model_wrapping_key_list.go @@ -0,0 +1,125 @@ +/* +STACKIT Key Management Service API + +This API provides endpoints for managing keys and key rings. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package kms + +import ( + "encoding/json" +) + +// checks if the WrappingKeyList type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &WrappingKeyList{} + +/* + types and functions for wrappingKeys +*/ + +// isArray +type WrappingKeyListGetWrappingKeysAttributeType = *[]WrappingKey +type WrappingKeyListGetWrappingKeysArgType = []WrappingKey +type WrappingKeyListGetWrappingKeysRetType = []WrappingKey + +func getWrappingKeyListGetWrappingKeysAttributeTypeOk(arg WrappingKeyListGetWrappingKeysAttributeType) (ret WrappingKeyListGetWrappingKeysRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setWrappingKeyListGetWrappingKeysAttributeType(arg *WrappingKeyListGetWrappingKeysAttributeType, val WrappingKeyListGetWrappingKeysRetType) { + *arg = &val +} + +// WrappingKeyList struct for WrappingKeyList +type WrappingKeyList struct { + // REQUIRED + WrappingKeys WrappingKeyListGetWrappingKeysAttributeType `json:"wrappingKeys"` +} + +type _WrappingKeyList WrappingKeyList + +// NewWrappingKeyList instantiates a new WrappingKeyList 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 NewWrappingKeyList(wrappingKeys WrappingKeyListGetWrappingKeysArgType) *WrappingKeyList { + this := WrappingKeyList{} + setWrappingKeyListGetWrappingKeysAttributeType(&this.WrappingKeys, wrappingKeys) + return &this +} + +// NewWrappingKeyListWithDefaults instantiates a new WrappingKeyList 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 NewWrappingKeyListWithDefaults() *WrappingKeyList { + this := WrappingKeyList{} + return &this +} + +// GetWrappingKeys returns the WrappingKeys field value +func (o *WrappingKeyList) GetWrappingKeys() (ret WrappingKeyListGetWrappingKeysRetType) { + ret, _ = o.GetWrappingKeysOk() + return ret +} + +// GetWrappingKeysOk returns a tuple with the WrappingKeys field value +// and a boolean to check if the value has been set. +func (o *WrappingKeyList) GetWrappingKeysOk() (ret WrappingKeyListGetWrappingKeysRetType, ok bool) { + return getWrappingKeyListGetWrappingKeysAttributeTypeOk(o.WrappingKeys) +} + +// SetWrappingKeys sets field value +func (o *WrappingKeyList) SetWrappingKeys(v WrappingKeyListGetWrappingKeysRetType) { + setWrappingKeyListGetWrappingKeysAttributeType(&o.WrappingKeys, v) +} + +func (o WrappingKeyList) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getWrappingKeyListGetWrappingKeysAttributeTypeOk(o.WrappingKeys); ok { + toSerialize["WrappingKeys"] = val + } + return toSerialize, nil +} + +type NullableWrappingKeyList struct { + value *WrappingKeyList + isSet bool +} + +func (v NullableWrappingKeyList) Get() *WrappingKeyList { + return v.value +} + +func (v *NullableWrappingKeyList) Set(val *WrappingKeyList) { + v.value = val + v.isSet = true +} + +func (v NullableWrappingKeyList) IsSet() bool { + return v.isSet +} + +func (v *NullableWrappingKeyList) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableWrappingKeyList(val *WrappingKeyList) *NullableWrappingKeyList { + return &NullableWrappingKeyList{value: val, isSet: true} +} + +func (v NullableWrappingKeyList) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableWrappingKeyList) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/kms/model_wrapping_purpose.go b/services/kms/model_wrapping_purpose.go new file mode 100644 index 000000000..c952b12e9 --- /dev/null +++ b/services/kms/model_wrapping_purpose.go @@ -0,0 +1,115 @@ +/* +STACKIT Key Management Service API + +This API provides endpoints for managing keys and key rings. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package kms + +import ( + "encoding/json" + "fmt" +) + +// WrappingPurpose The wrapping purpose for the wrapping key. +type WrappingPurpose string + +// List of wrappingPurpose +const ( + WRAPPINGPURPOSE_SYMMETRIC_KEY WrappingPurpose = "wrap_symmetric_key" + WRAPPINGPURPOSE_ASYMMETRIC_KEY WrappingPurpose = "wrap_asymmetric_key" +) + +// All allowed values of WrappingPurpose enum +var AllowedWrappingPurposeEnumValues = []WrappingPurpose{ + "wrap_symmetric_key", + "wrap_asymmetric_key", +} + +func (v *WrappingPurpose) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + // Allow unmarshalling zero value for testing purposes + var zeroValue string + if value == zeroValue { + return nil + } + enumTypeValue := WrappingPurpose(value) + for _, existing := range AllowedWrappingPurposeEnumValues { + if existing == enumTypeValue { + *v = enumTypeValue + return nil + } + } + + return fmt.Errorf("%+v is not a valid WrappingPurpose", value) +} + +// NewWrappingPurposeFromValue returns a pointer to a valid WrappingPurpose +// for the value passed as argument, or an error if the value passed is not allowed by the enum +func NewWrappingPurposeFromValue(v string) (*WrappingPurpose, error) { + ev := WrappingPurpose(v) + if ev.IsValid() { + return &ev, nil + } else { + return nil, fmt.Errorf("invalid value '%v' for WrappingPurpose: valid values are %v", v, AllowedWrappingPurposeEnumValues) + } +} + +// IsValid return true if the value is valid for the enum, false otherwise +func (v WrappingPurpose) IsValid() bool { + for _, existing := range AllowedWrappingPurposeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to wrappingPurpose value +func (v WrappingPurpose) Ptr() *WrappingPurpose { + return &v +} + +type NullableWrappingPurpose struct { + value *WrappingPurpose + isSet bool +} + +func (v NullableWrappingPurpose) Get() *WrappingPurpose { + return v.value +} + +func (v *NullableWrappingPurpose) Set(val *WrappingPurpose) { + v.value = val + v.isSet = true +} + +func (v NullableWrappingPurpose) IsSet() bool { + return v.isSet +} + +func (v *NullableWrappingPurpose) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableWrappingPurpose(val *WrappingPurpose) *NullableWrappingPurpose { + return &NullableWrappingPurpose{value: val, isSet: true} +} + +func (v NullableWrappingPurpose) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableWrappingPurpose) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/kms/utils.go b/services/kms/utils.go new file mode 100644 index 000000000..30638fcad --- /dev/null +++ b/services/kms/utils.go @@ -0,0 +1,373 @@ +/* +STACKIT Key Management Service API + +This API provides endpoints for managing keys and key rings. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package kms + +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 NullableValue[T any] struct { + value *T + isSet bool +} + +func (v NullableValue[T]) Get() *T { + return v.value +} + +func (v *NullableValue[T]) Set(val *T) { + v.value = val + v.isSet = true +} + +func (v NullableValue[T]) IsSet() bool { + return v.isSet +} + +func (v *NullableValue[T]) Unset() { + v.value = nil + v.isSet = false +} + +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 v.value.MarshalJSON() +} + +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 + } + if t, ok := i.(interface{ IsSet() bool }); ok { + return !t.IsSet() + } + 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) +}