diff --git a/CHANGELOG.md b/CHANGELOG.md index 764e3c089..bd4326a45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## Release (2025-XX-YY) +- `cdn`: [0.1.0](services/cdn/CHANGELOG.md#v010-2025-xx-yy) + - **New:** Introduce new API for content delivery + + ## Release (2025-03-14) - `certificates`: [v1.0.0](services/certificates/CHANGELOG.md#v100-2025-03-14) - **Breaking Change:** The region is no longer specified within the client configuration. Instead, the region must be passed as a parameter to any region-specific request. diff --git a/go.work b/go.work index 3e224617f..0861ef7dc 100644 --- a/go.work +++ b/go.work @@ -32,6 +32,7 @@ use ( ./scripts ./services/archiving ./services/authorization + ./services/cdn ./services/certificates ./services/dns ./services/iaas diff --git a/services/cdn/.openapi-generator/VERSION b/services/cdn/.openapi-generator/VERSION new file mode 100644 index 000000000..cd802a1ec --- /dev/null +++ b/services/cdn/.openapi-generator/VERSION @@ -0,0 +1 @@ +6.6.0 \ No newline at end of file diff --git a/services/cdn/CHANGELOG.md b/services/cdn/CHANGELOG.md new file mode 100644 index 000000000..209d44292 --- /dev/null +++ b/services/cdn/CHANGELOG.md @@ -0,0 +1,2 @@ +## v0.1.0 (2025-XX-YY) +- **New:** Introduce new API for content delivery diff --git a/services/cdn/api_default.go b/services/cdn/api_default.go new file mode 100644 index 000000000..e2e0d32c1 --- /dev/null +++ b/services/cdn/api_default.go @@ -0,0 +1,2211 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +import ( + "bytes" + "context" + "fmt" + "io" + "net/http" + "net/url" + "strings" + "time" + + "github.com/stackitcloud/stackit-sdk-go/core/config" + "github.com/stackitcloud/stackit-sdk-go/core/oapierror" +) + +// DefaultApiService DefaultApi service +type DefaultApiService service + +type ApiCreateDistributionRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + createDistributionPayload *CreateDistributionPayload +} + +func (r ApiCreateDistributionRequest) CreateDistributionPayload(createDistributionPayload CreateDistributionPayload) ApiCreateDistributionRequest { + r.createDistributionPayload = &createDistributionPayload + return r +} + +func (r ApiCreateDistributionRequest) Execute() (*CreateDistributionResponse, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *CreateDistributionResponse + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.CreateDistribution") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1beta/projects/{projectId}/distributions" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.createDistributionPayload == nil { + return localVarReturnValue, fmt.Errorf("createDistributionPayload 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", "text/plain"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.createDistributionPayload + 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 GenericJSONResponse + 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 string + 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 == 422 { + var v GenericJSONResponse + 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 GenericJSONResponse + 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 + } + var v GenericJSONResponse + 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 +} + +/* +CreateDistribution: Create new distribution + +CreateDistribution will create a new CDN distribution + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId Your STACKIT Project's ID + @return ApiCreateDistributionRequest +*/ +func (a *APIClient) CreateDistribution(ctx context.Context, projectId string) ApiCreateDistributionRequest { + return ApiCreateDistributionRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + } +} + +func (a *APIClient) CreateDistributionExecute(ctx context.Context, projectId string) (*CreateDistributionResponse, error) { + r := ApiCreateDistributionRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + } + return r.Execute() +} + +type ApiDeleteCustomDomainRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + distributionId string + domain string + intentId *string +} + +func (r ApiDeleteCustomDomainRequest) IntentId(intentId string) ApiDeleteCustomDomainRequest { + r.intentId = &intentId + return r +} + +func (r ApiDeleteCustomDomainRequest) Execute() (*DeleteCustomDomainResponse, error) { + var ( + localVarHTTPMethod = http.MethodDelete + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *DeleteCustomDomainResponse + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.DeleteCustomDomain") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1beta/projects/{projectId}/distributions/{distributionId}/customDomains/{domain}" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"distributionId"+"}", url.PathEscape(ParameterValueToString(r.distributionId, "distributionId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"domain"+"}", url.PathEscape(ParameterValueToString(r.domain, "domain")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if strlen(r.domain) > 72 { + return localVarReturnValue, fmt.Errorf("domain must have less than 72 elements") + } + + if r.intentId != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "intentId", r.intentId, "") + } + // 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", "text/plain"} + + // 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 == 401 { + var v string + 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 == 422 { + var v GenericJSONResponse + 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 GenericJSONResponse + 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 + } + var v GenericJSONResponse + 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 +} + +/* +DeleteCustomDomain: Delete a custom domain + +# Removes a custom domain + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId Your STACKIT Project's ID + @param distributionId + @param domain + @return ApiDeleteCustomDomainRequest +*/ +func (a *APIClient) DeleteCustomDomain(ctx context.Context, projectId string, distributionId string, domain string) ApiDeleteCustomDomainRequest { + return ApiDeleteCustomDomainRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + distributionId: distributionId, + domain: domain, + } +} + +func (a *APIClient) DeleteCustomDomainExecute(ctx context.Context, projectId string, distributionId string, domain string) (*DeleteCustomDomainResponse, error) { + r := ApiDeleteCustomDomainRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + distributionId: distributionId, + domain: domain, + } + return r.Execute() +} + +type ApiDeleteDistributionRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + distributionId string + intentId *string +} + +// While optional, it is greatly encouraged to provide an `intentId`. This is used to deduplicate requests. If multiple DELETE-Requests with the same `intentId` are received, all but the first request are dropped. + +func (r ApiDeleteDistributionRequest) IntentId(intentId string) ApiDeleteDistributionRequest { + r.intentId = &intentId + return r +} + +func (r ApiDeleteDistributionRequest) Execute() (*DeleteDistributionResponse, error) { + var ( + localVarHTTPMethod = http.MethodDelete + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *DeleteDistributionResponse + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.DeleteDistribution") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1beta/projects/{projectId}/distributions/{distributionId}" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"distributionId"+"}", url.PathEscape(ParameterValueToString(r.distributionId, "distributionId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if r.intentId != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "intentId", r.intentId, "") + } + // 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", "text/plain"} + + // 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 == 401 { + var v string + 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 == 422 { + var v GenericJSONResponse + 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 GenericJSONResponse + 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 + } + var v GenericJSONResponse + 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 +} + +/* +DeleteDistribution: Delete distribution + +DeleteDistribution accepts a project- and distribution-ID and will delete a distribution. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId Your STACKIT Project's ID + @param distributionId + @return ApiDeleteDistributionRequest +*/ +func (a *APIClient) DeleteDistribution(ctx context.Context, projectId string, distributionId string) ApiDeleteDistributionRequest { + return ApiDeleteDistributionRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + distributionId: distributionId, + } +} + +func (a *APIClient) DeleteDistributionExecute(ctx context.Context, projectId string, distributionId string) (*DeleteDistributionResponse, error) { + r := ApiDeleteDistributionRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + distributionId: distributionId, + } + return r.Execute() +} + +type ApiFindCachePathsRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + distributionId string + path *string +} + +// A substring of the search query. + +func (r ApiFindCachePathsRequest) Path(path string) ApiFindCachePathsRequest { + r.path = &path + return r +} + +func (r ApiFindCachePathsRequest) Execute() (*FindCachePathsResponse, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *FindCachePathsResponse + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.FindCachePaths") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1beta/projects/{projectId}/distributions/{distributionId}/cache/paths" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"distributionId"+"}", url.PathEscape(ParameterValueToString(r.distributionId, "distributionId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.path == nil { + return localVarReturnValue, fmt.Errorf("path is required and must be specified") + } + + parameterAddToHeaderOrQuery(localVarQueryParams, "path", r.path, "") + // 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", "text/plain"} + + // 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 == 401 { + var v string + 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 == 422 { + var v GenericJSONResponse + 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 GenericJSONResponse + 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 + } + var v GenericJSONResponse + 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 +} + +/* +FindCachePaths: Return Paths that were purged + +This returns paths that are present in the cache purging history. +Only substrings of the provided input are returned. +The response is sorted in descending order by the most recent purge. + +So, assuming you have have the following purged for a distribution +- `/test/1` at `2025-01-01` +- `/test/2` at `2025-01-02` +- `/someOtherPath/1` at `2025-01-03` +- `/test/1` at `2025-01-04` +- `/test/3` at `2025-01-05`, +this would return the following paths, in the following order, assuming `/te` was the search parameter: +- `/test/3` +- `/test/1` +- `/test/2` + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId Your STACKIT Project's ID + @param distributionId + @return ApiFindCachePathsRequest +*/ +func (a *APIClient) FindCachePaths(ctx context.Context, projectId string, distributionId string) ApiFindCachePathsRequest { + return ApiFindCachePathsRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + distributionId: distributionId, + } +} + +func (a *APIClient) FindCachePathsExecute(ctx context.Context, projectId string, distributionId string) (*FindCachePathsResponse, error) { + r := ApiFindCachePathsRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + distributionId: distributionId, + } + return r.Execute() +} + +type ApiGetCacheInfoRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + distributionId string + purgePath *string +} + +func (r ApiGetCacheInfoRequest) PurgePath(purgePath string) ApiGetCacheInfoRequest { + r.purgePath = &purgePath + return r +} + +func (r ApiGetCacheInfoRequest) Execute() (*GetCacheInfoResponse, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *GetCacheInfoResponse + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.GetCacheInfo") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1beta/projects/{projectId}/distributions/{distributionId}/cache" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"distributionId"+"}", url.PathEscape(ParameterValueToString(r.distributionId, "distributionId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if r.purgePath != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "purgePath", r.purgePath, "") + } + // 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", "text/plain"} + + // 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 == 401 { + var v string + 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 == 422 { + var v GenericJSONResponse + 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 GenericJSONResponse + 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 + } + var v GenericJSONResponse + 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 +} + +/* +GetCacheInfo: Get Infos about the Caching State + +Return caching info metadata, which contains the last cache purging time and a history of the most recent *full* purges. + +If (and only if) you provide the path query parameter, the history will also contain granular cache purges. +The request will not fail if no data about a path is found. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId Your STACKIT Project's ID + @param distributionId + @return ApiGetCacheInfoRequest +*/ +func (a *APIClient) GetCacheInfo(ctx context.Context, projectId string, distributionId string) ApiGetCacheInfoRequest { + return ApiGetCacheInfoRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + distributionId: distributionId, + } +} + +func (a *APIClient) GetCacheInfoExecute(ctx context.Context, projectId string, distributionId string) (*GetCacheInfoResponse, error) { + r := ApiGetCacheInfoRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + distributionId: distributionId, + } + return r.Execute() +} + +type ApiGetCustomDomainRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + distributionId string + domain string +} + +func (r ApiGetCustomDomainRequest) Execute() (*GetCustomDomainResponse, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *GetCustomDomainResponse + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.GetCustomDomain") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1beta/projects/{projectId}/distributions/{distributionId}/customDomains/{domain}" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"distributionId"+"}", url.PathEscape(ParameterValueToString(r.distributionId, "distributionId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"domain"+"}", url.PathEscape(ParameterValueToString(r.domain, "domain")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if strlen(r.domain) > 72 { + return localVarReturnValue, fmt.Errorf("domain must have less than 72 elements") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json", "text/plain"} + + // 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 == 401 { + var v string + 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 GenericJSONResponse + 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 == 422 { + var v GenericJSONResponse + 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 GenericJSONResponse + 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 + } + var v GenericJSONResponse + 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 +} + +/* +GetCustomDomain: Retrieve a specific custom domain + +# Returns a 200 and the custom domain if this custom domain was associated to this distribution, else 404 + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId Your STACKIT Project's ID + @param distributionId + @param domain + @return ApiGetCustomDomainRequest +*/ +func (a *APIClient) GetCustomDomain(ctx context.Context, projectId string, distributionId string, domain string) ApiGetCustomDomainRequest { + return ApiGetCustomDomainRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + distributionId: distributionId, + domain: domain, + } +} + +func (a *APIClient) GetCustomDomainExecute(ctx context.Context, projectId string, distributionId string, domain string) (*GetCustomDomainResponse, error) { + r := ApiGetCustomDomainRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + distributionId: distributionId, + domain: domain, + } + return r.Execute() +} + +type ApiGetDistributionRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + distributionId string +} + +func (r ApiGetDistributionRequest) Execute() (*GetDistributionResponse, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *GetDistributionResponse + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.GetDistribution") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1beta/projects/{projectId}/distributions/{distributionId}" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"distributionId"+"}", url.PathEscape(ParameterValueToString(r.distributionId, "distributionId")), -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", "text/plain"} + + // 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 == 401 { + var v string + 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 GenericJSONResponse + 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 == 422 { + var v GenericJSONResponse + 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 GenericJSONResponse + 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 + } + var v GenericJSONResponse + 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 +} + +/* +GetDistribution: Get distribution by ID + +This returns a specific distribution by its ID. If no distribution with the given ID exists the endpoint returns 404. Trying to get a deleted distributions also return 404. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId Your STACKIT Project's ID + @param distributionId + @return ApiGetDistributionRequest +*/ +func (a *APIClient) GetDistribution(ctx context.Context, projectId string, distributionId string) ApiGetDistributionRequest { + return ApiGetDistributionRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + distributionId: distributionId, + } +} + +func (a *APIClient) GetDistributionExecute(ctx context.Context, projectId string, distributionId string) (*GetDistributionResponse, error) { + r := ApiGetDistributionRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + distributionId: distributionId, + } + return r.Execute() +} + +type ApiGetStatisticsRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + distributionId string + from *time.Time + to *time.Time + interval *string +} + +// the start of the time range for which statistics should be returned + +func (r ApiGetStatisticsRequest) From(from time.Time) ApiGetStatisticsRequest { + r.from = &from + return r +} + +// the end of the time range for which statistics should be returned. If not specified, the end of the current time's interval is used, e.g. next day for daily, next month for monthly, and so on. + +func (r ApiGetStatisticsRequest) To(to time.Time) ApiGetStatisticsRequest { + r.to = &to + return r +} + +// Over which interval should statistics be aggregated? defaults to hourly resolution **NOTE**: Intervals are grouped in buckets that start and end based on a day in UTC+0 time. So for the `daily` interval, the group starts (inclusive) and ends (exclusive) at `00:00Z` + +func (r ApiGetStatisticsRequest) Interval(interval string) ApiGetStatisticsRequest { + r.interval = &interval + return r +} + +func (r ApiGetStatisticsRequest) Execute() (*GetStatisticsResponse, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *GetStatisticsResponse + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.GetStatistics") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1beta/projects/{projectId}/distributions/{distributionId}/statistics" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"distributionId"+"}", url.PathEscape(ParameterValueToString(r.distributionId, "distributionId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.from == nil { + return localVarReturnValue, fmt.Errorf("from is required and must be specified") + } + + parameterAddToHeaderOrQuery(localVarQueryParams, "from", r.from, "") + if r.to != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "to", r.to, "") + } + if r.interval != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "interval", r.interval, "") + } + // 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", "text/plain"} + + // 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 == 401 { + var v string + 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 == 422 { + var v GenericJSONResponse + 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 GenericJSONResponse + 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 + } + var v GenericJSONResponse + 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 +} + +/* +GetStatistics: Retrieve the statistics of a distribution + +Returns the statistics of the distribution in the given +time range. The response is a list of statistics records. Each record aggregates the statistics for its time interval. +In case no statistics for a time interval exist, no record is returned. +The time range for which statistics should be returned can be configured using query parameters. + +Timestamps are assumed to be UTC. This is especially important for the "buckets" when you, for example, return daily information. A day always starts and ends at 00:00Z. + +**Important Note:** Lower bounds are inclusive, upper bounds are exclusive. If you, for example, want a daily grouped which starts on the 1st Jan and also contains the full 10th Jan day, you would define `2025-01-01T00:00:00Z` as the lower and `2025-01-11T00:00:00Z` as the upper bound. + +The upper bound is optional. If you omit it, the API will use the start of the next interval as the upper bound. +Example: if `interval` is `hourly`, `from` would default to the start of the next hour, if it's `daily`, `from` would default to the start of the next day, etc. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId Your STACKIT Project's ID + @param distributionId + @return ApiGetStatisticsRequest +*/ +func (a *APIClient) GetStatistics(ctx context.Context, projectId string, distributionId string) ApiGetStatisticsRequest { + return ApiGetStatisticsRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + distributionId: distributionId, + } +} + +func (a *APIClient) GetStatisticsExecute(ctx context.Context, projectId string, distributionId string) (*GetStatisticsResponse, error) { + r := ApiGetStatisticsRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + distributionId: distributionId, + } + return r.Execute() +} + +type ApiListDistributionsRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + pageSize *int32 + pageIdentifier *string + sortBy *string + sortOrder *string +} + +// Quantifies how many distributions should be returned on this page. Must be a natural number between 1 and 100 (inclusive) + +func (r ApiListDistributionsRequest) PageSize(pageSize int32) ApiListDistributionsRequest { + r.pageSize = &pageSize + return r +} + +// Identifier is returned by the previous response and is used to request the next page. As the `pageIdentifier` encodes an element, inserts during pagination will *not* shift the result. So a scenario like: - Start listing first page - Insert new element - Start listing second page will *never* result in an element from the first page to get \"pushed\" to the second page, like it could occur with basic limit + offset pagination. The identifier should be treated as an opaque string and never modified. Only pass values returned by the API. + +func (r ApiListDistributionsRequest) PageIdentifier(pageIdentifier string) ApiListDistributionsRequest { + r.pageIdentifier = &pageIdentifier + return r +} + +// The following sort options exist. We default to `createdAt` - `id` - Sort by the distributions's ID using String comparison - `updatedAt` - Sort by when the distribution's configuration was last modified, for example by changing the regions or response headers - `createdAt` - Sort by when the distribution was initially created. - `originUrl` - Sort by originURL using String comparison - `status` - Sort by looking at the distribution's status, using String comparison + +func (r ApiListDistributionsRequest) SortBy(sortBy string) ApiListDistributionsRequest { + r.sortBy = &sortBy + return r +} + +func (r ApiListDistributionsRequest) SortOrder(sortOrder string) ApiListDistributionsRequest { + r.sortOrder = &sortOrder + return r +} + +func (r ApiListDistributionsRequest) Execute() (*ListDistributionsResponse, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *ListDistributionsResponse + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ListDistributions") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1beta/projects/{projectId}/distributions" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if r.pageSize != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "pageSize", r.pageSize, "") + } + if r.pageIdentifier != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "pageIdentifier", r.pageIdentifier, "") + } + if r.sortBy != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "sortBy", r.sortBy, "") + } + if r.sortOrder != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "sortOrder", r.sortOrder, "") + } + // 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", "text/plain"} + + // 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 == 401 { + var v string + 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 == 422 { + var v GenericJSONResponse + 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 GenericJSONResponse + 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 + } + var v GenericJSONResponse + 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 +} + +/* +ListDistributions: List all distributions belonging to a specific project + +ListDistributions returns a list of all CDN distributions associated with +a given project, ordered by their distribution ID. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId Your STACKIT Project's ID + @return ApiListDistributionsRequest +*/ +func (a *APIClient) ListDistributions(ctx context.Context, projectId string) ApiListDistributionsRequest { + return ApiListDistributionsRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + } +} + +func (a *APIClient) ListDistributionsExecute(ctx context.Context, projectId string) (*ListDistributionsResponse, error) { + r := ApiListDistributionsRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + } + return r.Execute() +} + +type ApiPatchDistributionRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + distributionId string + patchDistributionPayload *PatchDistributionPayload +} + +func (r ApiPatchDistributionRequest) PatchDistributionPayload(patchDistributionPayload PatchDistributionPayload) ApiPatchDistributionRequest { + r.patchDistributionPayload = &patchDistributionPayload + return r +} + +func (r ApiPatchDistributionRequest) Execute() (*PatchDistributionResponse, error) { + var ( + localVarHTTPMethod = http.MethodPatch + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *PatchDistributionResponse + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.PatchDistribution") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1beta/projects/{projectId}/distributions/{distributionId}" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"distributionId"+"}", url.PathEscape(ParameterValueToString(r.distributionId, "distributionId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // 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", "text/plain"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.patchDistributionPayload + 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 == 401 { + var v string + 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 == 422 { + var v GenericJSONResponse + 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 GenericJSONResponse + 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 + } + var v GenericJSONResponse + 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 +} + +/* +PatchDistribution: Update existing distribution + +Modify a CDN distribution with a partial update. Only the fields specified in the request will be modified. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId Your STACKIT Project's ID + @param distributionId + @return ApiPatchDistributionRequest +*/ +func (a *APIClient) PatchDistribution(ctx context.Context, projectId string, distributionId string) ApiPatchDistributionRequest { + return ApiPatchDistributionRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + distributionId: distributionId, + } +} + +func (a *APIClient) PatchDistributionExecute(ctx context.Context, projectId string, distributionId string) (*PatchDistributionResponse, error) { + r := ApiPatchDistributionRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + distributionId: distributionId, + } + return r.Execute() +} + +type ApiPurgeCacheRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + distributionId string + purgeCachePayload *PurgeCachePayload +} + +func (r ApiPurgeCacheRequest) PurgeCachePayload(purgeCachePayload PurgeCachePayload) ApiPurgeCacheRequest { + r.purgeCachePayload = &purgeCachePayload + return r +} + +func (r ApiPurgeCacheRequest) Execute() (map[string]interface{}, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue map[string]interface{} + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.PurgeCache") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1beta/projects/{projectId}/distributions/{distributionId}/cache/purge" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"distributionId"+"}", url.PathEscape(ParameterValueToString(r.distributionId, "distributionId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // 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", "text/plain"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.purgeCachePayload + 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 == 401 { + var v string + 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 == 422 { + var v GenericJSONResponse + 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 GenericJSONResponse + 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 + } + var v GenericJSONResponse + 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 +} + +/* +PurgeCache: Clear distribution's cache + +Clear the cache for this distribution. +All content, regardless of its staleness, will get refetched from the host. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId Your STACKIT Project's ID + @param distributionId + @return ApiPurgeCacheRequest +*/ +func (a *APIClient) PurgeCache(ctx context.Context, projectId string, distributionId string) ApiPurgeCacheRequest { + return ApiPurgeCacheRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + distributionId: distributionId, + } +} + +func (a *APIClient) PurgeCacheExecute(ctx context.Context, projectId string, distributionId string) (map[string]interface{}, error) { + r := ApiPurgeCacheRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + distributionId: distributionId, + } + return r.Execute() +} + +type ApiPutCustomDomainRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + distributionId string + domain string + putCustomDomainPayload *PutCustomDomainPayload +} + +func (r ApiPutCustomDomainRequest) PutCustomDomainPayload(putCustomDomainPayload PutCustomDomainPayload) ApiPutCustomDomainRequest { + r.putCustomDomainPayload = &putCustomDomainPayload + return r +} + +func (r ApiPutCustomDomainRequest) Execute() (*PutCustomDomainResponse, error) { + var ( + localVarHTTPMethod = http.MethodPut + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *PutCustomDomainResponse + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.PutCustomDomain") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1beta/projects/{projectId}/distributions/{distributionId}/customDomains/{domain}" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"distributionId"+"}", url.PathEscape(ParameterValueToString(r.distributionId, "distributionId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"domain"+"}", url.PathEscape(ParameterValueToString(r.domain, "domain")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if strlen(r.domain) > 72 { + return localVarReturnValue, fmt.Errorf("domain must have less than 72 elements") + } + + // 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", "text/plain"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.putCustomDomainPayload + 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 == 401 { + var v string + 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 == 422 { + var v GenericJSONResponse + 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 GenericJSONResponse + 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 + } + var v GenericJSONResponse + 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 +} + +/* +PutCustomDomain: Create or update a custom domain + +Creates a new custom domain. If it already exists, this will overwrite the previous custom domain's properties. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId Your STACKIT Project's ID + @param distributionId + @param domain + @return ApiPutCustomDomainRequest +*/ +func (a *APIClient) PutCustomDomain(ctx context.Context, projectId string, distributionId string, domain string) ApiPutCustomDomainRequest { + return ApiPutCustomDomainRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + distributionId: distributionId, + domain: domain, + } +} + +func (a *APIClient) PutCustomDomainExecute(ctx context.Context, projectId string, distributionId string, domain string) (*PutCustomDomainResponse, error) { + r := ApiPutCustomDomainRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + distributionId: distributionId, + domain: domain, + } + return r.Execute() +} diff --git a/services/cdn/api_default_test.go b/services/cdn/api_default_test.go new file mode 100644 index 000000000..f8874adfa --- /dev/null +++ b/services/cdn/api_default_test.go @@ -0,0 +1,694 @@ +/* +CDN API + +Testing DefaultApiService + +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); + +package cdn + +import ( + "context" + "encoding/json" + "net/http" + "net/http/httptest" + "net/url" + "strings" + "testing" + "time" + + "github.com/google/uuid" + "github.com/stackitcloud/stackit-sdk-go/core/config" +) + +func Test_cdn_DefaultApiService(t *testing.T) { + + t.Run("Test DefaultApiService CreateDistribution", func(t *testing.T) { + _apiUrlPath := "/v1beta/projects/{projectId}/distributions" + projectIdValue := "projectId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + data := CreateDistributionResponse{} + 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 cdn_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 + createDistributionPayload := CreateDistributionPayload{} + + resp, reqErr := apiClient.CreateDistribution(context.Background(), projectId).CreateDistributionPayload(createDistributionPayload).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if IsNil(resp) { + t.Fatalf("response not present") + } + }) + + t.Run("Test DefaultApiService DeleteCustomDomain", func(t *testing.T) { + _apiUrlPath := "/v1beta/projects/{projectId}/distributions/{distributionId}/customDomains/{domain}" + projectIdValue := "projectId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) + distributionIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"distributionId"+"}", url.PathEscape(ParameterValueToString(distributionIdValue, "distributionId")), -1) + domainValue := "domain" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"domain"+"}", url.PathEscape(ParameterValueToString(domainValue, "domain")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + data := DeleteCustomDomainResponse{} + 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 cdn_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 + distributionId := distributionIdValue + domain := domainValue + + resp, reqErr := apiClient.DeleteCustomDomain(context.Background(), projectId, distributionId, domain).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if IsNil(resp) { + t.Fatalf("response not present") + } + }) + + t.Run("Test DefaultApiService DeleteDistribution", func(t *testing.T) { + _apiUrlPath := "/v1beta/projects/{projectId}/distributions/{distributionId}" + projectIdValue := "projectId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) + distributionIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"distributionId"+"}", url.PathEscape(ParameterValueToString(distributionIdValue, "distributionId")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + data := DeleteDistributionResponse{} + 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 cdn_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 + distributionId := distributionIdValue + + resp, reqErr := apiClient.DeleteDistribution(context.Background(), projectId, distributionId).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if IsNil(resp) { + t.Fatalf("response not present") + } + }) + + t.Run("Test DefaultApiService FindCachePaths", func(t *testing.T) { + _apiUrlPath := "/v1beta/projects/{projectId}/distributions/{distributionId}/cache/paths" + projectIdValue := "projectId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) + distributionIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"distributionId"+"}", url.PathEscape(ParameterValueToString(distributionIdValue, "distributionId")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + data := FindCachePathsResponse{} + 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 cdn_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 + distributionId := distributionIdValue + var path string + + resp, reqErr := apiClient.FindCachePaths(context.Background(), projectId, distributionId).Path(path).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if IsNil(resp) { + t.Fatalf("response not present") + } + }) + + t.Run("Test DefaultApiService GetCacheInfo", func(t *testing.T) { + _apiUrlPath := "/v1beta/projects/{projectId}/distributions/{distributionId}/cache" + projectIdValue := "projectId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) + distributionIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"distributionId"+"}", url.PathEscape(ParameterValueToString(distributionIdValue, "distributionId")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + data := GetCacheInfoResponse{} + 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 cdn_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 + distributionId := distributionIdValue + + resp, reqErr := apiClient.GetCacheInfo(context.Background(), projectId, distributionId).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if IsNil(resp) { + t.Fatalf("response not present") + } + }) + + t.Run("Test DefaultApiService GetCustomDomain", func(t *testing.T) { + _apiUrlPath := "/v1beta/projects/{projectId}/distributions/{distributionId}/customDomains/{domain}" + projectIdValue := "projectId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) + distributionIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"distributionId"+"}", url.PathEscape(ParameterValueToString(distributionIdValue, "distributionId")), -1) + domainValue := "domain" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"domain"+"}", url.PathEscape(ParameterValueToString(domainValue, "domain")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + data := GetCustomDomainResponse{} + 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 cdn_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 + distributionId := distributionIdValue + domain := domainValue + + resp, reqErr := apiClient.GetCustomDomain(context.Background(), projectId, distributionId, domain).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if IsNil(resp) { + t.Fatalf("response not present") + } + }) + + t.Run("Test DefaultApiService GetDistribution", func(t *testing.T) { + _apiUrlPath := "/v1beta/projects/{projectId}/distributions/{distributionId}" + projectIdValue := "projectId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) + distributionIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"distributionId"+"}", url.PathEscape(ParameterValueToString(distributionIdValue, "distributionId")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + data := GetDistributionResponse{} + 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 cdn_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 + distributionId := distributionIdValue + + resp, reqErr := apiClient.GetDistribution(context.Background(), projectId, distributionId).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if IsNil(resp) { + t.Fatalf("response not present") + } + }) + + t.Run("Test DefaultApiService GetStatistics", func(t *testing.T) { + _apiUrlPath := "/v1beta/projects/{projectId}/distributions/{distributionId}/statistics" + projectIdValue := "projectId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) + distributionIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"distributionId"+"}", url.PathEscape(ParameterValueToString(distributionIdValue, "distributionId")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + data := GetStatisticsResponse{} + 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 cdn_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 + distributionId := distributionIdValue + var from time.Time + + resp, reqErr := apiClient.GetStatistics(context.Background(), projectId, distributionId).From(from).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if IsNil(resp) { + t.Fatalf("response not present") + } + }) + + t.Run("Test DefaultApiService ListDistributions", func(t *testing.T) { + _apiUrlPath := "/v1beta/projects/{projectId}/distributions" + projectIdValue := "projectId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + data := ListDistributionsResponse{} + 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 cdn_DefaultApi", + Variables: map[string]config.ServerVariable{ + "region": { + DefaultValue: "test_region.", + EnumValues: []string{ + "test_region.", + }, + }, + }, + }, + }, + OperationServers: map[string]config.ServerConfigurations{}, + } + apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication()) + if err != nil { + t.Fatalf("creating API client: %v", err) + } + + projectId := projectIdValue + + resp, reqErr := apiClient.ListDistributions(context.Background(), projectId).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if IsNil(resp) { + t.Fatalf("response not present") + } + }) + + t.Run("Test DefaultApiService PatchDistribution", func(t *testing.T) { + _apiUrlPath := "/v1beta/projects/{projectId}/distributions/{distributionId}" + projectIdValue := "projectId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) + distributionIdValue := "distributionId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"distributionId"+"}", url.PathEscape(ParameterValueToString(distributionIdValue, "distributionId")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + data := PatchDistributionResponse{} + 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 cdn_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 + distributionId := distributionIdValue + + resp, reqErr := apiClient.PatchDistribution(context.Background(), projectId, distributionId).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if IsNil(resp) { + t.Fatalf("response not present") + } + }) + + t.Run("Test DefaultApiService PurgeCache", func(t *testing.T) { + _apiUrlPath := "/v1beta/projects/{projectId}/distributions/{distributionId}/cache/purge" + projectIdValue := "projectId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) + distributionIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"distributionId"+"}", url.PathEscape(ParameterValueToString(distributionIdValue, "distributionId")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + data := map[string]interface{}{} + 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 cdn_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 + distributionId := distributionIdValue + + resp, reqErr := apiClient.PurgeCache(context.Background(), projectId, distributionId).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if IsNil(resp) { + t.Fatalf("response not present") + } + }) + + t.Run("Test DefaultApiService PutCustomDomain", func(t *testing.T) { + _apiUrlPath := "/v1beta/projects/{projectId}/distributions/{distributionId}/customDomains/{domain}" + projectIdValue := "projectId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) + distributionIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"distributionId"+"}", url.PathEscape(ParameterValueToString(distributionIdValue, "distributionId")), -1) + domainValue := "domain" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"domain"+"}", url.PathEscape(ParameterValueToString(domainValue, "domain")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + data := PutCustomDomainResponse{} + 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 cdn_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 + distributionId := distributionIdValue + domain := domainValue + + resp, reqErr := apiClient.PutCustomDomain(context.Background(), projectId, distributionId, domain).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if IsNil(resp) { + t.Fatalf("response not present") + } + }) + +} diff --git a/services/cdn/client.go b/services/cdn/client.go new file mode 100644 index 000000000..b3ef722b3 --- /dev/null +++ b/services/cdn/client.go @@ -0,0 +1,631 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +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 CDN 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/cdn/configuration.go b/services/cdn/configuration.go new file mode 100644 index 000000000..4c9a2b9b6 --- /dev/null +++ b/services/cdn/configuration.go @@ -0,0 +1,38 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +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://cdn.api.stackit.cloud", + Description: "No description provided", + Variables: map[string]config.ServerVariable{ + "region": { + Description: "No description provided", + DefaultValue: "global", + }, + }, + }, + }, + OperationServers: map[string]config.ServerConfigurations{}, + } + return cfg +} diff --git a/services/cdn/go.mod b/services/cdn/go.mod new file mode 100644 index 000000000..539ff1977 --- /dev/null +++ b/services/cdn/go.mod @@ -0,0 +1,13 @@ +module github.com/stackitcloud/stackit-sdk-go/services/cdn + +go 1.21 + +require ( + github.com/google/uuid v1.6.0 + github.com/stackitcloud/stackit-sdk-go/core v0.16.0 +) + +require ( + github.com/golang-jwt/jwt/v5 v5.2.1 // indirect + github.com/google/go-cmp v0.7.0 // indirect +) diff --git a/services/cdn/go.sum b/services/cdn/go.sum new file mode 100644 index 000000000..39bc73464 --- /dev/null +++ b/services/cdn/go.sum @@ -0,0 +1,8 @@ +github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= +github.com/golang-jwt/jwt/v5 v5.2.1/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.0 h1:9caGZwGLZDyBBe6ojk9VR4B2m3/0H5It6znBz76sH1w= +github.com/stackitcloud/stackit-sdk-go/core v0.16.0/go.mod h1:LRheSoXTFRHWAyA8Q9skWtWBp3ZZ+bFAKiKuf4lTDkE= diff --git a/services/cdn/model_config.go b/services/cdn/model_config.go new file mode 100644 index 000000000..e7819e958 --- /dev/null +++ b/services/cdn/model_config.go @@ -0,0 +1,168 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +import ( + "encoding/json" +) + +// checks if the Config type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &Config{} + +/* + types and functions for backend +*/ + +// isModel +type ConfigGetBackendAttributeType = *ConfigBackend +type ConfigGetBackendArgType = ConfigBackend +type ConfigGetBackendRetType = ConfigBackend + +func getConfigGetBackendAttributeTypeOk(arg ConfigGetBackendAttributeType) (ret ConfigGetBackendRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setConfigGetBackendAttributeType(arg *ConfigGetBackendAttributeType, val ConfigGetBackendRetType) { + *arg = &val +} + +/* + types and functions for regions +*/ + +// isArray +type ConfigGetRegionsAttributeType = *[]Region +type ConfigGetRegionsArgType = []Region +type ConfigGetRegionsRetType = []Region + +func getConfigGetRegionsAttributeTypeOk(arg ConfigGetRegionsAttributeType) (ret ConfigGetRegionsRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setConfigGetRegionsAttributeType(arg *ConfigGetRegionsAttributeType, val ConfigGetRegionsRetType) { + *arg = &val +} + +// Config struct for Config +type Config struct { + // REQUIRED + Backend ConfigGetBackendAttributeType `json:"backend"` + // REQUIRED + Regions ConfigGetRegionsAttributeType `json:"regions"` +} + +type _Config Config + +// NewConfig instantiates a new Config 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 NewConfig(backend ConfigGetBackendArgType, regions ConfigGetRegionsArgType) *Config { + this := Config{} + setConfigGetBackendAttributeType(&this.Backend, backend) + setConfigGetRegionsAttributeType(&this.Regions, regions) + return &this +} + +// NewConfigWithDefaults instantiates a new Config 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 NewConfigWithDefaults() *Config { + this := Config{} + return &this +} + +// GetBackend returns the Backend field value +func (o *Config) GetBackend() (ret ConfigGetBackendRetType) { + 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 *Config) GetBackendOk() (ret ConfigGetBackendRetType, ok bool) { + return getConfigGetBackendAttributeTypeOk(o.Backend) +} + +// SetBackend sets field value +func (o *Config) SetBackend(v ConfigGetBackendRetType) { + setConfigGetBackendAttributeType(&o.Backend, v) +} + +// GetRegions returns the Regions field value +func (o *Config) GetRegions() (ret ConfigGetRegionsRetType) { + ret, _ = o.GetRegionsOk() + return ret +} + +// GetRegionsOk returns a tuple with the Regions field value +// and a boolean to check if the value has been set. +func (o *Config) GetRegionsOk() (ret ConfigGetRegionsRetType, ok bool) { + return getConfigGetRegionsAttributeTypeOk(o.Regions) +} + +// SetRegions sets field value +func (o *Config) SetRegions(v ConfigGetRegionsRetType) { + setConfigGetRegionsAttributeType(&o.Regions, v) +} + +func (o Config) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getConfigGetBackendAttributeTypeOk(o.Backend); ok { + toSerialize["Backend"] = val + } + if val, ok := getConfigGetRegionsAttributeTypeOk(o.Regions); ok { + toSerialize["Regions"] = val + } + return toSerialize, nil +} + +type NullableConfig struct { + value *Config + isSet bool +} + +func (v NullableConfig) Get() *Config { + return v.value +} + +func (v *NullableConfig) Set(val *Config) { + v.value = val + v.isSet = true +} + +func (v NullableConfig) IsSet() bool { + return v.isSet +} + +func (v *NullableConfig) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableConfig(val *Config) *NullableConfig { + return &NullableConfig{value: val, isSet: true} +} + +func (v NullableConfig) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableConfig) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cdn/model_config_backend.go b/services/cdn/model_config_backend.go new file mode 100644 index 000000000..d9fecb340 --- /dev/null +++ b/services/cdn/model_config_backend.go @@ -0,0 +1,115 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +import ( + "encoding/json" + "fmt" +) + +// ConfigBackend - struct for ConfigBackend +type ConfigBackend struct { + HttpBackend *HttpBackend +} + +// HttpBackendAsConfigBackend is a convenience function that returns HttpBackend wrapped in ConfigBackend +func HttpBackendAsConfigBackend(v *HttpBackend) ConfigBackend { + return ConfigBackend{ + HttpBackend: v, + } +} + +// Unmarshal JSON data into one of the pointers in the struct +func (dst *ConfigBackend) UnmarshalJSON(data []byte) error { + var err error + match := 0 + // try to unmarshal data into HttpBackend + err = newStrictDecoder(data).Decode(&dst.HttpBackend) + if err == nil { + jsonHttpBackend, _ := json.Marshal(dst.HttpBackend) + if string(jsonHttpBackend) == "{}" { // empty struct + dst.HttpBackend = nil + } else { + match++ + } + } else { + dst.HttpBackend = nil + } + + if match > 1 { // more than 1 match + // reset to nil + dst.HttpBackend = nil + + return fmt.Errorf("data matches more than one schema in oneOf(ConfigBackend)") + } else if match == 1 { + return nil // exactly one match + } else { // no match + return fmt.Errorf("data failed to match schemas in oneOf(ConfigBackend)") + } +} + +// Marshal data from the first non-nil pointers in the struct to JSON +func (src ConfigBackend) MarshalJSON() ([]byte, error) { + if src.HttpBackend != nil { + return json.Marshal(&src.HttpBackend) + } + + return []byte("{}"), nil // no data in oneOf schemas => empty JSON object +} + +// Get the actual instance +func (obj *ConfigBackend) GetActualInstance() interface{} { + if obj == nil { + return nil + } + if obj.HttpBackend != nil { + return obj.HttpBackend + } + + // all schemas are nil + return nil +} + +type NullableConfigBackend struct { + value *ConfigBackend + isSet bool +} + +func (v NullableConfigBackend) Get() *ConfigBackend { + return v.value +} + +func (v *NullableConfigBackend) Set(val *ConfigBackend) { + v.value = val + v.isSet = true +} + +func (v NullableConfigBackend) IsSet() bool { + return v.isSet +} + +func (v *NullableConfigBackend) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableConfigBackend(val *ConfigBackend) *NullableConfigBackend { + return &NullableConfigBackend{value: val, isSet: true} +} + +func (v NullableConfigBackend) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableConfigBackend) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cdn/model_config_patch.go b/services/cdn/model_config_patch.go new file mode 100644 index 000000000..40dd3370e --- /dev/null +++ b/services/cdn/model_config_patch.go @@ -0,0 +1,174 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +import ( + "encoding/json" +) + +// checks if the ConfigPatch type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ConfigPatch{} + +/* + types and functions for backend +*/ + +// isModel +type ConfigPatchGetBackendAttributeType = *ConfigPatchBackend +type ConfigPatchGetBackendArgType = ConfigPatchBackend +type ConfigPatchGetBackendRetType = ConfigPatchBackend + +func getConfigPatchGetBackendAttributeTypeOk(arg ConfigPatchGetBackendAttributeType) (ret ConfigPatchGetBackendRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setConfigPatchGetBackendAttributeType(arg *ConfigPatchGetBackendAttributeType, val ConfigPatchGetBackendRetType) { + *arg = &val +} + +/* + types and functions for regions +*/ + +// isArray +type ConfigPatchGetRegionsAttributeType = *[]Region +type ConfigPatchGetRegionsArgType = []Region +type ConfigPatchGetRegionsRetType = []Region + +func getConfigPatchGetRegionsAttributeTypeOk(arg ConfigPatchGetRegionsAttributeType) (ret ConfigPatchGetRegionsRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setConfigPatchGetRegionsAttributeType(arg *ConfigPatchGetRegionsAttributeType, val ConfigPatchGetRegionsRetType) { + *arg = &val +} + +// ConfigPatch struct for ConfigPatch +type ConfigPatch struct { + Backend ConfigPatchGetBackendAttributeType `json:"backend,omitempty"` + Regions ConfigPatchGetRegionsAttributeType `json:"regions,omitempty"` +} + +// NewConfigPatch instantiates a new ConfigPatch 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 NewConfigPatch() *ConfigPatch { + this := ConfigPatch{} + return &this +} + +// NewConfigPatchWithDefaults instantiates a new ConfigPatch 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 NewConfigPatchWithDefaults() *ConfigPatch { + this := ConfigPatch{} + return &this +} + +// GetBackend returns the Backend field value if set, zero value otherwise. +func (o *ConfigPatch) GetBackend() (res ConfigPatchGetBackendRetType) { + res, _ = o.GetBackendOk() + return +} + +// GetBackendOk returns a tuple with the Backend field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ConfigPatch) GetBackendOk() (ret ConfigPatchGetBackendRetType, ok bool) { + return getConfigPatchGetBackendAttributeTypeOk(o.Backend) +} + +// HasBackend returns a boolean if a field has been set. +func (o *ConfigPatch) HasBackend() bool { + _, ok := o.GetBackendOk() + return ok +} + +// SetBackend gets a reference to the given ConfigPatchBackend and assigns it to the Backend field. +func (o *ConfigPatch) SetBackend(v ConfigPatchGetBackendRetType) { + setConfigPatchGetBackendAttributeType(&o.Backend, v) +} + +// GetRegions returns the Regions field value if set, zero value otherwise. +func (o *ConfigPatch) GetRegions() (res ConfigPatchGetRegionsRetType) { + res, _ = o.GetRegionsOk() + return +} + +// GetRegionsOk returns a tuple with the Regions field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ConfigPatch) GetRegionsOk() (ret ConfigPatchGetRegionsRetType, ok bool) { + return getConfigPatchGetRegionsAttributeTypeOk(o.Regions) +} + +// HasRegions returns a boolean if a field has been set. +func (o *ConfigPatch) HasRegions() bool { + _, ok := o.GetRegionsOk() + return ok +} + +// SetRegions gets a reference to the given []Region and assigns it to the Regions field. +func (o *ConfigPatch) SetRegions(v ConfigPatchGetRegionsRetType) { + setConfigPatchGetRegionsAttributeType(&o.Regions, v) +} + +func (o ConfigPatch) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getConfigPatchGetBackendAttributeTypeOk(o.Backend); ok { + toSerialize["Backend"] = val + } + if val, ok := getConfigPatchGetRegionsAttributeTypeOk(o.Regions); ok { + toSerialize["Regions"] = val + } + return toSerialize, nil +} + +type NullableConfigPatch struct { + value *ConfigPatch + isSet bool +} + +func (v NullableConfigPatch) Get() *ConfigPatch { + return v.value +} + +func (v *NullableConfigPatch) Set(val *ConfigPatch) { + v.value = val + v.isSet = true +} + +func (v NullableConfigPatch) IsSet() bool { + return v.isSet +} + +func (v *NullableConfigPatch) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableConfigPatch(val *ConfigPatch) *NullableConfigPatch { + return &NullableConfigPatch{value: val, isSet: true} +} + +func (v NullableConfigPatch) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableConfigPatch) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cdn/model_config_patch_backend.go b/services/cdn/model_config_patch_backend.go new file mode 100644 index 000000000..aab1c4242 --- /dev/null +++ b/services/cdn/model_config_patch_backend.go @@ -0,0 +1,115 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +import ( + "encoding/json" + "fmt" +) + +// ConfigPatchBackend - struct for ConfigPatchBackend +type ConfigPatchBackend struct { + HttpBackendPatch *HttpBackendPatch +} + +// HttpBackendPatchAsConfigPatchBackend is a convenience function that returns HttpBackendPatch wrapped in ConfigPatchBackend +func HttpBackendPatchAsConfigPatchBackend(v *HttpBackendPatch) ConfigPatchBackend { + return ConfigPatchBackend{ + HttpBackendPatch: v, + } +} + +// Unmarshal JSON data into one of the pointers in the struct +func (dst *ConfigPatchBackend) UnmarshalJSON(data []byte) error { + var err error + match := 0 + // try to unmarshal data into HttpBackendPatch + err = newStrictDecoder(data).Decode(&dst.HttpBackendPatch) + if err == nil { + jsonHttpBackendPatch, _ := json.Marshal(dst.HttpBackendPatch) + if string(jsonHttpBackendPatch) == "{}" { // empty struct + dst.HttpBackendPatch = nil + } else { + match++ + } + } else { + dst.HttpBackendPatch = nil + } + + if match > 1 { // more than 1 match + // reset to nil + dst.HttpBackendPatch = nil + + return fmt.Errorf("data matches more than one schema in oneOf(ConfigPatchBackend)") + } else if match == 1 { + return nil // exactly one match + } else { // no match + return fmt.Errorf("data failed to match schemas in oneOf(ConfigPatchBackend)") + } +} + +// Marshal data from the first non-nil pointers in the struct to JSON +func (src ConfigPatchBackend) MarshalJSON() ([]byte, error) { + if src.HttpBackendPatch != nil { + return json.Marshal(&src.HttpBackendPatch) + } + + return []byte("{}"), nil // no data in oneOf schemas => empty JSON object +} + +// Get the actual instance +func (obj *ConfigPatchBackend) GetActualInstance() interface{} { + if obj == nil { + return nil + } + if obj.HttpBackendPatch != nil { + return obj.HttpBackendPatch + } + + // all schemas are nil + return nil +} + +type NullableConfigPatchBackend struct { + value *ConfigPatchBackend + isSet bool +} + +func (v NullableConfigPatchBackend) Get() *ConfigPatchBackend { + return v.value +} + +func (v *NullableConfigPatchBackend) Set(val *ConfigPatchBackend) { + v.value = val + v.isSet = true +} + +func (v NullableConfigPatchBackend) IsSet() bool { + return v.isSet +} + +func (v *NullableConfigPatchBackend) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableConfigPatchBackend(val *ConfigPatchBackend) *NullableConfigPatchBackend { + return &NullableConfigPatchBackend{value: val, isSet: true} +} + +func (v NullableConfigPatchBackend) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableConfigPatchBackend) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cdn/model_create_distribution_payload.go b/services/cdn/model_create_distribution_payload.go new file mode 100644 index 000000000..2af6baaa5 --- /dev/null +++ b/services/cdn/model_create_distribution_payload.go @@ -0,0 +1,268 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +import ( + "encoding/json" +) + +// checks if the CreateDistributionPayload type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &CreateDistributionPayload{} + +/* + types and functions for intentId +*/ + +// isNotNullableString +type CreateDistributionPayloadGetIntentIdAttributeType = *string + +func getCreateDistributionPayloadGetIntentIdAttributeTypeOk(arg CreateDistributionPayloadGetIntentIdAttributeType) (ret CreateDistributionPayloadGetIntentIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setCreateDistributionPayloadGetIntentIdAttributeType(arg *CreateDistributionPayloadGetIntentIdAttributeType, val CreateDistributionPayloadGetIntentIdRetType) { + *arg = &val +} + +type CreateDistributionPayloadGetIntentIdArgType = string +type CreateDistributionPayloadGetIntentIdRetType = string + +/* + types and functions for originRequestHeaders +*/ + +// isContainer +type CreateDistributionPayloadGetOriginRequestHeadersAttributeType = *map[string]string +type CreateDistributionPayloadGetOriginRequestHeadersArgType = map[string]string +type CreateDistributionPayloadGetOriginRequestHeadersRetType = map[string]string + +func getCreateDistributionPayloadGetOriginRequestHeadersAttributeTypeOk(arg CreateDistributionPayloadGetOriginRequestHeadersAttributeType) (ret CreateDistributionPayloadGetOriginRequestHeadersRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setCreateDistributionPayloadGetOriginRequestHeadersAttributeType(arg *CreateDistributionPayloadGetOriginRequestHeadersAttributeType, val CreateDistributionPayloadGetOriginRequestHeadersRetType) { + *arg = &val +} + +/* + types and functions for originUrl +*/ + +// isNotNullableString +type CreateDistributionPayloadGetOriginUrlAttributeType = *string + +func getCreateDistributionPayloadGetOriginUrlAttributeTypeOk(arg CreateDistributionPayloadGetOriginUrlAttributeType) (ret CreateDistributionPayloadGetOriginUrlRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setCreateDistributionPayloadGetOriginUrlAttributeType(arg *CreateDistributionPayloadGetOriginUrlAttributeType, val CreateDistributionPayloadGetOriginUrlRetType) { + *arg = &val +} + +type CreateDistributionPayloadGetOriginUrlArgType = string +type CreateDistributionPayloadGetOriginUrlRetType = string + +/* + types and functions for regions +*/ + +// isArray +type CreateDistributionPayloadGetRegionsAttributeType = *[]Region +type CreateDistributionPayloadGetRegionsArgType = []Region +type CreateDistributionPayloadGetRegionsRetType = []Region + +func getCreateDistributionPayloadGetRegionsAttributeTypeOk(arg CreateDistributionPayloadGetRegionsAttributeType) (ret CreateDistributionPayloadGetRegionsRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setCreateDistributionPayloadGetRegionsAttributeType(arg *CreateDistributionPayloadGetRegionsAttributeType, val CreateDistributionPayloadGetRegionsRetType) { + *arg = &val +} + +// CreateDistributionPayload struct for CreateDistributionPayload +type CreateDistributionPayload struct { + // While optional, it is greatly encouraged to provide an `intentId`. This is used to deduplicate requests. If multiple POST-Requests with the same `intentId` for a given `projectId` are received, all but the first request are dropped. + IntentId CreateDistributionPayloadGetIntentIdAttributeType `json:"intentId,omitempty"` + // Headers that will be sent with every request to the configured origin. WARNING: Do not store sensitive values in the headers. The data is stores as plain text. + OriginRequestHeaders CreateDistributionPayloadGetOriginRequestHeadersAttributeType `json:"originRequestHeaders,omitempty"` + // The origin of the content that should be made available through the CDN. Note that the path and query parameters are ignored. Ports are allowed. If no protocol is provided, `https` is assumed. So `www.example.com:1234/somePath?q=123` is normalized to `https://www.example.com:1234` + // REQUIRED + OriginUrl CreateDistributionPayloadGetOriginUrlAttributeType `json:"originUrl"` + // Define in which regions you would like your content to be cached. + // REQUIRED + Regions CreateDistributionPayloadGetRegionsAttributeType `json:"regions"` +} + +type _CreateDistributionPayload CreateDistributionPayload + +// NewCreateDistributionPayload instantiates a new CreateDistributionPayload 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 NewCreateDistributionPayload(originUrl CreateDistributionPayloadGetOriginUrlArgType, regions CreateDistributionPayloadGetRegionsArgType) *CreateDistributionPayload { + this := CreateDistributionPayload{} + setCreateDistributionPayloadGetOriginUrlAttributeType(&this.OriginUrl, originUrl) + setCreateDistributionPayloadGetRegionsAttributeType(&this.Regions, regions) + return &this +} + +// NewCreateDistributionPayloadWithDefaults instantiates a new CreateDistributionPayload 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 NewCreateDistributionPayloadWithDefaults() *CreateDistributionPayload { + this := CreateDistributionPayload{} + return &this +} + +// GetIntentId returns the IntentId field value if set, zero value otherwise. +func (o *CreateDistributionPayload) GetIntentId() (res CreateDistributionPayloadGetIntentIdRetType) { + res, _ = o.GetIntentIdOk() + return +} + +// GetIntentIdOk returns a tuple with the IntentId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateDistributionPayload) GetIntentIdOk() (ret CreateDistributionPayloadGetIntentIdRetType, ok bool) { + return getCreateDistributionPayloadGetIntentIdAttributeTypeOk(o.IntentId) +} + +// HasIntentId returns a boolean if a field has been set. +func (o *CreateDistributionPayload) HasIntentId() bool { + _, ok := o.GetIntentIdOk() + return ok +} + +// SetIntentId gets a reference to the given string and assigns it to the IntentId field. +func (o *CreateDistributionPayload) SetIntentId(v CreateDistributionPayloadGetIntentIdRetType) { + setCreateDistributionPayloadGetIntentIdAttributeType(&o.IntentId, v) +} + +// GetOriginRequestHeaders returns the OriginRequestHeaders field value if set, zero value otherwise. +func (o *CreateDistributionPayload) GetOriginRequestHeaders() (res CreateDistributionPayloadGetOriginRequestHeadersRetType) { + res, _ = o.GetOriginRequestHeadersOk() + return +} + +// GetOriginRequestHeadersOk returns a tuple with the OriginRequestHeaders field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateDistributionPayload) GetOriginRequestHeadersOk() (ret CreateDistributionPayloadGetOriginRequestHeadersRetType, ok bool) { + return getCreateDistributionPayloadGetOriginRequestHeadersAttributeTypeOk(o.OriginRequestHeaders) +} + +// HasOriginRequestHeaders returns a boolean if a field has been set. +func (o *CreateDistributionPayload) HasOriginRequestHeaders() bool { + _, ok := o.GetOriginRequestHeadersOk() + return ok +} + +// SetOriginRequestHeaders gets a reference to the given map[string]string and assigns it to the OriginRequestHeaders field. +func (o *CreateDistributionPayload) SetOriginRequestHeaders(v CreateDistributionPayloadGetOriginRequestHeadersRetType) { + setCreateDistributionPayloadGetOriginRequestHeadersAttributeType(&o.OriginRequestHeaders, v) +} + +// GetOriginUrl returns the OriginUrl field value +func (o *CreateDistributionPayload) GetOriginUrl() (ret CreateDistributionPayloadGetOriginUrlRetType) { + ret, _ = o.GetOriginUrlOk() + return ret +} + +// GetOriginUrlOk returns a tuple with the OriginUrl field value +// and a boolean to check if the value has been set. +func (o *CreateDistributionPayload) GetOriginUrlOk() (ret CreateDistributionPayloadGetOriginUrlRetType, ok bool) { + return getCreateDistributionPayloadGetOriginUrlAttributeTypeOk(o.OriginUrl) +} + +// SetOriginUrl sets field value +func (o *CreateDistributionPayload) SetOriginUrl(v CreateDistributionPayloadGetOriginUrlRetType) { + setCreateDistributionPayloadGetOriginUrlAttributeType(&o.OriginUrl, v) +} + +// GetRegions returns the Regions field value +func (o *CreateDistributionPayload) GetRegions() (ret CreateDistributionPayloadGetRegionsRetType) { + ret, _ = o.GetRegionsOk() + return ret +} + +// GetRegionsOk returns a tuple with the Regions field value +// and a boolean to check if the value has been set. +func (o *CreateDistributionPayload) GetRegionsOk() (ret CreateDistributionPayloadGetRegionsRetType, ok bool) { + return getCreateDistributionPayloadGetRegionsAttributeTypeOk(o.Regions) +} + +// SetRegions sets field value +func (o *CreateDistributionPayload) SetRegions(v CreateDistributionPayloadGetRegionsRetType) { + setCreateDistributionPayloadGetRegionsAttributeType(&o.Regions, v) +} + +func (o CreateDistributionPayload) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getCreateDistributionPayloadGetIntentIdAttributeTypeOk(o.IntentId); ok { + toSerialize["IntentId"] = val + } + if val, ok := getCreateDistributionPayloadGetOriginRequestHeadersAttributeTypeOk(o.OriginRequestHeaders); ok { + toSerialize["OriginRequestHeaders"] = val + } + if val, ok := getCreateDistributionPayloadGetOriginUrlAttributeTypeOk(o.OriginUrl); ok { + toSerialize["OriginUrl"] = val + } + if val, ok := getCreateDistributionPayloadGetRegionsAttributeTypeOk(o.Regions); ok { + toSerialize["Regions"] = val + } + return toSerialize, nil +} + +type NullableCreateDistributionPayload struct { + value *CreateDistributionPayload + isSet bool +} + +func (v NullableCreateDistributionPayload) Get() *CreateDistributionPayload { + return v.value +} + +func (v *NullableCreateDistributionPayload) Set(val *CreateDistributionPayload) { + v.value = val + v.isSet = true +} + +func (v NullableCreateDistributionPayload) IsSet() bool { + return v.isSet +} + +func (v *NullableCreateDistributionPayload) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableCreateDistributionPayload(val *CreateDistributionPayload) *NullableCreateDistributionPayload { + return &NullableCreateDistributionPayload{value: val, isSet: true} +} + +func (v NullableCreateDistributionPayload) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableCreateDistributionPayload) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cdn/model_create_distribution_response.go b/services/cdn/model_create_distribution_response.go new file mode 100644 index 000000000..f2c4dd8f1 --- /dev/null +++ b/services/cdn/model_create_distribution_response.go @@ -0,0 +1,125 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +import ( + "encoding/json" +) + +// checks if the CreateDistributionResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &CreateDistributionResponse{} + +/* + types and functions for distribution +*/ + +// isModel +type CreateDistributionResponseGetDistributionAttributeType = *Distribution +type CreateDistributionResponseGetDistributionArgType = Distribution +type CreateDistributionResponseGetDistributionRetType = Distribution + +func getCreateDistributionResponseGetDistributionAttributeTypeOk(arg CreateDistributionResponseGetDistributionAttributeType) (ret CreateDistributionResponseGetDistributionRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setCreateDistributionResponseGetDistributionAttributeType(arg *CreateDistributionResponseGetDistributionAttributeType, val CreateDistributionResponseGetDistributionRetType) { + *arg = &val +} + +// CreateDistributionResponse struct for CreateDistributionResponse +type CreateDistributionResponse struct { + // REQUIRED + Distribution CreateDistributionResponseGetDistributionAttributeType `json:"distribution"` +} + +type _CreateDistributionResponse CreateDistributionResponse + +// NewCreateDistributionResponse instantiates a new CreateDistributionResponse 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 NewCreateDistributionResponse(distribution CreateDistributionResponseGetDistributionArgType) *CreateDistributionResponse { + this := CreateDistributionResponse{} + setCreateDistributionResponseGetDistributionAttributeType(&this.Distribution, distribution) + return &this +} + +// NewCreateDistributionResponseWithDefaults instantiates a new CreateDistributionResponse 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 NewCreateDistributionResponseWithDefaults() *CreateDistributionResponse { + this := CreateDistributionResponse{} + return &this +} + +// GetDistribution returns the Distribution field value +func (o *CreateDistributionResponse) GetDistribution() (ret CreateDistributionResponseGetDistributionRetType) { + ret, _ = o.GetDistributionOk() + return ret +} + +// GetDistributionOk returns a tuple with the Distribution field value +// and a boolean to check if the value has been set. +func (o *CreateDistributionResponse) GetDistributionOk() (ret CreateDistributionResponseGetDistributionRetType, ok bool) { + return getCreateDistributionResponseGetDistributionAttributeTypeOk(o.Distribution) +} + +// SetDistribution sets field value +func (o *CreateDistributionResponse) SetDistribution(v CreateDistributionResponseGetDistributionRetType) { + setCreateDistributionResponseGetDistributionAttributeType(&o.Distribution, v) +} + +func (o CreateDistributionResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getCreateDistributionResponseGetDistributionAttributeTypeOk(o.Distribution); ok { + toSerialize["Distribution"] = val + } + return toSerialize, nil +} + +type NullableCreateDistributionResponse struct { + value *CreateDistributionResponse + isSet bool +} + +func (v NullableCreateDistributionResponse) Get() *CreateDistributionResponse { + return v.value +} + +func (v *NullableCreateDistributionResponse) Set(val *CreateDistributionResponse) { + v.value = val + v.isSet = true +} + +func (v NullableCreateDistributionResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableCreateDistributionResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableCreateDistributionResponse(val *CreateDistributionResponse) *NullableCreateDistributionResponse { + return &NullableCreateDistributionResponse{value: val, isSet: true} +} + +func (v NullableCreateDistributionResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableCreateDistributionResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cdn/model_custom_domain.go b/services/cdn/model_custom_domain.go new file mode 100644 index 000000000..20c51dca1 --- /dev/null +++ b/services/cdn/model_custom_domain.go @@ -0,0 +1,218 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +import ( + "encoding/json" +) + +// checks if the CustomDomain type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &CustomDomain{} + +/* + types and functions for errors +*/ + +// isArray +type CustomDomainGetErrorsAttributeType = *[]StatusError +type CustomDomainGetErrorsArgType = []StatusError +type CustomDomainGetErrorsRetType = []StatusError + +func getCustomDomainGetErrorsAttributeTypeOk(arg CustomDomainGetErrorsAttributeType) (ret CustomDomainGetErrorsRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setCustomDomainGetErrorsAttributeType(arg *CustomDomainGetErrorsAttributeType, val CustomDomainGetErrorsRetType) { + *arg = &val +} + +/* + types and functions for name +*/ + +// isNotNullableString +type CustomDomainGetNameAttributeType = *string + +func getCustomDomainGetNameAttributeTypeOk(arg CustomDomainGetNameAttributeType) (ret CustomDomainGetNameRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setCustomDomainGetNameAttributeType(arg *CustomDomainGetNameAttributeType, val CustomDomainGetNameRetType) { + *arg = &val +} + +type CustomDomainGetNameArgType = string +type CustomDomainGetNameRetType = string + +/* + types and functions for status +*/ + +// isEnumRef +type CustomDomainGetStatusAttributeType = *DomainStatus +type CustomDomainGetStatusArgType = DomainStatus +type CustomDomainGetStatusRetType = DomainStatus + +func getCustomDomainGetStatusAttributeTypeOk(arg CustomDomainGetStatusAttributeType) (ret CustomDomainGetStatusRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setCustomDomainGetStatusAttributeType(arg *CustomDomainGetStatusAttributeType, val CustomDomainGetStatusRetType) { + *arg = &val +} + +// CustomDomain Definition of a custom domain +type CustomDomain struct { + // This object is present if the custom domain has errors. + Errors CustomDomainGetErrorsAttributeType `json:"errors,omitempty"` + // The domain. Can be used as input for the GetCustomDomain endpoint + // REQUIRED + Name CustomDomainGetNameAttributeType `json:"name"` + // REQUIRED + Status CustomDomainGetStatusAttributeType `json:"status"` +} + +type _CustomDomain CustomDomain + +// NewCustomDomain instantiates a new CustomDomain 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 NewCustomDomain(name CustomDomainGetNameArgType, status CustomDomainGetStatusArgType) *CustomDomain { + this := CustomDomain{} + setCustomDomainGetNameAttributeType(&this.Name, name) + setCustomDomainGetStatusAttributeType(&this.Status, status) + return &this +} + +// NewCustomDomainWithDefaults instantiates a new CustomDomain 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 NewCustomDomainWithDefaults() *CustomDomain { + this := CustomDomain{} + return &this +} + +// GetErrors returns the Errors field value if set, zero value otherwise. +func (o *CustomDomain) GetErrors() (res CustomDomainGetErrorsRetType) { + res, _ = o.GetErrorsOk() + return +} + +// GetErrorsOk returns a tuple with the Errors field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CustomDomain) GetErrorsOk() (ret CustomDomainGetErrorsRetType, ok bool) { + return getCustomDomainGetErrorsAttributeTypeOk(o.Errors) +} + +// HasErrors returns a boolean if a field has been set. +func (o *CustomDomain) HasErrors() bool { + _, ok := o.GetErrorsOk() + return ok +} + +// SetErrors gets a reference to the given []StatusError and assigns it to the Errors field. +func (o *CustomDomain) SetErrors(v CustomDomainGetErrorsRetType) { + setCustomDomainGetErrorsAttributeType(&o.Errors, v) +} + +// GetName returns the Name field value +func (o *CustomDomain) GetName() (ret CustomDomainGetNameRetType) { + ret, _ = o.GetNameOk() + return ret +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *CustomDomain) GetNameOk() (ret CustomDomainGetNameRetType, ok bool) { + return getCustomDomainGetNameAttributeTypeOk(o.Name) +} + +// SetName sets field value +func (o *CustomDomain) SetName(v CustomDomainGetNameRetType) { + setCustomDomainGetNameAttributeType(&o.Name, v) +} + +// GetStatus returns the Status field value +func (o *CustomDomain) GetStatus() (ret CustomDomainGetStatusRetType) { + ret, _ = o.GetStatusOk() + return ret +} + +// GetStatusOk returns a tuple with the Status field value +// and a boolean to check if the value has been set. +func (o *CustomDomain) GetStatusOk() (ret CustomDomainGetStatusRetType, ok bool) { + return getCustomDomainGetStatusAttributeTypeOk(o.Status) +} + +// SetStatus sets field value +func (o *CustomDomain) SetStatus(v CustomDomainGetStatusRetType) { + setCustomDomainGetStatusAttributeType(&o.Status, v) +} + +func (o CustomDomain) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getCustomDomainGetErrorsAttributeTypeOk(o.Errors); ok { + toSerialize["Errors"] = val + } + if val, ok := getCustomDomainGetNameAttributeTypeOk(o.Name); ok { + toSerialize["Name"] = val + } + if val, ok := getCustomDomainGetStatusAttributeTypeOk(o.Status); ok { + toSerialize["Status"] = val + } + return toSerialize, nil +} + +type NullableCustomDomain struct { + value *CustomDomain + isSet bool +} + +func (v NullableCustomDomain) Get() *CustomDomain { + return v.value +} + +func (v *NullableCustomDomain) Set(val *CustomDomain) { + v.value = val + v.isSet = true +} + +func (v NullableCustomDomain) IsSet() bool { + return v.isSet +} + +func (v *NullableCustomDomain) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableCustomDomain(val *CustomDomain) *NullableCustomDomain { + return &NullableCustomDomain{value: val, isSet: true} +} + +func (v NullableCustomDomain) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableCustomDomain) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cdn/model_delete_custom_domain_response.go b/services/cdn/model_delete_custom_domain_response.go new file mode 100644 index 000000000..d642772e2 --- /dev/null +++ b/services/cdn/model_delete_custom_domain_response.go @@ -0,0 +1,127 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +import ( + "encoding/json" +) + +// checks if the DeleteCustomDomainResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &DeleteCustomDomainResponse{} + +/* + types and functions for customDomain +*/ + +// isModel +type DeleteCustomDomainResponseGetCustomDomainAttributeType = *CustomDomain +type DeleteCustomDomainResponseGetCustomDomainArgType = CustomDomain +type DeleteCustomDomainResponseGetCustomDomainRetType = CustomDomain + +func getDeleteCustomDomainResponseGetCustomDomainAttributeTypeOk(arg DeleteCustomDomainResponseGetCustomDomainAttributeType) (ret DeleteCustomDomainResponseGetCustomDomainRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDeleteCustomDomainResponseGetCustomDomainAttributeType(arg *DeleteCustomDomainResponseGetCustomDomainAttributeType, val DeleteCustomDomainResponseGetCustomDomainRetType) { + *arg = &val +} + +// DeleteCustomDomainResponse Returns the custom domain that was deleted while the deletion has not completed yet. After the deletion was successful the response will be empty. +type DeleteCustomDomainResponse struct { + CustomDomain DeleteCustomDomainResponseGetCustomDomainAttributeType `json:"customDomain,omitempty"` +} + +// NewDeleteCustomDomainResponse instantiates a new DeleteCustomDomainResponse 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 NewDeleteCustomDomainResponse() *DeleteCustomDomainResponse { + this := DeleteCustomDomainResponse{} + return &this +} + +// NewDeleteCustomDomainResponseWithDefaults instantiates a new DeleteCustomDomainResponse 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 NewDeleteCustomDomainResponseWithDefaults() *DeleteCustomDomainResponse { + this := DeleteCustomDomainResponse{} + return &this +} + +// GetCustomDomain returns the CustomDomain field value if set, zero value otherwise. +func (o *DeleteCustomDomainResponse) GetCustomDomain() (res DeleteCustomDomainResponseGetCustomDomainRetType) { + res, _ = o.GetCustomDomainOk() + return +} + +// GetCustomDomainOk returns a tuple with the CustomDomain field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DeleteCustomDomainResponse) GetCustomDomainOk() (ret DeleteCustomDomainResponseGetCustomDomainRetType, ok bool) { + return getDeleteCustomDomainResponseGetCustomDomainAttributeTypeOk(o.CustomDomain) +} + +// HasCustomDomain returns a boolean if a field has been set. +func (o *DeleteCustomDomainResponse) HasCustomDomain() bool { + _, ok := o.GetCustomDomainOk() + return ok +} + +// SetCustomDomain gets a reference to the given CustomDomain and assigns it to the CustomDomain field. +func (o *DeleteCustomDomainResponse) SetCustomDomain(v DeleteCustomDomainResponseGetCustomDomainRetType) { + setDeleteCustomDomainResponseGetCustomDomainAttributeType(&o.CustomDomain, v) +} + +func (o DeleteCustomDomainResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getDeleteCustomDomainResponseGetCustomDomainAttributeTypeOk(o.CustomDomain); ok { + toSerialize["CustomDomain"] = val + } + return toSerialize, nil +} + +type NullableDeleteCustomDomainResponse struct { + value *DeleteCustomDomainResponse + isSet bool +} + +func (v NullableDeleteCustomDomainResponse) Get() *DeleteCustomDomainResponse { + return v.value +} + +func (v *NullableDeleteCustomDomainResponse) Set(val *DeleteCustomDomainResponse) { + v.value = val + v.isSet = true +} + +func (v NullableDeleteCustomDomainResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableDeleteCustomDomainResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableDeleteCustomDomainResponse(val *DeleteCustomDomainResponse) *NullableDeleteCustomDomainResponse { + return &NullableDeleteCustomDomainResponse{value: val, isSet: true} +} + +func (v NullableDeleteCustomDomainResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableDeleteCustomDomainResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cdn/model_delete_distribution_response.go b/services/cdn/model_delete_distribution_response.go new file mode 100644 index 000000000..0ef54a210 --- /dev/null +++ b/services/cdn/model_delete_distribution_response.go @@ -0,0 +1,127 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +import ( + "encoding/json" +) + +// checks if the DeleteDistributionResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &DeleteDistributionResponse{} + +/* + types and functions for distribution +*/ + +// isModel +type DeleteDistributionResponseGetDistributionAttributeType = *Distribution +type DeleteDistributionResponseGetDistributionArgType = Distribution +type DeleteDistributionResponseGetDistributionRetType = Distribution + +func getDeleteDistributionResponseGetDistributionAttributeTypeOk(arg DeleteDistributionResponseGetDistributionAttributeType) (ret DeleteDistributionResponseGetDistributionRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDeleteDistributionResponseGetDistributionAttributeType(arg *DeleteDistributionResponseGetDistributionAttributeType, val DeleteDistributionResponseGetDistributionRetType) { + *arg = &val +} + +// DeleteDistributionResponse struct for DeleteDistributionResponse +type DeleteDistributionResponse struct { + Distribution DeleteDistributionResponseGetDistributionAttributeType `json:"distribution,omitempty"` +} + +// NewDeleteDistributionResponse instantiates a new DeleteDistributionResponse 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 NewDeleteDistributionResponse() *DeleteDistributionResponse { + this := DeleteDistributionResponse{} + return &this +} + +// NewDeleteDistributionResponseWithDefaults instantiates a new DeleteDistributionResponse 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 NewDeleteDistributionResponseWithDefaults() *DeleteDistributionResponse { + this := DeleteDistributionResponse{} + return &this +} + +// GetDistribution returns the Distribution field value if set, zero value otherwise. +func (o *DeleteDistributionResponse) GetDistribution() (res DeleteDistributionResponseGetDistributionRetType) { + res, _ = o.GetDistributionOk() + return +} + +// GetDistributionOk returns a tuple with the Distribution field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DeleteDistributionResponse) GetDistributionOk() (ret DeleteDistributionResponseGetDistributionRetType, ok bool) { + return getDeleteDistributionResponseGetDistributionAttributeTypeOk(o.Distribution) +} + +// HasDistribution returns a boolean if a field has been set. +func (o *DeleteDistributionResponse) HasDistribution() bool { + _, ok := o.GetDistributionOk() + return ok +} + +// SetDistribution gets a reference to the given Distribution and assigns it to the Distribution field. +func (o *DeleteDistributionResponse) SetDistribution(v DeleteDistributionResponseGetDistributionRetType) { + setDeleteDistributionResponseGetDistributionAttributeType(&o.Distribution, v) +} + +func (o DeleteDistributionResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getDeleteDistributionResponseGetDistributionAttributeTypeOk(o.Distribution); ok { + toSerialize["Distribution"] = val + } + return toSerialize, nil +} + +type NullableDeleteDistributionResponse struct { + value *DeleteDistributionResponse + isSet bool +} + +func (v NullableDeleteDistributionResponse) Get() *DeleteDistributionResponse { + return v.value +} + +func (v *NullableDeleteDistributionResponse) Set(val *DeleteDistributionResponse) { + v.value = val + v.isSet = true +} + +func (v NullableDeleteDistributionResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableDeleteDistributionResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableDeleteDistributionResponse(val *DeleteDistributionResponse) *NullableDeleteDistributionResponse { + return &NullableDeleteDistributionResponse{value: val, isSet: true} +} + +func (v NullableDeleteDistributionResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableDeleteDistributionResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cdn/model_distribution.go b/services/cdn/model_distribution.go new file mode 100644 index 000000000..69c327557 --- /dev/null +++ b/services/cdn/model_distribution.go @@ -0,0 +1,437 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +import ( + "encoding/json" + "time" +) + +// checks if the Distribution type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &Distribution{} + +/* + types and functions for config +*/ + +// isModel +type DistributionGetConfigAttributeType = *Config +type DistributionGetConfigArgType = Config +type DistributionGetConfigRetType = Config + +func getDistributionGetConfigAttributeTypeOk(arg DistributionGetConfigAttributeType) (ret DistributionGetConfigRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDistributionGetConfigAttributeType(arg *DistributionGetConfigAttributeType, val DistributionGetConfigRetType) { + *arg = &val +} + +/* + types and functions for createdAt +*/ + +// isDateTime +type DistributionGetCreatedAtAttributeType = *time.Time +type DistributionGetCreatedAtArgType = time.Time +type DistributionGetCreatedAtRetType = time.Time + +func getDistributionGetCreatedAtAttributeTypeOk(arg DistributionGetCreatedAtAttributeType) (ret DistributionGetCreatedAtRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDistributionGetCreatedAtAttributeType(arg *DistributionGetCreatedAtAttributeType, val DistributionGetCreatedAtRetType) { + *arg = &val +} + +/* + types and functions for domains +*/ + +// isArray +type DistributionGetDomainsAttributeType = *[]Domain +type DistributionGetDomainsArgType = []Domain +type DistributionGetDomainsRetType = []Domain + +func getDistributionGetDomainsAttributeTypeOk(arg DistributionGetDomainsAttributeType) (ret DistributionGetDomainsRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDistributionGetDomainsAttributeType(arg *DistributionGetDomainsAttributeType, val DistributionGetDomainsRetType) { + *arg = &val +} + +/* + types and functions for errors +*/ + +// isArray +type DistributionGetErrorsAttributeType = *[]StatusError +type DistributionGetErrorsArgType = []StatusError +type DistributionGetErrorsRetType = []StatusError + +func getDistributionGetErrorsAttributeTypeOk(arg DistributionGetErrorsAttributeType) (ret DistributionGetErrorsRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDistributionGetErrorsAttributeType(arg *DistributionGetErrorsAttributeType, val DistributionGetErrorsRetType) { + *arg = &val +} + +/* + types and functions for id +*/ + +// isNotNullableString +type DistributionGetIdAttributeType = *string + +func getDistributionGetIdAttributeTypeOk(arg DistributionGetIdAttributeType) (ret DistributionGetIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDistributionGetIdAttributeType(arg *DistributionGetIdAttributeType, val DistributionGetIdRetType) { + *arg = &val +} + +type DistributionGetIdArgType = string +type DistributionGetIdRetType = string + +/* + types and functions for projectId +*/ + +// isNotNullableString +type DistributionGetProjectIdAttributeType = *string + +func getDistributionGetProjectIdAttributeTypeOk(arg DistributionGetProjectIdAttributeType) (ret DistributionGetProjectIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDistributionGetProjectIdAttributeType(arg *DistributionGetProjectIdAttributeType, val DistributionGetProjectIdRetType) { + *arg = &val +} + +type DistributionGetProjectIdArgType = string +type DistributionGetProjectIdRetType = string + +/* + types and functions for status +*/ + +// isEnumRef +type DistributionGetStatusAttributeType = *string +type DistributionGetStatusArgType = string +type DistributionGetStatusRetType = string + +func getDistributionGetStatusAttributeTypeOk(arg DistributionGetStatusAttributeType) (ret DistributionGetStatusRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDistributionGetStatusAttributeType(arg *DistributionGetStatusAttributeType, val DistributionGetStatusRetType) { + *arg = &val +} + +/* + types and functions for updatedAt +*/ + +// isDateTime +type DistributionGetUpdatedAtAttributeType = *time.Time +type DistributionGetUpdatedAtArgType = time.Time +type DistributionGetUpdatedAtRetType = time.Time + +func getDistributionGetUpdatedAtAttributeTypeOk(arg DistributionGetUpdatedAtAttributeType) (ret DistributionGetUpdatedAtRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDistributionGetUpdatedAtAttributeType(arg *DistributionGetUpdatedAtAttributeType, val DistributionGetUpdatedAtRetType) { + *arg = &val +} + +// Distribution struct for Distribution +type Distribution struct { + // REQUIRED + Config DistributionGetConfigAttributeType `json:"config"` + // RFC3339 string defining when the distribution was created + // REQUIRED + CreatedAt DistributionGetCreatedAtAttributeType `json:"createdAt"` + // REQUIRED + Domains DistributionGetDomainsAttributeType `json:"domains"` + // This object may be present if, and only if the distribution has encountered an error state. + Errors DistributionGetErrorsAttributeType `json:"errors,omitempty"` + // REQUIRED + Id DistributionGetIdAttributeType `json:"id"` + // REQUIRED + ProjectId DistributionGetProjectIdAttributeType `json:"projectId"` + // - `CREATING`: The distribution was just created. All the relevant resources are created in the background. Once fully reconciled, this switches to `ACTIVE`. If there are any issues, the status changes to `ERROR`. You can look at the `errors` array to get more infos. - `ACTIVE`: The usual state. The desired configuration is synced, there are no errors - `UPDATING`: The state when there is a discrepancy between the desired and actual configuration state. This occurs right after an update. Will switch to `ACTIVE` or `ERROR`, depending on if synchronizing succeeds or not. - `DELETING`: The state right after a delete request was received. The distribution will stay in this status until all resources have been successfully removed, or until we encounter an `ERROR` state. **NOTE:** You can keep fetching the distribution while it is deleting. After successful deletion, trying to get a distribution will return a 404 Not Found response - `ERROR`: The error state. Look at the `errors` array for more info. + // REQUIRED + Status DistributionGetStatusAttributeType `json:"status"` + // RFC3339 string which returns the last time the distribution's configuration was modified. + // REQUIRED + UpdatedAt DistributionGetUpdatedAtAttributeType `json:"updatedAt"` +} + +type _Distribution Distribution + +// NewDistribution instantiates a new Distribution 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 NewDistribution(config DistributionGetConfigArgType, createdAt DistributionGetCreatedAtArgType, domains DistributionGetDomainsArgType, id DistributionGetIdArgType, projectId DistributionGetProjectIdArgType, status DistributionGetStatusArgType, updatedAt DistributionGetUpdatedAtArgType) *Distribution { + this := Distribution{} + setDistributionGetConfigAttributeType(&this.Config, config) + setDistributionGetCreatedAtAttributeType(&this.CreatedAt, createdAt) + setDistributionGetDomainsAttributeType(&this.Domains, domains) + setDistributionGetIdAttributeType(&this.Id, id) + setDistributionGetProjectIdAttributeType(&this.ProjectId, projectId) + setDistributionGetStatusAttributeType(&this.Status, status) + setDistributionGetUpdatedAtAttributeType(&this.UpdatedAt, updatedAt) + return &this +} + +// NewDistributionWithDefaults instantiates a new Distribution 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 NewDistributionWithDefaults() *Distribution { + this := Distribution{} + return &this +} + +// GetConfig returns the Config field value +func (o *Distribution) GetConfig() (ret DistributionGetConfigRetType) { + ret, _ = o.GetConfigOk() + return ret +} + +// GetConfigOk returns a tuple with the Config field value +// and a boolean to check if the value has been set. +func (o *Distribution) GetConfigOk() (ret DistributionGetConfigRetType, ok bool) { + return getDistributionGetConfigAttributeTypeOk(o.Config) +} + +// SetConfig sets field value +func (o *Distribution) SetConfig(v DistributionGetConfigRetType) { + setDistributionGetConfigAttributeType(&o.Config, v) +} + +// GetCreatedAt returns the CreatedAt field value +func (o *Distribution) GetCreatedAt() (ret DistributionGetCreatedAtRetType) { + 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 *Distribution) GetCreatedAtOk() (ret DistributionGetCreatedAtRetType, ok bool) { + return getDistributionGetCreatedAtAttributeTypeOk(o.CreatedAt) +} + +// SetCreatedAt sets field value +func (o *Distribution) SetCreatedAt(v DistributionGetCreatedAtRetType) { + setDistributionGetCreatedAtAttributeType(&o.CreatedAt, v) +} + +// GetDomains returns the Domains field value +func (o *Distribution) GetDomains() (ret DistributionGetDomainsRetType) { + ret, _ = o.GetDomainsOk() + return ret +} + +// GetDomainsOk returns a tuple with the Domains field value +// and a boolean to check if the value has been set. +func (o *Distribution) GetDomainsOk() (ret DistributionGetDomainsRetType, ok bool) { + return getDistributionGetDomainsAttributeTypeOk(o.Domains) +} + +// SetDomains sets field value +func (o *Distribution) SetDomains(v DistributionGetDomainsRetType) { + setDistributionGetDomainsAttributeType(&o.Domains, v) +} + +// GetErrors returns the Errors field value if set, zero value otherwise. +func (o *Distribution) GetErrors() (res DistributionGetErrorsRetType) { + res, _ = o.GetErrorsOk() + return +} + +// GetErrorsOk returns a tuple with the Errors field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Distribution) GetErrorsOk() (ret DistributionGetErrorsRetType, ok bool) { + return getDistributionGetErrorsAttributeTypeOk(o.Errors) +} + +// HasErrors returns a boolean if a field has been set. +func (o *Distribution) HasErrors() bool { + _, ok := o.GetErrorsOk() + return ok +} + +// SetErrors gets a reference to the given []StatusError and assigns it to the Errors field. +func (o *Distribution) SetErrors(v DistributionGetErrorsRetType) { + setDistributionGetErrorsAttributeType(&o.Errors, v) +} + +// GetId returns the Id field value +func (o *Distribution) GetId() (ret DistributionGetIdRetType) { + 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 *Distribution) GetIdOk() (ret DistributionGetIdRetType, ok bool) { + return getDistributionGetIdAttributeTypeOk(o.Id) +} + +// SetId sets field value +func (o *Distribution) SetId(v DistributionGetIdRetType) { + setDistributionGetIdAttributeType(&o.Id, v) +} + +// GetProjectId returns the ProjectId field value +func (o *Distribution) GetProjectId() (ret DistributionGetProjectIdRetType) { + ret, _ = o.GetProjectIdOk() + return ret +} + +// GetProjectIdOk returns a tuple with the ProjectId field value +// and a boolean to check if the value has been set. +func (o *Distribution) GetProjectIdOk() (ret DistributionGetProjectIdRetType, ok bool) { + return getDistributionGetProjectIdAttributeTypeOk(o.ProjectId) +} + +// SetProjectId sets field value +func (o *Distribution) SetProjectId(v DistributionGetProjectIdRetType) { + setDistributionGetProjectIdAttributeType(&o.ProjectId, v) +} + +// GetStatus returns the Status field value +func (o *Distribution) GetStatus() (ret DistributionGetStatusRetType) { + ret, _ = o.GetStatusOk() + return ret +} + +// GetStatusOk returns a tuple with the Status field value +// and a boolean to check if the value has been set. +func (o *Distribution) GetStatusOk() (ret DistributionGetStatusRetType, ok bool) { + return getDistributionGetStatusAttributeTypeOk(o.Status) +} + +// SetStatus sets field value +func (o *Distribution) SetStatus(v DistributionGetStatusRetType) { + setDistributionGetStatusAttributeType(&o.Status, v) +} + +// GetUpdatedAt returns the UpdatedAt field value +func (o *Distribution) GetUpdatedAt() (ret DistributionGetUpdatedAtRetType) { + ret, _ = o.GetUpdatedAtOk() + return ret +} + +// GetUpdatedAtOk returns a tuple with the UpdatedAt field value +// and a boolean to check if the value has been set. +func (o *Distribution) GetUpdatedAtOk() (ret DistributionGetUpdatedAtRetType, ok bool) { + return getDistributionGetUpdatedAtAttributeTypeOk(o.UpdatedAt) +} + +// SetUpdatedAt sets field value +func (o *Distribution) SetUpdatedAt(v DistributionGetUpdatedAtRetType) { + setDistributionGetUpdatedAtAttributeType(&o.UpdatedAt, v) +} + +func (o Distribution) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getDistributionGetConfigAttributeTypeOk(o.Config); ok { + toSerialize["Config"] = val + } + if val, ok := getDistributionGetCreatedAtAttributeTypeOk(o.CreatedAt); ok { + toSerialize["CreatedAt"] = val + } + if val, ok := getDistributionGetDomainsAttributeTypeOk(o.Domains); ok { + toSerialize["Domains"] = val + } + if val, ok := getDistributionGetErrorsAttributeTypeOk(o.Errors); ok { + toSerialize["Errors"] = val + } + if val, ok := getDistributionGetIdAttributeTypeOk(o.Id); ok { + toSerialize["Id"] = val + } + if val, ok := getDistributionGetProjectIdAttributeTypeOk(o.ProjectId); ok { + toSerialize["ProjectId"] = val + } + if val, ok := getDistributionGetStatusAttributeTypeOk(o.Status); ok { + toSerialize["Status"] = val + } + if val, ok := getDistributionGetUpdatedAtAttributeTypeOk(o.UpdatedAt); ok { + toSerialize["UpdatedAt"] = val + } + return toSerialize, nil +} + +type NullableDistribution struct { + value *Distribution + isSet bool +} + +func (v NullableDistribution) Get() *Distribution { + return v.value +} + +func (v *NullableDistribution) Set(val *Distribution) { + v.value = val + v.isSet = true +} + +func (v NullableDistribution) IsSet() bool { + return v.isSet +} + +func (v *NullableDistribution) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableDistribution(val *Distribution) *NullableDistribution { + return &NullableDistribution{value: val, isSet: true} +} + +func (v NullableDistribution) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableDistribution) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cdn/model_distribution_statistics_record.go b/services/cdn/model_distribution_statistics_record.go new file mode 100644 index 000000000..5b44d03d0 --- /dev/null +++ b/services/cdn/model_distribution_statistics_record.go @@ -0,0 +1,346 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +import ( + "encoding/json" + "time" +) + +// checks if the DistributionStatisticsRecord type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &DistributionStatisticsRecord{} + +/* + types and functions for cachedRequests +*/ + +// isLong +type DistributionStatisticsRecordGetCachedRequestsAttributeType = *int64 +type DistributionStatisticsRecordGetCachedRequestsArgType = int64 +type DistributionStatisticsRecordGetCachedRequestsRetType = int64 + +func getDistributionStatisticsRecordGetCachedRequestsAttributeTypeOk(arg DistributionStatisticsRecordGetCachedRequestsAttributeType) (ret DistributionStatisticsRecordGetCachedRequestsRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDistributionStatisticsRecordGetCachedRequestsAttributeType(arg *DistributionStatisticsRecordGetCachedRequestsAttributeType, val DistributionStatisticsRecordGetCachedRequestsRetType) { + *arg = &val +} + +/* + types and functions for totalRequests +*/ + +// isLong +type DistributionStatisticsRecordGetTotalRequestsAttributeType = *int64 +type DistributionStatisticsRecordGetTotalRequestsArgType = int64 +type DistributionStatisticsRecordGetTotalRequestsRetType = int64 + +func getDistributionStatisticsRecordGetTotalRequestsAttributeTypeOk(arg DistributionStatisticsRecordGetTotalRequestsAttributeType) (ret DistributionStatisticsRecordGetTotalRequestsRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDistributionStatisticsRecordGetTotalRequestsAttributeType(arg *DistributionStatisticsRecordGetTotalRequestsAttributeType, val DistributionStatisticsRecordGetTotalRequestsRetType) { + *arg = &val +} + +/* + types and functions for totalTrafficBytes +*/ + +// isLong +type DistributionStatisticsRecordGetTotalTrafficBytesAttributeType = *int64 +type DistributionStatisticsRecordGetTotalTrafficBytesArgType = int64 +type DistributionStatisticsRecordGetTotalTrafficBytesRetType = int64 + +func getDistributionStatisticsRecordGetTotalTrafficBytesAttributeTypeOk(arg DistributionStatisticsRecordGetTotalTrafficBytesAttributeType) (ret DistributionStatisticsRecordGetTotalTrafficBytesRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDistributionStatisticsRecordGetTotalTrafficBytesAttributeType(arg *DistributionStatisticsRecordGetTotalTrafficBytesAttributeType, val DistributionStatisticsRecordGetTotalTrafficBytesRetType) { + *arg = &val +} + +/* + types and functions for end +*/ + +// isDateTime +type DistributionStatisticsRecordGetEndAttributeType = *time.Time +type DistributionStatisticsRecordGetEndArgType = time.Time +type DistributionStatisticsRecordGetEndRetType = time.Time + +func getDistributionStatisticsRecordGetEndAttributeTypeOk(arg DistributionStatisticsRecordGetEndAttributeType) (ret DistributionStatisticsRecordGetEndRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDistributionStatisticsRecordGetEndAttributeType(arg *DistributionStatisticsRecordGetEndAttributeType, val DistributionStatisticsRecordGetEndRetType) { + *arg = &val +} + +/* + types and functions for regions +*/ + +// isModel +type DistributionStatisticsRecordGetRegionsAttributeType = *DistributionStatisticsRecordRegions +type DistributionStatisticsRecordGetRegionsArgType = DistributionStatisticsRecordRegions +type DistributionStatisticsRecordGetRegionsRetType = DistributionStatisticsRecordRegions + +func getDistributionStatisticsRecordGetRegionsAttributeTypeOk(arg DistributionStatisticsRecordGetRegionsAttributeType) (ret DistributionStatisticsRecordGetRegionsRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDistributionStatisticsRecordGetRegionsAttributeType(arg *DistributionStatisticsRecordGetRegionsAttributeType, val DistributionStatisticsRecordGetRegionsRetType) { + *arg = &val +} + +/* + types and functions for start +*/ + +// isDateTime +type DistributionStatisticsRecordGetStartAttributeType = *time.Time +type DistributionStatisticsRecordGetStartArgType = time.Time +type DistributionStatisticsRecordGetStartRetType = time.Time + +func getDistributionStatisticsRecordGetStartAttributeTypeOk(arg DistributionStatisticsRecordGetStartAttributeType) (ret DistributionStatisticsRecordGetStartRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDistributionStatisticsRecordGetStartAttributeType(arg *DistributionStatisticsRecordGetStartAttributeType, val DistributionStatisticsRecordGetStartRetType) { + *arg = &val +} + +// DistributionStatisticsRecord Aggregated statistics of a distribution during a time interval +type DistributionStatisticsRecord struct { + // Number of cached requests that were served + // REQUIRED + CachedRequests DistributionStatisticsRecordGetCachedRequestsAttributeType `json:"cachedRequests"` + // Total number of requests that were served + // REQUIRED + TotalRequests DistributionStatisticsRecordGetTotalRequestsAttributeType `json:"totalRequests"` + // Total traffic in bytes that occurred during the time interval + // REQUIRED + TotalTrafficBytes DistributionStatisticsRecordGetTotalTrafficBytesAttributeType `json:"totalTrafficBytes"` + // Exclusive end of the time interval the statistics refer to + // REQUIRED + End DistributionStatisticsRecordGetEndAttributeType `json:"end"` + // REQUIRED + Regions DistributionStatisticsRecordGetRegionsAttributeType `json:"regions"` + // Start of the time interval the statistics refer to + // REQUIRED + Start DistributionStatisticsRecordGetStartAttributeType `json:"start"` +} + +type _DistributionStatisticsRecord DistributionStatisticsRecord + +// NewDistributionStatisticsRecord instantiates a new DistributionStatisticsRecord 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 NewDistributionStatisticsRecord(cachedRequests DistributionStatisticsRecordGetCachedRequestsArgType, totalRequests DistributionStatisticsRecordGetTotalRequestsArgType, totalTrafficBytes DistributionStatisticsRecordGetTotalTrafficBytesArgType, end DistributionStatisticsRecordGetEndArgType, regions DistributionStatisticsRecordGetRegionsArgType, start DistributionStatisticsRecordGetStartArgType) *DistributionStatisticsRecord { + this := DistributionStatisticsRecord{} + setDistributionStatisticsRecordGetCachedRequestsAttributeType(&this.CachedRequests, cachedRequests) + setDistributionStatisticsRecordGetTotalRequestsAttributeType(&this.TotalRequests, totalRequests) + setDistributionStatisticsRecordGetTotalTrafficBytesAttributeType(&this.TotalTrafficBytes, totalTrafficBytes) + setDistributionStatisticsRecordGetEndAttributeType(&this.End, end) + setDistributionStatisticsRecordGetRegionsAttributeType(&this.Regions, regions) + setDistributionStatisticsRecordGetStartAttributeType(&this.Start, start) + return &this +} + +// NewDistributionStatisticsRecordWithDefaults instantiates a new DistributionStatisticsRecord 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 NewDistributionStatisticsRecordWithDefaults() *DistributionStatisticsRecord { + this := DistributionStatisticsRecord{} + return &this +} + +// GetCachedRequests returns the CachedRequests field value +func (o *DistributionStatisticsRecord) GetCachedRequests() (ret DistributionStatisticsRecordGetCachedRequestsRetType) { + ret, _ = o.GetCachedRequestsOk() + return ret +} + +// GetCachedRequestsOk returns a tuple with the CachedRequests field value +// and a boolean to check if the value has been set. +func (o *DistributionStatisticsRecord) GetCachedRequestsOk() (ret DistributionStatisticsRecordGetCachedRequestsRetType, ok bool) { + return getDistributionStatisticsRecordGetCachedRequestsAttributeTypeOk(o.CachedRequests) +} + +// SetCachedRequests sets field value +func (o *DistributionStatisticsRecord) SetCachedRequests(v DistributionStatisticsRecordGetCachedRequestsRetType) { + setDistributionStatisticsRecordGetCachedRequestsAttributeType(&o.CachedRequests, v) +} + +// GetTotalRequests returns the TotalRequests field value +func (o *DistributionStatisticsRecord) GetTotalRequests() (ret DistributionStatisticsRecordGetTotalRequestsRetType) { + ret, _ = o.GetTotalRequestsOk() + return ret +} + +// GetTotalRequestsOk returns a tuple with the TotalRequests field value +// and a boolean to check if the value has been set. +func (o *DistributionStatisticsRecord) GetTotalRequestsOk() (ret DistributionStatisticsRecordGetTotalRequestsRetType, ok bool) { + return getDistributionStatisticsRecordGetTotalRequestsAttributeTypeOk(o.TotalRequests) +} + +// SetTotalRequests sets field value +func (o *DistributionStatisticsRecord) SetTotalRequests(v DistributionStatisticsRecordGetTotalRequestsRetType) { + setDistributionStatisticsRecordGetTotalRequestsAttributeType(&o.TotalRequests, v) +} + +// GetTotalTrafficBytes returns the TotalTrafficBytes field value +func (o *DistributionStatisticsRecord) GetTotalTrafficBytes() (ret DistributionStatisticsRecordGetTotalTrafficBytesRetType) { + ret, _ = o.GetTotalTrafficBytesOk() + return ret +} + +// GetTotalTrafficBytesOk returns a tuple with the TotalTrafficBytes field value +// and a boolean to check if the value has been set. +func (o *DistributionStatisticsRecord) GetTotalTrafficBytesOk() (ret DistributionStatisticsRecordGetTotalTrafficBytesRetType, ok bool) { + return getDistributionStatisticsRecordGetTotalTrafficBytesAttributeTypeOk(o.TotalTrafficBytes) +} + +// SetTotalTrafficBytes sets field value +func (o *DistributionStatisticsRecord) SetTotalTrafficBytes(v DistributionStatisticsRecordGetTotalTrafficBytesRetType) { + setDistributionStatisticsRecordGetTotalTrafficBytesAttributeType(&o.TotalTrafficBytes, v) +} + +// GetEnd returns the End field value +func (o *DistributionStatisticsRecord) GetEnd() (ret DistributionStatisticsRecordGetEndRetType) { + ret, _ = o.GetEndOk() + return ret +} + +// GetEndOk returns a tuple with the End field value +// and a boolean to check if the value has been set. +func (o *DistributionStatisticsRecord) GetEndOk() (ret DistributionStatisticsRecordGetEndRetType, ok bool) { + return getDistributionStatisticsRecordGetEndAttributeTypeOk(o.End) +} + +// SetEnd sets field value +func (o *DistributionStatisticsRecord) SetEnd(v DistributionStatisticsRecordGetEndRetType) { + setDistributionStatisticsRecordGetEndAttributeType(&o.End, v) +} + +// GetRegions returns the Regions field value +func (o *DistributionStatisticsRecord) GetRegions() (ret DistributionStatisticsRecordGetRegionsRetType) { + ret, _ = o.GetRegionsOk() + return ret +} + +// GetRegionsOk returns a tuple with the Regions field value +// and a boolean to check if the value has been set. +func (o *DistributionStatisticsRecord) GetRegionsOk() (ret DistributionStatisticsRecordGetRegionsRetType, ok bool) { + return getDistributionStatisticsRecordGetRegionsAttributeTypeOk(o.Regions) +} + +// SetRegions sets field value +func (o *DistributionStatisticsRecord) SetRegions(v DistributionStatisticsRecordGetRegionsRetType) { + setDistributionStatisticsRecordGetRegionsAttributeType(&o.Regions, v) +} + +// GetStart returns the Start field value +func (o *DistributionStatisticsRecord) GetStart() (ret DistributionStatisticsRecordGetStartRetType) { + ret, _ = o.GetStartOk() + return ret +} + +// GetStartOk returns a tuple with the Start field value +// and a boolean to check if the value has been set. +func (o *DistributionStatisticsRecord) GetStartOk() (ret DistributionStatisticsRecordGetStartRetType, ok bool) { + return getDistributionStatisticsRecordGetStartAttributeTypeOk(o.Start) +} + +// SetStart sets field value +func (o *DistributionStatisticsRecord) SetStart(v DistributionStatisticsRecordGetStartRetType) { + setDistributionStatisticsRecordGetStartAttributeType(&o.Start, v) +} + +func (o DistributionStatisticsRecord) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getDistributionStatisticsRecordGetCachedRequestsAttributeTypeOk(o.CachedRequests); ok { + toSerialize["CachedRequests"] = val + } + if val, ok := getDistributionStatisticsRecordGetTotalRequestsAttributeTypeOk(o.TotalRequests); ok { + toSerialize["TotalRequests"] = val + } + if val, ok := getDistributionStatisticsRecordGetTotalTrafficBytesAttributeTypeOk(o.TotalTrafficBytes); ok { + toSerialize["TotalTrafficBytes"] = val + } + if val, ok := getDistributionStatisticsRecordGetEndAttributeTypeOk(o.End); ok { + toSerialize["End"] = val + } + if val, ok := getDistributionStatisticsRecordGetRegionsAttributeTypeOk(o.Regions); ok { + toSerialize["Regions"] = val + } + if val, ok := getDistributionStatisticsRecordGetStartAttributeTypeOk(o.Start); ok { + toSerialize["Start"] = val + } + return toSerialize, nil +} + +type NullableDistributionStatisticsRecord struct { + value *DistributionStatisticsRecord + isSet bool +} + +func (v NullableDistributionStatisticsRecord) Get() *DistributionStatisticsRecord { + return v.value +} + +func (v *NullableDistributionStatisticsRecord) Set(val *DistributionStatisticsRecord) { + v.value = val + v.isSet = true +} + +func (v NullableDistributionStatisticsRecord) IsSet() bool { + return v.isSet +} + +func (v *NullableDistributionStatisticsRecord) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableDistributionStatisticsRecord(val *DistributionStatisticsRecord) *NullableDistributionStatisticsRecord { + return &NullableDistributionStatisticsRecord{value: val, isSet: true} +} + +func (v NullableDistributionStatisticsRecord) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableDistributionStatisticsRecord) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cdn/model_distribution_statistics_record_all_of.go b/services/cdn/model_distribution_statistics_record_all_of.go new file mode 100644 index 000000000..08e87c5ec --- /dev/null +++ b/services/cdn/model_distribution_statistics_record_all_of.go @@ -0,0 +1,214 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +import ( + "encoding/json" + "time" +) + +// checks if the DistributionStatisticsRecordAllOf type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &DistributionStatisticsRecordAllOf{} + +/* + types and functions for end +*/ + +// isDateTime +type DistributionStatisticsRecordAllOfGetEndAttributeType = *time.Time +type DistributionStatisticsRecordAllOfGetEndArgType = time.Time +type DistributionStatisticsRecordAllOfGetEndRetType = time.Time + +func getDistributionStatisticsRecordAllOfGetEndAttributeTypeOk(arg DistributionStatisticsRecordAllOfGetEndAttributeType) (ret DistributionStatisticsRecordAllOfGetEndRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDistributionStatisticsRecordAllOfGetEndAttributeType(arg *DistributionStatisticsRecordAllOfGetEndAttributeType, val DistributionStatisticsRecordAllOfGetEndRetType) { + *arg = &val +} + +/* + types and functions for regions +*/ + +// isModel +type DistributionStatisticsRecordAllOfGetRegionsAttributeType = *DistributionStatisticsRecordRegions +type DistributionStatisticsRecordAllOfGetRegionsArgType = DistributionStatisticsRecordRegions +type DistributionStatisticsRecordAllOfGetRegionsRetType = DistributionStatisticsRecordRegions + +func getDistributionStatisticsRecordAllOfGetRegionsAttributeTypeOk(arg DistributionStatisticsRecordAllOfGetRegionsAttributeType) (ret DistributionStatisticsRecordAllOfGetRegionsRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDistributionStatisticsRecordAllOfGetRegionsAttributeType(arg *DistributionStatisticsRecordAllOfGetRegionsAttributeType, val DistributionStatisticsRecordAllOfGetRegionsRetType) { + *arg = &val +} + +/* + types and functions for start +*/ + +// isDateTime +type DistributionStatisticsRecordAllOfGetStartAttributeType = *time.Time +type DistributionStatisticsRecordAllOfGetStartArgType = time.Time +type DistributionStatisticsRecordAllOfGetStartRetType = time.Time + +func getDistributionStatisticsRecordAllOfGetStartAttributeTypeOk(arg DistributionStatisticsRecordAllOfGetStartAttributeType) (ret DistributionStatisticsRecordAllOfGetStartRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDistributionStatisticsRecordAllOfGetStartAttributeType(arg *DistributionStatisticsRecordAllOfGetStartAttributeType, val DistributionStatisticsRecordAllOfGetStartRetType) { + *arg = &val +} + +// DistributionStatisticsRecordAllOf struct for DistributionStatisticsRecordAllOf +type DistributionStatisticsRecordAllOf struct { + // Exclusive end of the time interval the statistics refer to + // REQUIRED + End DistributionStatisticsRecordAllOfGetEndAttributeType `json:"end"` + // REQUIRED + Regions DistributionStatisticsRecordAllOfGetRegionsAttributeType `json:"regions"` + // Start of the time interval the statistics refer to + // REQUIRED + Start DistributionStatisticsRecordAllOfGetStartAttributeType `json:"start"` +} + +type _DistributionStatisticsRecordAllOf DistributionStatisticsRecordAllOf + +// NewDistributionStatisticsRecordAllOf instantiates a new DistributionStatisticsRecordAllOf 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 NewDistributionStatisticsRecordAllOf(end DistributionStatisticsRecordAllOfGetEndArgType, regions DistributionStatisticsRecordAllOfGetRegionsArgType, start DistributionStatisticsRecordAllOfGetStartArgType) *DistributionStatisticsRecordAllOf { + this := DistributionStatisticsRecordAllOf{} + setDistributionStatisticsRecordAllOfGetEndAttributeType(&this.End, end) + setDistributionStatisticsRecordAllOfGetRegionsAttributeType(&this.Regions, regions) + setDistributionStatisticsRecordAllOfGetStartAttributeType(&this.Start, start) + return &this +} + +// NewDistributionStatisticsRecordAllOfWithDefaults instantiates a new DistributionStatisticsRecordAllOf 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 NewDistributionStatisticsRecordAllOfWithDefaults() *DistributionStatisticsRecordAllOf { + this := DistributionStatisticsRecordAllOf{} + return &this +} + +// GetEnd returns the End field value +func (o *DistributionStatisticsRecordAllOf) GetEnd() (ret DistributionStatisticsRecordAllOfGetEndRetType) { + ret, _ = o.GetEndOk() + return ret +} + +// GetEndOk returns a tuple with the End field value +// and a boolean to check if the value has been set. +func (o *DistributionStatisticsRecordAllOf) GetEndOk() (ret DistributionStatisticsRecordAllOfGetEndRetType, ok bool) { + return getDistributionStatisticsRecordAllOfGetEndAttributeTypeOk(o.End) +} + +// SetEnd sets field value +func (o *DistributionStatisticsRecordAllOf) SetEnd(v DistributionStatisticsRecordAllOfGetEndRetType) { + setDistributionStatisticsRecordAllOfGetEndAttributeType(&o.End, v) +} + +// GetRegions returns the Regions field value +func (o *DistributionStatisticsRecordAllOf) GetRegions() (ret DistributionStatisticsRecordAllOfGetRegionsRetType) { + ret, _ = o.GetRegionsOk() + return ret +} + +// GetRegionsOk returns a tuple with the Regions field value +// and a boolean to check if the value has been set. +func (o *DistributionStatisticsRecordAllOf) GetRegionsOk() (ret DistributionStatisticsRecordAllOfGetRegionsRetType, ok bool) { + return getDistributionStatisticsRecordAllOfGetRegionsAttributeTypeOk(o.Regions) +} + +// SetRegions sets field value +func (o *DistributionStatisticsRecordAllOf) SetRegions(v DistributionStatisticsRecordAllOfGetRegionsRetType) { + setDistributionStatisticsRecordAllOfGetRegionsAttributeType(&o.Regions, v) +} + +// GetStart returns the Start field value +func (o *DistributionStatisticsRecordAllOf) GetStart() (ret DistributionStatisticsRecordAllOfGetStartRetType) { + ret, _ = o.GetStartOk() + return ret +} + +// GetStartOk returns a tuple with the Start field value +// and a boolean to check if the value has been set. +func (o *DistributionStatisticsRecordAllOf) GetStartOk() (ret DistributionStatisticsRecordAllOfGetStartRetType, ok bool) { + return getDistributionStatisticsRecordAllOfGetStartAttributeTypeOk(o.Start) +} + +// SetStart sets field value +func (o *DistributionStatisticsRecordAllOf) SetStart(v DistributionStatisticsRecordAllOfGetStartRetType) { + setDistributionStatisticsRecordAllOfGetStartAttributeType(&o.Start, v) +} + +func (o DistributionStatisticsRecordAllOf) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getDistributionStatisticsRecordAllOfGetEndAttributeTypeOk(o.End); ok { + toSerialize["End"] = val + } + if val, ok := getDistributionStatisticsRecordAllOfGetRegionsAttributeTypeOk(o.Regions); ok { + toSerialize["Regions"] = val + } + if val, ok := getDistributionStatisticsRecordAllOfGetStartAttributeTypeOk(o.Start); ok { + toSerialize["Start"] = val + } + return toSerialize, nil +} + +type NullableDistributionStatisticsRecordAllOf struct { + value *DistributionStatisticsRecordAllOf + isSet bool +} + +func (v NullableDistributionStatisticsRecordAllOf) Get() *DistributionStatisticsRecordAllOf { + return v.value +} + +func (v *NullableDistributionStatisticsRecordAllOf) Set(val *DistributionStatisticsRecordAllOf) { + v.value = val + v.isSet = true +} + +func (v NullableDistributionStatisticsRecordAllOf) IsSet() bool { + return v.isSet +} + +func (v *NullableDistributionStatisticsRecordAllOf) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableDistributionStatisticsRecordAllOf(val *DistributionStatisticsRecordAllOf) *NullableDistributionStatisticsRecordAllOf { + return &NullableDistributionStatisticsRecordAllOf{value: val, isSet: true} +} + +func (v NullableDistributionStatisticsRecordAllOf) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableDistributionStatisticsRecordAllOf) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cdn/model_distribution_statistics_record_entry.go b/services/cdn/model_distribution_statistics_record_entry.go new file mode 100644 index 000000000..cf3b12326 --- /dev/null +++ b/services/cdn/model_distribution_statistics_record_entry.go @@ -0,0 +1,214 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +import ( + "encoding/json" +) + +// checks if the DistributionStatisticsRecordEntry type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &DistributionStatisticsRecordEntry{} + +/* + types and functions for cachedRequests +*/ + +// isLong +type DistributionStatisticsRecordEntryGetCachedRequestsAttributeType = *int64 +type DistributionStatisticsRecordEntryGetCachedRequestsArgType = int64 +type DistributionStatisticsRecordEntryGetCachedRequestsRetType = int64 + +func getDistributionStatisticsRecordEntryGetCachedRequestsAttributeTypeOk(arg DistributionStatisticsRecordEntryGetCachedRequestsAttributeType) (ret DistributionStatisticsRecordEntryGetCachedRequestsRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDistributionStatisticsRecordEntryGetCachedRequestsAttributeType(arg *DistributionStatisticsRecordEntryGetCachedRequestsAttributeType, val DistributionStatisticsRecordEntryGetCachedRequestsRetType) { + *arg = &val +} + +/* + types and functions for totalRequests +*/ + +// isLong +type DistributionStatisticsRecordEntryGetTotalRequestsAttributeType = *int64 +type DistributionStatisticsRecordEntryGetTotalRequestsArgType = int64 +type DistributionStatisticsRecordEntryGetTotalRequestsRetType = int64 + +func getDistributionStatisticsRecordEntryGetTotalRequestsAttributeTypeOk(arg DistributionStatisticsRecordEntryGetTotalRequestsAttributeType) (ret DistributionStatisticsRecordEntryGetTotalRequestsRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDistributionStatisticsRecordEntryGetTotalRequestsAttributeType(arg *DistributionStatisticsRecordEntryGetTotalRequestsAttributeType, val DistributionStatisticsRecordEntryGetTotalRequestsRetType) { + *arg = &val +} + +/* + types and functions for totalTrafficBytes +*/ + +// isLong +type DistributionStatisticsRecordEntryGetTotalTrafficBytesAttributeType = *int64 +type DistributionStatisticsRecordEntryGetTotalTrafficBytesArgType = int64 +type DistributionStatisticsRecordEntryGetTotalTrafficBytesRetType = int64 + +func getDistributionStatisticsRecordEntryGetTotalTrafficBytesAttributeTypeOk(arg DistributionStatisticsRecordEntryGetTotalTrafficBytesAttributeType) (ret DistributionStatisticsRecordEntryGetTotalTrafficBytesRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDistributionStatisticsRecordEntryGetTotalTrafficBytesAttributeType(arg *DistributionStatisticsRecordEntryGetTotalTrafficBytesAttributeType, val DistributionStatisticsRecordEntryGetTotalTrafficBytesRetType) { + *arg = &val +} + +// DistributionStatisticsRecordEntry struct for DistributionStatisticsRecordEntry +type DistributionStatisticsRecordEntry struct { + // Number of cached requests that were served + // REQUIRED + CachedRequests DistributionStatisticsRecordEntryGetCachedRequestsAttributeType `json:"cachedRequests"` + // Total number of requests that were served + // REQUIRED + TotalRequests DistributionStatisticsRecordEntryGetTotalRequestsAttributeType `json:"totalRequests"` + // Total traffic in bytes that occurred during the time interval + // REQUIRED + TotalTrafficBytes DistributionStatisticsRecordEntryGetTotalTrafficBytesAttributeType `json:"totalTrafficBytes"` +} + +type _DistributionStatisticsRecordEntry DistributionStatisticsRecordEntry + +// NewDistributionStatisticsRecordEntry instantiates a new DistributionStatisticsRecordEntry 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 NewDistributionStatisticsRecordEntry(cachedRequests DistributionStatisticsRecordEntryGetCachedRequestsArgType, totalRequests DistributionStatisticsRecordEntryGetTotalRequestsArgType, totalTrafficBytes DistributionStatisticsRecordEntryGetTotalTrafficBytesArgType) *DistributionStatisticsRecordEntry { + this := DistributionStatisticsRecordEntry{} + setDistributionStatisticsRecordEntryGetCachedRequestsAttributeType(&this.CachedRequests, cachedRequests) + setDistributionStatisticsRecordEntryGetTotalRequestsAttributeType(&this.TotalRequests, totalRequests) + setDistributionStatisticsRecordEntryGetTotalTrafficBytesAttributeType(&this.TotalTrafficBytes, totalTrafficBytes) + return &this +} + +// NewDistributionStatisticsRecordEntryWithDefaults instantiates a new DistributionStatisticsRecordEntry 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 NewDistributionStatisticsRecordEntryWithDefaults() *DistributionStatisticsRecordEntry { + this := DistributionStatisticsRecordEntry{} + return &this +} + +// GetCachedRequests returns the CachedRequests field value +func (o *DistributionStatisticsRecordEntry) GetCachedRequests() (ret DistributionStatisticsRecordEntryGetCachedRequestsRetType) { + ret, _ = o.GetCachedRequestsOk() + return ret +} + +// GetCachedRequestsOk returns a tuple with the CachedRequests field value +// and a boolean to check if the value has been set. +func (o *DistributionStatisticsRecordEntry) GetCachedRequestsOk() (ret DistributionStatisticsRecordEntryGetCachedRequestsRetType, ok bool) { + return getDistributionStatisticsRecordEntryGetCachedRequestsAttributeTypeOk(o.CachedRequests) +} + +// SetCachedRequests sets field value +func (o *DistributionStatisticsRecordEntry) SetCachedRequests(v DistributionStatisticsRecordEntryGetCachedRequestsRetType) { + setDistributionStatisticsRecordEntryGetCachedRequestsAttributeType(&o.CachedRequests, v) +} + +// GetTotalRequests returns the TotalRequests field value +func (o *DistributionStatisticsRecordEntry) GetTotalRequests() (ret DistributionStatisticsRecordEntryGetTotalRequestsRetType) { + ret, _ = o.GetTotalRequestsOk() + return ret +} + +// GetTotalRequestsOk returns a tuple with the TotalRequests field value +// and a boolean to check if the value has been set. +func (o *DistributionStatisticsRecordEntry) GetTotalRequestsOk() (ret DistributionStatisticsRecordEntryGetTotalRequestsRetType, ok bool) { + return getDistributionStatisticsRecordEntryGetTotalRequestsAttributeTypeOk(o.TotalRequests) +} + +// SetTotalRequests sets field value +func (o *DistributionStatisticsRecordEntry) SetTotalRequests(v DistributionStatisticsRecordEntryGetTotalRequestsRetType) { + setDistributionStatisticsRecordEntryGetTotalRequestsAttributeType(&o.TotalRequests, v) +} + +// GetTotalTrafficBytes returns the TotalTrafficBytes field value +func (o *DistributionStatisticsRecordEntry) GetTotalTrafficBytes() (ret DistributionStatisticsRecordEntryGetTotalTrafficBytesRetType) { + ret, _ = o.GetTotalTrafficBytesOk() + return ret +} + +// GetTotalTrafficBytesOk returns a tuple with the TotalTrafficBytes field value +// and a boolean to check if the value has been set. +func (o *DistributionStatisticsRecordEntry) GetTotalTrafficBytesOk() (ret DistributionStatisticsRecordEntryGetTotalTrafficBytesRetType, ok bool) { + return getDistributionStatisticsRecordEntryGetTotalTrafficBytesAttributeTypeOk(o.TotalTrafficBytes) +} + +// SetTotalTrafficBytes sets field value +func (o *DistributionStatisticsRecordEntry) SetTotalTrafficBytes(v DistributionStatisticsRecordEntryGetTotalTrafficBytesRetType) { + setDistributionStatisticsRecordEntryGetTotalTrafficBytesAttributeType(&o.TotalTrafficBytes, v) +} + +func (o DistributionStatisticsRecordEntry) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getDistributionStatisticsRecordEntryGetCachedRequestsAttributeTypeOk(o.CachedRequests); ok { + toSerialize["CachedRequests"] = val + } + if val, ok := getDistributionStatisticsRecordEntryGetTotalRequestsAttributeTypeOk(o.TotalRequests); ok { + toSerialize["TotalRequests"] = val + } + if val, ok := getDistributionStatisticsRecordEntryGetTotalTrafficBytesAttributeTypeOk(o.TotalTrafficBytes); ok { + toSerialize["TotalTrafficBytes"] = val + } + return toSerialize, nil +} + +type NullableDistributionStatisticsRecordEntry struct { + value *DistributionStatisticsRecordEntry + isSet bool +} + +func (v NullableDistributionStatisticsRecordEntry) Get() *DistributionStatisticsRecordEntry { + return v.value +} + +func (v *NullableDistributionStatisticsRecordEntry) Set(val *DistributionStatisticsRecordEntry) { + v.value = val + v.isSet = true +} + +func (v NullableDistributionStatisticsRecordEntry) IsSet() bool { + return v.isSet +} + +func (v *NullableDistributionStatisticsRecordEntry) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableDistributionStatisticsRecordEntry(val *DistributionStatisticsRecordEntry) *NullableDistributionStatisticsRecordEntry { + return &NullableDistributionStatisticsRecordEntry{value: val, isSet: true} +} + +func (v NullableDistributionStatisticsRecordEntry) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableDistributionStatisticsRecordEntry) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cdn/model_distribution_statistics_record_regions.go b/services/cdn/model_distribution_statistics_record_regions.go new file mode 100644 index 000000000..a88e24f37 --- /dev/null +++ b/services/cdn/model_distribution_statistics_record_regions.go @@ -0,0 +1,297 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +import ( + "encoding/json" +) + +// checks if the DistributionStatisticsRecordRegions type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &DistributionStatisticsRecordRegions{} + +/* + types and functions for AF +*/ + +// isModel +type DistributionStatisticsRecordRegionsGetAFAttributeType = *DistributionStatisticsRecordEntry +type DistributionStatisticsRecordRegionsGetAFArgType = DistributionStatisticsRecordEntry +type DistributionStatisticsRecordRegionsGetAFRetType = DistributionStatisticsRecordEntry + +func getDistributionStatisticsRecordRegionsGetAFAttributeTypeOk(arg DistributionStatisticsRecordRegionsGetAFAttributeType) (ret DistributionStatisticsRecordRegionsGetAFRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDistributionStatisticsRecordRegionsGetAFAttributeType(arg *DistributionStatisticsRecordRegionsGetAFAttributeType, val DistributionStatisticsRecordRegionsGetAFRetType) { + *arg = &val +} + +/* + types and functions for ASIA +*/ + +// isModel +type DistributionStatisticsRecordRegionsGetASIAAttributeType = *DistributionStatisticsRecordEntry +type DistributionStatisticsRecordRegionsGetASIAArgType = DistributionStatisticsRecordEntry +type DistributionStatisticsRecordRegionsGetASIARetType = DistributionStatisticsRecordEntry + +func getDistributionStatisticsRecordRegionsGetASIAAttributeTypeOk(arg DistributionStatisticsRecordRegionsGetASIAAttributeType) (ret DistributionStatisticsRecordRegionsGetASIARetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDistributionStatisticsRecordRegionsGetASIAAttributeType(arg *DistributionStatisticsRecordRegionsGetASIAAttributeType, val DistributionStatisticsRecordRegionsGetASIARetType) { + *arg = &val +} + +/* + types and functions for EU +*/ + +// isModel +type DistributionStatisticsRecordRegionsGetEUAttributeType = *DistributionStatisticsRecordEntry +type DistributionStatisticsRecordRegionsGetEUArgType = DistributionStatisticsRecordEntry +type DistributionStatisticsRecordRegionsGetEURetType = DistributionStatisticsRecordEntry + +func getDistributionStatisticsRecordRegionsGetEUAttributeTypeOk(arg DistributionStatisticsRecordRegionsGetEUAttributeType) (ret DistributionStatisticsRecordRegionsGetEURetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDistributionStatisticsRecordRegionsGetEUAttributeType(arg *DistributionStatisticsRecordRegionsGetEUAttributeType, val DistributionStatisticsRecordRegionsGetEURetType) { + *arg = &val +} + +/* + types and functions for SA +*/ + +// isModel +type DistributionStatisticsRecordRegionsGetSAAttributeType = *DistributionStatisticsRecordEntry +type DistributionStatisticsRecordRegionsGetSAArgType = DistributionStatisticsRecordEntry +type DistributionStatisticsRecordRegionsGetSARetType = DistributionStatisticsRecordEntry + +func getDistributionStatisticsRecordRegionsGetSAAttributeTypeOk(arg DistributionStatisticsRecordRegionsGetSAAttributeType) (ret DistributionStatisticsRecordRegionsGetSARetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDistributionStatisticsRecordRegionsGetSAAttributeType(arg *DistributionStatisticsRecordRegionsGetSAAttributeType, val DistributionStatisticsRecordRegionsGetSARetType) { + *arg = &val +} + +/* + types and functions for US +*/ + +// isModel +type DistributionStatisticsRecordRegionsGetUSAttributeType = *DistributionStatisticsRecordEntry +type DistributionStatisticsRecordRegionsGetUSArgType = DistributionStatisticsRecordEntry +type DistributionStatisticsRecordRegionsGetUSRetType = DistributionStatisticsRecordEntry + +func getDistributionStatisticsRecordRegionsGetUSAttributeTypeOk(arg DistributionStatisticsRecordRegionsGetUSAttributeType) (ret DistributionStatisticsRecordRegionsGetUSRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDistributionStatisticsRecordRegionsGetUSAttributeType(arg *DistributionStatisticsRecordRegionsGetUSAttributeType, val DistributionStatisticsRecordRegionsGetUSRetType) { + *arg = &val +} + +// DistributionStatisticsRecordRegions Mapping of regions to the metrics for this region for the defined time interval All regions are always present. If no traffic was reported for a region, it will still contain 0-filled properties +type DistributionStatisticsRecordRegions struct { + // REQUIRED + AF DistributionStatisticsRecordRegionsGetAFAttributeType `json:"AF"` + // REQUIRED + ASIA DistributionStatisticsRecordRegionsGetASIAAttributeType `json:"ASIA"` + // REQUIRED + EU DistributionStatisticsRecordRegionsGetEUAttributeType `json:"EU"` + // REQUIRED + SA DistributionStatisticsRecordRegionsGetSAAttributeType `json:"SA"` + // REQUIRED + US DistributionStatisticsRecordRegionsGetUSAttributeType `json:"US"` +} + +type _DistributionStatisticsRecordRegions DistributionStatisticsRecordRegions + +// NewDistributionStatisticsRecordRegions instantiates a new DistributionStatisticsRecordRegions 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 NewDistributionStatisticsRecordRegions(aF DistributionStatisticsRecordRegionsGetAFArgType, aSIA DistributionStatisticsRecordRegionsGetASIAArgType, eU DistributionStatisticsRecordRegionsGetEUArgType, sA DistributionStatisticsRecordRegionsGetSAArgType, uS DistributionStatisticsRecordRegionsGetUSArgType) *DistributionStatisticsRecordRegions { + this := DistributionStatisticsRecordRegions{} + setDistributionStatisticsRecordRegionsGetAFAttributeType(&this.AF, aF) + setDistributionStatisticsRecordRegionsGetASIAAttributeType(&this.ASIA, aSIA) + setDistributionStatisticsRecordRegionsGetEUAttributeType(&this.EU, eU) + setDistributionStatisticsRecordRegionsGetSAAttributeType(&this.SA, sA) + setDistributionStatisticsRecordRegionsGetUSAttributeType(&this.US, uS) + return &this +} + +// NewDistributionStatisticsRecordRegionsWithDefaults instantiates a new DistributionStatisticsRecordRegions 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 NewDistributionStatisticsRecordRegionsWithDefaults() *DistributionStatisticsRecordRegions { + this := DistributionStatisticsRecordRegions{} + return &this +} + +// GetAF returns the AF field value +func (o *DistributionStatisticsRecordRegions) GetAF() (ret DistributionStatisticsRecordRegionsGetAFRetType) { + ret, _ = o.GetAFOk() + return ret +} + +// GetAFOk returns a tuple with the AF field value +// and a boolean to check if the value has been set. +func (o *DistributionStatisticsRecordRegions) GetAFOk() (ret DistributionStatisticsRecordRegionsGetAFRetType, ok bool) { + return getDistributionStatisticsRecordRegionsGetAFAttributeTypeOk(o.AF) +} + +// SetAF sets field value +func (o *DistributionStatisticsRecordRegions) SetAF(v DistributionStatisticsRecordRegionsGetAFRetType) { + setDistributionStatisticsRecordRegionsGetAFAttributeType(&o.AF, v) +} + +// GetASIA returns the ASIA field value +func (o *DistributionStatisticsRecordRegions) GetASIA() (ret DistributionStatisticsRecordRegionsGetASIARetType) { + ret, _ = o.GetASIAOk() + return ret +} + +// GetASIAOk returns a tuple with the ASIA field value +// and a boolean to check if the value has been set. +func (o *DistributionStatisticsRecordRegions) GetASIAOk() (ret DistributionStatisticsRecordRegionsGetASIARetType, ok bool) { + return getDistributionStatisticsRecordRegionsGetASIAAttributeTypeOk(o.ASIA) +} + +// SetASIA sets field value +func (o *DistributionStatisticsRecordRegions) SetASIA(v DistributionStatisticsRecordRegionsGetASIARetType) { + setDistributionStatisticsRecordRegionsGetASIAAttributeType(&o.ASIA, v) +} + +// GetEU returns the EU field value +func (o *DistributionStatisticsRecordRegions) GetEU() (ret DistributionStatisticsRecordRegionsGetEURetType) { + ret, _ = o.GetEUOk() + return ret +} + +// GetEUOk returns a tuple with the EU field value +// and a boolean to check if the value has been set. +func (o *DistributionStatisticsRecordRegions) GetEUOk() (ret DistributionStatisticsRecordRegionsGetEURetType, ok bool) { + return getDistributionStatisticsRecordRegionsGetEUAttributeTypeOk(o.EU) +} + +// SetEU sets field value +func (o *DistributionStatisticsRecordRegions) SetEU(v DistributionStatisticsRecordRegionsGetEURetType) { + setDistributionStatisticsRecordRegionsGetEUAttributeType(&o.EU, v) +} + +// GetSA returns the SA field value +func (o *DistributionStatisticsRecordRegions) GetSA() (ret DistributionStatisticsRecordRegionsGetSARetType) { + ret, _ = o.GetSAOk() + return ret +} + +// GetSAOk returns a tuple with the SA field value +// and a boolean to check if the value has been set. +func (o *DistributionStatisticsRecordRegions) GetSAOk() (ret DistributionStatisticsRecordRegionsGetSARetType, ok bool) { + return getDistributionStatisticsRecordRegionsGetSAAttributeTypeOk(o.SA) +} + +// SetSA sets field value +func (o *DistributionStatisticsRecordRegions) SetSA(v DistributionStatisticsRecordRegionsGetSARetType) { + setDistributionStatisticsRecordRegionsGetSAAttributeType(&o.SA, v) +} + +// GetUS returns the US field value +func (o *DistributionStatisticsRecordRegions) GetUS() (ret DistributionStatisticsRecordRegionsGetUSRetType) { + ret, _ = o.GetUSOk() + return ret +} + +// GetUSOk returns a tuple with the US field value +// and a boolean to check if the value has been set. +func (o *DistributionStatisticsRecordRegions) GetUSOk() (ret DistributionStatisticsRecordRegionsGetUSRetType, ok bool) { + return getDistributionStatisticsRecordRegionsGetUSAttributeTypeOk(o.US) +} + +// SetUS sets field value +func (o *DistributionStatisticsRecordRegions) SetUS(v DistributionStatisticsRecordRegionsGetUSRetType) { + setDistributionStatisticsRecordRegionsGetUSAttributeType(&o.US, v) +} + +func (o DistributionStatisticsRecordRegions) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getDistributionStatisticsRecordRegionsGetAFAttributeTypeOk(o.AF); ok { + toSerialize["AF"] = val + } + if val, ok := getDistributionStatisticsRecordRegionsGetASIAAttributeTypeOk(o.ASIA); ok { + toSerialize["ASIA"] = val + } + if val, ok := getDistributionStatisticsRecordRegionsGetEUAttributeTypeOk(o.EU); ok { + toSerialize["EU"] = val + } + if val, ok := getDistributionStatisticsRecordRegionsGetSAAttributeTypeOk(o.SA); ok { + toSerialize["SA"] = val + } + if val, ok := getDistributionStatisticsRecordRegionsGetUSAttributeTypeOk(o.US); ok { + toSerialize["US"] = val + } + return toSerialize, nil +} + +type NullableDistributionStatisticsRecordRegions struct { + value *DistributionStatisticsRecordRegions + isSet bool +} + +func (v NullableDistributionStatisticsRecordRegions) Get() *DistributionStatisticsRecordRegions { + return v.value +} + +func (v *NullableDistributionStatisticsRecordRegions) Set(val *DistributionStatisticsRecordRegions) { + v.value = val + v.isSet = true +} + +func (v NullableDistributionStatisticsRecordRegions) IsSet() bool { + return v.isSet +} + +func (v *NullableDistributionStatisticsRecordRegions) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableDistributionStatisticsRecordRegions(val *DistributionStatisticsRecordRegions) *NullableDistributionStatisticsRecordRegions { + return &NullableDistributionStatisticsRecordRegions{value: val, isSet: true} +} + +func (v NullableDistributionStatisticsRecordRegions) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableDistributionStatisticsRecordRegions) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cdn/model_domain.go b/services/cdn/model_domain.go new file mode 100644 index 000000000..12db9fc7b --- /dev/null +++ b/services/cdn/model_domain.go @@ -0,0 +1,262 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +import ( + "encoding/json" +) + +// checks if the Domain type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &Domain{} + +/* + types and functions for errors +*/ + +// isArray +type DomainGetErrorsAttributeType = *[]StatusError +type DomainGetErrorsArgType = []StatusError +type DomainGetErrorsRetType = []StatusError + +func getDomainGetErrorsAttributeTypeOk(arg DomainGetErrorsAttributeType) (ret DomainGetErrorsRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDomainGetErrorsAttributeType(arg *DomainGetErrorsAttributeType, val DomainGetErrorsRetType) { + *arg = &val +} + +/* + types and functions for name +*/ + +// isNotNullableString +type DomainGetNameAttributeType = *string + +func getDomainGetNameAttributeTypeOk(arg DomainGetNameAttributeType) (ret DomainGetNameRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDomainGetNameAttributeType(arg *DomainGetNameAttributeType, val DomainGetNameRetType) { + *arg = &val +} + +type DomainGetNameArgType = string +type DomainGetNameRetType = string + +/* + types and functions for status +*/ + +// isEnumRef +type DomainGetStatusAttributeType = *DomainStatus +type DomainGetStatusArgType = DomainStatus +type DomainGetStatusRetType = DomainStatus + +func getDomainGetStatusAttributeTypeOk(arg DomainGetStatusAttributeType) (ret DomainGetStatusRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDomainGetStatusAttributeType(arg *DomainGetStatusAttributeType, val DomainGetStatusRetType) { + *arg = &val +} + +/* + types and functions for type +*/ + +// isEnumRef +type DomainGetTypeAttributeType = *string +type DomainGetTypeArgType = string +type DomainGetTypeRetType = string + +func getDomainGetTypeAttributeTypeOk(arg DomainGetTypeAttributeType) (ret DomainGetTypeRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDomainGetTypeAttributeType(arg *DomainGetTypeAttributeType, val DomainGetTypeRetType) { + *arg = &val +} + +// Domain Definition of a custom or managed domain without any certificates or keys +type Domain struct { + // This object is present if the custom domain has errors. + Errors DomainGetErrorsAttributeType `json:"errors,omitempty"` + // The domain. If this is a custom domain, you can call the GetCustomDomain Endpoint + // REQUIRED + Name DomainGetNameAttributeType `json:"name"` + // REQUIRED + Status DomainGetStatusAttributeType `json:"status"` + // Specifies the type of this Domain. Custom Domain can be further queries using the GetCustomDomain Endpoint + // REQUIRED + Type DomainGetTypeAttributeType `json:"type"` +} + +type _Domain Domain + +// NewDomain instantiates a new Domain 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 NewDomain(name DomainGetNameArgType, status DomainGetStatusArgType, type_ DomainGetTypeArgType) *Domain { + this := Domain{} + setDomainGetNameAttributeType(&this.Name, name) + setDomainGetStatusAttributeType(&this.Status, status) + setDomainGetTypeAttributeType(&this.Type, type_) + return &this +} + +// NewDomainWithDefaults instantiates a new Domain 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 NewDomainWithDefaults() *Domain { + this := Domain{} + return &this +} + +// GetErrors returns the Errors field value if set, zero value otherwise. +func (o *Domain) GetErrors() (res DomainGetErrorsRetType) { + res, _ = o.GetErrorsOk() + return +} + +// GetErrorsOk returns a tuple with the Errors field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Domain) GetErrorsOk() (ret DomainGetErrorsRetType, ok bool) { + return getDomainGetErrorsAttributeTypeOk(o.Errors) +} + +// HasErrors returns a boolean if a field has been set. +func (o *Domain) HasErrors() bool { + _, ok := o.GetErrorsOk() + return ok +} + +// SetErrors gets a reference to the given []StatusError and assigns it to the Errors field. +func (o *Domain) SetErrors(v DomainGetErrorsRetType) { + setDomainGetErrorsAttributeType(&o.Errors, v) +} + +// GetName returns the Name field value +func (o *Domain) GetName() (ret DomainGetNameRetType) { + ret, _ = o.GetNameOk() + return ret +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *Domain) GetNameOk() (ret DomainGetNameRetType, ok bool) { + return getDomainGetNameAttributeTypeOk(o.Name) +} + +// SetName sets field value +func (o *Domain) SetName(v DomainGetNameRetType) { + setDomainGetNameAttributeType(&o.Name, v) +} + +// GetStatus returns the Status field value +func (o *Domain) GetStatus() (ret DomainGetStatusRetType) { + ret, _ = o.GetStatusOk() + return ret +} + +// GetStatusOk returns a tuple with the Status field value +// and a boolean to check if the value has been set. +func (o *Domain) GetStatusOk() (ret DomainGetStatusRetType, ok bool) { + return getDomainGetStatusAttributeTypeOk(o.Status) +} + +// SetStatus sets field value +func (o *Domain) SetStatus(v DomainGetStatusRetType) { + setDomainGetStatusAttributeType(&o.Status, v) +} + +// GetType returns the Type field value +func (o *Domain) GetType() (ret DomainGetTypeRetType) { + ret, _ = o.GetTypeOk() + return ret +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *Domain) GetTypeOk() (ret DomainGetTypeRetType, ok bool) { + return getDomainGetTypeAttributeTypeOk(o.Type) +} + +// SetType sets field value +func (o *Domain) SetType(v DomainGetTypeRetType) { + setDomainGetTypeAttributeType(&o.Type, v) +} + +func (o Domain) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getDomainGetErrorsAttributeTypeOk(o.Errors); ok { + toSerialize["Errors"] = val + } + if val, ok := getDomainGetNameAttributeTypeOk(o.Name); ok { + toSerialize["Name"] = val + } + if val, ok := getDomainGetStatusAttributeTypeOk(o.Status); ok { + toSerialize["Status"] = val + } + if val, ok := getDomainGetTypeAttributeTypeOk(o.Type); ok { + toSerialize["Type"] = val + } + return toSerialize, nil +} + +type NullableDomain struct { + value *Domain + isSet bool +} + +func (v NullableDomain) Get() *Domain { + return v.value +} + +func (v *NullableDomain) Set(val *Domain) { + v.value = val + v.isSet = true +} + +func (v NullableDomain) IsSet() bool { + return v.isSet +} + +func (v *NullableDomain) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableDomain(val *Domain) *NullableDomain { + return &NullableDomain{value: val, isSet: true} +} + +func (v NullableDomain) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableDomain) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cdn/model_domain_status.go b/services/cdn/model_domain_status.go new file mode 100644 index 000000000..7b648ebe4 --- /dev/null +++ b/services/cdn/model_domain_status.go @@ -0,0 +1,121 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +import ( + "encoding/json" + "fmt" +) + +// DomainStatus The status of the domain: CREATING indicates that the custom domain is being set up. UPDATING means that requested changes are being applied to the custom domain. ACTIVE means the custom domain is currently configured and active. DELETING means that the domain is in the process of being removed from the distribution. In case the domain has the ERROR state, more information will be available in the errors list. +type DomainStatus string + +// List of DomainStatus +const ( + DOMAINSTATUS_CREATING DomainStatus = "CREATING" + DOMAINSTATUS_ACTIVE DomainStatus = "ACTIVE" + DOMAINSTATUS_UPDATING DomainStatus = "UPDATING" + DOMAINSTATUS_DELETING DomainStatus = "DELETING" + DOMAINSTATUS_ERROR DomainStatus = "ERROR" +) + +// All allowed values of DomainStatus enum +var AllowedDomainStatusEnumValues = []DomainStatus{ + "CREATING", + "ACTIVE", + "UPDATING", + "DELETING", + "ERROR", +} + +func (v *DomainStatus) 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 := DomainStatus(value) + for _, existing := range AllowedDomainStatusEnumValues { + if existing == enumTypeValue { + *v = enumTypeValue + return nil + } + } + + return fmt.Errorf("%+v is not a valid DomainStatus", value) +} + +// NewDomainStatusFromValue returns a pointer to a valid DomainStatus +// for the value passed as argument, or an error if the value passed is not allowed by the enum +func NewDomainStatusFromValue(v string) (*DomainStatus, error) { + ev := DomainStatus(v) + if ev.IsValid() { + return &ev, nil + } else { + return nil, fmt.Errorf("invalid value '%v' for DomainStatus: valid values are %v", v, AllowedDomainStatusEnumValues) + } +} + +// IsValid return true if the value is valid for the enum, false otherwise +func (v DomainStatus) IsValid() bool { + for _, existing := range AllowedDomainStatusEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to DomainStatus value +func (v DomainStatus) Ptr() *DomainStatus { + return &v +} + +type NullableDomainStatus struct { + value *DomainStatus + isSet bool +} + +func (v NullableDomainStatus) Get() *DomainStatus { + return v.value +} + +func (v *NullableDomainStatus) Set(val *DomainStatus) { + v.value = val + v.isSet = true +} + +func (v NullableDomainStatus) IsSet() bool { + return v.isSet +} + +func (v *NullableDomainStatus) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableDomainStatus(val *DomainStatus) *NullableDomainStatus { + return &NullableDomainStatus{value: val, isSet: true} +} + +func (v NullableDomainStatus) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableDomainStatus) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cdn/model_find_cache_paths_response.go b/services/cdn/model_find_cache_paths_response.go new file mode 100644 index 000000000..3e3d22efd --- /dev/null +++ b/services/cdn/model_find_cache_paths_response.go @@ -0,0 +1,125 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +import ( + "encoding/json" +) + +// checks if the FindCachePathsResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &FindCachePathsResponse{} + +/* + types and functions for response +*/ + +// isArray +type FindCachePathsResponseGetResponseAttributeType = *[]FindCachePathsResponseEntry +type FindCachePathsResponseGetResponseArgType = []FindCachePathsResponseEntry +type FindCachePathsResponseGetResponseRetType = []FindCachePathsResponseEntry + +func getFindCachePathsResponseGetResponseAttributeTypeOk(arg FindCachePathsResponseGetResponseAttributeType) (ret FindCachePathsResponseGetResponseRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setFindCachePathsResponseGetResponseAttributeType(arg *FindCachePathsResponseGetResponseAttributeType, val FindCachePathsResponseGetResponseRetType) { + *arg = &val +} + +// FindCachePathsResponse struct for FindCachePathsResponse +type FindCachePathsResponse struct { + // REQUIRED + Response FindCachePathsResponseGetResponseAttributeType `json:"response"` +} + +type _FindCachePathsResponse FindCachePathsResponse + +// NewFindCachePathsResponse instantiates a new FindCachePathsResponse 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 NewFindCachePathsResponse(response FindCachePathsResponseGetResponseArgType) *FindCachePathsResponse { + this := FindCachePathsResponse{} + setFindCachePathsResponseGetResponseAttributeType(&this.Response, response) + return &this +} + +// NewFindCachePathsResponseWithDefaults instantiates a new FindCachePathsResponse 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 NewFindCachePathsResponseWithDefaults() *FindCachePathsResponse { + this := FindCachePathsResponse{} + return &this +} + +// GetResponse returns the Response field value +func (o *FindCachePathsResponse) GetResponse() (ret FindCachePathsResponseGetResponseRetType) { + ret, _ = o.GetResponseOk() + return ret +} + +// GetResponseOk returns a tuple with the Response field value +// and a boolean to check if the value has been set. +func (o *FindCachePathsResponse) GetResponseOk() (ret FindCachePathsResponseGetResponseRetType, ok bool) { + return getFindCachePathsResponseGetResponseAttributeTypeOk(o.Response) +} + +// SetResponse sets field value +func (o *FindCachePathsResponse) SetResponse(v FindCachePathsResponseGetResponseRetType) { + setFindCachePathsResponseGetResponseAttributeType(&o.Response, v) +} + +func (o FindCachePathsResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getFindCachePathsResponseGetResponseAttributeTypeOk(o.Response); ok { + toSerialize["Response"] = val + } + return toSerialize, nil +} + +type NullableFindCachePathsResponse struct { + value *FindCachePathsResponse + isSet bool +} + +func (v NullableFindCachePathsResponse) Get() *FindCachePathsResponse { + return v.value +} + +func (v *NullableFindCachePathsResponse) Set(val *FindCachePathsResponse) { + v.value = val + v.isSet = true +} + +func (v NullableFindCachePathsResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableFindCachePathsResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableFindCachePathsResponse(val *FindCachePathsResponse) *NullableFindCachePathsResponse { + return &NullableFindCachePathsResponse{value: val, isSet: true} +} + +func (v NullableFindCachePathsResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableFindCachePathsResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cdn/model_find_cache_paths_response_entry.go b/services/cdn/model_find_cache_paths_response_entry.go new file mode 100644 index 000000000..f77d29582 --- /dev/null +++ b/services/cdn/model_find_cache_paths_response_entry.go @@ -0,0 +1,127 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +import ( + "encoding/json" +) + +// checks if the FindCachePathsResponseEntry type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &FindCachePathsResponseEntry{} + +/* + types and functions for path +*/ + +// isNotNullableString +type FindCachePathsResponseEntryGetPathAttributeType = *string + +func getFindCachePathsResponseEntryGetPathAttributeTypeOk(arg FindCachePathsResponseEntryGetPathAttributeType) (ret FindCachePathsResponseEntryGetPathRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setFindCachePathsResponseEntryGetPathAttributeType(arg *FindCachePathsResponseEntryGetPathAttributeType, val FindCachePathsResponseEntryGetPathRetType) { + *arg = &val +} + +type FindCachePathsResponseEntryGetPathArgType = string +type FindCachePathsResponseEntryGetPathRetType = string + +// FindCachePathsResponseEntry struct for FindCachePathsResponseEntry +type FindCachePathsResponseEntry struct { + // Defines one path that was previously used as part of a granular purge + // REQUIRED + Path FindCachePathsResponseEntryGetPathAttributeType `json:"path"` +} + +type _FindCachePathsResponseEntry FindCachePathsResponseEntry + +// NewFindCachePathsResponseEntry instantiates a new FindCachePathsResponseEntry 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 NewFindCachePathsResponseEntry(path FindCachePathsResponseEntryGetPathArgType) *FindCachePathsResponseEntry { + this := FindCachePathsResponseEntry{} + setFindCachePathsResponseEntryGetPathAttributeType(&this.Path, path) + return &this +} + +// NewFindCachePathsResponseEntryWithDefaults instantiates a new FindCachePathsResponseEntry 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 NewFindCachePathsResponseEntryWithDefaults() *FindCachePathsResponseEntry { + this := FindCachePathsResponseEntry{} + return &this +} + +// GetPath returns the Path field value +func (o *FindCachePathsResponseEntry) GetPath() (ret FindCachePathsResponseEntryGetPathRetType) { + ret, _ = o.GetPathOk() + return ret +} + +// GetPathOk returns a tuple with the Path field value +// and a boolean to check if the value has been set. +func (o *FindCachePathsResponseEntry) GetPathOk() (ret FindCachePathsResponseEntryGetPathRetType, ok bool) { + return getFindCachePathsResponseEntryGetPathAttributeTypeOk(o.Path) +} + +// SetPath sets field value +func (o *FindCachePathsResponseEntry) SetPath(v FindCachePathsResponseEntryGetPathRetType) { + setFindCachePathsResponseEntryGetPathAttributeType(&o.Path, v) +} + +func (o FindCachePathsResponseEntry) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getFindCachePathsResponseEntryGetPathAttributeTypeOk(o.Path); ok { + toSerialize["Path"] = val + } + return toSerialize, nil +} + +type NullableFindCachePathsResponseEntry struct { + value *FindCachePathsResponseEntry + isSet bool +} + +func (v NullableFindCachePathsResponseEntry) Get() *FindCachePathsResponseEntry { + return v.value +} + +func (v *NullableFindCachePathsResponseEntry) Set(val *FindCachePathsResponseEntry) { + v.value = val + v.isSet = true +} + +func (v NullableFindCachePathsResponseEntry) IsSet() bool { + return v.isSet +} + +func (v *NullableFindCachePathsResponseEntry) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableFindCachePathsResponseEntry(val *FindCachePathsResponseEntry) *NullableFindCachePathsResponseEntry { + return &NullableFindCachePathsResponseEntry{value: val, isSet: true} +} + +func (v NullableFindCachePathsResponseEntry) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableFindCachePathsResponseEntry) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cdn/model_generic_json_response.go b/services/cdn/model_generic_json_response.go new file mode 100644 index 000000000..104bbf67d --- /dev/null +++ b/services/cdn/model_generic_json_response.go @@ -0,0 +1,174 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +import ( + "encoding/json" +) + +// checks if the GenericJSONResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &GenericJSONResponse{} + +/* + types and functions for details +*/ + +// isArray +type GenericJSONResponseGetDetailsAttributeType = *[]GenericJSONResponseDetailsInner +type GenericJSONResponseGetDetailsArgType = []GenericJSONResponseDetailsInner +type GenericJSONResponseGetDetailsRetType = []GenericJSONResponseDetailsInner + +func getGenericJSONResponseGetDetailsAttributeTypeOk(arg GenericJSONResponseGetDetailsAttributeType) (ret GenericJSONResponseGetDetailsRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setGenericJSONResponseGetDetailsAttributeType(arg *GenericJSONResponseGetDetailsAttributeType, val GenericJSONResponseGetDetailsRetType) { + *arg = &val +} + +/* + types and functions for message +*/ + +// isNotNullableString +type GenericJSONResponseGetMessageAttributeType = *string + +func getGenericJSONResponseGetMessageAttributeTypeOk(arg GenericJSONResponseGetMessageAttributeType) (ret GenericJSONResponseGetMessageRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setGenericJSONResponseGetMessageAttributeType(arg *GenericJSONResponseGetMessageAttributeType, val GenericJSONResponseGetMessageRetType) { + *arg = &val +} + +type GenericJSONResponseGetMessageArgType = string +type GenericJSONResponseGetMessageRetType = string + +// GenericJSONResponse struct for GenericJSONResponse +type GenericJSONResponse struct { + // Listing of issues with your request + Details GenericJSONResponseGetDetailsAttributeType `json:"details,omitempty"` + // REQUIRED + Message GenericJSONResponseGetMessageAttributeType `json:"message"` +} + +type _GenericJSONResponse GenericJSONResponse + +// NewGenericJSONResponse instantiates a new GenericJSONResponse 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 NewGenericJSONResponse(message GenericJSONResponseGetMessageArgType) *GenericJSONResponse { + this := GenericJSONResponse{} + setGenericJSONResponseGetMessageAttributeType(&this.Message, message) + return &this +} + +// NewGenericJSONResponseWithDefaults instantiates a new GenericJSONResponse 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 NewGenericJSONResponseWithDefaults() *GenericJSONResponse { + this := GenericJSONResponse{} + return &this +} + +// GetDetails returns the Details field value if set, zero value otherwise. +func (o *GenericJSONResponse) GetDetails() (res GenericJSONResponseGetDetailsRetType) { + res, _ = o.GetDetailsOk() + return +} + +// GetDetailsOk returns a tuple with the Details field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GenericJSONResponse) GetDetailsOk() (ret GenericJSONResponseGetDetailsRetType, ok bool) { + return getGenericJSONResponseGetDetailsAttributeTypeOk(o.Details) +} + +// HasDetails returns a boolean if a field has been set. +func (o *GenericJSONResponse) HasDetails() bool { + _, ok := o.GetDetailsOk() + return ok +} + +// SetDetails gets a reference to the given []GenericJSONResponseDetailsInner and assigns it to the Details field. +func (o *GenericJSONResponse) SetDetails(v GenericJSONResponseGetDetailsRetType) { + setGenericJSONResponseGetDetailsAttributeType(&o.Details, v) +} + +// GetMessage returns the Message field value +func (o *GenericJSONResponse) GetMessage() (ret GenericJSONResponseGetMessageRetType) { + 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 *GenericJSONResponse) GetMessageOk() (ret GenericJSONResponseGetMessageRetType, ok bool) { + return getGenericJSONResponseGetMessageAttributeTypeOk(o.Message) +} + +// SetMessage sets field value +func (o *GenericJSONResponse) SetMessage(v GenericJSONResponseGetMessageRetType) { + setGenericJSONResponseGetMessageAttributeType(&o.Message, v) +} + +func (o GenericJSONResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getGenericJSONResponseGetDetailsAttributeTypeOk(o.Details); ok { + toSerialize["Details"] = val + } + if val, ok := getGenericJSONResponseGetMessageAttributeTypeOk(o.Message); ok { + toSerialize["Message"] = val + } + return toSerialize, nil +} + +type NullableGenericJSONResponse struct { + value *GenericJSONResponse + isSet bool +} + +func (v NullableGenericJSONResponse) Get() *GenericJSONResponse { + return v.value +} + +func (v *NullableGenericJSONResponse) Set(val *GenericJSONResponse) { + v.value = val + v.isSet = true +} + +func (v NullableGenericJSONResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableGenericJSONResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableGenericJSONResponse(val *GenericJSONResponse) *NullableGenericJSONResponse { + return &NullableGenericJSONResponse{value: val, isSet: true} +} + +func (v NullableGenericJSONResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableGenericJSONResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cdn/model_generic_json_response_details_inner.go b/services/cdn/model_generic_json_response_details_inner.go new file mode 100644 index 000000000..7515904d7 --- /dev/null +++ b/services/cdn/model_generic_json_response_details_inner.go @@ -0,0 +1,170 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +import ( + "encoding/json" +) + +// checks if the GenericJSONResponseDetailsInner type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &GenericJSONResponseDetailsInner{} + +/* + types and functions for description +*/ + +// isNotNullableString +type GenericJSONResponseDetailsInnerGetDescriptionAttributeType = *string + +func getGenericJSONResponseDetailsInnerGetDescriptionAttributeTypeOk(arg GenericJSONResponseDetailsInnerGetDescriptionAttributeType) (ret GenericJSONResponseDetailsInnerGetDescriptionRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setGenericJSONResponseDetailsInnerGetDescriptionAttributeType(arg *GenericJSONResponseDetailsInnerGetDescriptionAttributeType, val GenericJSONResponseDetailsInnerGetDescriptionRetType) { + *arg = &val +} + +type GenericJSONResponseDetailsInnerGetDescriptionArgType = string +type GenericJSONResponseDetailsInnerGetDescriptionRetType = string + +/* + types and functions for field +*/ + +// isNotNullableString +type GenericJSONResponseDetailsInnerGetFieldAttributeType = *string + +func getGenericJSONResponseDetailsInnerGetFieldAttributeTypeOk(arg GenericJSONResponseDetailsInnerGetFieldAttributeType) (ret GenericJSONResponseDetailsInnerGetFieldRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setGenericJSONResponseDetailsInnerGetFieldAttributeType(arg *GenericJSONResponseDetailsInnerGetFieldAttributeType, val GenericJSONResponseDetailsInnerGetFieldRetType) { + *arg = &val +} + +type GenericJSONResponseDetailsInnerGetFieldArgType = string +type GenericJSONResponseDetailsInnerGetFieldRetType = string + +// GenericJSONResponseDetailsInner struct for GenericJSONResponseDetailsInner +type GenericJSONResponseDetailsInner struct { + // REQUIRED + Description GenericJSONResponseDetailsInnerGetDescriptionAttributeType `json:"description"` + // REQUIRED + Field GenericJSONResponseDetailsInnerGetFieldAttributeType `json:"field"` +} + +type _GenericJSONResponseDetailsInner GenericJSONResponseDetailsInner + +// NewGenericJSONResponseDetailsInner instantiates a new GenericJSONResponseDetailsInner 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 NewGenericJSONResponseDetailsInner(description GenericJSONResponseDetailsInnerGetDescriptionArgType, field GenericJSONResponseDetailsInnerGetFieldArgType) *GenericJSONResponseDetailsInner { + this := GenericJSONResponseDetailsInner{} + setGenericJSONResponseDetailsInnerGetDescriptionAttributeType(&this.Description, description) + setGenericJSONResponseDetailsInnerGetFieldAttributeType(&this.Field, field) + return &this +} + +// NewGenericJSONResponseDetailsInnerWithDefaults instantiates a new GenericJSONResponseDetailsInner 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 NewGenericJSONResponseDetailsInnerWithDefaults() *GenericJSONResponseDetailsInner { + this := GenericJSONResponseDetailsInner{} + return &this +} + +// GetDescription returns the Description field value +func (o *GenericJSONResponseDetailsInner) GetDescription() (ret GenericJSONResponseDetailsInnerGetDescriptionRetType) { + ret, _ = o.GetDescriptionOk() + return ret +} + +// GetDescriptionOk returns a tuple with the Description field value +// and a boolean to check if the value has been set. +func (o *GenericJSONResponseDetailsInner) GetDescriptionOk() (ret GenericJSONResponseDetailsInnerGetDescriptionRetType, ok bool) { + return getGenericJSONResponseDetailsInnerGetDescriptionAttributeTypeOk(o.Description) +} + +// SetDescription sets field value +func (o *GenericJSONResponseDetailsInner) SetDescription(v GenericJSONResponseDetailsInnerGetDescriptionRetType) { + setGenericJSONResponseDetailsInnerGetDescriptionAttributeType(&o.Description, v) +} + +// GetField returns the Field field value +func (o *GenericJSONResponseDetailsInner) GetField() (ret GenericJSONResponseDetailsInnerGetFieldRetType) { + ret, _ = o.GetFieldOk() + return ret +} + +// GetFieldOk returns a tuple with the Field field value +// and a boolean to check if the value has been set. +func (o *GenericJSONResponseDetailsInner) GetFieldOk() (ret GenericJSONResponseDetailsInnerGetFieldRetType, ok bool) { + return getGenericJSONResponseDetailsInnerGetFieldAttributeTypeOk(o.Field) +} + +// SetField sets field value +func (o *GenericJSONResponseDetailsInner) SetField(v GenericJSONResponseDetailsInnerGetFieldRetType) { + setGenericJSONResponseDetailsInnerGetFieldAttributeType(&o.Field, v) +} + +func (o GenericJSONResponseDetailsInner) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getGenericJSONResponseDetailsInnerGetDescriptionAttributeTypeOk(o.Description); ok { + toSerialize["Description"] = val + } + if val, ok := getGenericJSONResponseDetailsInnerGetFieldAttributeTypeOk(o.Field); ok { + toSerialize["Field"] = val + } + return toSerialize, nil +} + +type NullableGenericJSONResponseDetailsInner struct { + value *GenericJSONResponseDetailsInner + isSet bool +} + +func (v NullableGenericJSONResponseDetailsInner) Get() *GenericJSONResponseDetailsInner { + return v.value +} + +func (v *NullableGenericJSONResponseDetailsInner) Set(val *GenericJSONResponseDetailsInner) { + v.value = val + v.isSet = true +} + +func (v NullableGenericJSONResponseDetailsInner) IsSet() bool { + return v.isSet +} + +func (v *NullableGenericJSONResponseDetailsInner) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableGenericJSONResponseDetailsInner(val *GenericJSONResponseDetailsInner) *NullableGenericJSONResponseDetailsInner { + return &NullableGenericJSONResponseDetailsInner{value: val, isSet: true} +} + +func (v NullableGenericJSONResponseDetailsInner) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableGenericJSONResponseDetailsInner) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cdn/model_get_cache_info_response.go b/services/cdn/model_get_cache_info_response.go new file mode 100644 index 000000000..371ec23e2 --- /dev/null +++ b/services/cdn/model_get_cache_info_response.go @@ -0,0 +1,172 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +import ( + "encoding/json" + "time" +) + +// checks if the GetCacheInfoResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &GetCacheInfoResponse{} + +/* + types and functions for history +*/ + +// isArray +type GetCacheInfoResponseGetHistoryAttributeType = *[]GetCacheInfoResponseHistoryEntry +type GetCacheInfoResponseGetHistoryArgType = []GetCacheInfoResponseHistoryEntry +type GetCacheInfoResponseGetHistoryRetType = []GetCacheInfoResponseHistoryEntry + +func getGetCacheInfoResponseGetHistoryAttributeTypeOk(arg GetCacheInfoResponseGetHistoryAttributeType) (ret GetCacheInfoResponseGetHistoryRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setGetCacheInfoResponseGetHistoryAttributeType(arg *GetCacheInfoResponseGetHistoryAttributeType, val GetCacheInfoResponseGetHistoryRetType) { + *arg = &val +} + +/* + types and functions for lastPurgeTime +*/ + +// isDateTime +type GetCacheInfoResponseGetLastPurgeTimeAttributeType = *time.Time +type GetCacheInfoResponseGetLastPurgeTimeArgType = *time.Time +type GetCacheInfoResponseGetLastPurgeTimeRetType = *time.Time + +func getGetCacheInfoResponseGetLastPurgeTimeAttributeTypeOk(arg GetCacheInfoResponseGetLastPurgeTimeAttributeType) (ret GetCacheInfoResponseGetLastPurgeTimeRetType, ok bool) { + if arg == nil { + return nil, false + } + return arg, true +} + +func setGetCacheInfoResponseGetLastPurgeTimeAttributeType(arg *GetCacheInfoResponseGetLastPurgeTimeAttributeType, val GetCacheInfoResponseGetLastPurgeTimeRetType) { + *arg = val +} + +// GetCacheInfoResponse struct for GetCacheInfoResponse +type GetCacheInfoResponse struct { + // REQUIRED + History GetCacheInfoResponseGetHistoryAttributeType `json:"history"` + // Returns the last time the cache was purged by calling the PurgeCache endpoint. Time represented as RFC3339 compliant string. If the cache was never purged, this returns `null` + // REQUIRED + LastPurgeTime GetCacheInfoResponseGetLastPurgeTimeAttributeType `json:"lastPurgeTime"` +} + +type _GetCacheInfoResponse GetCacheInfoResponse + +// NewGetCacheInfoResponse instantiates a new GetCacheInfoResponse 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 NewGetCacheInfoResponse(history GetCacheInfoResponseGetHistoryArgType, lastPurgeTime GetCacheInfoResponseGetLastPurgeTimeArgType) *GetCacheInfoResponse { + this := GetCacheInfoResponse{} + setGetCacheInfoResponseGetHistoryAttributeType(&this.History, history) + setGetCacheInfoResponseGetLastPurgeTimeAttributeType(&this.LastPurgeTime, lastPurgeTime) + return &this +} + +// NewGetCacheInfoResponseWithDefaults instantiates a new GetCacheInfoResponse 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 NewGetCacheInfoResponseWithDefaults() *GetCacheInfoResponse { + this := GetCacheInfoResponse{} + return &this +} + +// GetHistory returns the History field value +func (o *GetCacheInfoResponse) GetHistory() (ret GetCacheInfoResponseGetHistoryRetType) { + ret, _ = o.GetHistoryOk() + return ret +} + +// GetHistoryOk returns a tuple with the History field value +// and a boolean to check if the value has been set. +func (o *GetCacheInfoResponse) GetHistoryOk() (ret GetCacheInfoResponseGetHistoryRetType, ok bool) { + return getGetCacheInfoResponseGetHistoryAttributeTypeOk(o.History) +} + +// SetHistory sets field value +func (o *GetCacheInfoResponse) SetHistory(v GetCacheInfoResponseGetHistoryRetType) { + setGetCacheInfoResponseGetHistoryAttributeType(&o.History, v) +} + +// GetLastPurgeTime returns the LastPurgeTime field value +// If the value is explicit nil, the zero value for time.Time will be returned +func (o *GetCacheInfoResponse) GetLastPurgeTime() (ret GetCacheInfoResponseGetLastPurgeTimeRetType) { + ret, _ = o.GetLastPurgeTimeOk() + return ret +} + +// GetLastPurgeTimeOk returns a tuple with the LastPurgeTime field value +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned +func (o *GetCacheInfoResponse) GetLastPurgeTimeOk() (ret GetCacheInfoResponseGetLastPurgeTimeRetType, ok bool) { + return getGetCacheInfoResponseGetLastPurgeTimeAttributeTypeOk(o.LastPurgeTime) +} + +// SetLastPurgeTime sets field value +func (o *GetCacheInfoResponse) SetLastPurgeTime(v GetCacheInfoResponseGetLastPurgeTimeRetType) { + setGetCacheInfoResponseGetLastPurgeTimeAttributeType(&o.LastPurgeTime, v) +} + +func (o GetCacheInfoResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getGetCacheInfoResponseGetHistoryAttributeTypeOk(o.History); ok { + toSerialize["History"] = val + } + if val, ok := getGetCacheInfoResponseGetLastPurgeTimeAttributeTypeOk(o.LastPurgeTime); ok { + toSerialize["LastPurgeTime"] = val + } + return toSerialize, nil +} + +type NullableGetCacheInfoResponse struct { + value *GetCacheInfoResponse + isSet bool +} + +func (v NullableGetCacheInfoResponse) Get() *GetCacheInfoResponse { + return v.value +} + +func (v *NullableGetCacheInfoResponse) Set(val *GetCacheInfoResponse) { + v.value = val + v.isSet = true +} + +func (v NullableGetCacheInfoResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableGetCacheInfoResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableGetCacheInfoResponse(val *GetCacheInfoResponse) *NullableGetCacheInfoResponse { + return &NullableGetCacheInfoResponse{value: val, isSet: true} +} + +func (v NullableGetCacheInfoResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableGetCacheInfoResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cdn/model_get_cache_info_response_history_entry.go b/services/cdn/model_get_cache_info_response_history_entry.go new file mode 100644 index 000000000..f3782c424 --- /dev/null +++ b/services/cdn/model_get_cache_info_response_history_entry.go @@ -0,0 +1,216 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +import ( + "encoding/json" + "time" +) + +// checks if the GetCacheInfoResponseHistoryEntry type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &GetCacheInfoResponseHistoryEntry{} + +/* + types and functions for occuredAt +*/ + +// isDateTime +type GetCacheInfoResponseHistoryEntryGetOccuredAtAttributeType = *time.Time +type GetCacheInfoResponseHistoryEntryGetOccuredAtArgType = time.Time +type GetCacheInfoResponseHistoryEntryGetOccuredAtRetType = time.Time + +func getGetCacheInfoResponseHistoryEntryGetOccuredAtAttributeTypeOk(arg GetCacheInfoResponseHistoryEntryGetOccuredAtAttributeType) (ret GetCacheInfoResponseHistoryEntryGetOccuredAtRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setGetCacheInfoResponseHistoryEntryGetOccuredAtAttributeType(arg *GetCacheInfoResponseHistoryEntryGetOccuredAtAttributeType, val GetCacheInfoResponseHistoryEntryGetOccuredAtRetType) { + *arg = &val +} + +/* + types and functions for occurredAt +*/ + +// isDateTime +type GetCacheInfoResponseHistoryEntryGetOccurredAtAttributeType = *time.Time +type GetCacheInfoResponseHistoryEntryGetOccurredAtArgType = time.Time +type GetCacheInfoResponseHistoryEntryGetOccurredAtRetType = time.Time + +func getGetCacheInfoResponseHistoryEntryGetOccurredAtAttributeTypeOk(arg GetCacheInfoResponseHistoryEntryGetOccurredAtAttributeType) (ret GetCacheInfoResponseHistoryEntryGetOccurredAtRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setGetCacheInfoResponseHistoryEntryGetOccurredAtAttributeType(arg *GetCacheInfoResponseHistoryEntryGetOccurredAtAttributeType, val GetCacheInfoResponseHistoryEntryGetOccurredAtRetType) { + *arg = &val +} + +/* + types and functions for type +*/ + +// isEnumRef +type GetCacheInfoResponseHistoryEntryGetTypeAttributeType = *string +type GetCacheInfoResponseHistoryEntryGetTypeArgType = string +type GetCacheInfoResponseHistoryEntryGetTypeRetType = string + +func getGetCacheInfoResponseHistoryEntryGetTypeAttributeTypeOk(arg GetCacheInfoResponseHistoryEntryGetTypeAttributeType) (ret GetCacheInfoResponseHistoryEntryGetTypeRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setGetCacheInfoResponseHistoryEntryGetTypeAttributeType(arg *GetCacheInfoResponseHistoryEntryGetTypeAttributeType, val GetCacheInfoResponseHistoryEntryGetTypeRetType) { + *arg = &val +} + +// GetCacheInfoResponseHistoryEntry struct for GetCacheInfoResponseHistoryEntry +type GetCacheInfoResponseHistoryEntry struct { + // Deprecated: Check the GitHub changelog for alternatives + // REQUIRED + OccuredAt GetCacheInfoResponseHistoryEntryGetOccuredAtAttributeType `json:"occuredAt"` + // REQUIRED + OccurredAt GetCacheInfoResponseHistoryEntryGetOccurredAtAttributeType `json:"occurredAt"` + // REQUIRED + Type GetCacheInfoResponseHistoryEntryGetTypeAttributeType `json:"type"` +} + +type _GetCacheInfoResponseHistoryEntry GetCacheInfoResponseHistoryEntry + +// NewGetCacheInfoResponseHistoryEntry instantiates a new GetCacheInfoResponseHistoryEntry 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 NewGetCacheInfoResponseHistoryEntry(occuredAt GetCacheInfoResponseHistoryEntryGetOccuredAtArgType, occurredAt GetCacheInfoResponseHistoryEntryGetOccurredAtArgType, type_ GetCacheInfoResponseHistoryEntryGetTypeArgType) *GetCacheInfoResponseHistoryEntry { + this := GetCacheInfoResponseHistoryEntry{} + setGetCacheInfoResponseHistoryEntryGetOccuredAtAttributeType(&this.OccuredAt, occuredAt) + setGetCacheInfoResponseHistoryEntryGetOccurredAtAttributeType(&this.OccurredAt, occurredAt) + setGetCacheInfoResponseHistoryEntryGetTypeAttributeType(&this.Type, type_) + return &this +} + +// NewGetCacheInfoResponseHistoryEntryWithDefaults instantiates a new GetCacheInfoResponseHistoryEntry 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 NewGetCacheInfoResponseHistoryEntryWithDefaults() *GetCacheInfoResponseHistoryEntry { + this := GetCacheInfoResponseHistoryEntry{} + return &this +} + +// GetOccuredAt returns the OccuredAt field value +// Deprecated +func (o *GetCacheInfoResponseHistoryEntry) GetOccuredAt() (ret GetCacheInfoResponseHistoryEntryGetOccuredAtRetType) { + ret, _ = o.GetOccuredAtOk() + return ret +} + +// GetOccuredAtOk returns a tuple with the OccuredAt field value +// and a boolean to check if the value has been set. +// Deprecated +func (o *GetCacheInfoResponseHistoryEntry) GetOccuredAtOk() (ret GetCacheInfoResponseHistoryEntryGetOccuredAtRetType, ok bool) { + return getGetCacheInfoResponseHistoryEntryGetOccuredAtAttributeTypeOk(o.OccuredAt) +} + +// SetOccuredAt sets field value +// Deprecated +func (o *GetCacheInfoResponseHistoryEntry) SetOccuredAt(v GetCacheInfoResponseHistoryEntryGetOccuredAtRetType) { + setGetCacheInfoResponseHistoryEntryGetOccuredAtAttributeType(&o.OccuredAt, v) +} + +// GetOccurredAt returns the OccurredAt field value +func (o *GetCacheInfoResponseHistoryEntry) GetOccurredAt() (ret GetCacheInfoResponseHistoryEntryGetOccurredAtRetType) { + ret, _ = o.GetOccurredAtOk() + return ret +} + +// GetOccurredAtOk returns a tuple with the OccurredAt field value +// and a boolean to check if the value has been set. +func (o *GetCacheInfoResponseHistoryEntry) GetOccurredAtOk() (ret GetCacheInfoResponseHistoryEntryGetOccurredAtRetType, ok bool) { + return getGetCacheInfoResponseHistoryEntryGetOccurredAtAttributeTypeOk(o.OccurredAt) +} + +// SetOccurredAt sets field value +func (o *GetCacheInfoResponseHistoryEntry) SetOccurredAt(v GetCacheInfoResponseHistoryEntryGetOccurredAtRetType) { + setGetCacheInfoResponseHistoryEntryGetOccurredAtAttributeType(&o.OccurredAt, v) +} + +// GetType returns the Type field value +func (o *GetCacheInfoResponseHistoryEntry) GetType() (ret GetCacheInfoResponseHistoryEntryGetTypeRetType) { + ret, _ = o.GetTypeOk() + return ret +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *GetCacheInfoResponseHistoryEntry) GetTypeOk() (ret GetCacheInfoResponseHistoryEntryGetTypeRetType, ok bool) { + return getGetCacheInfoResponseHistoryEntryGetTypeAttributeTypeOk(o.Type) +} + +// SetType sets field value +func (o *GetCacheInfoResponseHistoryEntry) SetType(v GetCacheInfoResponseHistoryEntryGetTypeRetType) { + setGetCacheInfoResponseHistoryEntryGetTypeAttributeType(&o.Type, v) +} + +func (o GetCacheInfoResponseHistoryEntry) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getGetCacheInfoResponseHistoryEntryGetOccuredAtAttributeTypeOk(o.OccuredAt); ok { + toSerialize["OccuredAt"] = val + } + if val, ok := getGetCacheInfoResponseHistoryEntryGetOccurredAtAttributeTypeOk(o.OccurredAt); ok { + toSerialize["OccurredAt"] = val + } + if val, ok := getGetCacheInfoResponseHistoryEntryGetTypeAttributeTypeOk(o.Type); ok { + toSerialize["Type"] = val + } + return toSerialize, nil +} + +type NullableGetCacheInfoResponseHistoryEntry struct { + value *GetCacheInfoResponseHistoryEntry + isSet bool +} + +func (v NullableGetCacheInfoResponseHistoryEntry) Get() *GetCacheInfoResponseHistoryEntry { + return v.value +} + +func (v *NullableGetCacheInfoResponseHistoryEntry) Set(val *GetCacheInfoResponseHistoryEntry) { + v.value = val + v.isSet = true +} + +func (v NullableGetCacheInfoResponseHistoryEntry) IsSet() bool { + return v.isSet +} + +func (v *NullableGetCacheInfoResponseHistoryEntry) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableGetCacheInfoResponseHistoryEntry(val *GetCacheInfoResponseHistoryEntry) *NullableGetCacheInfoResponseHistoryEntry { + return &NullableGetCacheInfoResponseHistoryEntry{value: val, isSet: true} +} + +func (v NullableGetCacheInfoResponseHistoryEntry) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableGetCacheInfoResponseHistoryEntry) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cdn/model_get_custom_domain_response.go b/services/cdn/model_get_custom_domain_response.go new file mode 100644 index 000000000..40a945394 --- /dev/null +++ b/services/cdn/model_get_custom_domain_response.go @@ -0,0 +1,173 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +import ( + "encoding/json" +) + +// checks if the GetCustomDomainResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &GetCustomDomainResponse{} + +/* + types and functions for customDomain +*/ + +// isModel +type GetCustomDomainResponseGetCustomDomainAttributeType = *CustomDomain +type GetCustomDomainResponseGetCustomDomainArgType = CustomDomain +type GetCustomDomainResponseGetCustomDomainRetType = CustomDomain + +func getGetCustomDomainResponseGetCustomDomainAttributeTypeOk(arg GetCustomDomainResponseGetCustomDomainAttributeType) (ret GetCustomDomainResponseGetCustomDomainRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setGetCustomDomainResponseGetCustomDomainAttributeType(arg *GetCustomDomainResponseGetCustomDomainAttributeType, val GetCustomDomainResponseGetCustomDomainRetType) { + *arg = &val +} + +/* + types and functions for domain +*/ + +// isNotNullableString +type GetCustomDomainResponseGetDomainAttributeType = *string + +func getGetCustomDomainResponseGetDomainAttributeTypeOk(arg GetCustomDomainResponseGetDomainAttributeType) (ret GetCustomDomainResponseGetDomainRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setGetCustomDomainResponseGetDomainAttributeType(arg *GetCustomDomainResponseGetDomainAttributeType, val GetCustomDomainResponseGetDomainRetType) { + *arg = &val +} + +type GetCustomDomainResponseGetDomainArgType = string +type GetCustomDomainResponseGetDomainRetType = string + +// GetCustomDomainResponse struct for GetCustomDomainResponse +type GetCustomDomainResponse struct { + // REQUIRED + CustomDomain GetCustomDomainResponseGetCustomDomainAttributeType `json:"customDomain"` + // Deprecated: Check the GitHub changelog for alternatives + // REQUIRED + Domain GetCustomDomainResponseGetDomainAttributeType `json:"domain"` +} + +type _GetCustomDomainResponse GetCustomDomainResponse + +// NewGetCustomDomainResponse instantiates a new GetCustomDomainResponse 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 NewGetCustomDomainResponse(customDomain GetCustomDomainResponseGetCustomDomainArgType, domain GetCustomDomainResponseGetDomainArgType) *GetCustomDomainResponse { + this := GetCustomDomainResponse{} + setGetCustomDomainResponseGetCustomDomainAttributeType(&this.CustomDomain, customDomain) + setGetCustomDomainResponseGetDomainAttributeType(&this.Domain, domain) + return &this +} + +// NewGetCustomDomainResponseWithDefaults instantiates a new GetCustomDomainResponse 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 NewGetCustomDomainResponseWithDefaults() *GetCustomDomainResponse { + this := GetCustomDomainResponse{} + return &this +} + +// GetCustomDomain returns the CustomDomain field value +func (o *GetCustomDomainResponse) GetCustomDomain() (ret GetCustomDomainResponseGetCustomDomainRetType) { + ret, _ = o.GetCustomDomainOk() + return ret +} + +// GetCustomDomainOk returns a tuple with the CustomDomain field value +// and a boolean to check if the value has been set. +func (o *GetCustomDomainResponse) GetCustomDomainOk() (ret GetCustomDomainResponseGetCustomDomainRetType, ok bool) { + return getGetCustomDomainResponseGetCustomDomainAttributeTypeOk(o.CustomDomain) +} + +// SetCustomDomain sets field value +func (o *GetCustomDomainResponse) SetCustomDomain(v GetCustomDomainResponseGetCustomDomainRetType) { + setGetCustomDomainResponseGetCustomDomainAttributeType(&o.CustomDomain, v) +} + +// GetDomain returns the Domain field value +// Deprecated +func (o *GetCustomDomainResponse) GetDomain() (ret GetCustomDomainResponseGetDomainRetType) { + ret, _ = o.GetDomainOk() + return ret +} + +// GetDomainOk returns a tuple with the Domain field value +// and a boolean to check if the value has been set. +// Deprecated +func (o *GetCustomDomainResponse) GetDomainOk() (ret GetCustomDomainResponseGetDomainRetType, ok bool) { + return getGetCustomDomainResponseGetDomainAttributeTypeOk(o.Domain) +} + +// SetDomain sets field value +// Deprecated +func (o *GetCustomDomainResponse) SetDomain(v GetCustomDomainResponseGetDomainRetType) { + setGetCustomDomainResponseGetDomainAttributeType(&o.Domain, v) +} + +func (o GetCustomDomainResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getGetCustomDomainResponseGetCustomDomainAttributeTypeOk(o.CustomDomain); ok { + toSerialize["CustomDomain"] = val + } + if val, ok := getGetCustomDomainResponseGetDomainAttributeTypeOk(o.Domain); ok { + toSerialize["Domain"] = val + } + return toSerialize, nil +} + +type NullableGetCustomDomainResponse struct { + value *GetCustomDomainResponse + isSet bool +} + +func (v NullableGetCustomDomainResponse) Get() *GetCustomDomainResponse { + return v.value +} + +func (v *NullableGetCustomDomainResponse) Set(val *GetCustomDomainResponse) { + v.value = val + v.isSet = true +} + +func (v NullableGetCustomDomainResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableGetCustomDomainResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableGetCustomDomainResponse(val *GetCustomDomainResponse) *NullableGetCustomDomainResponse { + return &NullableGetCustomDomainResponse{value: val, isSet: true} +} + +func (v NullableGetCustomDomainResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableGetCustomDomainResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cdn/model_get_distribution_response.go b/services/cdn/model_get_distribution_response.go new file mode 100644 index 000000000..32dce8709 --- /dev/null +++ b/services/cdn/model_get_distribution_response.go @@ -0,0 +1,125 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +import ( + "encoding/json" +) + +// checks if the GetDistributionResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &GetDistributionResponse{} + +/* + types and functions for distribution +*/ + +// isModel +type GetDistributionResponseGetDistributionAttributeType = *Distribution +type GetDistributionResponseGetDistributionArgType = Distribution +type GetDistributionResponseGetDistributionRetType = Distribution + +func getGetDistributionResponseGetDistributionAttributeTypeOk(arg GetDistributionResponseGetDistributionAttributeType) (ret GetDistributionResponseGetDistributionRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setGetDistributionResponseGetDistributionAttributeType(arg *GetDistributionResponseGetDistributionAttributeType, val GetDistributionResponseGetDistributionRetType) { + *arg = &val +} + +// GetDistributionResponse struct for GetDistributionResponse +type GetDistributionResponse struct { + // REQUIRED + Distribution GetDistributionResponseGetDistributionAttributeType `json:"distribution"` +} + +type _GetDistributionResponse GetDistributionResponse + +// NewGetDistributionResponse instantiates a new GetDistributionResponse 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 NewGetDistributionResponse(distribution GetDistributionResponseGetDistributionArgType) *GetDistributionResponse { + this := GetDistributionResponse{} + setGetDistributionResponseGetDistributionAttributeType(&this.Distribution, distribution) + return &this +} + +// NewGetDistributionResponseWithDefaults instantiates a new GetDistributionResponse 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 NewGetDistributionResponseWithDefaults() *GetDistributionResponse { + this := GetDistributionResponse{} + return &this +} + +// GetDistribution returns the Distribution field value +func (o *GetDistributionResponse) GetDistribution() (ret GetDistributionResponseGetDistributionRetType) { + ret, _ = o.GetDistributionOk() + return ret +} + +// GetDistributionOk returns a tuple with the Distribution field value +// and a boolean to check if the value has been set. +func (o *GetDistributionResponse) GetDistributionOk() (ret GetDistributionResponseGetDistributionRetType, ok bool) { + return getGetDistributionResponseGetDistributionAttributeTypeOk(o.Distribution) +} + +// SetDistribution sets field value +func (o *GetDistributionResponse) SetDistribution(v GetDistributionResponseGetDistributionRetType) { + setGetDistributionResponseGetDistributionAttributeType(&o.Distribution, v) +} + +func (o GetDistributionResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getGetDistributionResponseGetDistributionAttributeTypeOk(o.Distribution); ok { + toSerialize["Distribution"] = val + } + return toSerialize, nil +} + +type NullableGetDistributionResponse struct { + value *GetDistributionResponse + isSet bool +} + +func (v NullableGetDistributionResponse) Get() *GetDistributionResponse { + return v.value +} + +func (v *NullableGetDistributionResponse) Set(val *GetDistributionResponse) { + v.value = val + v.isSet = true +} + +func (v NullableGetDistributionResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableGetDistributionResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableGetDistributionResponse(val *GetDistributionResponse) *NullableGetDistributionResponse { + return &NullableGetDistributionResponse{value: val, isSet: true} +} + +func (v NullableGetDistributionResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableGetDistributionResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cdn/model_get_statistics_response.go b/services/cdn/model_get_statistics_response.go new file mode 100644 index 000000000..90528bdf6 --- /dev/null +++ b/services/cdn/model_get_statistics_response.go @@ -0,0 +1,125 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +import ( + "encoding/json" +) + +// checks if the GetStatisticsResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &GetStatisticsResponse{} + +/* + types and functions for records +*/ + +// isArray +type GetStatisticsResponseGetRecordsAttributeType = *[]DistributionStatisticsRecord +type GetStatisticsResponseGetRecordsArgType = []DistributionStatisticsRecord +type GetStatisticsResponseGetRecordsRetType = []DistributionStatisticsRecord + +func getGetStatisticsResponseGetRecordsAttributeTypeOk(arg GetStatisticsResponseGetRecordsAttributeType) (ret GetStatisticsResponseGetRecordsRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setGetStatisticsResponseGetRecordsAttributeType(arg *GetStatisticsResponseGetRecordsAttributeType, val GetStatisticsResponseGetRecordsRetType) { + *arg = &val +} + +// GetStatisticsResponse struct for GetStatisticsResponse +type GetStatisticsResponse struct { + // REQUIRED + Records GetStatisticsResponseGetRecordsAttributeType `json:"records"` +} + +type _GetStatisticsResponse GetStatisticsResponse + +// NewGetStatisticsResponse instantiates a new GetStatisticsResponse 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 NewGetStatisticsResponse(records GetStatisticsResponseGetRecordsArgType) *GetStatisticsResponse { + this := GetStatisticsResponse{} + setGetStatisticsResponseGetRecordsAttributeType(&this.Records, records) + return &this +} + +// NewGetStatisticsResponseWithDefaults instantiates a new GetStatisticsResponse 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 NewGetStatisticsResponseWithDefaults() *GetStatisticsResponse { + this := GetStatisticsResponse{} + return &this +} + +// GetRecords returns the Records field value +func (o *GetStatisticsResponse) GetRecords() (ret GetStatisticsResponseGetRecordsRetType) { + ret, _ = o.GetRecordsOk() + return ret +} + +// GetRecordsOk returns a tuple with the Records field value +// and a boolean to check if the value has been set. +func (o *GetStatisticsResponse) GetRecordsOk() (ret GetStatisticsResponseGetRecordsRetType, ok bool) { + return getGetStatisticsResponseGetRecordsAttributeTypeOk(o.Records) +} + +// SetRecords sets field value +func (o *GetStatisticsResponse) SetRecords(v GetStatisticsResponseGetRecordsRetType) { + setGetStatisticsResponseGetRecordsAttributeType(&o.Records, v) +} + +func (o GetStatisticsResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getGetStatisticsResponseGetRecordsAttributeTypeOk(o.Records); ok { + toSerialize["Records"] = val + } + return toSerialize, nil +} + +type NullableGetStatisticsResponse struct { + value *GetStatisticsResponse + isSet bool +} + +func (v NullableGetStatisticsResponse) Get() *GetStatisticsResponse { + return v.value +} + +func (v *NullableGetStatisticsResponse) Set(val *GetStatisticsResponse) { + v.value = val + v.isSet = true +} + +func (v NullableGetStatisticsResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableGetStatisticsResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableGetStatisticsResponse(val *GetStatisticsResponse) *NullableGetStatisticsResponse { + return &NullableGetStatisticsResponse{value: val, isSet: true} +} + +func (v NullableGetStatisticsResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableGetStatisticsResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cdn/model_http_backend.go b/services/cdn/model_http_backend.go new file mode 100644 index 000000000..1df8aec85 --- /dev/null +++ b/services/cdn/model_http_backend.go @@ -0,0 +1,214 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +import ( + "encoding/json" +) + +// checks if the HttpBackend type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &HttpBackend{} + +/* + types and functions for originRequestHeaders +*/ + +// isContainer +type HttpBackendGetOriginRequestHeadersAttributeType = *map[string]string +type HttpBackendGetOriginRequestHeadersArgType = map[string]string +type HttpBackendGetOriginRequestHeadersRetType = map[string]string + +func getHttpBackendGetOriginRequestHeadersAttributeTypeOk(arg HttpBackendGetOriginRequestHeadersAttributeType) (ret HttpBackendGetOriginRequestHeadersRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setHttpBackendGetOriginRequestHeadersAttributeType(arg *HttpBackendGetOriginRequestHeadersAttributeType, val HttpBackendGetOriginRequestHeadersRetType) { + *arg = &val +} + +/* + types and functions for originUrl +*/ + +// isNotNullableString +type HttpBackendGetOriginUrlAttributeType = *string + +func getHttpBackendGetOriginUrlAttributeTypeOk(arg HttpBackendGetOriginUrlAttributeType) (ret HttpBackendGetOriginUrlRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setHttpBackendGetOriginUrlAttributeType(arg *HttpBackendGetOriginUrlAttributeType, val HttpBackendGetOriginUrlRetType) { + *arg = &val +} + +type HttpBackendGetOriginUrlArgType = string +type HttpBackendGetOriginUrlRetType = string + +/* + types and functions for type +*/ + +// isNotNullableString +type HttpBackendGetTypeAttributeType = *string + +func getHttpBackendGetTypeAttributeTypeOk(arg HttpBackendGetTypeAttributeType) (ret HttpBackendGetTypeRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setHttpBackendGetTypeAttributeType(arg *HttpBackendGetTypeAttributeType, val HttpBackendGetTypeRetType) { + *arg = &val +} + +type HttpBackendGetTypeArgType = string +type HttpBackendGetTypeRetType = string + +// HttpBackend struct for HttpBackend +type HttpBackend struct { + // Headers that will be sent with every request to the configured origin. **WARNING**: Do not store sensitive values in the headers. The configuration is stored as plain text. + // REQUIRED + OriginRequestHeaders HttpBackendGetOriginRequestHeadersAttributeType `json:"originRequestHeaders"` + // REQUIRED + OriginUrl HttpBackendGetOriginUrlAttributeType `json:"originUrl"` + // REQUIRED + Type HttpBackendGetTypeAttributeType `json:"type"` +} + +type _HttpBackend HttpBackend + +// NewHttpBackend instantiates a new HttpBackend 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 NewHttpBackend(originRequestHeaders HttpBackendGetOriginRequestHeadersArgType, originUrl HttpBackendGetOriginUrlArgType, type_ HttpBackendGetTypeArgType) *HttpBackend { + this := HttpBackend{} + setHttpBackendGetOriginRequestHeadersAttributeType(&this.OriginRequestHeaders, originRequestHeaders) + setHttpBackendGetOriginUrlAttributeType(&this.OriginUrl, originUrl) + setHttpBackendGetTypeAttributeType(&this.Type, type_) + return &this +} + +// NewHttpBackendWithDefaults instantiates a new HttpBackend 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 NewHttpBackendWithDefaults() *HttpBackend { + this := HttpBackend{} + return &this +} + +// GetOriginRequestHeaders returns the OriginRequestHeaders field value +func (o *HttpBackend) GetOriginRequestHeaders() (ret HttpBackendGetOriginRequestHeadersRetType) { + ret, _ = o.GetOriginRequestHeadersOk() + return ret +} + +// GetOriginRequestHeadersOk returns a tuple with the OriginRequestHeaders field value +// and a boolean to check if the value has been set. +func (o *HttpBackend) GetOriginRequestHeadersOk() (ret HttpBackendGetOriginRequestHeadersRetType, ok bool) { + return getHttpBackendGetOriginRequestHeadersAttributeTypeOk(o.OriginRequestHeaders) +} + +// SetOriginRequestHeaders sets field value +func (o *HttpBackend) SetOriginRequestHeaders(v HttpBackendGetOriginRequestHeadersRetType) { + setHttpBackendGetOriginRequestHeadersAttributeType(&o.OriginRequestHeaders, v) +} + +// GetOriginUrl returns the OriginUrl field value +func (o *HttpBackend) GetOriginUrl() (ret HttpBackendGetOriginUrlRetType) { + ret, _ = o.GetOriginUrlOk() + return ret +} + +// GetOriginUrlOk returns a tuple with the OriginUrl field value +// and a boolean to check if the value has been set. +func (o *HttpBackend) GetOriginUrlOk() (ret HttpBackendGetOriginUrlRetType, ok bool) { + return getHttpBackendGetOriginUrlAttributeTypeOk(o.OriginUrl) +} + +// SetOriginUrl sets field value +func (o *HttpBackend) SetOriginUrl(v HttpBackendGetOriginUrlRetType) { + setHttpBackendGetOriginUrlAttributeType(&o.OriginUrl, v) +} + +// GetType returns the Type field value +func (o *HttpBackend) GetType() (ret HttpBackendGetTypeRetType) { + ret, _ = o.GetTypeOk() + return ret +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *HttpBackend) GetTypeOk() (ret HttpBackendGetTypeRetType, ok bool) { + return getHttpBackendGetTypeAttributeTypeOk(o.Type) +} + +// SetType sets field value +func (o *HttpBackend) SetType(v HttpBackendGetTypeRetType) { + setHttpBackendGetTypeAttributeType(&o.Type, v) +} + +func (o HttpBackend) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getHttpBackendGetOriginRequestHeadersAttributeTypeOk(o.OriginRequestHeaders); ok { + toSerialize["OriginRequestHeaders"] = val + } + if val, ok := getHttpBackendGetOriginUrlAttributeTypeOk(o.OriginUrl); ok { + toSerialize["OriginUrl"] = val + } + if val, ok := getHttpBackendGetTypeAttributeTypeOk(o.Type); ok { + toSerialize["Type"] = val + } + return toSerialize, nil +} + +type NullableHttpBackend struct { + value *HttpBackend + isSet bool +} + +func (v NullableHttpBackend) Get() *HttpBackend { + return v.value +} + +func (v *NullableHttpBackend) Set(val *HttpBackend) { + v.value = val + v.isSet = true +} + +func (v NullableHttpBackend) IsSet() bool { + return v.isSet +} + +func (v *NullableHttpBackend) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableHttpBackend(val *HttpBackend) *NullableHttpBackend { + return &NullableHttpBackend{value: val, isSet: true} +} + +func (v NullableHttpBackend) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableHttpBackend) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cdn/model_http_backend_patch.go b/services/cdn/model_http_backend_patch.go new file mode 100644 index 000000000..82fd341bd --- /dev/null +++ b/services/cdn/model_http_backend_patch.go @@ -0,0 +1,223 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +import ( + "encoding/json" +) + +// checks if the HttpBackendPatch type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &HttpBackendPatch{} + +/* + types and functions for originRequestHeaders +*/ + +// isContainer +type HttpBackendPatchGetOriginRequestHeadersAttributeType = *map[string]string +type HttpBackendPatchGetOriginRequestHeadersArgType = map[string]string +type HttpBackendPatchGetOriginRequestHeadersRetType = map[string]string + +func getHttpBackendPatchGetOriginRequestHeadersAttributeTypeOk(arg HttpBackendPatchGetOriginRequestHeadersAttributeType) (ret HttpBackendPatchGetOriginRequestHeadersRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setHttpBackendPatchGetOriginRequestHeadersAttributeType(arg *HttpBackendPatchGetOriginRequestHeadersAttributeType, val HttpBackendPatchGetOriginRequestHeadersRetType) { + *arg = &val +} + +/* + types and functions for originUrl +*/ + +// isNotNullableString +type HttpBackendPatchGetOriginUrlAttributeType = *string + +func getHttpBackendPatchGetOriginUrlAttributeTypeOk(arg HttpBackendPatchGetOriginUrlAttributeType) (ret HttpBackendPatchGetOriginUrlRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setHttpBackendPatchGetOriginUrlAttributeType(arg *HttpBackendPatchGetOriginUrlAttributeType, val HttpBackendPatchGetOriginUrlRetType) { + *arg = &val +} + +type HttpBackendPatchGetOriginUrlArgType = string +type HttpBackendPatchGetOriginUrlRetType = string + +/* + types and functions for type +*/ + +// isNotNullableString +type HttpBackendPatchGetTypeAttributeType = *string + +func getHttpBackendPatchGetTypeAttributeTypeOk(arg HttpBackendPatchGetTypeAttributeType) (ret HttpBackendPatchGetTypeRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setHttpBackendPatchGetTypeAttributeType(arg *HttpBackendPatchGetTypeAttributeType, val HttpBackendPatchGetTypeRetType) { + *arg = &val +} + +type HttpBackendPatchGetTypeArgType = string +type HttpBackendPatchGetTypeRetType = string + +// HttpBackendPatch A partial HTTP Backend +type HttpBackendPatch struct { + // Headers that will be sent with every request to the configured origin. **WARNING**: Do not store sensitive values in the headers. The configuration is stored as plain text. + OriginRequestHeaders HttpBackendPatchGetOriginRequestHeadersAttributeType `json:"originRequestHeaders,omitempty"` + OriginUrl HttpBackendPatchGetOriginUrlAttributeType `json:"originUrl,omitempty"` + // This property is required to determine the used backend type. + // REQUIRED + Type HttpBackendPatchGetTypeAttributeType `json:"type"` +} + +type _HttpBackendPatch HttpBackendPatch + +// NewHttpBackendPatch instantiates a new HttpBackendPatch 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 NewHttpBackendPatch(type_ HttpBackendPatchGetTypeArgType) *HttpBackendPatch { + this := HttpBackendPatch{} + setHttpBackendPatchGetTypeAttributeType(&this.Type, type_) + return &this +} + +// NewHttpBackendPatchWithDefaults instantiates a new HttpBackendPatch 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 NewHttpBackendPatchWithDefaults() *HttpBackendPatch { + this := HttpBackendPatch{} + return &this +} + +// GetOriginRequestHeaders returns the OriginRequestHeaders field value if set, zero value otherwise. +func (o *HttpBackendPatch) GetOriginRequestHeaders() (res HttpBackendPatchGetOriginRequestHeadersRetType) { + res, _ = o.GetOriginRequestHeadersOk() + return +} + +// GetOriginRequestHeadersOk returns a tuple with the OriginRequestHeaders field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HttpBackendPatch) GetOriginRequestHeadersOk() (ret HttpBackendPatchGetOriginRequestHeadersRetType, ok bool) { + return getHttpBackendPatchGetOriginRequestHeadersAttributeTypeOk(o.OriginRequestHeaders) +} + +// HasOriginRequestHeaders returns a boolean if a field has been set. +func (o *HttpBackendPatch) HasOriginRequestHeaders() bool { + _, ok := o.GetOriginRequestHeadersOk() + return ok +} + +// SetOriginRequestHeaders gets a reference to the given map[string]string and assigns it to the OriginRequestHeaders field. +func (o *HttpBackendPatch) SetOriginRequestHeaders(v HttpBackendPatchGetOriginRequestHeadersRetType) { + setHttpBackendPatchGetOriginRequestHeadersAttributeType(&o.OriginRequestHeaders, v) +} + +// GetOriginUrl returns the OriginUrl field value if set, zero value otherwise. +func (o *HttpBackendPatch) GetOriginUrl() (res HttpBackendPatchGetOriginUrlRetType) { + res, _ = o.GetOriginUrlOk() + return +} + +// GetOriginUrlOk returns a tuple with the OriginUrl field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HttpBackendPatch) GetOriginUrlOk() (ret HttpBackendPatchGetOriginUrlRetType, ok bool) { + return getHttpBackendPatchGetOriginUrlAttributeTypeOk(o.OriginUrl) +} + +// HasOriginUrl returns a boolean if a field has been set. +func (o *HttpBackendPatch) HasOriginUrl() bool { + _, ok := o.GetOriginUrlOk() + return ok +} + +// SetOriginUrl gets a reference to the given string and assigns it to the OriginUrl field. +func (o *HttpBackendPatch) SetOriginUrl(v HttpBackendPatchGetOriginUrlRetType) { + setHttpBackendPatchGetOriginUrlAttributeType(&o.OriginUrl, v) +} + +// GetType returns the Type field value +func (o *HttpBackendPatch) GetType() (ret HttpBackendPatchGetTypeRetType) { + ret, _ = o.GetTypeOk() + return ret +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *HttpBackendPatch) GetTypeOk() (ret HttpBackendPatchGetTypeRetType, ok bool) { + return getHttpBackendPatchGetTypeAttributeTypeOk(o.Type) +} + +// SetType sets field value +func (o *HttpBackendPatch) SetType(v HttpBackendPatchGetTypeRetType) { + setHttpBackendPatchGetTypeAttributeType(&o.Type, v) +} + +func (o HttpBackendPatch) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getHttpBackendPatchGetOriginRequestHeadersAttributeTypeOk(o.OriginRequestHeaders); ok { + toSerialize["OriginRequestHeaders"] = val + } + if val, ok := getHttpBackendPatchGetOriginUrlAttributeTypeOk(o.OriginUrl); ok { + toSerialize["OriginUrl"] = val + } + if val, ok := getHttpBackendPatchGetTypeAttributeTypeOk(o.Type); ok { + toSerialize["Type"] = val + } + return toSerialize, nil +} + +type NullableHttpBackendPatch struct { + value *HttpBackendPatch + isSet bool +} + +func (v NullableHttpBackendPatch) Get() *HttpBackendPatch { + return v.value +} + +func (v *NullableHttpBackendPatch) Set(val *HttpBackendPatch) { + v.value = val + v.isSet = true +} + +func (v NullableHttpBackendPatch) IsSet() bool { + return v.isSet +} + +func (v *NullableHttpBackendPatch) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableHttpBackendPatch(val *HttpBackendPatch) *NullableHttpBackendPatch { + return &NullableHttpBackendPatch{value: val, isSet: true} +} + +func (v NullableHttpBackendPatch) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableHttpBackendPatch) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cdn/model_list_distributions_response.go b/services/cdn/model_list_distributions_response.go new file mode 100644 index 000000000..8bd574d59 --- /dev/null +++ b/services/cdn/model_list_distributions_response.go @@ -0,0 +1,173 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +import ( + "encoding/json" +) + +// checks if the ListDistributionsResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ListDistributionsResponse{} + +/* + types and functions for distributions +*/ + +// isArray +type ListDistributionsResponseGetDistributionsAttributeType = *[]Distribution +type ListDistributionsResponseGetDistributionsArgType = []Distribution +type ListDistributionsResponseGetDistributionsRetType = []Distribution + +func getListDistributionsResponseGetDistributionsAttributeTypeOk(arg ListDistributionsResponseGetDistributionsAttributeType) (ret ListDistributionsResponseGetDistributionsRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setListDistributionsResponseGetDistributionsAttributeType(arg *ListDistributionsResponseGetDistributionsAttributeType, val ListDistributionsResponseGetDistributionsRetType) { + *arg = &val +} + +/* + types and functions for nextPageIdentifier +*/ + +// isNotNullableString +type ListDistributionsResponseGetNextPageIdentifierAttributeType = *string + +func getListDistributionsResponseGetNextPageIdentifierAttributeTypeOk(arg ListDistributionsResponseGetNextPageIdentifierAttributeType) (ret ListDistributionsResponseGetNextPageIdentifierRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setListDistributionsResponseGetNextPageIdentifierAttributeType(arg *ListDistributionsResponseGetNextPageIdentifierAttributeType, val ListDistributionsResponseGetNextPageIdentifierRetType) { + *arg = &val +} + +type ListDistributionsResponseGetNextPageIdentifierArgType = string +type ListDistributionsResponseGetNextPageIdentifierRetType = string + +// ListDistributionsResponse struct for ListDistributionsResponse +type ListDistributionsResponse struct { + // REQUIRED + Distributions ListDistributionsResponseGetDistributionsAttributeType `json:"distributions"` + NextPageIdentifier ListDistributionsResponseGetNextPageIdentifierAttributeType `json:"nextPageIdentifier,omitempty"` +} + +type _ListDistributionsResponse ListDistributionsResponse + +// NewListDistributionsResponse instantiates a new ListDistributionsResponse 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 NewListDistributionsResponse(distributions ListDistributionsResponseGetDistributionsArgType) *ListDistributionsResponse { + this := ListDistributionsResponse{} + setListDistributionsResponseGetDistributionsAttributeType(&this.Distributions, distributions) + return &this +} + +// NewListDistributionsResponseWithDefaults instantiates a new ListDistributionsResponse 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 NewListDistributionsResponseWithDefaults() *ListDistributionsResponse { + this := ListDistributionsResponse{} + return &this +} + +// GetDistributions returns the Distributions field value +func (o *ListDistributionsResponse) GetDistributions() (ret ListDistributionsResponseGetDistributionsRetType) { + ret, _ = o.GetDistributionsOk() + return ret +} + +// GetDistributionsOk returns a tuple with the Distributions field value +// and a boolean to check if the value has been set. +func (o *ListDistributionsResponse) GetDistributionsOk() (ret ListDistributionsResponseGetDistributionsRetType, ok bool) { + return getListDistributionsResponseGetDistributionsAttributeTypeOk(o.Distributions) +} + +// SetDistributions sets field value +func (o *ListDistributionsResponse) SetDistributions(v ListDistributionsResponseGetDistributionsRetType) { + setListDistributionsResponseGetDistributionsAttributeType(&o.Distributions, v) +} + +// GetNextPageIdentifier returns the NextPageIdentifier field value if set, zero value otherwise. +func (o *ListDistributionsResponse) GetNextPageIdentifier() (res ListDistributionsResponseGetNextPageIdentifierRetType) { + res, _ = o.GetNextPageIdentifierOk() + return +} + +// GetNextPageIdentifierOk returns a tuple with the NextPageIdentifier field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ListDistributionsResponse) GetNextPageIdentifierOk() (ret ListDistributionsResponseGetNextPageIdentifierRetType, ok bool) { + return getListDistributionsResponseGetNextPageIdentifierAttributeTypeOk(o.NextPageIdentifier) +} + +// HasNextPageIdentifier returns a boolean if a field has been set. +func (o *ListDistributionsResponse) HasNextPageIdentifier() bool { + _, ok := o.GetNextPageIdentifierOk() + return ok +} + +// SetNextPageIdentifier gets a reference to the given string and assigns it to the NextPageIdentifier field. +func (o *ListDistributionsResponse) SetNextPageIdentifier(v ListDistributionsResponseGetNextPageIdentifierRetType) { + setListDistributionsResponseGetNextPageIdentifierAttributeType(&o.NextPageIdentifier, v) +} + +func (o ListDistributionsResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getListDistributionsResponseGetDistributionsAttributeTypeOk(o.Distributions); ok { + toSerialize["Distributions"] = val + } + if val, ok := getListDistributionsResponseGetNextPageIdentifierAttributeTypeOk(o.NextPageIdentifier); ok { + toSerialize["NextPageIdentifier"] = val + } + return toSerialize, nil +} + +type NullableListDistributionsResponse struct { + value *ListDistributionsResponse + isSet bool +} + +func (v NullableListDistributionsResponse) Get() *ListDistributionsResponse { + return v.value +} + +func (v *NullableListDistributionsResponse) Set(val *ListDistributionsResponse) { + v.value = val + v.isSet = true +} + +func (v NullableListDistributionsResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableListDistributionsResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableListDistributionsResponse(val *ListDistributionsResponse) *NullableListDistributionsResponse { + return &NullableListDistributionsResponse{value: val, isSet: true} +} + +func (v NullableListDistributionsResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableListDistributionsResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cdn/model_patch_distribution_payload.go b/services/cdn/model_patch_distribution_payload.go new file mode 100644 index 000000000..cbdbe688d --- /dev/null +++ b/services/cdn/model_patch_distribution_payload.go @@ -0,0 +1,176 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +import ( + "encoding/json" +) + +// checks if the PatchDistributionPayload type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &PatchDistributionPayload{} + +/* + types and functions for config +*/ + +// isModel +type PatchDistributionPayloadGetConfigAttributeType = *ConfigPatch +type PatchDistributionPayloadGetConfigArgType = ConfigPatch +type PatchDistributionPayloadGetConfigRetType = ConfigPatch + +func getPatchDistributionPayloadGetConfigAttributeTypeOk(arg PatchDistributionPayloadGetConfigAttributeType) (ret PatchDistributionPayloadGetConfigRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setPatchDistributionPayloadGetConfigAttributeType(arg *PatchDistributionPayloadGetConfigAttributeType, val PatchDistributionPayloadGetConfigRetType) { + *arg = &val +} + +/* + types and functions for intentId +*/ + +// isNotNullableString +type PatchDistributionPayloadGetIntentIdAttributeType = *string + +func getPatchDistributionPayloadGetIntentIdAttributeTypeOk(arg PatchDistributionPayloadGetIntentIdAttributeType) (ret PatchDistributionPayloadGetIntentIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setPatchDistributionPayloadGetIntentIdAttributeType(arg *PatchDistributionPayloadGetIntentIdAttributeType, val PatchDistributionPayloadGetIntentIdRetType) { + *arg = &val +} + +type PatchDistributionPayloadGetIntentIdArgType = string +type PatchDistributionPayloadGetIntentIdRetType = string + +// PatchDistributionPayload Defines a partial distribution. Set values +type PatchDistributionPayload struct { + Config PatchDistributionPayloadGetConfigAttributeType `json:"config,omitempty"` + // While optional, it is greatly encouraged to provide an `intentId`. This is used to deduplicate requests. If multiple modifying requests with the same `intentId` for a given `projectId` are received, all but the first request are dropped. + IntentId PatchDistributionPayloadGetIntentIdAttributeType `json:"intentId,omitempty"` +} + +// NewPatchDistributionPayload instantiates a new PatchDistributionPayload 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 NewPatchDistributionPayload() *PatchDistributionPayload { + this := PatchDistributionPayload{} + return &this +} + +// NewPatchDistributionPayloadWithDefaults instantiates a new PatchDistributionPayload 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 NewPatchDistributionPayloadWithDefaults() *PatchDistributionPayload { + this := PatchDistributionPayload{} + return &this +} + +// GetConfig returns the Config field value if set, zero value otherwise. +func (o *PatchDistributionPayload) GetConfig() (res PatchDistributionPayloadGetConfigRetType) { + res, _ = o.GetConfigOk() + return +} + +// GetConfigOk returns a tuple with the Config field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PatchDistributionPayload) GetConfigOk() (ret PatchDistributionPayloadGetConfigRetType, ok bool) { + return getPatchDistributionPayloadGetConfigAttributeTypeOk(o.Config) +} + +// HasConfig returns a boolean if a field has been set. +func (o *PatchDistributionPayload) HasConfig() bool { + _, ok := o.GetConfigOk() + return ok +} + +// SetConfig gets a reference to the given ConfigPatch and assigns it to the Config field. +func (o *PatchDistributionPayload) SetConfig(v PatchDistributionPayloadGetConfigRetType) { + setPatchDistributionPayloadGetConfigAttributeType(&o.Config, v) +} + +// GetIntentId returns the IntentId field value if set, zero value otherwise. +func (o *PatchDistributionPayload) GetIntentId() (res PatchDistributionPayloadGetIntentIdRetType) { + res, _ = o.GetIntentIdOk() + return +} + +// GetIntentIdOk returns a tuple with the IntentId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PatchDistributionPayload) GetIntentIdOk() (ret PatchDistributionPayloadGetIntentIdRetType, ok bool) { + return getPatchDistributionPayloadGetIntentIdAttributeTypeOk(o.IntentId) +} + +// HasIntentId returns a boolean if a field has been set. +func (o *PatchDistributionPayload) HasIntentId() bool { + _, ok := o.GetIntentIdOk() + return ok +} + +// SetIntentId gets a reference to the given string and assigns it to the IntentId field. +func (o *PatchDistributionPayload) SetIntentId(v PatchDistributionPayloadGetIntentIdRetType) { + setPatchDistributionPayloadGetIntentIdAttributeType(&o.IntentId, v) +} + +func (o PatchDistributionPayload) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getPatchDistributionPayloadGetConfigAttributeTypeOk(o.Config); ok { + toSerialize["Config"] = val + } + if val, ok := getPatchDistributionPayloadGetIntentIdAttributeTypeOk(o.IntentId); ok { + toSerialize["IntentId"] = val + } + return toSerialize, nil +} + +type NullablePatchDistributionPayload struct { + value *PatchDistributionPayload + isSet bool +} + +func (v NullablePatchDistributionPayload) Get() *PatchDistributionPayload { + return v.value +} + +func (v *NullablePatchDistributionPayload) Set(val *PatchDistributionPayload) { + v.value = val + v.isSet = true +} + +func (v NullablePatchDistributionPayload) IsSet() bool { + return v.isSet +} + +func (v *NullablePatchDistributionPayload) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullablePatchDistributionPayload(val *PatchDistributionPayload) *NullablePatchDistributionPayload { + return &NullablePatchDistributionPayload{value: val, isSet: true} +} + +func (v NullablePatchDistributionPayload) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullablePatchDistributionPayload) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cdn/model_patch_distribution_response.go b/services/cdn/model_patch_distribution_response.go new file mode 100644 index 000000000..da2687f6e --- /dev/null +++ b/services/cdn/model_patch_distribution_response.go @@ -0,0 +1,125 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +import ( + "encoding/json" +) + +// checks if the PatchDistributionResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &PatchDistributionResponse{} + +/* + types and functions for distribution +*/ + +// isModel +type PatchDistributionResponseGetDistributionAttributeType = *Distribution +type PatchDistributionResponseGetDistributionArgType = Distribution +type PatchDistributionResponseGetDistributionRetType = Distribution + +func getPatchDistributionResponseGetDistributionAttributeTypeOk(arg PatchDistributionResponseGetDistributionAttributeType) (ret PatchDistributionResponseGetDistributionRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setPatchDistributionResponseGetDistributionAttributeType(arg *PatchDistributionResponseGetDistributionAttributeType, val PatchDistributionResponseGetDistributionRetType) { + *arg = &val +} + +// PatchDistributionResponse struct for PatchDistributionResponse +type PatchDistributionResponse struct { + // REQUIRED + Distribution PatchDistributionResponseGetDistributionAttributeType `json:"distribution"` +} + +type _PatchDistributionResponse PatchDistributionResponse + +// NewPatchDistributionResponse instantiates a new PatchDistributionResponse 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 NewPatchDistributionResponse(distribution PatchDistributionResponseGetDistributionArgType) *PatchDistributionResponse { + this := PatchDistributionResponse{} + setPatchDistributionResponseGetDistributionAttributeType(&this.Distribution, distribution) + return &this +} + +// NewPatchDistributionResponseWithDefaults instantiates a new PatchDistributionResponse 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 NewPatchDistributionResponseWithDefaults() *PatchDistributionResponse { + this := PatchDistributionResponse{} + return &this +} + +// GetDistribution returns the Distribution field value +func (o *PatchDistributionResponse) GetDistribution() (ret PatchDistributionResponseGetDistributionRetType) { + ret, _ = o.GetDistributionOk() + return ret +} + +// GetDistributionOk returns a tuple with the Distribution field value +// and a boolean to check if the value has been set. +func (o *PatchDistributionResponse) GetDistributionOk() (ret PatchDistributionResponseGetDistributionRetType, ok bool) { + return getPatchDistributionResponseGetDistributionAttributeTypeOk(o.Distribution) +} + +// SetDistribution sets field value +func (o *PatchDistributionResponse) SetDistribution(v PatchDistributionResponseGetDistributionRetType) { + setPatchDistributionResponseGetDistributionAttributeType(&o.Distribution, v) +} + +func (o PatchDistributionResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getPatchDistributionResponseGetDistributionAttributeTypeOk(o.Distribution); ok { + toSerialize["Distribution"] = val + } + return toSerialize, nil +} + +type NullablePatchDistributionResponse struct { + value *PatchDistributionResponse + isSet bool +} + +func (v NullablePatchDistributionResponse) Get() *PatchDistributionResponse { + return v.value +} + +func (v *NullablePatchDistributionResponse) Set(val *PatchDistributionResponse) { + v.value = val + v.isSet = true +} + +func (v NullablePatchDistributionResponse) IsSet() bool { + return v.isSet +} + +func (v *NullablePatchDistributionResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullablePatchDistributionResponse(val *PatchDistributionResponse) *NullablePatchDistributionResponse { + return &NullablePatchDistributionResponse{value: val, isSet: true} +} + +func (v NullablePatchDistributionResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullablePatchDistributionResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cdn/model_purge_cache_payload.go b/services/cdn/model_purge_cache_payload.go new file mode 100644 index 000000000..88bac16c4 --- /dev/null +++ b/services/cdn/model_purge_cache_payload.go @@ -0,0 +1,129 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +import ( + "encoding/json" +) + +// checks if the PurgeCachePayload type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &PurgeCachePayload{} + +/* + types and functions for path +*/ + +// isNotNullableString +type PurgeCachePayloadGetPathAttributeType = *string + +func getPurgeCachePayloadGetPathAttributeTypeOk(arg PurgeCachePayloadGetPathAttributeType) (ret PurgeCachePayloadGetPathRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setPurgeCachePayloadGetPathAttributeType(arg *PurgeCachePayloadGetPathAttributeType, val PurgeCachePayloadGetPathRetType) { + *arg = &val +} + +type PurgeCachePayloadGetPathArgType = string +type PurgeCachePayloadGetPathRetType = string + +// PurgeCachePayload struct for PurgeCachePayload +type PurgeCachePayload struct { + // Defines an optional path. If this is set, a granular purge is done. If missing, the entire cache is invalidated. During a granular cache purge, only the provided path is purged. Please do not that for example `/some/path` and `/some/path.txt` are considered different paths. + Path PurgeCachePayloadGetPathAttributeType `json:"path,omitempty"` +} + +// NewPurgeCachePayload instantiates a new PurgeCachePayload 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 NewPurgeCachePayload() *PurgeCachePayload { + this := PurgeCachePayload{} + return &this +} + +// NewPurgeCachePayloadWithDefaults instantiates a new PurgeCachePayload 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 NewPurgeCachePayloadWithDefaults() *PurgeCachePayload { + this := PurgeCachePayload{} + return &this +} + +// GetPath returns the Path field value if set, zero value otherwise. +func (o *PurgeCachePayload) GetPath() (res PurgeCachePayloadGetPathRetType) { + res, _ = o.GetPathOk() + return +} + +// GetPathOk returns a tuple with the Path field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PurgeCachePayload) GetPathOk() (ret PurgeCachePayloadGetPathRetType, ok bool) { + return getPurgeCachePayloadGetPathAttributeTypeOk(o.Path) +} + +// HasPath returns a boolean if a field has been set. +func (o *PurgeCachePayload) HasPath() bool { + _, ok := o.GetPathOk() + return ok +} + +// SetPath gets a reference to the given string and assigns it to the Path field. +func (o *PurgeCachePayload) SetPath(v PurgeCachePayloadGetPathRetType) { + setPurgeCachePayloadGetPathAttributeType(&o.Path, v) +} + +func (o PurgeCachePayload) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getPurgeCachePayloadGetPathAttributeTypeOk(o.Path); ok { + toSerialize["Path"] = val + } + return toSerialize, nil +} + +type NullablePurgeCachePayload struct { + value *PurgeCachePayload + isSet bool +} + +func (v NullablePurgeCachePayload) Get() *PurgeCachePayload { + return v.value +} + +func (v *NullablePurgeCachePayload) Set(val *PurgeCachePayload) { + v.value = val + v.isSet = true +} + +func (v NullablePurgeCachePayload) IsSet() bool { + return v.isSet +} + +func (v *NullablePurgeCachePayload) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullablePurgeCachePayload(val *PurgeCachePayload) *NullablePurgeCachePayload { + return &NullablePurgeCachePayload{value: val, isSet: true} +} + +func (v NullablePurgeCachePayload) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullablePurgeCachePayload) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cdn/model_put_custom_domain_payload.go b/services/cdn/model_put_custom_domain_payload.go new file mode 100644 index 000000000..3d39d5f2a --- /dev/null +++ b/services/cdn/model_put_custom_domain_payload.go @@ -0,0 +1,129 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +import ( + "encoding/json" +) + +// checks if the PutCustomDomainPayload type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &PutCustomDomainPayload{} + +/* + types and functions for intentId +*/ + +// isNotNullableString +type PutCustomDomainPayloadGetIntentIdAttributeType = *string + +func getPutCustomDomainPayloadGetIntentIdAttributeTypeOk(arg PutCustomDomainPayloadGetIntentIdAttributeType) (ret PutCustomDomainPayloadGetIntentIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setPutCustomDomainPayloadGetIntentIdAttributeType(arg *PutCustomDomainPayloadGetIntentIdAttributeType, val PutCustomDomainPayloadGetIntentIdRetType) { + *arg = &val +} + +type PutCustomDomainPayloadGetIntentIdArgType = string +type PutCustomDomainPayloadGetIntentIdRetType = string + +// PutCustomDomainPayload struct for PutCustomDomainPayload +type PutCustomDomainPayload struct { + // While optional, it is greatly encouraged to provide an `intentId`. This is used to deduplicate requests. If multiple modifying Requests with the same `intentId` for a given `projectId` are received, all but the first request are dropped. + IntentId PutCustomDomainPayloadGetIntentIdAttributeType `json:"intentId,omitempty"` +} + +// NewPutCustomDomainPayload instantiates a new PutCustomDomainPayload 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 NewPutCustomDomainPayload() *PutCustomDomainPayload { + this := PutCustomDomainPayload{} + return &this +} + +// NewPutCustomDomainPayloadWithDefaults instantiates a new PutCustomDomainPayload 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 NewPutCustomDomainPayloadWithDefaults() *PutCustomDomainPayload { + this := PutCustomDomainPayload{} + return &this +} + +// GetIntentId returns the IntentId field value if set, zero value otherwise. +func (o *PutCustomDomainPayload) GetIntentId() (res PutCustomDomainPayloadGetIntentIdRetType) { + res, _ = o.GetIntentIdOk() + return +} + +// GetIntentIdOk returns a tuple with the IntentId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PutCustomDomainPayload) GetIntentIdOk() (ret PutCustomDomainPayloadGetIntentIdRetType, ok bool) { + return getPutCustomDomainPayloadGetIntentIdAttributeTypeOk(o.IntentId) +} + +// HasIntentId returns a boolean if a field has been set. +func (o *PutCustomDomainPayload) HasIntentId() bool { + _, ok := o.GetIntentIdOk() + return ok +} + +// SetIntentId gets a reference to the given string and assigns it to the IntentId field. +func (o *PutCustomDomainPayload) SetIntentId(v PutCustomDomainPayloadGetIntentIdRetType) { + setPutCustomDomainPayloadGetIntentIdAttributeType(&o.IntentId, v) +} + +func (o PutCustomDomainPayload) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getPutCustomDomainPayloadGetIntentIdAttributeTypeOk(o.IntentId); ok { + toSerialize["IntentId"] = val + } + return toSerialize, nil +} + +type NullablePutCustomDomainPayload struct { + value *PutCustomDomainPayload + isSet bool +} + +func (v NullablePutCustomDomainPayload) Get() *PutCustomDomainPayload { + return v.value +} + +func (v *NullablePutCustomDomainPayload) Set(val *PutCustomDomainPayload) { + v.value = val + v.isSet = true +} + +func (v NullablePutCustomDomainPayload) IsSet() bool { + return v.isSet +} + +func (v *NullablePutCustomDomainPayload) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullablePutCustomDomainPayload(val *PutCustomDomainPayload) *NullablePutCustomDomainPayload { + return &NullablePutCustomDomainPayload{value: val, isSet: true} +} + +func (v NullablePutCustomDomainPayload) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullablePutCustomDomainPayload) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cdn/model_put_custom_domain_response.go b/services/cdn/model_put_custom_domain_response.go new file mode 100644 index 000000000..997141438 --- /dev/null +++ b/services/cdn/model_put_custom_domain_response.go @@ -0,0 +1,173 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +import ( + "encoding/json" +) + +// checks if the PutCustomDomainResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &PutCustomDomainResponse{} + +/* + types and functions for customDomain +*/ + +// isModel +type PutCustomDomainResponseGetCustomDomainAttributeType = *CustomDomain +type PutCustomDomainResponseGetCustomDomainArgType = CustomDomain +type PutCustomDomainResponseGetCustomDomainRetType = CustomDomain + +func getPutCustomDomainResponseGetCustomDomainAttributeTypeOk(arg PutCustomDomainResponseGetCustomDomainAttributeType) (ret PutCustomDomainResponseGetCustomDomainRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setPutCustomDomainResponseGetCustomDomainAttributeType(arg *PutCustomDomainResponseGetCustomDomainAttributeType, val PutCustomDomainResponseGetCustomDomainRetType) { + *arg = &val +} + +/* + types and functions for domain +*/ + +// isNotNullableString +type PutCustomDomainResponseGetDomainAttributeType = *string + +func getPutCustomDomainResponseGetDomainAttributeTypeOk(arg PutCustomDomainResponseGetDomainAttributeType) (ret PutCustomDomainResponseGetDomainRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setPutCustomDomainResponseGetDomainAttributeType(arg *PutCustomDomainResponseGetDomainAttributeType, val PutCustomDomainResponseGetDomainRetType) { + *arg = &val +} + +type PutCustomDomainResponseGetDomainArgType = string +type PutCustomDomainResponseGetDomainRetType = string + +// PutCustomDomainResponse struct for PutCustomDomainResponse +type PutCustomDomainResponse struct { + // REQUIRED + CustomDomain PutCustomDomainResponseGetCustomDomainAttributeType `json:"customDomain"` + // Deprecated: Check the GitHub changelog for alternatives + // REQUIRED + Domain PutCustomDomainResponseGetDomainAttributeType `json:"domain"` +} + +type _PutCustomDomainResponse PutCustomDomainResponse + +// NewPutCustomDomainResponse instantiates a new PutCustomDomainResponse 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 NewPutCustomDomainResponse(customDomain PutCustomDomainResponseGetCustomDomainArgType, domain PutCustomDomainResponseGetDomainArgType) *PutCustomDomainResponse { + this := PutCustomDomainResponse{} + setPutCustomDomainResponseGetCustomDomainAttributeType(&this.CustomDomain, customDomain) + setPutCustomDomainResponseGetDomainAttributeType(&this.Domain, domain) + return &this +} + +// NewPutCustomDomainResponseWithDefaults instantiates a new PutCustomDomainResponse 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 NewPutCustomDomainResponseWithDefaults() *PutCustomDomainResponse { + this := PutCustomDomainResponse{} + return &this +} + +// GetCustomDomain returns the CustomDomain field value +func (o *PutCustomDomainResponse) GetCustomDomain() (ret PutCustomDomainResponseGetCustomDomainRetType) { + ret, _ = o.GetCustomDomainOk() + return ret +} + +// GetCustomDomainOk returns a tuple with the CustomDomain field value +// and a boolean to check if the value has been set. +func (o *PutCustomDomainResponse) GetCustomDomainOk() (ret PutCustomDomainResponseGetCustomDomainRetType, ok bool) { + return getPutCustomDomainResponseGetCustomDomainAttributeTypeOk(o.CustomDomain) +} + +// SetCustomDomain sets field value +func (o *PutCustomDomainResponse) SetCustomDomain(v PutCustomDomainResponseGetCustomDomainRetType) { + setPutCustomDomainResponseGetCustomDomainAttributeType(&o.CustomDomain, v) +} + +// GetDomain returns the Domain field value +// Deprecated +func (o *PutCustomDomainResponse) GetDomain() (ret PutCustomDomainResponseGetDomainRetType) { + ret, _ = o.GetDomainOk() + return ret +} + +// GetDomainOk returns a tuple with the Domain field value +// and a boolean to check if the value has been set. +// Deprecated +func (o *PutCustomDomainResponse) GetDomainOk() (ret PutCustomDomainResponseGetDomainRetType, ok bool) { + return getPutCustomDomainResponseGetDomainAttributeTypeOk(o.Domain) +} + +// SetDomain sets field value +// Deprecated +func (o *PutCustomDomainResponse) SetDomain(v PutCustomDomainResponseGetDomainRetType) { + setPutCustomDomainResponseGetDomainAttributeType(&o.Domain, v) +} + +func (o PutCustomDomainResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getPutCustomDomainResponseGetCustomDomainAttributeTypeOk(o.CustomDomain); ok { + toSerialize["CustomDomain"] = val + } + if val, ok := getPutCustomDomainResponseGetDomainAttributeTypeOk(o.Domain); ok { + toSerialize["Domain"] = val + } + return toSerialize, nil +} + +type NullablePutCustomDomainResponse struct { + value *PutCustomDomainResponse + isSet bool +} + +func (v NullablePutCustomDomainResponse) Get() *PutCustomDomainResponse { + return v.value +} + +func (v *NullablePutCustomDomainResponse) Set(val *PutCustomDomainResponse) { + v.value = val + v.isSet = true +} + +func (v NullablePutCustomDomainResponse) IsSet() bool { + return v.isSet +} + +func (v *NullablePutCustomDomainResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullablePutCustomDomainResponse(val *PutCustomDomainResponse) *NullablePutCustomDomainResponse { + return &NullablePutCustomDomainResponse{value: val, isSet: true} +} + +func (v NullablePutCustomDomainResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullablePutCustomDomainResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cdn/model_region.go b/services/cdn/model_region.go new file mode 100644 index 000000000..004f9c91c --- /dev/null +++ b/services/cdn/model_region.go @@ -0,0 +1,121 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +import ( + "encoding/json" + "fmt" +) + +// Region The following regions exist: - `EU` - Europe - `US` - United States / North America - `AF` - Africa - `SA` - South America - `ASIA` - Asia and Oceania +type Region string + +// List of Region +const ( + REGION_EU Region = "EU" + REGION_US Region = "US" + REGION_AF Region = "AF" + REGION_SA Region = "SA" + REGION_ASIA Region = "ASIA" +) + +// All allowed values of Region enum +var AllowedRegionEnumValues = []Region{ + "EU", + "US", + "AF", + "SA", + "ASIA", +} + +func (v *Region) 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 := Region(value) + for _, existing := range AllowedRegionEnumValues { + if existing == enumTypeValue { + *v = enumTypeValue + return nil + } + } + + return fmt.Errorf("%+v is not a valid Region", value) +} + +// NewRegionFromValue returns a pointer to a valid Region +// for the value passed as argument, or an error if the value passed is not allowed by the enum +func NewRegionFromValue(v string) (*Region, error) { + ev := Region(v) + if ev.IsValid() { + return &ev, nil + } else { + return nil, fmt.Errorf("invalid value '%v' for Region: valid values are %v", v, AllowedRegionEnumValues) + } +} + +// IsValid return true if the value is valid for the enum, false otherwise +func (v Region) IsValid() bool { + for _, existing := range AllowedRegionEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to Region value +func (v Region) Ptr() *Region { + return &v +} + +type NullableRegion struct { + value *Region + isSet bool +} + +func (v NullableRegion) Get() *Region { + return v.value +} + +func (v *NullableRegion) Set(val *Region) { + v.value = val + v.isSet = true +} + +func (v NullableRegion) IsSet() bool { + return v.isSet +} + +func (v *NullableRegion) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableRegion(val *Region) *NullableRegion { + return &NullableRegion{value: val, isSet: true} +} + +func (v NullableRegion) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableRegion) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cdn/model_status_error.go b/services/cdn/model_status_error.go new file mode 100644 index 000000000..fa013e13d --- /dev/null +++ b/services/cdn/model_status_error.go @@ -0,0 +1,220 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +import ( + "encoding/json" +) + +// checks if the StatusError type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &StatusError{} + +/* + types and functions for de +*/ + +// isNotNullableString +type StatusErrorGetDeAttributeType = *string + +func getStatusErrorGetDeAttributeTypeOk(arg StatusErrorGetDeAttributeType) (ret StatusErrorGetDeRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setStatusErrorGetDeAttributeType(arg *StatusErrorGetDeAttributeType, val StatusErrorGetDeRetType) { + *arg = &val +} + +type StatusErrorGetDeArgType = string +type StatusErrorGetDeRetType = string + +/* + types and functions for en +*/ + +// isNotNullableString +type StatusErrorGetEnAttributeType = *string + +func getStatusErrorGetEnAttributeTypeOk(arg StatusErrorGetEnAttributeType) (ret StatusErrorGetEnRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setStatusErrorGetEnAttributeType(arg *StatusErrorGetEnAttributeType, val StatusErrorGetEnRetType) { + *arg = &val +} + +type StatusErrorGetEnArgType = string +type StatusErrorGetEnRetType = string + +/* + types and functions for key +*/ + +// isEnumRef +type StatusErrorGetKeyAttributeType = *string +type StatusErrorGetKeyArgType = string +type StatusErrorGetKeyRetType = string + +func getStatusErrorGetKeyAttributeTypeOk(arg StatusErrorGetKeyAttributeType) (ret StatusErrorGetKeyRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setStatusErrorGetKeyAttributeType(arg *StatusErrorGetKeyAttributeType, val StatusErrorGetKeyRetType) { + *arg = &val +} + +// StatusError struct for StatusError +type StatusError struct { + // A german translation string corresponding to the error key. Note that we do not guarantee german translations are present. + De StatusErrorGetDeAttributeType `json:"de,omitempty"` + // An english translation string corresponding to the error key. An english translation key is always present. + // REQUIRED + En StatusErrorGetEnAttributeType `json:"en"` + // An enum value that describes a Status Error. + // REQUIRED + Key StatusErrorGetKeyAttributeType `json:"key"` +} + +type _StatusError StatusError + +// NewStatusError instantiates a new StatusError 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 NewStatusError(en StatusErrorGetEnArgType, key StatusErrorGetKeyArgType) *StatusError { + this := StatusError{} + setStatusErrorGetEnAttributeType(&this.En, en) + setStatusErrorGetKeyAttributeType(&this.Key, key) + return &this +} + +// NewStatusErrorWithDefaults instantiates a new StatusError 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 NewStatusErrorWithDefaults() *StatusError { + this := StatusError{} + return &this +} + +// GetDe returns the De field value if set, zero value otherwise. +func (o *StatusError) GetDe() (res StatusErrorGetDeRetType) { + res, _ = o.GetDeOk() + return +} + +// GetDeOk returns a tuple with the De field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *StatusError) GetDeOk() (ret StatusErrorGetDeRetType, ok bool) { + return getStatusErrorGetDeAttributeTypeOk(o.De) +} + +// HasDe returns a boolean if a field has been set. +func (o *StatusError) HasDe() bool { + _, ok := o.GetDeOk() + return ok +} + +// SetDe gets a reference to the given string and assigns it to the De field. +func (o *StatusError) SetDe(v StatusErrorGetDeRetType) { + setStatusErrorGetDeAttributeType(&o.De, v) +} + +// GetEn returns the En field value +func (o *StatusError) GetEn() (ret StatusErrorGetEnRetType) { + ret, _ = o.GetEnOk() + return ret +} + +// GetEnOk returns a tuple with the En field value +// and a boolean to check if the value has been set. +func (o *StatusError) GetEnOk() (ret StatusErrorGetEnRetType, ok bool) { + return getStatusErrorGetEnAttributeTypeOk(o.En) +} + +// SetEn sets field value +func (o *StatusError) SetEn(v StatusErrorGetEnRetType) { + setStatusErrorGetEnAttributeType(&o.En, v) +} + +// GetKey returns the Key field value +func (o *StatusError) GetKey() (ret StatusErrorGetKeyRetType) { + ret, _ = o.GetKeyOk() + return ret +} + +// GetKeyOk returns a tuple with the Key field value +// and a boolean to check if the value has been set. +func (o *StatusError) GetKeyOk() (ret StatusErrorGetKeyRetType, ok bool) { + return getStatusErrorGetKeyAttributeTypeOk(o.Key) +} + +// SetKey sets field value +func (o *StatusError) SetKey(v StatusErrorGetKeyRetType) { + setStatusErrorGetKeyAttributeType(&o.Key, v) +} + +func (o StatusError) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getStatusErrorGetDeAttributeTypeOk(o.De); ok { + toSerialize["De"] = val + } + if val, ok := getStatusErrorGetEnAttributeTypeOk(o.En); ok { + toSerialize["En"] = val + } + if val, ok := getStatusErrorGetKeyAttributeTypeOk(o.Key); ok { + toSerialize["Key"] = val + } + return toSerialize, nil +} + +type NullableStatusError struct { + value *StatusError + isSet bool +} + +func (v NullableStatusError) Get() *StatusError { + return v.value +} + +func (v *NullableStatusError) Set(val *StatusError) { + v.value = val + v.isSet = true +} + +func (v NullableStatusError) IsSet() bool { + return v.isSet +} + +func (v *NullableStatusError) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableStatusError(val *StatusError) *NullableStatusError { + return &NullableStatusError{value: val, isSet: true} +} + +func (v NullableStatusError) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableStatusError) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cdn/utils.go b/services/cdn/utils.go new file mode 100644 index 000000000..f9d2afe77 --- /dev/null +++ b/services/cdn/utils.go @@ -0,0 +1,373 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +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) +}