From 93a90b240a3e52fc02b60610d50f5d4379512072 Mon Sep 17 00:00:00 2001 From: SDK Generator Bot Date: Wed, 22 Oct 2025 11:49:26 +0000 Subject: [PATCH] Generate cost --- go.work | 1 + services/cost/.openapi-generator/VERSION | 1 + services/cost/api_default.go | 763 ++++++++++++++++++ services/cost/api_default_test.go | 192 +++++ services/cost/client.go | 631 +++++++++++++++ services/cost/configuration.go | 38 + services/cost/go.mod | 10 + services/cost/go.sum | 8 + services/cost/model_default_error.go | 174 ++++ services/cost/model_default_error_test.go | 11 + services/cost/model_detailed_service_cost.go | 443 ++++++++++ .../cost/model_detailed_service_cost_test.go | 11 + services/cost/model_project_cost.go | 139 ++++ services/cost/model_project_cost_test.go | 11 + ...del_project_cost_with_detailed_services.go | 350 ++++++++ ...roject_cost_with_detailed_services_test.go | 11 + .../cost/model_project_cost_with_reports.go | 350 ++++++++ .../model_project_cost_with_reports_test.go | 11 + ...l_project_cost_with_summarized_services.go | 350 ++++++++ ...ject_cost_with_summarized_services_test.go | 11 + services/cost/model_report_data.go | 258 ++++++ services/cost/model_report_data_test.go | 11 + .../cost/model_report_data_time_period.go | 174 ++++ .../model_report_data_time_period_test.go | 11 + .../cost/model_summarized_project_cost.go | 302 +++++++ .../model_summarized_project_cost_test.go | 11 + .../cost/model_summarized_service_cost.go | 302 +++++++ .../model_summarized_service_cost_test.go | 11 + services/cost/utils.go | 385 +++++++++ 29 files changed, 4981 insertions(+) create mode 100644 services/cost/.openapi-generator/VERSION create mode 100644 services/cost/api_default.go create mode 100644 services/cost/api_default_test.go create mode 100644 services/cost/client.go create mode 100644 services/cost/configuration.go create mode 100644 services/cost/go.mod create mode 100644 services/cost/go.sum create mode 100644 services/cost/model_default_error.go create mode 100644 services/cost/model_default_error_test.go create mode 100644 services/cost/model_detailed_service_cost.go create mode 100644 services/cost/model_detailed_service_cost_test.go create mode 100644 services/cost/model_project_cost.go create mode 100644 services/cost/model_project_cost_test.go create mode 100644 services/cost/model_project_cost_with_detailed_services.go create mode 100644 services/cost/model_project_cost_with_detailed_services_test.go create mode 100644 services/cost/model_project_cost_with_reports.go create mode 100644 services/cost/model_project_cost_with_reports_test.go create mode 100644 services/cost/model_project_cost_with_summarized_services.go create mode 100644 services/cost/model_project_cost_with_summarized_services_test.go create mode 100644 services/cost/model_report_data.go create mode 100644 services/cost/model_report_data_test.go create mode 100644 services/cost/model_report_data_time_period.go create mode 100644 services/cost/model_report_data_time_period_test.go create mode 100644 services/cost/model_summarized_project_cost.go create mode 100644 services/cost/model_summarized_project_cost_test.go create mode 100644 services/cost/model_summarized_service_cost.go create mode 100644 services/cost/model_summarized_service_cost_test.go create mode 100644 services/cost/utils.go diff --git a/go.work b/go.work index 478149caf..c46a7a1d6 100644 --- a/go.work +++ b/go.work @@ -36,6 +36,7 @@ use ( ./services/authorization ./services/cdn ./services/certificates + ./services/cost ./services/dns ./services/git ./services/iaas diff --git a/services/cost/.openapi-generator/VERSION b/services/cost/.openapi-generator/VERSION new file mode 100644 index 000000000..cd802a1ec --- /dev/null +++ b/services/cost/.openapi-generator/VERSION @@ -0,0 +1 @@ +6.6.0 \ No newline at end of file diff --git a/services/cost/api_default.go b/services/cost/api_default.go new file mode 100644 index 000000000..af2a81864 --- /dev/null +++ b/services/cost/api_default.go @@ -0,0 +1,763 @@ +/* +STACKIT Cost API + +The cost API provides detailed reports on the costs for a customer or project over a certain amount of time + +API version: 3.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cost + +import ( + "bytes" + "context" + "fmt" + "io" + "net/http" + "net/url" + "strings" + + "github.com/stackitcloud/stackit-sdk-go/core/config" + "github.com/stackitcloud/stackit-sdk-go/core/oapierror" +) + +type DefaultApi interface { + /* + ListCostsForCustomer V3 Costs for all projects + Get costs for all projects in a customer account + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param customerAccountId ID of a customer account + @return ApiListCostsForCustomerRequest + */ + ListCostsForCustomer(ctx context.Context, customerAccountId string) ApiListCostsForCustomerRequest + /* + ListCostsForCustomerExecute executes the request + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param customerAccountId ID of a customer account + @return []ProjectCost + + */ + ListCostsForCustomerExecute(ctx context.Context, customerAccountId string) ([]ProjectCost, error) + /* + ListCostsForProject V3 Costs for a certain project + Get costs for a certain project in a customer account + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param customerAccountId ID of a customer account + @param projectId ID of a project + @return ApiListCostsForProjectRequest + */ + ListCostsForProject(ctx context.Context, customerAccountId string, projectId string) ApiListCostsForProjectRequest + /* + ListCostsForProjectExecute executes the request + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param customerAccountId ID of a customer account + @param projectId ID of a project + @return ProjectCost + + */ + ListCostsForProjectExecute(ctx context.Context, customerAccountId string, projectId string) (*ProjectCost, error) + /* + ListCostsForReseller V3 Costs for all projects of all related sub-customers + Get costs for all projects of all related sub-customer accounts + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param customerAccountId ID of a customer account + @return ApiListCostsForResellerRequest + */ + ListCostsForReseller(ctx context.Context, customerAccountId string) ApiListCostsForResellerRequest + /* + ListCostsForResellerExecute executes the request + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param customerAccountId ID of a customer account + @return []ProjectCost + + */ + ListCostsForResellerExecute(ctx context.Context, customerAccountId string) ([]ProjectCost, error) +} + +type ApiListCostsForCustomerRequest interface { + // Start date (including) + From(from string) ApiListCostsForCustomerRequest + // End date (including) + To(to string) ApiListCostsForCustomerRequest + // Depth of desired cost information. \"project\" provides costs grouped by project, without services. \"service\" provides costs separated on service level. + Depth(depth string) ApiListCostsForCustomerRequest + // Define granularity of costs – Default is \"none\" which does NOT include detailed report data. If \"monthly\", \"weekly\" or \"yearly\" is requested, the \"from\" parameter SHOULD be the first day and the \"to\" parameter SHOULD be the last day of that time period. If not, they are normalized accordingly. If \"daily\" is requested, the date range defined by \"from\" and \"to\" MUST NOT be longer than 92 days. + Granularity(granularity string) ApiListCostsForCustomerRequest + // Whether costs of 0 should be included in the response + IncludeZeroCosts(includeZeroCosts bool) ApiListCostsForCustomerRequest + // Desired content type + Accept(accept string) ApiListCostsForCustomerRequest + Execute() ([]ProjectCost, error) +} + +type ApiListCostsForProjectRequest interface { + // Start date (including) + From(from string) ApiListCostsForProjectRequest + // End date (including) + To(to string) ApiListCostsForProjectRequest + // Depth of desired cost information. \"project\" provides costs grouped by project, without services. \"service\" provides costs separated on service level. + Depth(depth string) ApiListCostsForProjectRequest + // Define granularity of costs – Default is \"none\" which does NOT include detailed report data. If \"monthly\", \"weekly\" or \"yearly\" is requested, the \"from\" parameter SHOULD be the first day and the \"to\" parameter SHOULD be the last day of that time period. If not, they are normalized accordingly. If \"daily\" is requested, the date range defined by \"from\" and \"to\" MUST NOT be longer than 92 days. + Granularity(granularity string) ApiListCostsForProjectRequest + // Whether costs of 0 should be included in the response + IncludeZeroCosts(includeZeroCosts bool) ApiListCostsForProjectRequest + // Desired content type + Accept(accept string) ApiListCostsForProjectRequest + Execute() (*ProjectCost, error) +} + +type ApiListCostsForResellerRequest interface { + // Start date (including) + From(from string) ApiListCostsForResellerRequest + // End date (including) + To(to string) ApiListCostsForResellerRequest + // Depth of desired cost information. \"project\" provides costs grouped by project, without services. \"service\" provides costs separated on service level. + Depth(depth string) ApiListCostsForResellerRequest + // Define granularity of costs – Default is \"none\" which does NOT include detailed report data. If \"monthly\", \"weekly\" or \"yearly\" is requested, the \"from\" parameter SHOULD be the first day and the \"to\" parameter SHOULD be the last day of that time period. If not, they are normalized accordingly. If \"daily\" is requested, the date range defined by \"from\" and \"to\" MUST NOT be longer than 92 days. + Granularity(granularity string) ApiListCostsForResellerRequest + // Whether costs of 0 should be included in the response + IncludeZeroCosts(includeZeroCosts bool) ApiListCostsForResellerRequest + // Desired content type + Accept(accept string) ApiListCostsForResellerRequest + Execute() ([]ProjectCost, error) +} + +// DefaultApiService DefaultApi service +type DefaultApiService service + +type ListCostsForCustomerRequest struct { + ctx context.Context + apiService *DefaultApiService + customerAccountId string + from *string + to *string + depth *string + granularity *string + includeZeroCosts *bool + accept *string +} + +// Start date (including) + +func (r ListCostsForCustomerRequest) From(from string) ApiListCostsForCustomerRequest { + r.from = &from + return r +} + +// End date (including) + +func (r ListCostsForCustomerRequest) To(to string) ApiListCostsForCustomerRequest { + r.to = &to + return r +} + +// Depth of desired cost information. \"project\" provides costs grouped by project, without services. \"service\" provides costs separated on service level. + +func (r ListCostsForCustomerRequest) Depth(depth string) ApiListCostsForCustomerRequest { + r.depth = &depth + return r +} + +// Define granularity of costs – Default is \"none\" which does NOT include detailed report data. If \"monthly\", \"weekly\" or \"yearly\" is requested, the \"from\" parameter SHOULD be the first day and the \"to\" parameter SHOULD be the last day of that time period. If not, they are normalized accordingly. If \"daily\" is requested, the date range defined by \"from\" and \"to\" MUST NOT be longer than 92 days. + +func (r ListCostsForCustomerRequest) Granularity(granularity string) ApiListCostsForCustomerRequest { + r.granularity = &granularity + return r +} + +// Whether costs of 0 should be included in the response + +func (r ListCostsForCustomerRequest) IncludeZeroCosts(includeZeroCosts bool) ApiListCostsForCustomerRequest { + r.includeZeroCosts = &includeZeroCosts + return r +} + +// Desired content type + +func (r ListCostsForCustomerRequest) Accept(accept string) ApiListCostsForCustomerRequest { + r.accept = &accept + return r +} + +func (r ListCostsForCustomerRequest) Execute() ([]ProjectCost, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue []ProjectCost + ) + a := r.apiService + client, ok := a.client.(*APIClient) + if !ok { + return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient") + } + localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ListCostsForCustomer") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v3/costs/{customerAccountId}" + localVarPath = strings.Replace(localVarPath, "{"+"customerAccountId"+"}", url.PathEscape(ParameterValueToString(r.customerAccountId, "customerAccountId")), -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") + } + if r.to == nil { + return localVarReturnValue, fmt.Errorf("to is required and must be specified") + } + + parameterAddToHeaderOrQuery(localVarQueryParams, "from", r.from, "") + parameterAddToHeaderOrQuery(localVarQueryParams, "to", r.to, "") + if r.depth != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "depth", r.depth, "") + } + if r.granularity != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "granularity", r.granularity, "") + } + if r.includeZeroCosts != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "includeZeroCosts", r.includeZeroCosts, "") + } + // 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/csv"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + if r.accept != nil { + parameterAddToHeaderOrQuery(localVarHeaderParams, "Accept", r.accept, "") + } + req, err := 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 := 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 map[string]interface{} + err = 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 DefaultError + err = 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 = 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 +} + +/* +ListCostsForCustomer: V3 Costs for all projects + +Get costs for all projects in a customer account + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param customerAccountId ID of a customer account + @return ApiListCostsForCustomerRequest +*/ +func (a *APIClient) ListCostsForCustomer(ctx context.Context, customerAccountId string) ApiListCostsForCustomerRequest { + return ListCostsForCustomerRequest{ + apiService: a.defaultApi, + ctx: ctx, + customerAccountId: customerAccountId, + } +} + +func (a *APIClient) ListCostsForCustomerExecute(ctx context.Context, customerAccountId string) ([]ProjectCost, error) { + r := ListCostsForCustomerRequest{ + apiService: a.defaultApi, + ctx: ctx, + customerAccountId: customerAccountId, + } + return r.Execute() +} + +type ListCostsForProjectRequest struct { + ctx context.Context + apiService *DefaultApiService + customerAccountId string + projectId string + from *string + to *string + depth *string + granularity *string + includeZeroCosts *bool + accept *string +} + +// Start date (including) + +func (r ListCostsForProjectRequest) From(from string) ApiListCostsForProjectRequest { + r.from = &from + return r +} + +// End date (including) + +func (r ListCostsForProjectRequest) To(to string) ApiListCostsForProjectRequest { + r.to = &to + return r +} + +// Depth of desired cost information. \"project\" provides costs grouped by project, without services. \"service\" provides costs separated on service level. + +func (r ListCostsForProjectRequest) Depth(depth string) ApiListCostsForProjectRequest { + r.depth = &depth + return r +} + +// Define granularity of costs – Default is \"none\" which does NOT include detailed report data. If \"monthly\", \"weekly\" or \"yearly\" is requested, the \"from\" parameter SHOULD be the first day and the \"to\" parameter SHOULD be the last day of that time period. If not, they are normalized accordingly. If \"daily\" is requested, the date range defined by \"from\" and \"to\" MUST NOT be longer than 92 days. + +func (r ListCostsForProjectRequest) Granularity(granularity string) ApiListCostsForProjectRequest { + r.granularity = &granularity + return r +} + +// Whether costs of 0 should be included in the response + +func (r ListCostsForProjectRequest) IncludeZeroCosts(includeZeroCosts bool) ApiListCostsForProjectRequest { + r.includeZeroCosts = &includeZeroCosts + return r +} + +// Desired content type + +func (r ListCostsForProjectRequest) Accept(accept string) ApiListCostsForProjectRequest { + r.accept = &accept + return r +} + +func (r ListCostsForProjectRequest) Execute() (*ProjectCost, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *ProjectCost + ) + a := r.apiService + client, ok := a.client.(*APIClient) + if !ok { + return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient") + } + localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ListCostsForProject") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v3/costs/{customerAccountId}/projects/{projectId}" + localVarPath = strings.Replace(localVarPath, "{"+"customerAccountId"+"}", url.PathEscape(ParameterValueToString(r.customerAccountId, "customerAccountId")), -1) + 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.from == nil { + return localVarReturnValue, fmt.Errorf("from is required and must be specified") + } + if r.to == nil { + return localVarReturnValue, fmt.Errorf("to is required and must be specified") + } + + parameterAddToHeaderOrQuery(localVarQueryParams, "from", r.from, "") + parameterAddToHeaderOrQuery(localVarQueryParams, "to", r.to, "") + if r.depth != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "depth", r.depth, "") + } + if r.granularity != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "granularity", r.granularity, "") + } + if r.includeZeroCosts != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "includeZeroCosts", r.includeZeroCosts, "") + } + // 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/csv"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + if r.accept != nil { + parameterAddToHeaderOrQuery(localVarHeaderParams, "Accept", r.accept, "") + } + req, err := 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 := 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 map[string]interface{} + err = 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 DefaultError + err = 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 = 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 +} + +/* +ListCostsForProject: V3 Costs for a certain project + +Get costs for a certain project in a customer account + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param customerAccountId ID of a customer account + @param projectId ID of a project + @return ApiListCostsForProjectRequest +*/ +func (a *APIClient) ListCostsForProject(ctx context.Context, customerAccountId string, projectId string) ApiListCostsForProjectRequest { + return ListCostsForProjectRequest{ + apiService: a.defaultApi, + ctx: ctx, + customerAccountId: customerAccountId, + projectId: projectId, + } +} + +func (a *APIClient) ListCostsForProjectExecute(ctx context.Context, customerAccountId string, projectId string) (*ProjectCost, error) { + r := ListCostsForProjectRequest{ + apiService: a.defaultApi, + ctx: ctx, + customerAccountId: customerAccountId, + projectId: projectId, + } + return r.Execute() +} + +type ListCostsForResellerRequest struct { + ctx context.Context + apiService *DefaultApiService + customerAccountId string + from *string + to *string + depth *string + granularity *string + includeZeroCosts *bool + accept *string +} + +// Start date (including) + +func (r ListCostsForResellerRequest) From(from string) ApiListCostsForResellerRequest { + r.from = &from + return r +} + +// End date (including) + +func (r ListCostsForResellerRequest) To(to string) ApiListCostsForResellerRequest { + r.to = &to + return r +} + +// Depth of desired cost information. \"project\" provides costs grouped by project, without services. \"service\" provides costs separated on service level. + +func (r ListCostsForResellerRequest) Depth(depth string) ApiListCostsForResellerRequest { + r.depth = &depth + return r +} + +// Define granularity of costs – Default is \"none\" which does NOT include detailed report data. If \"monthly\", \"weekly\" or \"yearly\" is requested, the \"from\" parameter SHOULD be the first day and the \"to\" parameter SHOULD be the last day of that time period. If not, they are normalized accordingly. If \"daily\" is requested, the date range defined by \"from\" and \"to\" MUST NOT be longer than 92 days. + +func (r ListCostsForResellerRequest) Granularity(granularity string) ApiListCostsForResellerRequest { + r.granularity = &granularity + return r +} + +// Whether costs of 0 should be included in the response + +func (r ListCostsForResellerRequest) IncludeZeroCosts(includeZeroCosts bool) ApiListCostsForResellerRequest { + r.includeZeroCosts = &includeZeroCosts + return r +} + +// Desired content type + +func (r ListCostsForResellerRequest) Accept(accept string) ApiListCostsForResellerRequest { + r.accept = &accept + return r +} + +func (r ListCostsForResellerRequest) Execute() ([]ProjectCost, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue []ProjectCost + ) + a := r.apiService + client, ok := a.client.(*APIClient) + if !ok { + return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient") + } + localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ListCostsForReseller") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v3/costs/{customerAccountId}/customers" + localVarPath = strings.Replace(localVarPath, "{"+"customerAccountId"+"}", url.PathEscape(ParameterValueToString(r.customerAccountId, "customerAccountId")), -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") + } + if r.to == nil { + return localVarReturnValue, fmt.Errorf("to is required and must be specified") + } + + parameterAddToHeaderOrQuery(localVarQueryParams, "from", r.from, "") + parameterAddToHeaderOrQuery(localVarQueryParams, "to", r.to, "") + if r.depth != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "depth", r.depth, "") + } + if r.granularity != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "granularity", r.granularity, "") + } + if r.includeZeroCosts != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "includeZeroCosts", r.includeZeroCosts, "") + } + // 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/csv"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + if r.accept != nil { + parameterAddToHeaderOrQuery(localVarHeaderParams, "Accept", r.accept, "") + } + req, err := 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 := 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 map[string]interface{} + err = 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 DefaultError + err = 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 = 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 +} + +/* +ListCostsForReseller: V3 Costs for all projects of all related sub-customers + +Get costs for all projects of all related sub-customer accounts + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param customerAccountId ID of a customer account + @return ApiListCostsForResellerRequest +*/ +func (a *APIClient) ListCostsForReseller(ctx context.Context, customerAccountId string) ApiListCostsForResellerRequest { + return ListCostsForResellerRequest{ + apiService: a.defaultApi, + ctx: ctx, + customerAccountId: customerAccountId, + } +} + +func (a *APIClient) ListCostsForResellerExecute(ctx context.Context, customerAccountId string) ([]ProjectCost, error) { + r := ListCostsForResellerRequest{ + apiService: a.defaultApi, + ctx: ctx, + customerAccountId: customerAccountId, + } + return r.Execute() +} diff --git a/services/cost/api_default_test.go b/services/cost/api_default_test.go new file mode 100644 index 000000000..669856bb5 --- /dev/null +++ b/services/cost/api_default_test.go @@ -0,0 +1,192 @@ +/* +STACKIT Cost API + +Testing DefaultApiService + +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); + +package cost + +import ( + "context" + "encoding/json" + "net/http" + "net/http/httptest" + "net/url" + "strings" + "testing" + + "github.com/google/uuid" + "github.com/stackitcloud/stackit-sdk-go/core/config" +) + +func Test_cost_DefaultApiService(t *testing.T) { + + t.Run("Test DefaultApiService ListCostsForCustomer", func(t *testing.T) { + _apiUrlPath := "/v3/costs/{customerAccountId}" + customerAccountIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"customerAccountId"+"}", url.PathEscape(ParameterValueToString(customerAccountIdValue, "customerAccountId")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + data := []ProjectCost{} + 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 cost_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) + } + + customerAccountId := customerAccountIdValue + var from string + var to string + + resp, reqErr := apiClient.ListCostsForCustomer(context.Background(), customerAccountId).From(from).To(to).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if IsNil(resp) { + t.Fatalf("response not present") + } + }) + + t.Run("Test DefaultApiService ListCostsForProject", func(t *testing.T) { + _apiUrlPath := "/v3/costs/{customerAccountId}/projects/{projectId}" + customerAccountIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"customerAccountId"+"}", url.PathEscape(ParameterValueToString(customerAccountIdValue, "customerAccountId")), -1) + projectIdValue := uuid.NewString() + _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 := ProjectCost{} + 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 cost_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) + } + + customerAccountId := customerAccountIdValue + projectId := projectIdValue + var from string + var to string + + resp, reqErr := apiClient.ListCostsForProject(context.Background(), customerAccountId, projectId).From(from).To(to).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if IsNil(resp) { + t.Fatalf("response not present") + } + }) + + t.Run("Test DefaultApiService ListCostsForReseller", func(t *testing.T) { + _apiUrlPath := "/v3/costs/{customerAccountId}/customers" + customerAccountIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"customerAccountId"+"}", url.PathEscape(ParameterValueToString(customerAccountIdValue, "customerAccountId")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + data := []ProjectCost{} + 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 cost_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) + } + + customerAccountId := customerAccountIdValue + var from string + var to string + + resp, reqErr := apiClient.ListCostsForReseller(context.Background(), customerAccountId).From(from).To(to).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if IsNil(resp) { + t.Fatalf("response not present") + } + }) + +} diff --git a/services/cost/client.go b/services/cost/client.go new file mode 100644 index 000000000..e086b9737 --- /dev/null +++ b/services/cost/client.go @@ -0,0 +1,631 @@ +/* +STACKIT Cost API + +The cost API provides detailed reports on the costs for a customer or project over a certain amount of time + +API version: 3.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cost + +import ( + "bytes" + "context" + "encoding/json" + "encoding/xml" + "fmt" + "io" + "log" + "mime/multipart" + "net/http" + "net/http/httputil" + "net/url" + "os" + "path/filepath" + "reflect" + "regexp" + "strconv" + "strings" + "time" + "unicode/utf8" + + "github.com/stackitcloud/stackit-sdk-go/core/auth" + "github.com/stackitcloud/stackit-sdk-go/core/config" +) + +var ( + jsonCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:vnd\.[^;]+\+)?json)`) + xmlCheck = regexp.MustCompile(`(?i:(?:application|text)/xml)`) + queryParamSplit = regexp.MustCompile(`(^|&)([^&]+)`) + queryDescape = strings.NewReplacer("%5B", "[", "%5D", "]") +) + +// APIClient manages communication with the STACKIT Cost API API v3.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 DefaultApi +} + +// 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 !IsNil(postBody) { + 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/cost/configuration.go b/services/cost/configuration.go new file mode 100644 index 000000000..33b18c926 --- /dev/null +++ b/services/cost/configuration.go @@ -0,0 +1,38 @@ +/* +STACKIT Cost API + +The cost API provides detailed reports on the costs for a customer or project over a certain amount of time + +API version: 3.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cost + +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: "stackit-sdk-go/cost", + Debug: false, + Servers: config.ServerConfigurations{ + { + URL: "https://cost.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/cost/go.mod b/services/cost/go.mod new file mode 100644 index 000000000..9ca7d77a6 --- /dev/null +++ b/services/cost/go.mod @@ -0,0 +1,10 @@ +module github.com/stackitcloud/stackit-sdk-go/services/cost + +go 1.21 + +require ( + github.com/google/uuid v1.6.0 + github.com/stackitcloud/stackit-sdk-go/core v0.17.3 +) + +require github.com/golang-jwt/jwt/v5 v5.3.0 // indirect diff --git a/services/cost/go.sum b/services/cost/go.sum new file mode 100644 index 000000000..5069d5c27 --- /dev/null +++ b/services/cost/go.sum @@ -0,0 +1,8 @@ +github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo= +github.com/golang-jwt/jwt/v5 v5.3.0/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE= +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.17.3 h1:GsZGmRRc/3GJLmCUnsZswirr5wfLRrwavbnL/renOqg= +github.com/stackitcloud/stackit-sdk-go/core v0.17.3/go.mod h1:HBCXJGPgdRulplDzhrmwC+Dak9B/x0nzNtmOpu+1Ahg= diff --git a/services/cost/model_default_error.go b/services/cost/model_default_error.go new file mode 100644 index 000000000..1d3c44cca --- /dev/null +++ b/services/cost/model_default_error.go @@ -0,0 +1,174 @@ +/* +STACKIT Cost API + +The cost API provides detailed reports on the costs for a customer or project over a certain amount of time + +API version: 3.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cost + +import ( + "encoding/json" +) + +// checks if the DefaultError type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &DefaultError{} + +/* + types and functions for code +*/ + +// isNotNullableString +type DefaultErrorGetCodeAttributeType = *string + +func getDefaultErrorGetCodeAttributeTypeOk(arg DefaultErrorGetCodeAttributeType) (ret DefaultErrorGetCodeRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDefaultErrorGetCodeAttributeType(arg *DefaultErrorGetCodeAttributeType, val DefaultErrorGetCodeRetType) { + *arg = &val +} + +type DefaultErrorGetCodeArgType = string +type DefaultErrorGetCodeRetType = string + +/* + types and functions for message +*/ + +// isNotNullableString +type DefaultErrorGetMessageAttributeType = *string + +func getDefaultErrorGetMessageAttributeTypeOk(arg DefaultErrorGetMessageAttributeType) (ret DefaultErrorGetMessageRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDefaultErrorGetMessageAttributeType(arg *DefaultErrorGetMessageAttributeType, val DefaultErrorGetMessageRetType) { + *arg = &val +} + +type DefaultErrorGetMessageArgType = string +type DefaultErrorGetMessageRetType = string + +// DefaultError A standard error object. +type DefaultError struct { + // REQUIRED + Code DefaultErrorGetCodeAttributeType `json:"code" required:"true"` + Message DefaultErrorGetMessageAttributeType `json:"message,omitempty"` +} + +type _DefaultError DefaultError + +// NewDefaultError instantiates a new DefaultError 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 NewDefaultError(code DefaultErrorGetCodeArgType) *DefaultError { + this := DefaultError{} + setDefaultErrorGetCodeAttributeType(&this.Code, code) + return &this +} + +// NewDefaultErrorWithDefaults instantiates a new DefaultError 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 NewDefaultErrorWithDefaults() *DefaultError { + this := DefaultError{} + return &this +} + +// GetCode returns the Code field value +func (o *DefaultError) GetCode() (ret DefaultErrorGetCodeRetType) { + ret, _ = o.GetCodeOk() + return ret +} + +// GetCodeOk returns a tuple with the Code field value +// and a boolean to check if the value has been set. +func (o *DefaultError) GetCodeOk() (ret DefaultErrorGetCodeRetType, ok bool) { + return getDefaultErrorGetCodeAttributeTypeOk(o.Code) +} + +// SetCode sets field value +func (o *DefaultError) SetCode(v DefaultErrorGetCodeRetType) { + setDefaultErrorGetCodeAttributeType(&o.Code, v) +} + +// GetMessage returns the Message field value if set, zero value otherwise. +func (o *DefaultError) GetMessage() (res DefaultErrorGetMessageRetType) { + res, _ = o.GetMessageOk() + return +} + +// GetMessageOk returns a tuple with the Message field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DefaultError) GetMessageOk() (ret DefaultErrorGetMessageRetType, ok bool) { + return getDefaultErrorGetMessageAttributeTypeOk(o.Message) +} + +// HasMessage returns a boolean if a field has been set. +func (o *DefaultError) HasMessage() bool { + _, ok := o.GetMessageOk() + return ok +} + +// SetMessage gets a reference to the given string and assigns it to the Message field. +func (o *DefaultError) SetMessage(v DefaultErrorGetMessageRetType) { + setDefaultErrorGetMessageAttributeType(&o.Message, v) +} + +func (o DefaultError) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getDefaultErrorGetCodeAttributeTypeOk(o.Code); ok { + toSerialize["Code"] = val + } + if val, ok := getDefaultErrorGetMessageAttributeTypeOk(o.Message); ok { + toSerialize["Message"] = val + } + return toSerialize, nil +} + +type NullableDefaultError struct { + value *DefaultError + isSet bool +} + +func (v NullableDefaultError) Get() *DefaultError { + return v.value +} + +func (v *NullableDefaultError) Set(val *DefaultError) { + v.value = val + v.isSet = true +} + +func (v NullableDefaultError) IsSet() bool { + return v.isSet +} + +func (v *NullableDefaultError) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableDefaultError(val *DefaultError) *NullableDefaultError { + return &NullableDefaultError{value: val, isSet: true} +} + +func (v NullableDefaultError) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableDefaultError) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cost/model_default_error_test.go b/services/cost/model_default_error_test.go new file mode 100644 index 000000000..16ddfd392 --- /dev/null +++ b/services/cost/model_default_error_test.go @@ -0,0 +1,11 @@ +/* +STACKIT Cost API + +The cost API provides detailed reports on the costs for a customer or project over a certain amount of time + +API version: 3.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cost diff --git a/services/cost/model_detailed_service_cost.go b/services/cost/model_detailed_service_cost.go new file mode 100644 index 000000000..b814125d8 --- /dev/null +++ b/services/cost/model_detailed_service_cost.go @@ -0,0 +1,443 @@ +/* +STACKIT Cost API + +The cost API provides detailed reports on the costs for a customer or project over a certain amount of time + +API version: 3.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cost + +import ( + "encoding/json" +) + +// checks if the DetailedServiceCost type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &DetailedServiceCost{} + +/* + types and functions for reportData +*/ + +// isArray +type DetailedServiceCostGetReportDataAttributeType = *[]ReportData +type DetailedServiceCostGetReportDataArgType = []ReportData +type DetailedServiceCostGetReportDataRetType = []ReportData + +func getDetailedServiceCostGetReportDataAttributeTypeOk(arg DetailedServiceCostGetReportDataAttributeType) (ret DetailedServiceCostGetReportDataRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDetailedServiceCostGetReportDataAttributeType(arg *DetailedServiceCostGetReportDataAttributeType, val DetailedServiceCostGetReportDataRetType) { + *arg = &val +} + +/* + types and functions for serviceCategoryName +*/ + +// isNotNullableString +type DetailedServiceCostGetServiceCategoryNameAttributeType = *string + +func getDetailedServiceCostGetServiceCategoryNameAttributeTypeOk(arg DetailedServiceCostGetServiceCategoryNameAttributeType) (ret DetailedServiceCostGetServiceCategoryNameRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDetailedServiceCostGetServiceCategoryNameAttributeType(arg *DetailedServiceCostGetServiceCategoryNameAttributeType, val DetailedServiceCostGetServiceCategoryNameRetType) { + *arg = &val +} + +type DetailedServiceCostGetServiceCategoryNameArgType = string +type DetailedServiceCostGetServiceCategoryNameRetType = string + +/* + types and functions for serviceName +*/ + +// isNotNullableString +type DetailedServiceCostGetServiceNameAttributeType = *string + +func getDetailedServiceCostGetServiceNameAttributeTypeOk(arg DetailedServiceCostGetServiceNameAttributeType) (ret DetailedServiceCostGetServiceNameRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDetailedServiceCostGetServiceNameAttributeType(arg *DetailedServiceCostGetServiceNameAttributeType, val DetailedServiceCostGetServiceNameRetType) { + *arg = &val +} + +type DetailedServiceCostGetServiceNameArgType = string +type DetailedServiceCostGetServiceNameRetType = string + +/* + types and functions for sku +*/ + +// isNotNullableString +type DetailedServiceCostGetSkuAttributeType = *string + +func getDetailedServiceCostGetSkuAttributeTypeOk(arg DetailedServiceCostGetSkuAttributeType) (ret DetailedServiceCostGetSkuRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDetailedServiceCostGetSkuAttributeType(arg *DetailedServiceCostGetSkuAttributeType, val DetailedServiceCostGetSkuRetType) { + *arg = &val +} + +type DetailedServiceCostGetSkuArgType = string +type DetailedServiceCostGetSkuRetType = string + +/* + types and functions for totalCharge +*/ + +// isDouble +type DetailedServiceCostGetTotalChargeAttributeType = *float64 +type DetailedServiceCostGetTotalChargeArgType = float64 +type DetailedServiceCostGetTotalChargeRetType = float64 + +func getDetailedServiceCostGetTotalChargeAttributeTypeOk(arg DetailedServiceCostGetTotalChargeAttributeType) (ret DetailedServiceCostGetTotalChargeRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDetailedServiceCostGetTotalChargeAttributeType(arg *DetailedServiceCostGetTotalChargeAttributeType, val DetailedServiceCostGetTotalChargeRetType) { + *arg = &val +} + +/* + types and functions for totalDiscount +*/ + +// isDouble +type DetailedServiceCostGetTotalDiscountAttributeType = *float64 +type DetailedServiceCostGetTotalDiscountArgType = float64 +type DetailedServiceCostGetTotalDiscountRetType = float64 + +func getDetailedServiceCostGetTotalDiscountAttributeTypeOk(arg DetailedServiceCostGetTotalDiscountAttributeType) (ret DetailedServiceCostGetTotalDiscountRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDetailedServiceCostGetTotalDiscountAttributeType(arg *DetailedServiceCostGetTotalDiscountAttributeType, val DetailedServiceCostGetTotalDiscountRetType) { + *arg = &val +} + +/* + types and functions for totalQuantity +*/ + +// isInteger +type DetailedServiceCostGetTotalQuantityAttributeType = *int64 +type DetailedServiceCostGetTotalQuantityArgType = int64 +type DetailedServiceCostGetTotalQuantityRetType = int64 + +func getDetailedServiceCostGetTotalQuantityAttributeTypeOk(arg DetailedServiceCostGetTotalQuantityAttributeType) (ret DetailedServiceCostGetTotalQuantityRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDetailedServiceCostGetTotalQuantityAttributeType(arg *DetailedServiceCostGetTotalQuantityAttributeType, val DetailedServiceCostGetTotalQuantityRetType) { + *arg = &val +} + +/* + types and functions for unitLabel +*/ + +// isNotNullableString +type DetailedServiceCostGetUnitLabelAttributeType = *string + +func getDetailedServiceCostGetUnitLabelAttributeTypeOk(arg DetailedServiceCostGetUnitLabelAttributeType) (ret DetailedServiceCostGetUnitLabelRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDetailedServiceCostGetUnitLabelAttributeType(arg *DetailedServiceCostGetUnitLabelAttributeType, val DetailedServiceCostGetUnitLabelRetType) { + *arg = &val +} + +type DetailedServiceCostGetUnitLabelArgType = string +type DetailedServiceCostGetUnitLabelRetType = string + +// DetailedServiceCost Costs for a single service +type DetailedServiceCost struct { + // Detailed service costs which are ONLY included if granularity is provided + ReportData DetailedServiceCostGetReportDataAttributeType `json:"reportData,omitempty"` + // Service category name + // REQUIRED + ServiceCategoryName DetailedServiceCostGetServiceCategoryNameAttributeType `json:"serviceCategoryName" required:"true"` + // Name of the service + // REQUIRED + ServiceName DetailedServiceCostGetServiceNameAttributeType `json:"serviceName" required:"true"` + // Service key + // REQUIRED + Sku DetailedServiceCostGetSkuAttributeType `json:"sku" required:"true"` + // Total charge for the whole requested date range (value in cents) + // REQUIRED + TotalCharge DetailedServiceCostGetTotalChargeAttributeType `json:"totalCharge" required:"true"` + // Total discount for the whole requested date range (value in cents) + // REQUIRED + TotalDiscount DetailedServiceCostGetTotalDiscountAttributeType `json:"totalDiscount" required:"true"` + // Total quantity + // Can be cast to int32 without loss of precision. + // REQUIRED + TotalQuantity DetailedServiceCostGetTotalQuantityAttributeType `json:"totalQuantity" required:"true"` + // Label for unit + // REQUIRED + UnitLabel DetailedServiceCostGetUnitLabelAttributeType `json:"unitLabel" required:"true"` +} + +type _DetailedServiceCost DetailedServiceCost + +// NewDetailedServiceCost instantiates a new DetailedServiceCost 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 NewDetailedServiceCost(serviceCategoryName DetailedServiceCostGetServiceCategoryNameArgType, serviceName DetailedServiceCostGetServiceNameArgType, sku DetailedServiceCostGetSkuArgType, totalCharge DetailedServiceCostGetTotalChargeArgType, totalDiscount DetailedServiceCostGetTotalDiscountArgType, totalQuantity DetailedServiceCostGetTotalQuantityArgType, unitLabel DetailedServiceCostGetUnitLabelArgType) *DetailedServiceCost { + this := DetailedServiceCost{} + setDetailedServiceCostGetServiceCategoryNameAttributeType(&this.ServiceCategoryName, serviceCategoryName) + setDetailedServiceCostGetServiceNameAttributeType(&this.ServiceName, serviceName) + setDetailedServiceCostGetSkuAttributeType(&this.Sku, sku) + setDetailedServiceCostGetTotalChargeAttributeType(&this.TotalCharge, totalCharge) + setDetailedServiceCostGetTotalDiscountAttributeType(&this.TotalDiscount, totalDiscount) + setDetailedServiceCostGetTotalQuantityAttributeType(&this.TotalQuantity, totalQuantity) + setDetailedServiceCostGetUnitLabelAttributeType(&this.UnitLabel, unitLabel) + return &this +} + +// NewDetailedServiceCostWithDefaults instantiates a new DetailedServiceCost 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 NewDetailedServiceCostWithDefaults() *DetailedServiceCost { + this := DetailedServiceCost{} + return &this +} + +// GetReportData returns the ReportData field value if set, zero value otherwise. +func (o *DetailedServiceCost) GetReportData() (res DetailedServiceCostGetReportDataRetType) { + res, _ = o.GetReportDataOk() + return +} + +// GetReportDataOk returns a tuple with the ReportData field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DetailedServiceCost) GetReportDataOk() (ret DetailedServiceCostGetReportDataRetType, ok bool) { + return getDetailedServiceCostGetReportDataAttributeTypeOk(o.ReportData) +} + +// HasReportData returns a boolean if a field has been set. +func (o *DetailedServiceCost) HasReportData() bool { + _, ok := o.GetReportDataOk() + return ok +} + +// SetReportData gets a reference to the given []ReportData and assigns it to the ReportData field. +func (o *DetailedServiceCost) SetReportData(v DetailedServiceCostGetReportDataRetType) { + setDetailedServiceCostGetReportDataAttributeType(&o.ReportData, v) +} + +// GetServiceCategoryName returns the ServiceCategoryName field value +func (o *DetailedServiceCost) GetServiceCategoryName() (ret DetailedServiceCostGetServiceCategoryNameRetType) { + ret, _ = o.GetServiceCategoryNameOk() + return ret +} + +// GetServiceCategoryNameOk returns a tuple with the ServiceCategoryName field value +// and a boolean to check if the value has been set. +func (o *DetailedServiceCost) GetServiceCategoryNameOk() (ret DetailedServiceCostGetServiceCategoryNameRetType, ok bool) { + return getDetailedServiceCostGetServiceCategoryNameAttributeTypeOk(o.ServiceCategoryName) +} + +// SetServiceCategoryName sets field value +func (o *DetailedServiceCost) SetServiceCategoryName(v DetailedServiceCostGetServiceCategoryNameRetType) { + setDetailedServiceCostGetServiceCategoryNameAttributeType(&o.ServiceCategoryName, v) +} + +// GetServiceName returns the ServiceName field value +func (o *DetailedServiceCost) GetServiceName() (ret DetailedServiceCostGetServiceNameRetType) { + ret, _ = o.GetServiceNameOk() + return ret +} + +// GetServiceNameOk returns a tuple with the ServiceName field value +// and a boolean to check if the value has been set. +func (o *DetailedServiceCost) GetServiceNameOk() (ret DetailedServiceCostGetServiceNameRetType, ok bool) { + return getDetailedServiceCostGetServiceNameAttributeTypeOk(o.ServiceName) +} + +// SetServiceName sets field value +func (o *DetailedServiceCost) SetServiceName(v DetailedServiceCostGetServiceNameRetType) { + setDetailedServiceCostGetServiceNameAttributeType(&o.ServiceName, v) +} + +// GetSku returns the Sku field value +func (o *DetailedServiceCost) GetSku() (ret DetailedServiceCostGetSkuRetType) { + ret, _ = o.GetSkuOk() + return ret +} + +// GetSkuOk returns a tuple with the Sku field value +// and a boolean to check if the value has been set. +func (o *DetailedServiceCost) GetSkuOk() (ret DetailedServiceCostGetSkuRetType, ok bool) { + return getDetailedServiceCostGetSkuAttributeTypeOk(o.Sku) +} + +// SetSku sets field value +func (o *DetailedServiceCost) SetSku(v DetailedServiceCostGetSkuRetType) { + setDetailedServiceCostGetSkuAttributeType(&o.Sku, v) +} + +// GetTotalCharge returns the TotalCharge field value +func (o *DetailedServiceCost) GetTotalCharge() (ret DetailedServiceCostGetTotalChargeRetType) { + ret, _ = o.GetTotalChargeOk() + return ret +} + +// GetTotalChargeOk returns a tuple with the TotalCharge field value +// and a boolean to check if the value has been set. +func (o *DetailedServiceCost) GetTotalChargeOk() (ret DetailedServiceCostGetTotalChargeRetType, ok bool) { + return getDetailedServiceCostGetTotalChargeAttributeTypeOk(o.TotalCharge) +} + +// SetTotalCharge sets field value +func (o *DetailedServiceCost) SetTotalCharge(v DetailedServiceCostGetTotalChargeRetType) { + setDetailedServiceCostGetTotalChargeAttributeType(&o.TotalCharge, v) +} + +// GetTotalDiscount returns the TotalDiscount field value +func (o *DetailedServiceCost) GetTotalDiscount() (ret DetailedServiceCostGetTotalDiscountRetType) { + ret, _ = o.GetTotalDiscountOk() + return ret +} + +// GetTotalDiscountOk returns a tuple with the TotalDiscount field value +// and a boolean to check if the value has been set. +func (o *DetailedServiceCost) GetTotalDiscountOk() (ret DetailedServiceCostGetTotalDiscountRetType, ok bool) { + return getDetailedServiceCostGetTotalDiscountAttributeTypeOk(o.TotalDiscount) +} + +// SetTotalDiscount sets field value +func (o *DetailedServiceCost) SetTotalDiscount(v DetailedServiceCostGetTotalDiscountRetType) { + setDetailedServiceCostGetTotalDiscountAttributeType(&o.TotalDiscount, v) +} + +// GetTotalQuantity returns the TotalQuantity field value +func (o *DetailedServiceCost) GetTotalQuantity() (ret DetailedServiceCostGetTotalQuantityRetType) { + ret, _ = o.GetTotalQuantityOk() + return ret +} + +// GetTotalQuantityOk returns a tuple with the TotalQuantity field value +// and a boolean to check if the value has been set. +func (o *DetailedServiceCost) GetTotalQuantityOk() (ret DetailedServiceCostGetTotalQuantityRetType, ok bool) { + return getDetailedServiceCostGetTotalQuantityAttributeTypeOk(o.TotalQuantity) +} + +// SetTotalQuantity sets field value +func (o *DetailedServiceCost) SetTotalQuantity(v DetailedServiceCostGetTotalQuantityRetType) { + setDetailedServiceCostGetTotalQuantityAttributeType(&o.TotalQuantity, v) +} + +// GetUnitLabel returns the UnitLabel field value +func (o *DetailedServiceCost) GetUnitLabel() (ret DetailedServiceCostGetUnitLabelRetType) { + ret, _ = o.GetUnitLabelOk() + return ret +} + +// GetUnitLabelOk returns a tuple with the UnitLabel field value +// and a boolean to check if the value has been set. +func (o *DetailedServiceCost) GetUnitLabelOk() (ret DetailedServiceCostGetUnitLabelRetType, ok bool) { + return getDetailedServiceCostGetUnitLabelAttributeTypeOk(o.UnitLabel) +} + +// SetUnitLabel sets field value +func (o *DetailedServiceCost) SetUnitLabel(v DetailedServiceCostGetUnitLabelRetType) { + setDetailedServiceCostGetUnitLabelAttributeType(&o.UnitLabel, v) +} + +func (o DetailedServiceCost) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getDetailedServiceCostGetReportDataAttributeTypeOk(o.ReportData); ok { + toSerialize["ReportData"] = val + } + if val, ok := getDetailedServiceCostGetServiceCategoryNameAttributeTypeOk(o.ServiceCategoryName); ok { + toSerialize["ServiceCategoryName"] = val + } + if val, ok := getDetailedServiceCostGetServiceNameAttributeTypeOk(o.ServiceName); ok { + toSerialize["ServiceName"] = val + } + if val, ok := getDetailedServiceCostGetSkuAttributeTypeOk(o.Sku); ok { + toSerialize["Sku"] = val + } + if val, ok := getDetailedServiceCostGetTotalChargeAttributeTypeOk(o.TotalCharge); ok { + toSerialize["TotalCharge"] = val + } + if val, ok := getDetailedServiceCostGetTotalDiscountAttributeTypeOk(o.TotalDiscount); ok { + toSerialize["TotalDiscount"] = val + } + if val, ok := getDetailedServiceCostGetTotalQuantityAttributeTypeOk(o.TotalQuantity); ok { + toSerialize["TotalQuantity"] = val + } + if val, ok := getDetailedServiceCostGetUnitLabelAttributeTypeOk(o.UnitLabel); ok { + toSerialize["UnitLabel"] = val + } + return toSerialize, nil +} + +type NullableDetailedServiceCost struct { + value *DetailedServiceCost + isSet bool +} + +func (v NullableDetailedServiceCost) Get() *DetailedServiceCost { + return v.value +} + +func (v *NullableDetailedServiceCost) Set(val *DetailedServiceCost) { + v.value = val + v.isSet = true +} + +func (v NullableDetailedServiceCost) IsSet() bool { + return v.isSet +} + +func (v *NullableDetailedServiceCost) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableDetailedServiceCost(val *DetailedServiceCost) *NullableDetailedServiceCost { + return &NullableDetailedServiceCost{value: val, isSet: true} +} + +func (v NullableDetailedServiceCost) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableDetailedServiceCost) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cost/model_detailed_service_cost_test.go b/services/cost/model_detailed_service_cost_test.go new file mode 100644 index 000000000..16ddfd392 --- /dev/null +++ b/services/cost/model_detailed_service_cost_test.go @@ -0,0 +1,11 @@ +/* +STACKIT Cost API + +The cost API provides detailed reports on the costs for a customer or project over a certain amount of time + +API version: 3.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cost diff --git a/services/cost/model_project_cost.go b/services/cost/model_project_cost.go new file mode 100644 index 000000000..d50c35122 --- /dev/null +++ b/services/cost/model_project_cost.go @@ -0,0 +1,139 @@ +/* +STACKIT Cost API + +The cost API provides detailed reports on the costs for a customer or project over a certain amount of time + +API version: 3.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cost + +import ( + "encoding/json" + "fmt" +) + +// ProjectCost struct for ProjectCost +type ProjectCost struct { + ProjectCostWithDetailedServices *ProjectCostWithDetailedServices + ProjectCostWithReports *ProjectCostWithReports + ProjectCostWithSummarizedServices *ProjectCostWithSummarizedServices + SummarizedProjectCost *SummarizedProjectCost +} + +// Unmarshal JSON data into any of the pointers in the struct +func (dst *ProjectCost) UnmarshalJSON(data []byte) error { + var err error + // try to unmarshal JSON data into ProjectCostWithDetailedServices + err = json.Unmarshal(data, &dst.ProjectCostWithDetailedServices) + if err == nil { + jsonProjectCostWithDetailedServices, _ := json.Marshal(dst.ProjectCostWithDetailedServices) + if string(jsonProjectCostWithDetailedServices) == "{}" { // empty struct + dst.ProjectCostWithDetailedServices = nil + } else { + return nil // data stored in dst.ProjectCostWithDetailedServices, return on the first match + } + } else { + dst.ProjectCostWithDetailedServices = nil + } + + // try to unmarshal JSON data into ProjectCostWithReports + err = json.Unmarshal(data, &dst.ProjectCostWithReports) + if err == nil { + jsonProjectCostWithReports, _ := json.Marshal(dst.ProjectCostWithReports) + if string(jsonProjectCostWithReports) == "{}" { // empty struct + dst.ProjectCostWithReports = nil + } else { + return nil // data stored in dst.ProjectCostWithReports, return on the first match + } + } else { + dst.ProjectCostWithReports = nil + } + + // try to unmarshal JSON data into ProjectCostWithSummarizedServices + err = json.Unmarshal(data, &dst.ProjectCostWithSummarizedServices) + if err == nil { + jsonProjectCostWithSummarizedServices, _ := json.Marshal(dst.ProjectCostWithSummarizedServices) + if string(jsonProjectCostWithSummarizedServices) == "{}" { // empty struct + dst.ProjectCostWithSummarizedServices = nil + } else { + return nil // data stored in dst.ProjectCostWithSummarizedServices, return on the first match + } + } else { + dst.ProjectCostWithSummarizedServices = nil + } + + // try to unmarshal JSON data into SummarizedProjectCost + err = json.Unmarshal(data, &dst.SummarizedProjectCost) + if err == nil { + jsonSummarizedProjectCost, _ := json.Marshal(dst.SummarizedProjectCost) + if string(jsonSummarizedProjectCost) == "{}" { // empty struct + dst.SummarizedProjectCost = nil + } else { + return nil // data stored in dst.SummarizedProjectCost, return on the first match + } + } else { + dst.SummarizedProjectCost = nil + } + + return fmt.Errorf("data failed to match schemas in anyOf(ProjectCost)") +} + +// Marshal data from the first non-nil pointers in the struct to JSON +func (src *ProjectCost) MarshalJSON() ([]byte, error) { + if src.ProjectCostWithDetailedServices != nil { + return json.Marshal(&src.ProjectCostWithDetailedServices) + } + + if src.ProjectCostWithReports != nil { + return json.Marshal(&src.ProjectCostWithReports) + } + + if src.ProjectCostWithSummarizedServices != nil { + return json.Marshal(&src.ProjectCostWithSummarizedServices) + } + + if src.SummarizedProjectCost != nil { + return json.Marshal(&src.SummarizedProjectCost) + } + + return nil, nil // no data in anyOf schemas +} + +type NullableProjectCost struct { + value *ProjectCost + isSet bool +} + +func (v NullableProjectCost) Get() *ProjectCost { + return v.value +} + +func (v *NullableProjectCost) Set(val *ProjectCost) { + v.value = val + v.isSet = true +} + +func (v NullableProjectCost) IsSet() bool { + return v.isSet +} + +func (v *NullableProjectCost) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableProjectCost(val *ProjectCost) *NullableProjectCost { + return &NullableProjectCost{value: val, isSet: true} +} + +func (v NullableProjectCost) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableProjectCost) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cost/model_project_cost_test.go b/services/cost/model_project_cost_test.go new file mode 100644 index 000000000..16ddfd392 --- /dev/null +++ b/services/cost/model_project_cost_test.go @@ -0,0 +1,11 @@ +/* +STACKIT Cost API + +The cost API provides detailed reports on the costs for a customer or project over a certain amount of time + +API version: 3.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cost diff --git a/services/cost/model_project_cost_with_detailed_services.go b/services/cost/model_project_cost_with_detailed_services.go new file mode 100644 index 000000000..5bbe606c7 --- /dev/null +++ b/services/cost/model_project_cost_with_detailed_services.go @@ -0,0 +1,350 @@ +/* +STACKIT Cost API + +The cost API provides detailed reports on the costs for a customer or project over a certain amount of time + +API version: 3.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cost + +import ( + "encoding/json" +) + +// checks if the ProjectCostWithDetailedServices type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ProjectCostWithDetailedServices{} + +/* + types and functions for customerAccountId +*/ + +// isNotNullableString +type ProjectCostWithDetailedServicesGetCustomerAccountIdAttributeType = *string + +func getProjectCostWithDetailedServicesGetCustomerAccountIdAttributeTypeOk(arg ProjectCostWithDetailedServicesGetCustomerAccountIdAttributeType) (ret ProjectCostWithDetailedServicesGetCustomerAccountIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setProjectCostWithDetailedServicesGetCustomerAccountIdAttributeType(arg *ProjectCostWithDetailedServicesGetCustomerAccountIdAttributeType, val ProjectCostWithDetailedServicesGetCustomerAccountIdRetType) { + *arg = &val +} + +type ProjectCostWithDetailedServicesGetCustomerAccountIdArgType = string +type ProjectCostWithDetailedServicesGetCustomerAccountIdRetType = string + +/* + types and functions for projectId +*/ + +// isNotNullableString +type ProjectCostWithDetailedServicesGetProjectIdAttributeType = *string + +func getProjectCostWithDetailedServicesGetProjectIdAttributeTypeOk(arg ProjectCostWithDetailedServicesGetProjectIdAttributeType) (ret ProjectCostWithDetailedServicesGetProjectIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setProjectCostWithDetailedServicesGetProjectIdAttributeType(arg *ProjectCostWithDetailedServicesGetProjectIdAttributeType, val ProjectCostWithDetailedServicesGetProjectIdRetType) { + *arg = &val +} + +type ProjectCostWithDetailedServicesGetProjectIdArgType = string +type ProjectCostWithDetailedServicesGetProjectIdRetType = string + +/* + types and functions for projectName +*/ + +// isNotNullableString +type ProjectCostWithDetailedServicesGetProjectNameAttributeType = *string + +func getProjectCostWithDetailedServicesGetProjectNameAttributeTypeOk(arg ProjectCostWithDetailedServicesGetProjectNameAttributeType) (ret ProjectCostWithDetailedServicesGetProjectNameRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setProjectCostWithDetailedServicesGetProjectNameAttributeType(arg *ProjectCostWithDetailedServicesGetProjectNameAttributeType, val ProjectCostWithDetailedServicesGetProjectNameRetType) { + *arg = &val +} + +type ProjectCostWithDetailedServicesGetProjectNameArgType = string +type ProjectCostWithDetailedServicesGetProjectNameRetType = string + +/* + types and functions for services +*/ + +// isArray +type ProjectCostWithDetailedServicesGetServicesAttributeType = *[]DetailedServiceCost +type ProjectCostWithDetailedServicesGetServicesArgType = []DetailedServiceCost +type ProjectCostWithDetailedServicesGetServicesRetType = []DetailedServiceCost + +func getProjectCostWithDetailedServicesGetServicesAttributeTypeOk(arg ProjectCostWithDetailedServicesGetServicesAttributeType) (ret ProjectCostWithDetailedServicesGetServicesRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setProjectCostWithDetailedServicesGetServicesAttributeType(arg *ProjectCostWithDetailedServicesGetServicesAttributeType, val ProjectCostWithDetailedServicesGetServicesRetType) { + *arg = &val +} + +/* + types and functions for totalCharge +*/ + +// isDouble +type ProjectCostWithDetailedServicesGetTotalChargeAttributeType = *float64 +type ProjectCostWithDetailedServicesGetTotalChargeArgType = float64 +type ProjectCostWithDetailedServicesGetTotalChargeRetType = float64 + +func getProjectCostWithDetailedServicesGetTotalChargeAttributeTypeOk(arg ProjectCostWithDetailedServicesGetTotalChargeAttributeType) (ret ProjectCostWithDetailedServicesGetTotalChargeRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setProjectCostWithDetailedServicesGetTotalChargeAttributeType(arg *ProjectCostWithDetailedServicesGetTotalChargeAttributeType, val ProjectCostWithDetailedServicesGetTotalChargeRetType) { + *arg = &val +} + +/* + types and functions for totalDiscount +*/ + +// isDouble +type ProjectCostWithDetailedServicesGetTotalDiscountAttributeType = *float64 +type ProjectCostWithDetailedServicesGetTotalDiscountArgType = float64 +type ProjectCostWithDetailedServicesGetTotalDiscountRetType = float64 + +func getProjectCostWithDetailedServicesGetTotalDiscountAttributeTypeOk(arg ProjectCostWithDetailedServicesGetTotalDiscountAttributeType) (ret ProjectCostWithDetailedServicesGetTotalDiscountRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setProjectCostWithDetailedServicesGetTotalDiscountAttributeType(arg *ProjectCostWithDetailedServicesGetTotalDiscountAttributeType, val ProjectCostWithDetailedServicesGetTotalDiscountRetType) { + *arg = &val +} + +// ProjectCostWithDetailedServices Detailed costs for a project including service costs +type ProjectCostWithDetailedServices struct { + // REQUIRED + CustomerAccountId ProjectCostWithDetailedServicesGetCustomerAccountIdAttributeType `json:"customerAccountId" required:"true"` + // REQUIRED + ProjectId ProjectCostWithDetailedServicesGetProjectIdAttributeType `json:"projectId" required:"true"` + // REQUIRED + ProjectName ProjectCostWithDetailedServicesGetProjectNameAttributeType `json:"projectName" required:"true"` + // Total discount for all services and the whole requested date range (value in cents). Please see \"depth\" parameter for more details. + Services ProjectCostWithDetailedServicesGetServicesAttributeType `json:"services,omitempty"` + // Total charge for all services and the whole requested date range (value in cents) + // REQUIRED + TotalCharge ProjectCostWithDetailedServicesGetTotalChargeAttributeType `json:"totalCharge" required:"true"` + // Total discount rounded for all services and the whole requested date range (value in cents) + // REQUIRED + TotalDiscount ProjectCostWithDetailedServicesGetTotalDiscountAttributeType `json:"totalDiscount" required:"true"` +} + +type _ProjectCostWithDetailedServices ProjectCostWithDetailedServices + +// NewProjectCostWithDetailedServices instantiates a new ProjectCostWithDetailedServices 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 NewProjectCostWithDetailedServices(customerAccountId ProjectCostWithDetailedServicesGetCustomerAccountIdArgType, projectId ProjectCostWithDetailedServicesGetProjectIdArgType, projectName ProjectCostWithDetailedServicesGetProjectNameArgType, totalCharge ProjectCostWithDetailedServicesGetTotalChargeArgType, totalDiscount ProjectCostWithDetailedServicesGetTotalDiscountArgType) *ProjectCostWithDetailedServices { + this := ProjectCostWithDetailedServices{} + setProjectCostWithDetailedServicesGetCustomerAccountIdAttributeType(&this.CustomerAccountId, customerAccountId) + setProjectCostWithDetailedServicesGetProjectIdAttributeType(&this.ProjectId, projectId) + setProjectCostWithDetailedServicesGetProjectNameAttributeType(&this.ProjectName, projectName) + setProjectCostWithDetailedServicesGetTotalChargeAttributeType(&this.TotalCharge, totalCharge) + setProjectCostWithDetailedServicesGetTotalDiscountAttributeType(&this.TotalDiscount, totalDiscount) + return &this +} + +// NewProjectCostWithDetailedServicesWithDefaults instantiates a new ProjectCostWithDetailedServices 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 NewProjectCostWithDetailedServicesWithDefaults() *ProjectCostWithDetailedServices { + this := ProjectCostWithDetailedServices{} + return &this +} + +// GetCustomerAccountId returns the CustomerAccountId field value +func (o *ProjectCostWithDetailedServices) GetCustomerAccountId() (ret ProjectCostWithDetailedServicesGetCustomerAccountIdRetType) { + ret, _ = o.GetCustomerAccountIdOk() + return ret +} + +// GetCustomerAccountIdOk returns a tuple with the CustomerAccountId field value +// and a boolean to check if the value has been set. +func (o *ProjectCostWithDetailedServices) GetCustomerAccountIdOk() (ret ProjectCostWithDetailedServicesGetCustomerAccountIdRetType, ok bool) { + return getProjectCostWithDetailedServicesGetCustomerAccountIdAttributeTypeOk(o.CustomerAccountId) +} + +// SetCustomerAccountId sets field value +func (o *ProjectCostWithDetailedServices) SetCustomerAccountId(v ProjectCostWithDetailedServicesGetCustomerAccountIdRetType) { + setProjectCostWithDetailedServicesGetCustomerAccountIdAttributeType(&o.CustomerAccountId, v) +} + +// GetProjectId returns the ProjectId field value +func (o *ProjectCostWithDetailedServices) GetProjectId() (ret ProjectCostWithDetailedServicesGetProjectIdRetType) { + 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 *ProjectCostWithDetailedServices) GetProjectIdOk() (ret ProjectCostWithDetailedServicesGetProjectIdRetType, ok bool) { + return getProjectCostWithDetailedServicesGetProjectIdAttributeTypeOk(o.ProjectId) +} + +// SetProjectId sets field value +func (o *ProjectCostWithDetailedServices) SetProjectId(v ProjectCostWithDetailedServicesGetProjectIdRetType) { + setProjectCostWithDetailedServicesGetProjectIdAttributeType(&o.ProjectId, v) +} + +// GetProjectName returns the ProjectName field value +func (o *ProjectCostWithDetailedServices) GetProjectName() (ret ProjectCostWithDetailedServicesGetProjectNameRetType) { + ret, _ = o.GetProjectNameOk() + return ret +} + +// GetProjectNameOk returns a tuple with the ProjectName field value +// and a boolean to check if the value has been set. +func (o *ProjectCostWithDetailedServices) GetProjectNameOk() (ret ProjectCostWithDetailedServicesGetProjectNameRetType, ok bool) { + return getProjectCostWithDetailedServicesGetProjectNameAttributeTypeOk(o.ProjectName) +} + +// SetProjectName sets field value +func (o *ProjectCostWithDetailedServices) SetProjectName(v ProjectCostWithDetailedServicesGetProjectNameRetType) { + setProjectCostWithDetailedServicesGetProjectNameAttributeType(&o.ProjectName, v) +} + +// GetServices returns the Services field value if set, zero value otherwise. +func (o *ProjectCostWithDetailedServices) GetServices() (res ProjectCostWithDetailedServicesGetServicesRetType) { + res, _ = o.GetServicesOk() + return +} + +// GetServicesOk returns a tuple with the Services field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ProjectCostWithDetailedServices) GetServicesOk() (ret ProjectCostWithDetailedServicesGetServicesRetType, ok bool) { + return getProjectCostWithDetailedServicesGetServicesAttributeTypeOk(o.Services) +} + +// HasServices returns a boolean if a field has been set. +func (o *ProjectCostWithDetailedServices) HasServices() bool { + _, ok := o.GetServicesOk() + return ok +} + +// SetServices gets a reference to the given []DetailedServiceCost and assigns it to the Services field. +func (o *ProjectCostWithDetailedServices) SetServices(v ProjectCostWithDetailedServicesGetServicesRetType) { + setProjectCostWithDetailedServicesGetServicesAttributeType(&o.Services, v) +} + +// GetTotalCharge returns the TotalCharge field value +func (o *ProjectCostWithDetailedServices) GetTotalCharge() (ret ProjectCostWithDetailedServicesGetTotalChargeRetType) { + ret, _ = o.GetTotalChargeOk() + return ret +} + +// GetTotalChargeOk returns a tuple with the TotalCharge field value +// and a boolean to check if the value has been set. +func (o *ProjectCostWithDetailedServices) GetTotalChargeOk() (ret ProjectCostWithDetailedServicesGetTotalChargeRetType, ok bool) { + return getProjectCostWithDetailedServicesGetTotalChargeAttributeTypeOk(o.TotalCharge) +} + +// SetTotalCharge sets field value +func (o *ProjectCostWithDetailedServices) SetTotalCharge(v ProjectCostWithDetailedServicesGetTotalChargeRetType) { + setProjectCostWithDetailedServicesGetTotalChargeAttributeType(&o.TotalCharge, v) +} + +// GetTotalDiscount returns the TotalDiscount field value +func (o *ProjectCostWithDetailedServices) GetTotalDiscount() (ret ProjectCostWithDetailedServicesGetTotalDiscountRetType) { + ret, _ = o.GetTotalDiscountOk() + return ret +} + +// GetTotalDiscountOk returns a tuple with the TotalDiscount field value +// and a boolean to check if the value has been set. +func (o *ProjectCostWithDetailedServices) GetTotalDiscountOk() (ret ProjectCostWithDetailedServicesGetTotalDiscountRetType, ok bool) { + return getProjectCostWithDetailedServicesGetTotalDiscountAttributeTypeOk(o.TotalDiscount) +} + +// SetTotalDiscount sets field value +func (o *ProjectCostWithDetailedServices) SetTotalDiscount(v ProjectCostWithDetailedServicesGetTotalDiscountRetType) { + setProjectCostWithDetailedServicesGetTotalDiscountAttributeType(&o.TotalDiscount, v) +} + +func (o ProjectCostWithDetailedServices) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getProjectCostWithDetailedServicesGetCustomerAccountIdAttributeTypeOk(o.CustomerAccountId); ok { + toSerialize["CustomerAccountId"] = val + } + if val, ok := getProjectCostWithDetailedServicesGetProjectIdAttributeTypeOk(o.ProjectId); ok { + toSerialize["ProjectId"] = val + } + if val, ok := getProjectCostWithDetailedServicesGetProjectNameAttributeTypeOk(o.ProjectName); ok { + toSerialize["ProjectName"] = val + } + if val, ok := getProjectCostWithDetailedServicesGetServicesAttributeTypeOk(o.Services); ok { + toSerialize["Services"] = val + } + if val, ok := getProjectCostWithDetailedServicesGetTotalChargeAttributeTypeOk(o.TotalCharge); ok { + toSerialize["TotalCharge"] = val + } + if val, ok := getProjectCostWithDetailedServicesGetTotalDiscountAttributeTypeOk(o.TotalDiscount); ok { + toSerialize["TotalDiscount"] = val + } + return toSerialize, nil +} + +type NullableProjectCostWithDetailedServices struct { + value *ProjectCostWithDetailedServices + isSet bool +} + +func (v NullableProjectCostWithDetailedServices) Get() *ProjectCostWithDetailedServices { + return v.value +} + +func (v *NullableProjectCostWithDetailedServices) Set(val *ProjectCostWithDetailedServices) { + v.value = val + v.isSet = true +} + +func (v NullableProjectCostWithDetailedServices) IsSet() bool { + return v.isSet +} + +func (v *NullableProjectCostWithDetailedServices) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableProjectCostWithDetailedServices(val *ProjectCostWithDetailedServices) *NullableProjectCostWithDetailedServices { + return &NullableProjectCostWithDetailedServices{value: val, isSet: true} +} + +func (v NullableProjectCostWithDetailedServices) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableProjectCostWithDetailedServices) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cost/model_project_cost_with_detailed_services_test.go b/services/cost/model_project_cost_with_detailed_services_test.go new file mode 100644 index 000000000..16ddfd392 --- /dev/null +++ b/services/cost/model_project_cost_with_detailed_services_test.go @@ -0,0 +1,11 @@ +/* +STACKIT Cost API + +The cost API provides detailed reports on the costs for a customer or project over a certain amount of time + +API version: 3.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cost diff --git a/services/cost/model_project_cost_with_reports.go b/services/cost/model_project_cost_with_reports.go new file mode 100644 index 000000000..1fc2da42e --- /dev/null +++ b/services/cost/model_project_cost_with_reports.go @@ -0,0 +1,350 @@ +/* +STACKIT Cost API + +The cost API provides detailed reports on the costs for a customer or project over a certain amount of time + +API version: 3.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cost + +import ( + "encoding/json" +) + +// checks if the ProjectCostWithReports type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ProjectCostWithReports{} + +/* + types and functions for customerAccountId +*/ + +// isNotNullableString +type ProjectCostWithReportsGetCustomerAccountIdAttributeType = *string + +func getProjectCostWithReportsGetCustomerAccountIdAttributeTypeOk(arg ProjectCostWithReportsGetCustomerAccountIdAttributeType) (ret ProjectCostWithReportsGetCustomerAccountIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setProjectCostWithReportsGetCustomerAccountIdAttributeType(arg *ProjectCostWithReportsGetCustomerAccountIdAttributeType, val ProjectCostWithReportsGetCustomerAccountIdRetType) { + *arg = &val +} + +type ProjectCostWithReportsGetCustomerAccountIdArgType = string +type ProjectCostWithReportsGetCustomerAccountIdRetType = string + +/* + types and functions for projectId +*/ + +// isNotNullableString +type ProjectCostWithReportsGetProjectIdAttributeType = *string + +func getProjectCostWithReportsGetProjectIdAttributeTypeOk(arg ProjectCostWithReportsGetProjectIdAttributeType) (ret ProjectCostWithReportsGetProjectIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setProjectCostWithReportsGetProjectIdAttributeType(arg *ProjectCostWithReportsGetProjectIdAttributeType, val ProjectCostWithReportsGetProjectIdRetType) { + *arg = &val +} + +type ProjectCostWithReportsGetProjectIdArgType = string +type ProjectCostWithReportsGetProjectIdRetType = string + +/* + types and functions for projectName +*/ + +// isNotNullableString +type ProjectCostWithReportsGetProjectNameAttributeType = *string + +func getProjectCostWithReportsGetProjectNameAttributeTypeOk(arg ProjectCostWithReportsGetProjectNameAttributeType) (ret ProjectCostWithReportsGetProjectNameRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setProjectCostWithReportsGetProjectNameAttributeType(arg *ProjectCostWithReportsGetProjectNameAttributeType, val ProjectCostWithReportsGetProjectNameRetType) { + *arg = &val +} + +type ProjectCostWithReportsGetProjectNameArgType = string +type ProjectCostWithReportsGetProjectNameRetType = string + +/* + types and functions for reportData +*/ + +// isArray +type ProjectCostWithReportsGetReportDataAttributeType = *[]ReportData +type ProjectCostWithReportsGetReportDataArgType = []ReportData +type ProjectCostWithReportsGetReportDataRetType = []ReportData + +func getProjectCostWithReportsGetReportDataAttributeTypeOk(arg ProjectCostWithReportsGetReportDataAttributeType) (ret ProjectCostWithReportsGetReportDataRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setProjectCostWithReportsGetReportDataAttributeType(arg *ProjectCostWithReportsGetReportDataAttributeType, val ProjectCostWithReportsGetReportDataRetType) { + *arg = &val +} + +/* + types and functions for totalCharge +*/ + +// isDouble +type ProjectCostWithReportsGetTotalChargeAttributeType = *float64 +type ProjectCostWithReportsGetTotalChargeArgType = float64 +type ProjectCostWithReportsGetTotalChargeRetType = float64 + +func getProjectCostWithReportsGetTotalChargeAttributeTypeOk(arg ProjectCostWithReportsGetTotalChargeAttributeType) (ret ProjectCostWithReportsGetTotalChargeRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setProjectCostWithReportsGetTotalChargeAttributeType(arg *ProjectCostWithReportsGetTotalChargeAttributeType, val ProjectCostWithReportsGetTotalChargeRetType) { + *arg = &val +} + +/* + types and functions for totalDiscount +*/ + +// isDouble +type ProjectCostWithReportsGetTotalDiscountAttributeType = *float64 +type ProjectCostWithReportsGetTotalDiscountArgType = float64 +type ProjectCostWithReportsGetTotalDiscountRetType = float64 + +func getProjectCostWithReportsGetTotalDiscountAttributeTypeOk(arg ProjectCostWithReportsGetTotalDiscountAttributeType) (ret ProjectCostWithReportsGetTotalDiscountRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setProjectCostWithReportsGetTotalDiscountAttributeType(arg *ProjectCostWithReportsGetTotalDiscountAttributeType, val ProjectCostWithReportsGetTotalDiscountRetType) { + *arg = &val +} + +// ProjectCostWithReports Detailed costs for a project +type ProjectCostWithReports struct { + // REQUIRED + CustomerAccountId ProjectCostWithReportsGetCustomerAccountIdAttributeType `json:"customerAccountId" required:"true"` + // REQUIRED + ProjectId ProjectCostWithReportsGetProjectIdAttributeType `json:"projectId" required:"true"` + // REQUIRED + ProjectName ProjectCostWithReportsGetProjectNameAttributeType `json:"projectName" required:"true"` + // Detailed project costs which are ONLY included if granularity is provided AND depth is \"project\" + ReportData ProjectCostWithReportsGetReportDataAttributeType `json:"reportData,omitempty"` + // Total charge for all services and the whole requested date range (value in cents) + // REQUIRED + TotalCharge ProjectCostWithReportsGetTotalChargeAttributeType `json:"totalCharge" required:"true"` + // Total discount for all services and the whole requested date range (value in cents) + // REQUIRED + TotalDiscount ProjectCostWithReportsGetTotalDiscountAttributeType `json:"totalDiscount" required:"true"` +} + +type _ProjectCostWithReports ProjectCostWithReports + +// NewProjectCostWithReports instantiates a new ProjectCostWithReports 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 NewProjectCostWithReports(customerAccountId ProjectCostWithReportsGetCustomerAccountIdArgType, projectId ProjectCostWithReportsGetProjectIdArgType, projectName ProjectCostWithReportsGetProjectNameArgType, totalCharge ProjectCostWithReportsGetTotalChargeArgType, totalDiscount ProjectCostWithReportsGetTotalDiscountArgType) *ProjectCostWithReports { + this := ProjectCostWithReports{} + setProjectCostWithReportsGetCustomerAccountIdAttributeType(&this.CustomerAccountId, customerAccountId) + setProjectCostWithReportsGetProjectIdAttributeType(&this.ProjectId, projectId) + setProjectCostWithReportsGetProjectNameAttributeType(&this.ProjectName, projectName) + setProjectCostWithReportsGetTotalChargeAttributeType(&this.TotalCharge, totalCharge) + setProjectCostWithReportsGetTotalDiscountAttributeType(&this.TotalDiscount, totalDiscount) + return &this +} + +// NewProjectCostWithReportsWithDefaults instantiates a new ProjectCostWithReports 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 NewProjectCostWithReportsWithDefaults() *ProjectCostWithReports { + this := ProjectCostWithReports{} + return &this +} + +// GetCustomerAccountId returns the CustomerAccountId field value +func (o *ProjectCostWithReports) GetCustomerAccountId() (ret ProjectCostWithReportsGetCustomerAccountIdRetType) { + ret, _ = o.GetCustomerAccountIdOk() + return ret +} + +// GetCustomerAccountIdOk returns a tuple with the CustomerAccountId field value +// and a boolean to check if the value has been set. +func (o *ProjectCostWithReports) GetCustomerAccountIdOk() (ret ProjectCostWithReportsGetCustomerAccountIdRetType, ok bool) { + return getProjectCostWithReportsGetCustomerAccountIdAttributeTypeOk(o.CustomerAccountId) +} + +// SetCustomerAccountId sets field value +func (o *ProjectCostWithReports) SetCustomerAccountId(v ProjectCostWithReportsGetCustomerAccountIdRetType) { + setProjectCostWithReportsGetCustomerAccountIdAttributeType(&o.CustomerAccountId, v) +} + +// GetProjectId returns the ProjectId field value +func (o *ProjectCostWithReports) GetProjectId() (ret ProjectCostWithReportsGetProjectIdRetType) { + 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 *ProjectCostWithReports) GetProjectIdOk() (ret ProjectCostWithReportsGetProjectIdRetType, ok bool) { + return getProjectCostWithReportsGetProjectIdAttributeTypeOk(o.ProjectId) +} + +// SetProjectId sets field value +func (o *ProjectCostWithReports) SetProjectId(v ProjectCostWithReportsGetProjectIdRetType) { + setProjectCostWithReportsGetProjectIdAttributeType(&o.ProjectId, v) +} + +// GetProjectName returns the ProjectName field value +func (o *ProjectCostWithReports) GetProjectName() (ret ProjectCostWithReportsGetProjectNameRetType) { + ret, _ = o.GetProjectNameOk() + return ret +} + +// GetProjectNameOk returns a tuple with the ProjectName field value +// and a boolean to check if the value has been set. +func (o *ProjectCostWithReports) GetProjectNameOk() (ret ProjectCostWithReportsGetProjectNameRetType, ok bool) { + return getProjectCostWithReportsGetProjectNameAttributeTypeOk(o.ProjectName) +} + +// SetProjectName sets field value +func (o *ProjectCostWithReports) SetProjectName(v ProjectCostWithReportsGetProjectNameRetType) { + setProjectCostWithReportsGetProjectNameAttributeType(&o.ProjectName, v) +} + +// GetReportData returns the ReportData field value if set, zero value otherwise. +func (o *ProjectCostWithReports) GetReportData() (res ProjectCostWithReportsGetReportDataRetType) { + res, _ = o.GetReportDataOk() + return +} + +// GetReportDataOk returns a tuple with the ReportData field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ProjectCostWithReports) GetReportDataOk() (ret ProjectCostWithReportsGetReportDataRetType, ok bool) { + return getProjectCostWithReportsGetReportDataAttributeTypeOk(o.ReportData) +} + +// HasReportData returns a boolean if a field has been set. +func (o *ProjectCostWithReports) HasReportData() bool { + _, ok := o.GetReportDataOk() + return ok +} + +// SetReportData gets a reference to the given []ReportData and assigns it to the ReportData field. +func (o *ProjectCostWithReports) SetReportData(v ProjectCostWithReportsGetReportDataRetType) { + setProjectCostWithReportsGetReportDataAttributeType(&o.ReportData, v) +} + +// GetTotalCharge returns the TotalCharge field value +func (o *ProjectCostWithReports) GetTotalCharge() (ret ProjectCostWithReportsGetTotalChargeRetType) { + ret, _ = o.GetTotalChargeOk() + return ret +} + +// GetTotalChargeOk returns a tuple with the TotalCharge field value +// and a boolean to check if the value has been set. +func (o *ProjectCostWithReports) GetTotalChargeOk() (ret ProjectCostWithReportsGetTotalChargeRetType, ok bool) { + return getProjectCostWithReportsGetTotalChargeAttributeTypeOk(o.TotalCharge) +} + +// SetTotalCharge sets field value +func (o *ProjectCostWithReports) SetTotalCharge(v ProjectCostWithReportsGetTotalChargeRetType) { + setProjectCostWithReportsGetTotalChargeAttributeType(&o.TotalCharge, v) +} + +// GetTotalDiscount returns the TotalDiscount field value +func (o *ProjectCostWithReports) GetTotalDiscount() (ret ProjectCostWithReportsGetTotalDiscountRetType) { + ret, _ = o.GetTotalDiscountOk() + return ret +} + +// GetTotalDiscountOk returns a tuple with the TotalDiscount field value +// and a boolean to check if the value has been set. +func (o *ProjectCostWithReports) GetTotalDiscountOk() (ret ProjectCostWithReportsGetTotalDiscountRetType, ok bool) { + return getProjectCostWithReportsGetTotalDiscountAttributeTypeOk(o.TotalDiscount) +} + +// SetTotalDiscount sets field value +func (o *ProjectCostWithReports) SetTotalDiscount(v ProjectCostWithReportsGetTotalDiscountRetType) { + setProjectCostWithReportsGetTotalDiscountAttributeType(&o.TotalDiscount, v) +} + +func (o ProjectCostWithReports) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getProjectCostWithReportsGetCustomerAccountIdAttributeTypeOk(o.CustomerAccountId); ok { + toSerialize["CustomerAccountId"] = val + } + if val, ok := getProjectCostWithReportsGetProjectIdAttributeTypeOk(o.ProjectId); ok { + toSerialize["ProjectId"] = val + } + if val, ok := getProjectCostWithReportsGetProjectNameAttributeTypeOk(o.ProjectName); ok { + toSerialize["ProjectName"] = val + } + if val, ok := getProjectCostWithReportsGetReportDataAttributeTypeOk(o.ReportData); ok { + toSerialize["ReportData"] = val + } + if val, ok := getProjectCostWithReportsGetTotalChargeAttributeTypeOk(o.TotalCharge); ok { + toSerialize["TotalCharge"] = val + } + if val, ok := getProjectCostWithReportsGetTotalDiscountAttributeTypeOk(o.TotalDiscount); ok { + toSerialize["TotalDiscount"] = val + } + return toSerialize, nil +} + +type NullableProjectCostWithReports struct { + value *ProjectCostWithReports + isSet bool +} + +func (v NullableProjectCostWithReports) Get() *ProjectCostWithReports { + return v.value +} + +func (v *NullableProjectCostWithReports) Set(val *ProjectCostWithReports) { + v.value = val + v.isSet = true +} + +func (v NullableProjectCostWithReports) IsSet() bool { + return v.isSet +} + +func (v *NullableProjectCostWithReports) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableProjectCostWithReports(val *ProjectCostWithReports) *NullableProjectCostWithReports { + return &NullableProjectCostWithReports{value: val, isSet: true} +} + +func (v NullableProjectCostWithReports) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableProjectCostWithReports) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cost/model_project_cost_with_reports_test.go b/services/cost/model_project_cost_with_reports_test.go new file mode 100644 index 000000000..16ddfd392 --- /dev/null +++ b/services/cost/model_project_cost_with_reports_test.go @@ -0,0 +1,11 @@ +/* +STACKIT Cost API + +The cost API provides detailed reports on the costs for a customer or project over a certain amount of time + +API version: 3.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cost diff --git a/services/cost/model_project_cost_with_summarized_services.go b/services/cost/model_project_cost_with_summarized_services.go new file mode 100644 index 000000000..f79fd4429 --- /dev/null +++ b/services/cost/model_project_cost_with_summarized_services.go @@ -0,0 +1,350 @@ +/* +STACKIT Cost API + +The cost API provides detailed reports on the costs for a customer or project over a certain amount of time + +API version: 3.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cost + +import ( + "encoding/json" +) + +// checks if the ProjectCostWithSummarizedServices type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ProjectCostWithSummarizedServices{} + +/* + types and functions for customerAccountId +*/ + +// isNotNullableString +type ProjectCostWithSummarizedServicesGetCustomerAccountIdAttributeType = *string + +func getProjectCostWithSummarizedServicesGetCustomerAccountIdAttributeTypeOk(arg ProjectCostWithSummarizedServicesGetCustomerAccountIdAttributeType) (ret ProjectCostWithSummarizedServicesGetCustomerAccountIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setProjectCostWithSummarizedServicesGetCustomerAccountIdAttributeType(arg *ProjectCostWithSummarizedServicesGetCustomerAccountIdAttributeType, val ProjectCostWithSummarizedServicesGetCustomerAccountIdRetType) { + *arg = &val +} + +type ProjectCostWithSummarizedServicesGetCustomerAccountIdArgType = string +type ProjectCostWithSummarizedServicesGetCustomerAccountIdRetType = string + +/* + types and functions for projectId +*/ + +// isNotNullableString +type ProjectCostWithSummarizedServicesGetProjectIdAttributeType = *string + +func getProjectCostWithSummarizedServicesGetProjectIdAttributeTypeOk(arg ProjectCostWithSummarizedServicesGetProjectIdAttributeType) (ret ProjectCostWithSummarizedServicesGetProjectIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setProjectCostWithSummarizedServicesGetProjectIdAttributeType(arg *ProjectCostWithSummarizedServicesGetProjectIdAttributeType, val ProjectCostWithSummarizedServicesGetProjectIdRetType) { + *arg = &val +} + +type ProjectCostWithSummarizedServicesGetProjectIdArgType = string +type ProjectCostWithSummarizedServicesGetProjectIdRetType = string + +/* + types and functions for projectName +*/ + +// isNotNullableString +type ProjectCostWithSummarizedServicesGetProjectNameAttributeType = *string + +func getProjectCostWithSummarizedServicesGetProjectNameAttributeTypeOk(arg ProjectCostWithSummarizedServicesGetProjectNameAttributeType) (ret ProjectCostWithSummarizedServicesGetProjectNameRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setProjectCostWithSummarizedServicesGetProjectNameAttributeType(arg *ProjectCostWithSummarizedServicesGetProjectNameAttributeType, val ProjectCostWithSummarizedServicesGetProjectNameRetType) { + *arg = &val +} + +type ProjectCostWithSummarizedServicesGetProjectNameArgType = string +type ProjectCostWithSummarizedServicesGetProjectNameRetType = string + +/* + types and functions for services +*/ + +// isArray +type ProjectCostWithSummarizedServicesGetServicesAttributeType = *[]SummarizedServiceCost +type ProjectCostWithSummarizedServicesGetServicesArgType = []SummarizedServiceCost +type ProjectCostWithSummarizedServicesGetServicesRetType = []SummarizedServiceCost + +func getProjectCostWithSummarizedServicesGetServicesAttributeTypeOk(arg ProjectCostWithSummarizedServicesGetServicesAttributeType) (ret ProjectCostWithSummarizedServicesGetServicesRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setProjectCostWithSummarizedServicesGetServicesAttributeType(arg *ProjectCostWithSummarizedServicesGetServicesAttributeType, val ProjectCostWithSummarizedServicesGetServicesRetType) { + *arg = &val +} + +/* + types and functions for totalCharge +*/ + +// isDouble +type ProjectCostWithSummarizedServicesGetTotalChargeAttributeType = *float64 +type ProjectCostWithSummarizedServicesGetTotalChargeArgType = float64 +type ProjectCostWithSummarizedServicesGetTotalChargeRetType = float64 + +func getProjectCostWithSummarizedServicesGetTotalChargeAttributeTypeOk(arg ProjectCostWithSummarizedServicesGetTotalChargeAttributeType) (ret ProjectCostWithSummarizedServicesGetTotalChargeRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setProjectCostWithSummarizedServicesGetTotalChargeAttributeType(arg *ProjectCostWithSummarizedServicesGetTotalChargeAttributeType, val ProjectCostWithSummarizedServicesGetTotalChargeRetType) { + *arg = &val +} + +/* + types and functions for totalDiscount +*/ + +// isDouble +type ProjectCostWithSummarizedServicesGetTotalDiscountAttributeType = *float64 +type ProjectCostWithSummarizedServicesGetTotalDiscountArgType = float64 +type ProjectCostWithSummarizedServicesGetTotalDiscountRetType = float64 + +func getProjectCostWithSummarizedServicesGetTotalDiscountAttributeTypeOk(arg ProjectCostWithSummarizedServicesGetTotalDiscountAttributeType) (ret ProjectCostWithSummarizedServicesGetTotalDiscountRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setProjectCostWithSummarizedServicesGetTotalDiscountAttributeType(arg *ProjectCostWithSummarizedServicesGetTotalDiscountAttributeType, val ProjectCostWithSummarizedServicesGetTotalDiscountRetType) { + *arg = &val +} + +// ProjectCostWithSummarizedServices Costs for a project including summarized service costs +type ProjectCostWithSummarizedServices struct { + // REQUIRED + CustomerAccountId ProjectCostWithSummarizedServicesGetCustomerAccountIdAttributeType `json:"customerAccountId" required:"true"` + // REQUIRED + ProjectId ProjectCostWithSummarizedServicesGetProjectIdAttributeType `json:"projectId" required:"true"` + // REQUIRED + ProjectName ProjectCostWithSummarizedServicesGetProjectNameAttributeType `json:"projectName" required:"true"` + // Summarized service costs + Services ProjectCostWithSummarizedServicesGetServicesAttributeType `json:"services,omitempty"` + // Total charge for all services and the whole requested date range (value in cents) + // REQUIRED + TotalCharge ProjectCostWithSummarizedServicesGetTotalChargeAttributeType `json:"totalCharge" required:"true"` + // Total discount for all services and the whole requested date range (value in cents) + // REQUIRED + TotalDiscount ProjectCostWithSummarizedServicesGetTotalDiscountAttributeType `json:"totalDiscount" required:"true"` +} + +type _ProjectCostWithSummarizedServices ProjectCostWithSummarizedServices + +// NewProjectCostWithSummarizedServices instantiates a new ProjectCostWithSummarizedServices 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 NewProjectCostWithSummarizedServices(customerAccountId ProjectCostWithSummarizedServicesGetCustomerAccountIdArgType, projectId ProjectCostWithSummarizedServicesGetProjectIdArgType, projectName ProjectCostWithSummarizedServicesGetProjectNameArgType, totalCharge ProjectCostWithSummarizedServicesGetTotalChargeArgType, totalDiscount ProjectCostWithSummarizedServicesGetTotalDiscountArgType) *ProjectCostWithSummarizedServices { + this := ProjectCostWithSummarizedServices{} + setProjectCostWithSummarizedServicesGetCustomerAccountIdAttributeType(&this.CustomerAccountId, customerAccountId) + setProjectCostWithSummarizedServicesGetProjectIdAttributeType(&this.ProjectId, projectId) + setProjectCostWithSummarizedServicesGetProjectNameAttributeType(&this.ProjectName, projectName) + setProjectCostWithSummarizedServicesGetTotalChargeAttributeType(&this.TotalCharge, totalCharge) + setProjectCostWithSummarizedServicesGetTotalDiscountAttributeType(&this.TotalDiscount, totalDiscount) + return &this +} + +// NewProjectCostWithSummarizedServicesWithDefaults instantiates a new ProjectCostWithSummarizedServices 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 NewProjectCostWithSummarizedServicesWithDefaults() *ProjectCostWithSummarizedServices { + this := ProjectCostWithSummarizedServices{} + return &this +} + +// GetCustomerAccountId returns the CustomerAccountId field value +func (o *ProjectCostWithSummarizedServices) GetCustomerAccountId() (ret ProjectCostWithSummarizedServicesGetCustomerAccountIdRetType) { + ret, _ = o.GetCustomerAccountIdOk() + return ret +} + +// GetCustomerAccountIdOk returns a tuple with the CustomerAccountId field value +// and a boolean to check if the value has been set. +func (o *ProjectCostWithSummarizedServices) GetCustomerAccountIdOk() (ret ProjectCostWithSummarizedServicesGetCustomerAccountIdRetType, ok bool) { + return getProjectCostWithSummarizedServicesGetCustomerAccountIdAttributeTypeOk(o.CustomerAccountId) +} + +// SetCustomerAccountId sets field value +func (o *ProjectCostWithSummarizedServices) SetCustomerAccountId(v ProjectCostWithSummarizedServicesGetCustomerAccountIdRetType) { + setProjectCostWithSummarizedServicesGetCustomerAccountIdAttributeType(&o.CustomerAccountId, v) +} + +// GetProjectId returns the ProjectId field value +func (o *ProjectCostWithSummarizedServices) GetProjectId() (ret ProjectCostWithSummarizedServicesGetProjectIdRetType) { + 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 *ProjectCostWithSummarizedServices) GetProjectIdOk() (ret ProjectCostWithSummarizedServicesGetProjectIdRetType, ok bool) { + return getProjectCostWithSummarizedServicesGetProjectIdAttributeTypeOk(o.ProjectId) +} + +// SetProjectId sets field value +func (o *ProjectCostWithSummarizedServices) SetProjectId(v ProjectCostWithSummarizedServicesGetProjectIdRetType) { + setProjectCostWithSummarizedServicesGetProjectIdAttributeType(&o.ProjectId, v) +} + +// GetProjectName returns the ProjectName field value +func (o *ProjectCostWithSummarizedServices) GetProjectName() (ret ProjectCostWithSummarizedServicesGetProjectNameRetType) { + ret, _ = o.GetProjectNameOk() + return ret +} + +// GetProjectNameOk returns a tuple with the ProjectName field value +// and a boolean to check if the value has been set. +func (o *ProjectCostWithSummarizedServices) GetProjectNameOk() (ret ProjectCostWithSummarizedServicesGetProjectNameRetType, ok bool) { + return getProjectCostWithSummarizedServicesGetProjectNameAttributeTypeOk(o.ProjectName) +} + +// SetProjectName sets field value +func (o *ProjectCostWithSummarizedServices) SetProjectName(v ProjectCostWithSummarizedServicesGetProjectNameRetType) { + setProjectCostWithSummarizedServicesGetProjectNameAttributeType(&o.ProjectName, v) +} + +// GetServices returns the Services field value if set, zero value otherwise. +func (o *ProjectCostWithSummarizedServices) GetServices() (res ProjectCostWithSummarizedServicesGetServicesRetType) { + res, _ = o.GetServicesOk() + return +} + +// GetServicesOk returns a tuple with the Services field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ProjectCostWithSummarizedServices) GetServicesOk() (ret ProjectCostWithSummarizedServicesGetServicesRetType, ok bool) { + return getProjectCostWithSummarizedServicesGetServicesAttributeTypeOk(o.Services) +} + +// HasServices returns a boolean if a field has been set. +func (o *ProjectCostWithSummarizedServices) HasServices() bool { + _, ok := o.GetServicesOk() + return ok +} + +// SetServices gets a reference to the given []SummarizedServiceCost and assigns it to the Services field. +func (o *ProjectCostWithSummarizedServices) SetServices(v ProjectCostWithSummarizedServicesGetServicesRetType) { + setProjectCostWithSummarizedServicesGetServicesAttributeType(&o.Services, v) +} + +// GetTotalCharge returns the TotalCharge field value +func (o *ProjectCostWithSummarizedServices) GetTotalCharge() (ret ProjectCostWithSummarizedServicesGetTotalChargeRetType) { + ret, _ = o.GetTotalChargeOk() + return ret +} + +// GetTotalChargeOk returns a tuple with the TotalCharge field value +// and a boolean to check if the value has been set. +func (o *ProjectCostWithSummarizedServices) GetTotalChargeOk() (ret ProjectCostWithSummarizedServicesGetTotalChargeRetType, ok bool) { + return getProjectCostWithSummarizedServicesGetTotalChargeAttributeTypeOk(o.TotalCharge) +} + +// SetTotalCharge sets field value +func (o *ProjectCostWithSummarizedServices) SetTotalCharge(v ProjectCostWithSummarizedServicesGetTotalChargeRetType) { + setProjectCostWithSummarizedServicesGetTotalChargeAttributeType(&o.TotalCharge, v) +} + +// GetTotalDiscount returns the TotalDiscount field value +func (o *ProjectCostWithSummarizedServices) GetTotalDiscount() (ret ProjectCostWithSummarizedServicesGetTotalDiscountRetType) { + ret, _ = o.GetTotalDiscountOk() + return ret +} + +// GetTotalDiscountOk returns a tuple with the TotalDiscount field value +// and a boolean to check if the value has been set. +func (o *ProjectCostWithSummarizedServices) GetTotalDiscountOk() (ret ProjectCostWithSummarizedServicesGetTotalDiscountRetType, ok bool) { + return getProjectCostWithSummarizedServicesGetTotalDiscountAttributeTypeOk(o.TotalDiscount) +} + +// SetTotalDiscount sets field value +func (o *ProjectCostWithSummarizedServices) SetTotalDiscount(v ProjectCostWithSummarizedServicesGetTotalDiscountRetType) { + setProjectCostWithSummarizedServicesGetTotalDiscountAttributeType(&o.TotalDiscount, v) +} + +func (o ProjectCostWithSummarizedServices) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getProjectCostWithSummarizedServicesGetCustomerAccountIdAttributeTypeOk(o.CustomerAccountId); ok { + toSerialize["CustomerAccountId"] = val + } + if val, ok := getProjectCostWithSummarizedServicesGetProjectIdAttributeTypeOk(o.ProjectId); ok { + toSerialize["ProjectId"] = val + } + if val, ok := getProjectCostWithSummarizedServicesGetProjectNameAttributeTypeOk(o.ProjectName); ok { + toSerialize["ProjectName"] = val + } + if val, ok := getProjectCostWithSummarizedServicesGetServicesAttributeTypeOk(o.Services); ok { + toSerialize["Services"] = val + } + if val, ok := getProjectCostWithSummarizedServicesGetTotalChargeAttributeTypeOk(o.TotalCharge); ok { + toSerialize["TotalCharge"] = val + } + if val, ok := getProjectCostWithSummarizedServicesGetTotalDiscountAttributeTypeOk(o.TotalDiscount); ok { + toSerialize["TotalDiscount"] = val + } + return toSerialize, nil +} + +type NullableProjectCostWithSummarizedServices struct { + value *ProjectCostWithSummarizedServices + isSet bool +} + +func (v NullableProjectCostWithSummarizedServices) Get() *ProjectCostWithSummarizedServices { + return v.value +} + +func (v *NullableProjectCostWithSummarizedServices) Set(val *ProjectCostWithSummarizedServices) { + v.value = val + v.isSet = true +} + +func (v NullableProjectCostWithSummarizedServices) IsSet() bool { + return v.isSet +} + +func (v *NullableProjectCostWithSummarizedServices) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableProjectCostWithSummarizedServices(val *ProjectCostWithSummarizedServices) *NullableProjectCostWithSummarizedServices { + return &NullableProjectCostWithSummarizedServices{value: val, isSet: true} +} + +func (v NullableProjectCostWithSummarizedServices) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableProjectCostWithSummarizedServices) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cost/model_project_cost_with_summarized_services_test.go b/services/cost/model_project_cost_with_summarized_services_test.go new file mode 100644 index 000000000..16ddfd392 --- /dev/null +++ b/services/cost/model_project_cost_with_summarized_services_test.go @@ -0,0 +1,11 @@ +/* +STACKIT Cost API + +The cost API provides detailed reports on the costs for a customer or project over a certain amount of time + +API version: 3.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cost diff --git a/services/cost/model_report_data.go b/services/cost/model_report_data.go new file mode 100644 index 000000000..ad6a6ec74 --- /dev/null +++ b/services/cost/model_report_data.go @@ -0,0 +1,258 @@ +/* +STACKIT Cost API + +The cost API provides detailed reports on the costs for a customer or project over a certain amount of time + +API version: 3.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cost + +import ( + "encoding/json" +) + +// checks if the ReportData type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ReportData{} + +/* + types and functions for charge +*/ + +// isDouble +type ReportDataGetChargeAttributeType = *float64 +type ReportDataGetChargeArgType = float64 +type ReportDataGetChargeRetType = float64 + +func getReportDataGetChargeAttributeTypeOk(arg ReportDataGetChargeAttributeType) (ret ReportDataGetChargeRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setReportDataGetChargeAttributeType(arg *ReportDataGetChargeAttributeType, val ReportDataGetChargeRetType) { + *arg = &val +} + +/* + types and functions for discount +*/ + +// isDouble +type ReportDataGetDiscountAttributeType = *float64 +type ReportDataGetDiscountArgType = float64 +type ReportDataGetDiscountRetType = float64 + +func getReportDataGetDiscountAttributeTypeOk(arg ReportDataGetDiscountAttributeType) (ret ReportDataGetDiscountRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setReportDataGetDiscountAttributeType(arg *ReportDataGetDiscountAttributeType, val ReportDataGetDiscountRetType) { + *arg = &val +} + +/* + types and functions for quantity +*/ + +// isInteger +type ReportDataGetQuantityAttributeType = *int64 +type ReportDataGetQuantityArgType = int64 +type ReportDataGetQuantityRetType = int64 + +func getReportDataGetQuantityAttributeTypeOk(arg ReportDataGetQuantityAttributeType) (ret ReportDataGetQuantityRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setReportDataGetQuantityAttributeType(arg *ReportDataGetQuantityAttributeType, val ReportDataGetQuantityRetType) { + *arg = &val +} + +/* + types and functions for timePeriod +*/ + +// isModel +type ReportDataGetTimePeriodAttributeType = *ReportDataTimePeriod +type ReportDataGetTimePeriodArgType = ReportDataTimePeriod +type ReportDataGetTimePeriodRetType = ReportDataTimePeriod + +func getReportDataGetTimePeriodAttributeTypeOk(arg ReportDataGetTimePeriodAttributeType) (ret ReportDataGetTimePeriodRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setReportDataGetTimePeriodAttributeType(arg *ReportDataGetTimePeriodAttributeType, val ReportDataGetTimePeriodRetType) { + *arg = &val +} + +// ReportData Costs report for a certain period of time +type ReportData struct { + // Charge, value in cents + // REQUIRED + Charge ReportDataGetChargeAttributeType `json:"charge" required:"true"` + // Discount, value in cents + // REQUIRED + Discount ReportDataGetDiscountAttributeType `json:"discount" required:"true"` + // Quantity + // Can be cast to int32 without loss of precision. + // REQUIRED + Quantity ReportDataGetQuantityAttributeType `json:"quantity" required:"true"` + // REQUIRED + TimePeriod ReportDataGetTimePeriodAttributeType `json:"timePeriod" required:"true"` +} + +type _ReportData ReportData + +// NewReportData instantiates a new ReportData 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 NewReportData(charge ReportDataGetChargeArgType, discount ReportDataGetDiscountArgType, quantity ReportDataGetQuantityArgType, timePeriod ReportDataGetTimePeriodArgType) *ReportData { + this := ReportData{} + setReportDataGetChargeAttributeType(&this.Charge, charge) + setReportDataGetDiscountAttributeType(&this.Discount, discount) + setReportDataGetQuantityAttributeType(&this.Quantity, quantity) + setReportDataGetTimePeriodAttributeType(&this.TimePeriod, timePeriod) + return &this +} + +// NewReportDataWithDefaults instantiates a new ReportData 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 NewReportDataWithDefaults() *ReportData { + this := ReportData{} + return &this +} + +// GetCharge returns the Charge field value +func (o *ReportData) GetCharge() (ret ReportDataGetChargeRetType) { + ret, _ = o.GetChargeOk() + return ret +} + +// GetChargeOk returns a tuple with the Charge field value +// and a boolean to check if the value has been set. +func (o *ReportData) GetChargeOk() (ret ReportDataGetChargeRetType, ok bool) { + return getReportDataGetChargeAttributeTypeOk(o.Charge) +} + +// SetCharge sets field value +func (o *ReportData) SetCharge(v ReportDataGetChargeRetType) { + setReportDataGetChargeAttributeType(&o.Charge, v) +} + +// GetDiscount returns the Discount field value +func (o *ReportData) GetDiscount() (ret ReportDataGetDiscountRetType) { + ret, _ = o.GetDiscountOk() + return ret +} + +// GetDiscountOk returns a tuple with the Discount field value +// and a boolean to check if the value has been set. +func (o *ReportData) GetDiscountOk() (ret ReportDataGetDiscountRetType, ok bool) { + return getReportDataGetDiscountAttributeTypeOk(o.Discount) +} + +// SetDiscount sets field value +func (o *ReportData) SetDiscount(v ReportDataGetDiscountRetType) { + setReportDataGetDiscountAttributeType(&o.Discount, v) +} + +// GetQuantity returns the Quantity field value +func (o *ReportData) GetQuantity() (ret ReportDataGetQuantityRetType) { + ret, _ = o.GetQuantityOk() + return ret +} + +// GetQuantityOk returns a tuple with the Quantity field value +// and a boolean to check if the value has been set. +func (o *ReportData) GetQuantityOk() (ret ReportDataGetQuantityRetType, ok bool) { + return getReportDataGetQuantityAttributeTypeOk(o.Quantity) +} + +// SetQuantity sets field value +func (o *ReportData) SetQuantity(v ReportDataGetQuantityRetType) { + setReportDataGetQuantityAttributeType(&o.Quantity, v) +} + +// GetTimePeriod returns the TimePeriod field value +func (o *ReportData) GetTimePeriod() (ret ReportDataGetTimePeriodRetType) { + ret, _ = o.GetTimePeriodOk() + return ret +} + +// GetTimePeriodOk returns a tuple with the TimePeriod field value +// and a boolean to check if the value has been set. +func (o *ReportData) GetTimePeriodOk() (ret ReportDataGetTimePeriodRetType, ok bool) { + return getReportDataGetTimePeriodAttributeTypeOk(o.TimePeriod) +} + +// SetTimePeriod sets field value +func (o *ReportData) SetTimePeriod(v ReportDataGetTimePeriodRetType) { + setReportDataGetTimePeriodAttributeType(&o.TimePeriod, v) +} + +func (o ReportData) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getReportDataGetChargeAttributeTypeOk(o.Charge); ok { + toSerialize["Charge"] = val + } + if val, ok := getReportDataGetDiscountAttributeTypeOk(o.Discount); ok { + toSerialize["Discount"] = val + } + if val, ok := getReportDataGetQuantityAttributeTypeOk(o.Quantity); ok { + toSerialize["Quantity"] = val + } + if val, ok := getReportDataGetTimePeriodAttributeTypeOk(o.TimePeriod); ok { + toSerialize["TimePeriod"] = val + } + return toSerialize, nil +} + +type NullableReportData struct { + value *ReportData + isSet bool +} + +func (v NullableReportData) Get() *ReportData { + return v.value +} + +func (v *NullableReportData) Set(val *ReportData) { + v.value = val + v.isSet = true +} + +func (v NullableReportData) IsSet() bool { + return v.isSet +} + +func (v *NullableReportData) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableReportData(val *ReportData) *NullableReportData { + return &NullableReportData{value: val, isSet: true} +} + +func (v NullableReportData) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableReportData) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cost/model_report_data_test.go b/services/cost/model_report_data_test.go new file mode 100644 index 000000000..16ddfd392 --- /dev/null +++ b/services/cost/model_report_data_test.go @@ -0,0 +1,11 @@ +/* +STACKIT Cost API + +The cost API provides detailed reports on the costs for a customer or project over a certain amount of time + +API version: 3.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cost diff --git a/services/cost/model_report_data_time_period.go b/services/cost/model_report_data_time_period.go new file mode 100644 index 000000000..7997fdcd9 --- /dev/null +++ b/services/cost/model_report_data_time_period.go @@ -0,0 +1,174 @@ +/* +STACKIT Cost API + +The cost API provides detailed reports on the costs for a customer or project over a certain amount of time + +API version: 3.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cost + +import ( + "encoding/json" +) + +// checks if the ReportDataTimePeriod type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ReportDataTimePeriod{} + +/* + types and functions for end +*/ + +// isDate +type ReportDataTimePeriodGetEndAttributeType = *string +type ReportDataTimePeriodGetEndArgType = string +type ReportDataTimePeriodGetEndRetType = string + +func getReportDataTimePeriodGetEndAttributeTypeOk(arg ReportDataTimePeriodGetEndAttributeType) (ret ReportDataTimePeriodGetEndRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setReportDataTimePeriodGetEndAttributeType(arg *ReportDataTimePeriodGetEndAttributeType, val ReportDataTimePeriodGetEndRetType) { + *arg = &val +} + +/* + types and functions for start +*/ + +// isDate +type ReportDataTimePeriodGetStartAttributeType = *string +type ReportDataTimePeriodGetStartArgType = string +type ReportDataTimePeriodGetStartRetType = string + +func getReportDataTimePeriodGetStartAttributeTypeOk(arg ReportDataTimePeriodGetStartAttributeType) (ret ReportDataTimePeriodGetStartRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setReportDataTimePeriodGetStartAttributeType(arg *ReportDataTimePeriodGetStartAttributeType, val ReportDataTimePeriodGetStartRetType) { + *arg = &val +} + +// ReportDataTimePeriod Time period according to desired granularity +type ReportDataTimePeriod struct { + End ReportDataTimePeriodGetEndAttributeType `json:"end,omitempty"` + Start ReportDataTimePeriodGetStartAttributeType `json:"start,omitempty"` +} + +// NewReportDataTimePeriod instantiates a new ReportDataTimePeriod 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 NewReportDataTimePeriod() *ReportDataTimePeriod { + this := ReportDataTimePeriod{} + return &this +} + +// NewReportDataTimePeriodWithDefaults instantiates a new ReportDataTimePeriod 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 NewReportDataTimePeriodWithDefaults() *ReportDataTimePeriod { + this := ReportDataTimePeriod{} + return &this +} + +// GetEnd returns the End field value if set, zero value otherwise. +func (o *ReportDataTimePeriod) GetEnd() (res ReportDataTimePeriodGetEndRetType) { + res, _ = o.GetEndOk() + return +} + +// GetEndOk returns a tuple with the End field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ReportDataTimePeriod) GetEndOk() (ret ReportDataTimePeriodGetEndRetType, ok bool) { + return getReportDataTimePeriodGetEndAttributeTypeOk(o.End) +} + +// HasEnd returns a boolean if a field has been set. +func (o *ReportDataTimePeriod) HasEnd() bool { + _, ok := o.GetEndOk() + return ok +} + +// SetEnd gets a reference to the given string and assigns it to the End field. +func (o *ReportDataTimePeriod) SetEnd(v ReportDataTimePeriodGetEndRetType) { + setReportDataTimePeriodGetEndAttributeType(&o.End, v) +} + +// GetStart returns the Start field value if set, zero value otherwise. +func (o *ReportDataTimePeriod) GetStart() (res ReportDataTimePeriodGetStartRetType) { + res, _ = o.GetStartOk() + return +} + +// GetStartOk returns a tuple with the Start field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ReportDataTimePeriod) GetStartOk() (ret ReportDataTimePeriodGetStartRetType, ok bool) { + return getReportDataTimePeriodGetStartAttributeTypeOk(o.Start) +} + +// HasStart returns a boolean if a field has been set. +func (o *ReportDataTimePeriod) HasStart() bool { + _, ok := o.GetStartOk() + return ok +} + +// SetStart gets a reference to the given string and assigns it to the Start field. +func (o *ReportDataTimePeriod) SetStart(v ReportDataTimePeriodGetStartRetType) { + setReportDataTimePeriodGetStartAttributeType(&o.Start, v) +} + +func (o ReportDataTimePeriod) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getReportDataTimePeriodGetEndAttributeTypeOk(o.End); ok { + toSerialize["End"] = val + } + if val, ok := getReportDataTimePeriodGetStartAttributeTypeOk(o.Start); ok { + toSerialize["Start"] = val + } + return toSerialize, nil +} + +type NullableReportDataTimePeriod struct { + value *ReportDataTimePeriod + isSet bool +} + +func (v NullableReportDataTimePeriod) Get() *ReportDataTimePeriod { + return v.value +} + +func (v *NullableReportDataTimePeriod) Set(val *ReportDataTimePeriod) { + v.value = val + v.isSet = true +} + +func (v NullableReportDataTimePeriod) IsSet() bool { + return v.isSet +} + +func (v *NullableReportDataTimePeriod) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableReportDataTimePeriod(val *ReportDataTimePeriod) *NullableReportDataTimePeriod { + return &NullableReportDataTimePeriod{value: val, isSet: true} +} + +func (v NullableReportDataTimePeriod) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableReportDataTimePeriod) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cost/model_report_data_time_period_test.go b/services/cost/model_report_data_time_period_test.go new file mode 100644 index 000000000..16ddfd392 --- /dev/null +++ b/services/cost/model_report_data_time_period_test.go @@ -0,0 +1,11 @@ +/* +STACKIT Cost API + +The cost API provides detailed reports on the costs for a customer or project over a certain amount of time + +API version: 3.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cost diff --git a/services/cost/model_summarized_project_cost.go b/services/cost/model_summarized_project_cost.go new file mode 100644 index 000000000..f95bb1d9f --- /dev/null +++ b/services/cost/model_summarized_project_cost.go @@ -0,0 +1,302 @@ +/* +STACKIT Cost API + +The cost API provides detailed reports on the costs for a customer or project over a certain amount of time + +API version: 3.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cost + +import ( + "encoding/json" +) + +// checks if the SummarizedProjectCost type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &SummarizedProjectCost{} + +/* + types and functions for customerAccountId +*/ + +// isNotNullableString +type SummarizedProjectCostGetCustomerAccountIdAttributeType = *string + +func getSummarizedProjectCostGetCustomerAccountIdAttributeTypeOk(arg SummarizedProjectCostGetCustomerAccountIdAttributeType) (ret SummarizedProjectCostGetCustomerAccountIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setSummarizedProjectCostGetCustomerAccountIdAttributeType(arg *SummarizedProjectCostGetCustomerAccountIdAttributeType, val SummarizedProjectCostGetCustomerAccountIdRetType) { + *arg = &val +} + +type SummarizedProjectCostGetCustomerAccountIdArgType = string +type SummarizedProjectCostGetCustomerAccountIdRetType = string + +/* + types and functions for projectId +*/ + +// isNotNullableString +type SummarizedProjectCostGetProjectIdAttributeType = *string + +func getSummarizedProjectCostGetProjectIdAttributeTypeOk(arg SummarizedProjectCostGetProjectIdAttributeType) (ret SummarizedProjectCostGetProjectIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setSummarizedProjectCostGetProjectIdAttributeType(arg *SummarizedProjectCostGetProjectIdAttributeType, val SummarizedProjectCostGetProjectIdRetType) { + *arg = &val +} + +type SummarizedProjectCostGetProjectIdArgType = string +type SummarizedProjectCostGetProjectIdRetType = string + +/* + types and functions for projectName +*/ + +// isNotNullableString +type SummarizedProjectCostGetProjectNameAttributeType = *string + +func getSummarizedProjectCostGetProjectNameAttributeTypeOk(arg SummarizedProjectCostGetProjectNameAttributeType) (ret SummarizedProjectCostGetProjectNameRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setSummarizedProjectCostGetProjectNameAttributeType(arg *SummarizedProjectCostGetProjectNameAttributeType, val SummarizedProjectCostGetProjectNameRetType) { + *arg = &val +} + +type SummarizedProjectCostGetProjectNameArgType = string +type SummarizedProjectCostGetProjectNameRetType = string + +/* + types and functions for totalCharge +*/ + +// isDouble +type SummarizedProjectCostGetTotalChargeAttributeType = *float64 +type SummarizedProjectCostGetTotalChargeArgType = float64 +type SummarizedProjectCostGetTotalChargeRetType = float64 + +func getSummarizedProjectCostGetTotalChargeAttributeTypeOk(arg SummarizedProjectCostGetTotalChargeAttributeType) (ret SummarizedProjectCostGetTotalChargeRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setSummarizedProjectCostGetTotalChargeAttributeType(arg *SummarizedProjectCostGetTotalChargeAttributeType, val SummarizedProjectCostGetTotalChargeRetType) { + *arg = &val +} + +/* + types and functions for totalDiscount +*/ + +// isDouble +type SummarizedProjectCostGetTotalDiscountAttributeType = *float64 +type SummarizedProjectCostGetTotalDiscountArgType = float64 +type SummarizedProjectCostGetTotalDiscountRetType = float64 + +func getSummarizedProjectCostGetTotalDiscountAttributeTypeOk(arg SummarizedProjectCostGetTotalDiscountAttributeType) (ret SummarizedProjectCostGetTotalDiscountRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setSummarizedProjectCostGetTotalDiscountAttributeType(arg *SummarizedProjectCostGetTotalDiscountAttributeType, val SummarizedProjectCostGetTotalDiscountRetType) { + *arg = &val +} + +// SummarizedProjectCost Summarized costs for a project +type SummarizedProjectCost struct { + // REQUIRED + CustomerAccountId SummarizedProjectCostGetCustomerAccountIdAttributeType `json:"customerAccountId" required:"true"` + // REQUIRED + ProjectId SummarizedProjectCostGetProjectIdAttributeType `json:"projectId" required:"true"` + // REQUIRED + ProjectName SummarizedProjectCostGetProjectNameAttributeType `json:"projectName" required:"true"` + // Total charge for all services and the whole requested date range (value in cents) + // REQUIRED + TotalCharge SummarizedProjectCostGetTotalChargeAttributeType `json:"totalCharge" required:"true"` + // Total discount for all services and the whole requested date range (value in cents) + // REQUIRED + TotalDiscount SummarizedProjectCostGetTotalDiscountAttributeType `json:"totalDiscount" required:"true"` +} + +type _SummarizedProjectCost SummarizedProjectCost + +// NewSummarizedProjectCost instantiates a new SummarizedProjectCost 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 NewSummarizedProjectCost(customerAccountId SummarizedProjectCostGetCustomerAccountIdArgType, projectId SummarizedProjectCostGetProjectIdArgType, projectName SummarizedProjectCostGetProjectNameArgType, totalCharge SummarizedProjectCostGetTotalChargeArgType, totalDiscount SummarizedProjectCostGetTotalDiscountArgType) *SummarizedProjectCost { + this := SummarizedProjectCost{} + setSummarizedProjectCostGetCustomerAccountIdAttributeType(&this.CustomerAccountId, customerAccountId) + setSummarizedProjectCostGetProjectIdAttributeType(&this.ProjectId, projectId) + setSummarizedProjectCostGetProjectNameAttributeType(&this.ProjectName, projectName) + setSummarizedProjectCostGetTotalChargeAttributeType(&this.TotalCharge, totalCharge) + setSummarizedProjectCostGetTotalDiscountAttributeType(&this.TotalDiscount, totalDiscount) + return &this +} + +// NewSummarizedProjectCostWithDefaults instantiates a new SummarizedProjectCost 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 NewSummarizedProjectCostWithDefaults() *SummarizedProjectCost { + this := SummarizedProjectCost{} + return &this +} + +// GetCustomerAccountId returns the CustomerAccountId field value +func (o *SummarizedProjectCost) GetCustomerAccountId() (ret SummarizedProjectCostGetCustomerAccountIdRetType) { + ret, _ = o.GetCustomerAccountIdOk() + return ret +} + +// GetCustomerAccountIdOk returns a tuple with the CustomerAccountId field value +// and a boolean to check if the value has been set. +func (o *SummarizedProjectCost) GetCustomerAccountIdOk() (ret SummarizedProjectCostGetCustomerAccountIdRetType, ok bool) { + return getSummarizedProjectCostGetCustomerAccountIdAttributeTypeOk(o.CustomerAccountId) +} + +// SetCustomerAccountId sets field value +func (o *SummarizedProjectCost) SetCustomerAccountId(v SummarizedProjectCostGetCustomerAccountIdRetType) { + setSummarizedProjectCostGetCustomerAccountIdAttributeType(&o.CustomerAccountId, v) +} + +// GetProjectId returns the ProjectId field value +func (o *SummarizedProjectCost) GetProjectId() (ret SummarizedProjectCostGetProjectIdRetType) { + 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 *SummarizedProjectCost) GetProjectIdOk() (ret SummarizedProjectCostGetProjectIdRetType, ok bool) { + return getSummarizedProjectCostGetProjectIdAttributeTypeOk(o.ProjectId) +} + +// SetProjectId sets field value +func (o *SummarizedProjectCost) SetProjectId(v SummarizedProjectCostGetProjectIdRetType) { + setSummarizedProjectCostGetProjectIdAttributeType(&o.ProjectId, v) +} + +// GetProjectName returns the ProjectName field value +func (o *SummarizedProjectCost) GetProjectName() (ret SummarizedProjectCostGetProjectNameRetType) { + ret, _ = o.GetProjectNameOk() + return ret +} + +// GetProjectNameOk returns a tuple with the ProjectName field value +// and a boolean to check if the value has been set. +func (o *SummarizedProjectCost) GetProjectNameOk() (ret SummarizedProjectCostGetProjectNameRetType, ok bool) { + return getSummarizedProjectCostGetProjectNameAttributeTypeOk(o.ProjectName) +} + +// SetProjectName sets field value +func (o *SummarizedProjectCost) SetProjectName(v SummarizedProjectCostGetProjectNameRetType) { + setSummarizedProjectCostGetProjectNameAttributeType(&o.ProjectName, v) +} + +// GetTotalCharge returns the TotalCharge field value +func (o *SummarizedProjectCost) GetTotalCharge() (ret SummarizedProjectCostGetTotalChargeRetType) { + ret, _ = o.GetTotalChargeOk() + return ret +} + +// GetTotalChargeOk returns a tuple with the TotalCharge field value +// and a boolean to check if the value has been set. +func (o *SummarizedProjectCost) GetTotalChargeOk() (ret SummarizedProjectCostGetTotalChargeRetType, ok bool) { + return getSummarizedProjectCostGetTotalChargeAttributeTypeOk(o.TotalCharge) +} + +// SetTotalCharge sets field value +func (o *SummarizedProjectCost) SetTotalCharge(v SummarizedProjectCostGetTotalChargeRetType) { + setSummarizedProjectCostGetTotalChargeAttributeType(&o.TotalCharge, v) +} + +// GetTotalDiscount returns the TotalDiscount field value +func (o *SummarizedProjectCost) GetTotalDiscount() (ret SummarizedProjectCostGetTotalDiscountRetType) { + ret, _ = o.GetTotalDiscountOk() + return ret +} + +// GetTotalDiscountOk returns a tuple with the TotalDiscount field value +// and a boolean to check if the value has been set. +func (o *SummarizedProjectCost) GetTotalDiscountOk() (ret SummarizedProjectCostGetTotalDiscountRetType, ok bool) { + return getSummarizedProjectCostGetTotalDiscountAttributeTypeOk(o.TotalDiscount) +} + +// SetTotalDiscount sets field value +func (o *SummarizedProjectCost) SetTotalDiscount(v SummarizedProjectCostGetTotalDiscountRetType) { + setSummarizedProjectCostGetTotalDiscountAttributeType(&o.TotalDiscount, v) +} + +func (o SummarizedProjectCost) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getSummarizedProjectCostGetCustomerAccountIdAttributeTypeOk(o.CustomerAccountId); ok { + toSerialize["CustomerAccountId"] = val + } + if val, ok := getSummarizedProjectCostGetProjectIdAttributeTypeOk(o.ProjectId); ok { + toSerialize["ProjectId"] = val + } + if val, ok := getSummarizedProjectCostGetProjectNameAttributeTypeOk(o.ProjectName); ok { + toSerialize["ProjectName"] = val + } + if val, ok := getSummarizedProjectCostGetTotalChargeAttributeTypeOk(o.TotalCharge); ok { + toSerialize["TotalCharge"] = val + } + if val, ok := getSummarizedProjectCostGetTotalDiscountAttributeTypeOk(o.TotalDiscount); ok { + toSerialize["TotalDiscount"] = val + } + return toSerialize, nil +} + +type NullableSummarizedProjectCost struct { + value *SummarizedProjectCost + isSet bool +} + +func (v NullableSummarizedProjectCost) Get() *SummarizedProjectCost { + return v.value +} + +func (v *NullableSummarizedProjectCost) Set(val *SummarizedProjectCost) { + v.value = val + v.isSet = true +} + +func (v NullableSummarizedProjectCost) IsSet() bool { + return v.isSet +} + +func (v *NullableSummarizedProjectCost) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableSummarizedProjectCost(val *SummarizedProjectCost) *NullableSummarizedProjectCost { + return &NullableSummarizedProjectCost{value: val, isSet: true} +} + +func (v NullableSummarizedProjectCost) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableSummarizedProjectCost) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cost/model_summarized_project_cost_test.go b/services/cost/model_summarized_project_cost_test.go new file mode 100644 index 000000000..16ddfd392 --- /dev/null +++ b/services/cost/model_summarized_project_cost_test.go @@ -0,0 +1,11 @@ +/* +STACKIT Cost API + +The cost API provides detailed reports on the costs for a customer or project over a certain amount of time + +API version: 3.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cost diff --git a/services/cost/model_summarized_service_cost.go b/services/cost/model_summarized_service_cost.go new file mode 100644 index 000000000..fd55cc3f3 --- /dev/null +++ b/services/cost/model_summarized_service_cost.go @@ -0,0 +1,302 @@ +/* +STACKIT Cost API + +The cost API provides detailed reports on the costs for a customer or project over a certain amount of time + +API version: 3.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cost + +import ( + "encoding/json" +) + +// checks if the SummarizedServiceCost type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &SummarizedServiceCost{} + +/* + types and functions for customerAccountId +*/ + +// isNotNullableString +type SummarizedServiceCostGetCustomerAccountIdAttributeType = *string + +func getSummarizedServiceCostGetCustomerAccountIdAttributeTypeOk(arg SummarizedServiceCostGetCustomerAccountIdAttributeType) (ret SummarizedServiceCostGetCustomerAccountIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setSummarizedServiceCostGetCustomerAccountIdAttributeType(arg *SummarizedServiceCostGetCustomerAccountIdAttributeType, val SummarizedServiceCostGetCustomerAccountIdRetType) { + *arg = &val +} + +type SummarizedServiceCostGetCustomerAccountIdArgType = string +type SummarizedServiceCostGetCustomerAccountIdRetType = string + +/* + types and functions for projectId +*/ + +// isNotNullableString +type SummarizedServiceCostGetProjectIdAttributeType = *string + +func getSummarizedServiceCostGetProjectIdAttributeTypeOk(arg SummarizedServiceCostGetProjectIdAttributeType) (ret SummarizedServiceCostGetProjectIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setSummarizedServiceCostGetProjectIdAttributeType(arg *SummarizedServiceCostGetProjectIdAttributeType, val SummarizedServiceCostGetProjectIdRetType) { + *arg = &val +} + +type SummarizedServiceCostGetProjectIdArgType = string +type SummarizedServiceCostGetProjectIdRetType = string + +/* + types and functions for projectName +*/ + +// isNotNullableString +type SummarizedServiceCostGetProjectNameAttributeType = *string + +func getSummarizedServiceCostGetProjectNameAttributeTypeOk(arg SummarizedServiceCostGetProjectNameAttributeType) (ret SummarizedServiceCostGetProjectNameRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setSummarizedServiceCostGetProjectNameAttributeType(arg *SummarizedServiceCostGetProjectNameAttributeType, val SummarizedServiceCostGetProjectNameRetType) { + *arg = &val +} + +type SummarizedServiceCostGetProjectNameArgType = string +type SummarizedServiceCostGetProjectNameRetType = string + +/* + types and functions for totalCharge +*/ + +// isDouble +type SummarizedServiceCostGetTotalChargeAttributeType = *float64 +type SummarizedServiceCostGetTotalChargeArgType = float64 +type SummarizedServiceCostGetTotalChargeRetType = float64 + +func getSummarizedServiceCostGetTotalChargeAttributeTypeOk(arg SummarizedServiceCostGetTotalChargeAttributeType) (ret SummarizedServiceCostGetTotalChargeRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setSummarizedServiceCostGetTotalChargeAttributeType(arg *SummarizedServiceCostGetTotalChargeAttributeType, val SummarizedServiceCostGetTotalChargeRetType) { + *arg = &val +} + +/* + types and functions for totalDiscount +*/ + +// isDouble +type SummarizedServiceCostGetTotalDiscountAttributeType = *float64 +type SummarizedServiceCostGetTotalDiscountArgType = float64 +type SummarizedServiceCostGetTotalDiscountRetType = float64 + +func getSummarizedServiceCostGetTotalDiscountAttributeTypeOk(arg SummarizedServiceCostGetTotalDiscountAttributeType) (ret SummarizedServiceCostGetTotalDiscountRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setSummarizedServiceCostGetTotalDiscountAttributeType(arg *SummarizedServiceCostGetTotalDiscountAttributeType, val SummarizedServiceCostGetTotalDiscountRetType) { + *arg = &val +} + +// SummarizedServiceCost Summarized costs for a project +type SummarizedServiceCost struct { + // REQUIRED + CustomerAccountId SummarizedServiceCostGetCustomerAccountIdAttributeType `json:"customerAccountId" required:"true"` + // REQUIRED + ProjectId SummarizedServiceCostGetProjectIdAttributeType `json:"projectId" required:"true"` + // REQUIRED + ProjectName SummarizedServiceCostGetProjectNameAttributeType `json:"projectName" required:"true"` + // Total charge for all services and the whole requested date range (value in cents) + // REQUIRED + TotalCharge SummarizedServiceCostGetTotalChargeAttributeType `json:"totalCharge" required:"true"` + // Total discount for all services and the whole requested date range (value in cents) + // REQUIRED + TotalDiscount SummarizedServiceCostGetTotalDiscountAttributeType `json:"totalDiscount" required:"true"` +} + +type _SummarizedServiceCost SummarizedServiceCost + +// NewSummarizedServiceCost instantiates a new SummarizedServiceCost 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 NewSummarizedServiceCost(customerAccountId SummarizedServiceCostGetCustomerAccountIdArgType, projectId SummarizedServiceCostGetProjectIdArgType, projectName SummarizedServiceCostGetProjectNameArgType, totalCharge SummarizedServiceCostGetTotalChargeArgType, totalDiscount SummarizedServiceCostGetTotalDiscountArgType) *SummarizedServiceCost { + this := SummarizedServiceCost{} + setSummarizedServiceCostGetCustomerAccountIdAttributeType(&this.CustomerAccountId, customerAccountId) + setSummarizedServiceCostGetProjectIdAttributeType(&this.ProjectId, projectId) + setSummarizedServiceCostGetProjectNameAttributeType(&this.ProjectName, projectName) + setSummarizedServiceCostGetTotalChargeAttributeType(&this.TotalCharge, totalCharge) + setSummarizedServiceCostGetTotalDiscountAttributeType(&this.TotalDiscount, totalDiscount) + return &this +} + +// NewSummarizedServiceCostWithDefaults instantiates a new SummarizedServiceCost 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 NewSummarizedServiceCostWithDefaults() *SummarizedServiceCost { + this := SummarizedServiceCost{} + return &this +} + +// GetCustomerAccountId returns the CustomerAccountId field value +func (o *SummarizedServiceCost) GetCustomerAccountId() (ret SummarizedServiceCostGetCustomerAccountIdRetType) { + ret, _ = o.GetCustomerAccountIdOk() + return ret +} + +// GetCustomerAccountIdOk returns a tuple with the CustomerAccountId field value +// and a boolean to check if the value has been set. +func (o *SummarizedServiceCost) GetCustomerAccountIdOk() (ret SummarizedServiceCostGetCustomerAccountIdRetType, ok bool) { + return getSummarizedServiceCostGetCustomerAccountIdAttributeTypeOk(o.CustomerAccountId) +} + +// SetCustomerAccountId sets field value +func (o *SummarizedServiceCost) SetCustomerAccountId(v SummarizedServiceCostGetCustomerAccountIdRetType) { + setSummarizedServiceCostGetCustomerAccountIdAttributeType(&o.CustomerAccountId, v) +} + +// GetProjectId returns the ProjectId field value +func (o *SummarizedServiceCost) GetProjectId() (ret SummarizedServiceCostGetProjectIdRetType) { + 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 *SummarizedServiceCost) GetProjectIdOk() (ret SummarizedServiceCostGetProjectIdRetType, ok bool) { + return getSummarizedServiceCostGetProjectIdAttributeTypeOk(o.ProjectId) +} + +// SetProjectId sets field value +func (o *SummarizedServiceCost) SetProjectId(v SummarizedServiceCostGetProjectIdRetType) { + setSummarizedServiceCostGetProjectIdAttributeType(&o.ProjectId, v) +} + +// GetProjectName returns the ProjectName field value +func (o *SummarizedServiceCost) GetProjectName() (ret SummarizedServiceCostGetProjectNameRetType) { + ret, _ = o.GetProjectNameOk() + return ret +} + +// GetProjectNameOk returns a tuple with the ProjectName field value +// and a boolean to check if the value has been set. +func (o *SummarizedServiceCost) GetProjectNameOk() (ret SummarizedServiceCostGetProjectNameRetType, ok bool) { + return getSummarizedServiceCostGetProjectNameAttributeTypeOk(o.ProjectName) +} + +// SetProjectName sets field value +func (o *SummarizedServiceCost) SetProjectName(v SummarizedServiceCostGetProjectNameRetType) { + setSummarizedServiceCostGetProjectNameAttributeType(&o.ProjectName, v) +} + +// GetTotalCharge returns the TotalCharge field value +func (o *SummarizedServiceCost) GetTotalCharge() (ret SummarizedServiceCostGetTotalChargeRetType) { + ret, _ = o.GetTotalChargeOk() + return ret +} + +// GetTotalChargeOk returns a tuple with the TotalCharge field value +// and a boolean to check if the value has been set. +func (o *SummarizedServiceCost) GetTotalChargeOk() (ret SummarizedServiceCostGetTotalChargeRetType, ok bool) { + return getSummarizedServiceCostGetTotalChargeAttributeTypeOk(o.TotalCharge) +} + +// SetTotalCharge sets field value +func (o *SummarizedServiceCost) SetTotalCharge(v SummarizedServiceCostGetTotalChargeRetType) { + setSummarizedServiceCostGetTotalChargeAttributeType(&o.TotalCharge, v) +} + +// GetTotalDiscount returns the TotalDiscount field value +func (o *SummarizedServiceCost) GetTotalDiscount() (ret SummarizedServiceCostGetTotalDiscountRetType) { + ret, _ = o.GetTotalDiscountOk() + return ret +} + +// GetTotalDiscountOk returns a tuple with the TotalDiscount field value +// and a boolean to check if the value has been set. +func (o *SummarizedServiceCost) GetTotalDiscountOk() (ret SummarizedServiceCostGetTotalDiscountRetType, ok bool) { + return getSummarizedServiceCostGetTotalDiscountAttributeTypeOk(o.TotalDiscount) +} + +// SetTotalDiscount sets field value +func (o *SummarizedServiceCost) SetTotalDiscount(v SummarizedServiceCostGetTotalDiscountRetType) { + setSummarizedServiceCostGetTotalDiscountAttributeType(&o.TotalDiscount, v) +} + +func (o SummarizedServiceCost) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getSummarizedServiceCostGetCustomerAccountIdAttributeTypeOk(o.CustomerAccountId); ok { + toSerialize["CustomerAccountId"] = val + } + if val, ok := getSummarizedServiceCostGetProjectIdAttributeTypeOk(o.ProjectId); ok { + toSerialize["ProjectId"] = val + } + if val, ok := getSummarizedServiceCostGetProjectNameAttributeTypeOk(o.ProjectName); ok { + toSerialize["ProjectName"] = val + } + if val, ok := getSummarizedServiceCostGetTotalChargeAttributeTypeOk(o.TotalCharge); ok { + toSerialize["TotalCharge"] = val + } + if val, ok := getSummarizedServiceCostGetTotalDiscountAttributeTypeOk(o.TotalDiscount); ok { + toSerialize["TotalDiscount"] = val + } + return toSerialize, nil +} + +type NullableSummarizedServiceCost struct { + value *SummarizedServiceCost + isSet bool +} + +func (v NullableSummarizedServiceCost) Get() *SummarizedServiceCost { + return v.value +} + +func (v *NullableSummarizedServiceCost) Set(val *SummarizedServiceCost) { + v.value = val + v.isSet = true +} + +func (v NullableSummarizedServiceCost) IsSet() bool { + return v.isSet +} + +func (v *NullableSummarizedServiceCost) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableSummarizedServiceCost(val *SummarizedServiceCost) *NullableSummarizedServiceCost { + return &NullableSummarizedServiceCost{value: val, isSet: true} +} + +func (v NullableSummarizedServiceCost) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableSummarizedServiceCost) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cost/model_summarized_service_cost_test.go b/services/cost/model_summarized_service_cost_test.go new file mode 100644 index 000000000..16ddfd392 --- /dev/null +++ b/services/cost/model_summarized_service_cost_test.go @@ -0,0 +1,11 @@ +/* +STACKIT Cost API + +The cost API provides detailed reports on the costs for a customer or project over a certain amount of time + +API version: 3.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cost diff --git a/services/cost/utils.go b/services/cost/utils.go new file mode 100644 index 000000000..24ae526b0 --- /dev/null +++ b/services/cost/utils.go @@ -0,0 +1,385 @@ +/* +STACKIT Cost API + +The cost API provides detailed reports on the costs for a customer or project over a certain amount of time + +API version: 3.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cost + +import ( + "encoding/json" + "math/rand" + "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) +} + +const letterRunes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" + +// randString returns a random string with a specified length. It panics if n <= 0. +func randString(n int) string { + b := make([]byte, n) + for i := range b { + b[i] = letterRunes[rand.Intn(len(letterRunes))] + } + return string(b) +}