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..5a4c35e98 --- /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 []ListCostsForCustomer200ResponseInner + + */ + ListCostsForCustomerExecute(ctx context.Context, customerAccountId string) ([]ListCostsForCustomer200ResponseInner, 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 ListCostsForCustomer200ResponseInner + + */ + ListCostsForProjectExecute(ctx context.Context, customerAccountId string, projectId string) (*ListCostsForCustomer200ResponseInner, 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 []ListCostsForCustomer200ResponseInner + + */ + ListCostsForResellerExecute(ctx context.Context, customerAccountId string) ([]ListCostsForCustomer200ResponseInner, 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() ([]ListCostsForCustomer200ResponseInner, 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() (*ListCostsForCustomer200ResponseInner, 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() ([]ListCostsForCustomer200ResponseInner, 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() ([]ListCostsForCustomer200ResponseInner, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue []ListCostsForCustomer200ResponseInner + ) + 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) ([]ListCostsForCustomer200ResponseInner, 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() (*ListCostsForCustomer200ResponseInner, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *ListCostsForCustomer200ResponseInner + ) + 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) (*ListCostsForCustomer200ResponseInner, 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() ([]ListCostsForCustomer200ResponseInner, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue []ListCostsForCustomer200ResponseInner + ) + 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) ([]ListCostsForCustomer200ResponseInner, 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..e98ae15e3 --- /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 := []ListCostsForCustomer200ResponseInner{} + 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 := ListCostsForCustomer200ResponseInner{} + 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 := []ListCostsForCustomer200ResponseInner{} + 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_costs.go b/services/cost/model_detailed_service_costs.go new file mode 100644 index 000000000..b2fe7e736 --- /dev/null +++ b/services/cost/model_detailed_service_costs.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 DetailedServiceCosts type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &DetailedServiceCosts{} + +/* + types and functions for reportData +*/ + +// isArray +type DetailedServiceCostsGetReportDataAttributeType = *[]ReportData +type DetailedServiceCostsGetReportDataArgType = []ReportData +type DetailedServiceCostsGetReportDataRetType = []ReportData + +func getDetailedServiceCostsGetReportDataAttributeTypeOk(arg DetailedServiceCostsGetReportDataAttributeType) (ret DetailedServiceCostsGetReportDataRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDetailedServiceCostsGetReportDataAttributeType(arg *DetailedServiceCostsGetReportDataAttributeType, val DetailedServiceCostsGetReportDataRetType) { + *arg = &val +} + +/* + types and functions for serviceCategoryName +*/ + +// isNotNullableString +type DetailedServiceCostsGetServiceCategoryNameAttributeType = *string + +func getDetailedServiceCostsGetServiceCategoryNameAttributeTypeOk(arg DetailedServiceCostsGetServiceCategoryNameAttributeType) (ret DetailedServiceCostsGetServiceCategoryNameRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDetailedServiceCostsGetServiceCategoryNameAttributeType(arg *DetailedServiceCostsGetServiceCategoryNameAttributeType, val DetailedServiceCostsGetServiceCategoryNameRetType) { + *arg = &val +} + +type DetailedServiceCostsGetServiceCategoryNameArgType = string +type DetailedServiceCostsGetServiceCategoryNameRetType = string + +/* + types and functions for serviceName +*/ + +// isNotNullableString +type DetailedServiceCostsGetServiceNameAttributeType = *string + +func getDetailedServiceCostsGetServiceNameAttributeTypeOk(arg DetailedServiceCostsGetServiceNameAttributeType) (ret DetailedServiceCostsGetServiceNameRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDetailedServiceCostsGetServiceNameAttributeType(arg *DetailedServiceCostsGetServiceNameAttributeType, val DetailedServiceCostsGetServiceNameRetType) { + *arg = &val +} + +type DetailedServiceCostsGetServiceNameArgType = string +type DetailedServiceCostsGetServiceNameRetType = string + +/* + types and functions for sku +*/ + +// isNotNullableString +type DetailedServiceCostsGetSkuAttributeType = *string + +func getDetailedServiceCostsGetSkuAttributeTypeOk(arg DetailedServiceCostsGetSkuAttributeType) (ret DetailedServiceCostsGetSkuRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDetailedServiceCostsGetSkuAttributeType(arg *DetailedServiceCostsGetSkuAttributeType, val DetailedServiceCostsGetSkuRetType) { + *arg = &val +} + +type DetailedServiceCostsGetSkuArgType = string +type DetailedServiceCostsGetSkuRetType = string + +/* + types and functions for totalCharge +*/ + +// isDouble +type DetailedServiceCostsGetTotalChargeAttributeType = *float64 +type DetailedServiceCostsGetTotalChargeArgType = float64 +type DetailedServiceCostsGetTotalChargeRetType = float64 + +func getDetailedServiceCostsGetTotalChargeAttributeTypeOk(arg DetailedServiceCostsGetTotalChargeAttributeType) (ret DetailedServiceCostsGetTotalChargeRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDetailedServiceCostsGetTotalChargeAttributeType(arg *DetailedServiceCostsGetTotalChargeAttributeType, val DetailedServiceCostsGetTotalChargeRetType) { + *arg = &val +} + +/* + types and functions for totalDiscount +*/ + +// isDouble +type DetailedServiceCostsGetTotalDiscountAttributeType = *float64 +type DetailedServiceCostsGetTotalDiscountArgType = float64 +type DetailedServiceCostsGetTotalDiscountRetType = float64 + +func getDetailedServiceCostsGetTotalDiscountAttributeTypeOk(arg DetailedServiceCostsGetTotalDiscountAttributeType) (ret DetailedServiceCostsGetTotalDiscountRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDetailedServiceCostsGetTotalDiscountAttributeType(arg *DetailedServiceCostsGetTotalDiscountAttributeType, val DetailedServiceCostsGetTotalDiscountRetType) { + *arg = &val +} + +/* + types and functions for totalQuantity +*/ + +// isInteger +type DetailedServiceCostsGetTotalQuantityAttributeType = *int64 +type DetailedServiceCostsGetTotalQuantityArgType = int64 +type DetailedServiceCostsGetTotalQuantityRetType = int64 + +func getDetailedServiceCostsGetTotalQuantityAttributeTypeOk(arg DetailedServiceCostsGetTotalQuantityAttributeType) (ret DetailedServiceCostsGetTotalQuantityRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDetailedServiceCostsGetTotalQuantityAttributeType(arg *DetailedServiceCostsGetTotalQuantityAttributeType, val DetailedServiceCostsGetTotalQuantityRetType) { + *arg = &val +} + +/* + types and functions for unitLabel +*/ + +// isNotNullableString +type DetailedServiceCostsGetUnitLabelAttributeType = *string + +func getDetailedServiceCostsGetUnitLabelAttributeTypeOk(arg DetailedServiceCostsGetUnitLabelAttributeType) (ret DetailedServiceCostsGetUnitLabelRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDetailedServiceCostsGetUnitLabelAttributeType(arg *DetailedServiceCostsGetUnitLabelAttributeType, val DetailedServiceCostsGetUnitLabelRetType) { + *arg = &val +} + +type DetailedServiceCostsGetUnitLabelArgType = string +type DetailedServiceCostsGetUnitLabelRetType = string + +// DetailedServiceCosts Costs for a single service +type DetailedServiceCosts struct { + // Detailed service costs which are ONLY included if granularity is provided + ReportData DetailedServiceCostsGetReportDataAttributeType `json:"reportData,omitempty"` + // Service category name + // REQUIRED + ServiceCategoryName DetailedServiceCostsGetServiceCategoryNameAttributeType `json:"serviceCategoryName" required:"true"` + // Name of the service + // REQUIRED + ServiceName DetailedServiceCostsGetServiceNameAttributeType `json:"serviceName" required:"true"` + // Service key + // REQUIRED + Sku DetailedServiceCostsGetSkuAttributeType `json:"sku" required:"true"` + // Total charge for the whole requested date range (value in cents) + // REQUIRED + TotalCharge DetailedServiceCostsGetTotalChargeAttributeType `json:"totalCharge" required:"true"` + // Total discount for the whole requested date range (value in cents) + // REQUIRED + TotalDiscount DetailedServiceCostsGetTotalDiscountAttributeType `json:"totalDiscount" required:"true"` + // Total quantity + // Can be cast to int32 without loss of precision. + // REQUIRED + TotalQuantity DetailedServiceCostsGetTotalQuantityAttributeType `json:"totalQuantity" required:"true"` + // Label for unit + // REQUIRED + UnitLabel DetailedServiceCostsGetUnitLabelAttributeType `json:"unitLabel" required:"true"` +} + +type _DetailedServiceCosts DetailedServiceCosts + +// NewDetailedServiceCosts instantiates a new DetailedServiceCosts 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 NewDetailedServiceCosts(serviceCategoryName DetailedServiceCostsGetServiceCategoryNameArgType, serviceName DetailedServiceCostsGetServiceNameArgType, sku DetailedServiceCostsGetSkuArgType, totalCharge DetailedServiceCostsGetTotalChargeArgType, totalDiscount DetailedServiceCostsGetTotalDiscountArgType, totalQuantity DetailedServiceCostsGetTotalQuantityArgType, unitLabel DetailedServiceCostsGetUnitLabelArgType) *DetailedServiceCosts { + this := DetailedServiceCosts{} + setDetailedServiceCostsGetServiceCategoryNameAttributeType(&this.ServiceCategoryName, serviceCategoryName) + setDetailedServiceCostsGetServiceNameAttributeType(&this.ServiceName, serviceName) + setDetailedServiceCostsGetSkuAttributeType(&this.Sku, sku) + setDetailedServiceCostsGetTotalChargeAttributeType(&this.TotalCharge, totalCharge) + setDetailedServiceCostsGetTotalDiscountAttributeType(&this.TotalDiscount, totalDiscount) + setDetailedServiceCostsGetTotalQuantityAttributeType(&this.TotalQuantity, totalQuantity) + setDetailedServiceCostsGetUnitLabelAttributeType(&this.UnitLabel, unitLabel) + return &this +} + +// NewDetailedServiceCostsWithDefaults instantiates a new DetailedServiceCosts 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 NewDetailedServiceCostsWithDefaults() *DetailedServiceCosts { + this := DetailedServiceCosts{} + return &this +} + +// GetReportData returns the ReportData field value if set, zero value otherwise. +func (o *DetailedServiceCosts) GetReportData() (res DetailedServiceCostsGetReportDataRetType) { + 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 *DetailedServiceCosts) GetReportDataOk() (ret DetailedServiceCostsGetReportDataRetType, ok bool) { + return getDetailedServiceCostsGetReportDataAttributeTypeOk(o.ReportData) +} + +// HasReportData returns a boolean if a field has been set. +func (o *DetailedServiceCosts) HasReportData() bool { + _, ok := o.GetReportDataOk() + return ok +} + +// SetReportData gets a reference to the given []ReportData and assigns it to the ReportData field. +func (o *DetailedServiceCosts) SetReportData(v DetailedServiceCostsGetReportDataRetType) { + setDetailedServiceCostsGetReportDataAttributeType(&o.ReportData, v) +} + +// GetServiceCategoryName returns the ServiceCategoryName field value +func (o *DetailedServiceCosts) GetServiceCategoryName() (ret DetailedServiceCostsGetServiceCategoryNameRetType) { + 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 *DetailedServiceCosts) GetServiceCategoryNameOk() (ret DetailedServiceCostsGetServiceCategoryNameRetType, ok bool) { + return getDetailedServiceCostsGetServiceCategoryNameAttributeTypeOk(o.ServiceCategoryName) +} + +// SetServiceCategoryName sets field value +func (o *DetailedServiceCosts) SetServiceCategoryName(v DetailedServiceCostsGetServiceCategoryNameRetType) { + setDetailedServiceCostsGetServiceCategoryNameAttributeType(&o.ServiceCategoryName, v) +} + +// GetServiceName returns the ServiceName field value +func (o *DetailedServiceCosts) GetServiceName() (ret DetailedServiceCostsGetServiceNameRetType) { + 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 *DetailedServiceCosts) GetServiceNameOk() (ret DetailedServiceCostsGetServiceNameRetType, ok bool) { + return getDetailedServiceCostsGetServiceNameAttributeTypeOk(o.ServiceName) +} + +// SetServiceName sets field value +func (o *DetailedServiceCosts) SetServiceName(v DetailedServiceCostsGetServiceNameRetType) { + setDetailedServiceCostsGetServiceNameAttributeType(&o.ServiceName, v) +} + +// GetSku returns the Sku field value +func (o *DetailedServiceCosts) GetSku() (ret DetailedServiceCostsGetSkuRetType) { + 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 *DetailedServiceCosts) GetSkuOk() (ret DetailedServiceCostsGetSkuRetType, ok bool) { + return getDetailedServiceCostsGetSkuAttributeTypeOk(o.Sku) +} + +// SetSku sets field value +func (o *DetailedServiceCosts) SetSku(v DetailedServiceCostsGetSkuRetType) { + setDetailedServiceCostsGetSkuAttributeType(&o.Sku, v) +} + +// GetTotalCharge returns the TotalCharge field value +func (o *DetailedServiceCosts) GetTotalCharge() (ret DetailedServiceCostsGetTotalChargeRetType) { + 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 *DetailedServiceCosts) GetTotalChargeOk() (ret DetailedServiceCostsGetTotalChargeRetType, ok bool) { + return getDetailedServiceCostsGetTotalChargeAttributeTypeOk(o.TotalCharge) +} + +// SetTotalCharge sets field value +func (o *DetailedServiceCosts) SetTotalCharge(v DetailedServiceCostsGetTotalChargeRetType) { + setDetailedServiceCostsGetTotalChargeAttributeType(&o.TotalCharge, v) +} + +// GetTotalDiscount returns the TotalDiscount field value +func (o *DetailedServiceCosts) GetTotalDiscount() (ret DetailedServiceCostsGetTotalDiscountRetType) { + 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 *DetailedServiceCosts) GetTotalDiscountOk() (ret DetailedServiceCostsGetTotalDiscountRetType, ok bool) { + return getDetailedServiceCostsGetTotalDiscountAttributeTypeOk(o.TotalDiscount) +} + +// SetTotalDiscount sets field value +func (o *DetailedServiceCosts) SetTotalDiscount(v DetailedServiceCostsGetTotalDiscountRetType) { + setDetailedServiceCostsGetTotalDiscountAttributeType(&o.TotalDiscount, v) +} + +// GetTotalQuantity returns the TotalQuantity field value +func (o *DetailedServiceCosts) GetTotalQuantity() (ret DetailedServiceCostsGetTotalQuantityRetType) { + 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 *DetailedServiceCosts) GetTotalQuantityOk() (ret DetailedServiceCostsGetTotalQuantityRetType, ok bool) { + return getDetailedServiceCostsGetTotalQuantityAttributeTypeOk(o.TotalQuantity) +} + +// SetTotalQuantity sets field value +func (o *DetailedServiceCosts) SetTotalQuantity(v DetailedServiceCostsGetTotalQuantityRetType) { + setDetailedServiceCostsGetTotalQuantityAttributeType(&o.TotalQuantity, v) +} + +// GetUnitLabel returns the UnitLabel field value +func (o *DetailedServiceCosts) GetUnitLabel() (ret DetailedServiceCostsGetUnitLabelRetType) { + 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 *DetailedServiceCosts) GetUnitLabelOk() (ret DetailedServiceCostsGetUnitLabelRetType, ok bool) { + return getDetailedServiceCostsGetUnitLabelAttributeTypeOk(o.UnitLabel) +} + +// SetUnitLabel sets field value +func (o *DetailedServiceCosts) SetUnitLabel(v DetailedServiceCostsGetUnitLabelRetType) { + setDetailedServiceCostsGetUnitLabelAttributeType(&o.UnitLabel, v) +} + +func (o DetailedServiceCosts) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getDetailedServiceCostsGetReportDataAttributeTypeOk(o.ReportData); ok { + toSerialize["ReportData"] = val + } + if val, ok := getDetailedServiceCostsGetServiceCategoryNameAttributeTypeOk(o.ServiceCategoryName); ok { + toSerialize["ServiceCategoryName"] = val + } + if val, ok := getDetailedServiceCostsGetServiceNameAttributeTypeOk(o.ServiceName); ok { + toSerialize["ServiceName"] = val + } + if val, ok := getDetailedServiceCostsGetSkuAttributeTypeOk(o.Sku); ok { + toSerialize["Sku"] = val + } + if val, ok := getDetailedServiceCostsGetTotalChargeAttributeTypeOk(o.TotalCharge); ok { + toSerialize["TotalCharge"] = val + } + if val, ok := getDetailedServiceCostsGetTotalDiscountAttributeTypeOk(o.TotalDiscount); ok { + toSerialize["TotalDiscount"] = val + } + if val, ok := getDetailedServiceCostsGetTotalQuantityAttributeTypeOk(o.TotalQuantity); ok { + toSerialize["TotalQuantity"] = val + } + if val, ok := getDetailedServiceCostsGetUnitLabelAttributeTypeOk(o.UnitLabel); ok { + toSerialize["UnitLabel"] = val + } + return toSerialize, nil +} + +type NullableDetailedServiceCosts struct { + value *DetailedServiceCosts + isSet bool +} + +func (v NullableDetailedServiceCosts) Get() *DetailedServiceCosts { + return v.value +} + +func (v *NullableDetailedServiceCosts) Set(val *DetailedServiceCosts) { + v.value = val + v.isSet = true +} + +func (v NullableDetailedServiceCosts) IsSet() bool { + return v.isSet +} + +func (v *NullableDetailedServiceCosts) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableDetailedServiceCosts(val *DetailedServiceCosts) *NullableDetailedServiceCosts { + return &NullableDetailedServiceCosts{value: val, isSet: true} +} + +func (v NullableDetailedServiceCosts) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableDetailedServiceCosts) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cost/model_detailed_service_costs_test.go b/services/cost/model_detailed_service_costs_test.go new file mode 100644 index 000000000..16ddfd392 --- /dev/null +++ b/services/cost/model_detailed_service_costs_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_list_costs_for_customer_200_response_inner.go b/services/cost/model_list_costs_for_customer_200_response_inner.go new file mode 100644 index 000000000..95f0c060f --- /dev/null +++ b/services/cost/model_list_costs_for_customer_200_response_inner.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" +) + +// ListCostsForCustomer200ResponseInner struct for ListCostsForCustomer200ResponseInner +type ListCostsForCustomer200ResponseInner struct { + ProjectCostsWithDetailedServices *ProjectCostsWithDetailedServices + ProjectCostsWithReports *ProjectCostsWithReports + ProjectCostsWithSummarizedServices *ProjectCostsWithSummarizedServices + SummarizedProjectCosts *SummarizedProjectCosts +} + +// Unmarshal JSON data into any of the pointers in the struct +func (dst *ListCostsForCustomer200ResponseInner) UnmarshalJSON(data []byte) error { + var err error + // try to unmarshal JSON data into ProjectCostsWithDetailedServices + err = json.Unmarshal(data, &dst.ProjectCostsWithDetailedServices) + if err == nil { + jsonProjectCostsWithDetailedServices, _ := json.Marshal(dst.ProjectCostsWithDetailedServices) + if string(jsonProjectCostsWithDetailedServices) == "{}" { // empty struct + dst.ProjectCostsWithDetailedServices = nil + } else { + return nil // data stored in dst.ProjectCostsWithDetailedServices, return on the first match + } + } else { + dst.ProjectCostsWithDetailedServices = nil + } + + // try to unmarshal JSON data into ProjectCostsWithReports + err = json.Unmarshal(data, &dst.ProjectCostsWithReports) + if err == nil { + jsonProjectCostsWithReports, _ := json.Marshal(dst.ProjectCostsWithReports) + if string(jsonProjectCostsWithReports) == "{}" { // empty struct + dst.ProjectCostsWithReports = nil + } else { + return nil // data stored in dst.ProjectCostsWithReports, return on the first match + } + } else { + dst.ProjectCostsWithReports = nil + } + + // try to unmarshal JSON data into ProjectCostsWithSummarizedServices + err = json.Unmarshal(data, &dst.ProjectCostsWithSummarizedServices) + if err == nil { + jsonProjectCostsWithSummarizedServices, _ := json.Marshal(dst.ProjectCostsWithSummarizedServices) + if string(jsonProjectCostsWithSummarizedServices) == "{}" { // empty struct + dst.ProjectCostsWithSummarizedServices = nil + } else { + return nil // data stored in dst.ProjectCostsWithSummarizedServices, return on the first match + } + } else { + dst.ProjectCostsWithSummarizedServices = nil + } + + // try to unmarshal JSON data into SummarizedProjectCosts + err = json.Unmarshal(data, &dst.SummarizedProjectCosts) + if err == nil { + jsonSummarizedProjectCosts, _ := json.Marshal(dst.SummarizedProjectCosts) + if string(jsonSummarizedProjectCosts) == "{}" { // empty struct + dst.SummarizedProjectCosts = nil + } else { + return nil // data stored in dst.SummarizedProjectCosts, return on the first match + } + } else { + dst.SummarizedProjectCosts = nil + } + + return fmt.Errorf("data failed to match schemas in anyOf(ListCostsForCustomer200ResponseInner)") +} + +// Marshal data from the first non-nil pointers in the struct to JSON +func (src *ListCostsForCustomer200ResponseInner) MarshalJSON() ([]byte, error) { + if src.ProjectCostsWithDetailedServices != nil { + return json.Marshal(&src.ProjectCostsWithDetailedServices) + } + + if src.ProjectCostsWithReports != nil { + return json.Marshal(&src.ProjectCostsWithReports) + } + + if src.ProjectCostsWithSummarizedServices != nil { + return json.Marshal(&src.ProjectCostsWithSummarizedServices) + } + + if src.SummarizedProjectCosts != nil { + return json.Marshal(&src.SummarizedProjectCosts) + } + + return nil, nil // no data in anyOf schemas +} + +type NullableListCostsForCustomer200ResponseInner struct { + value *ListCostsForCustomer200ResponseInner + isSet bool +} + +func (v NullableListCostsForCustomer200ResponseInner) Get() *ListCostsForCustomer200ResponseInner { + return v.value +} + +func (v *NullableListCostsForCustomer200ResponseInner) Set(val *ListCostsForCustomer200ResponseInner) { + v.value = val + v.isSet = true +} + +func (v NullableListCostsForCustomer200ResponseInner) IsSet() bool { + return v.isSet +} + +func (v *NullableListCostsForCustomer200ResponseInner) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableListCostsForCustomer200ResponseInner(val *ListCostsForCustomer200ResponseInner) *NullableListCostsForCustomer200ResponseInner { + return &NullableListCostsForCustomer200ResponseInner{value: val, isSet: true} +} + +func (v NullableListCostsForCustomer200ResponseInner) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableListCostsForCustomer200ResponseInner) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cost/model_list_costs_for_customer_200_response_inner_test.go b/services/cost/model_list_costs_for_customer_200_response_inner_test.go new file mode 100644 index 000000000..16ddfd392 --- /dev/null +++ b/services/cost/model_list_costs_for_customer_200_response_inner_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_costs_with_detailed_services.go b/services/cost/model_project_costs_with_detailed_services.go new file mode 100644 index 000000000..c0e6cec50 --- /dev/null +++ b/services/cost/model_project_costs_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 ProjectCostsWithDetailedServices type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ProjectCostsWithDetailedServices{} + +/* + types and functions for customerAccountId +*/ + +// isNotNullableString +type ProjectCostsWithDetailedServicesGetCustomerAccountIdAttributeType = *string + +func getProjectCostsWithDetailedServicesGetCustomerAccountIdAttributeTypeOk(arg ProjectCostsWithDetailedServicesGetCustomerAccountIdAttributeType) (ret ProjectCostsWithDetailedServicesGetCustomerAccountIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setProjectCostsWithDetailedServicesGetCustomerAccountIdAttributeType(arg *ProjectCostsWithDetailedServicesGetCustomerAccountIdAttributeType, val ProjectCostsWithDetailedServicesGetCustomerAccountIdRetType) { + *arg = &val +} + +type ProjectCostsWithDetailedServicesGetCustomerAccountIdArgType = string +type ProjectCostsWithDetailedServicesGetCustomerAccountIdRetType = string + +/* + types and functions for projectId +*/ + +// isNotNullableString +type ProjectCostsWithDetailedServicesGetProjectIdAttributeType = *string + +func getProjectCostsWithDetailedServicesGetProjectIdAttributeTypeOk(arg ProjectCostsWithDetailedServicesGetProjectIdAttributeType) (ret ProjectCostsWithDetailedServicesGetProjectIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setProjectCostsWithDetailedServicesGetProjectIdAttributeType(arg *ProjectCostsWithDetailedServicesGetProjectIdAttributeType, val ProjectCostsWithDetailedServicesGetProjectIdRetType) { + *arg = &val +} + +type ProjectCostsWithDetailedServicesGetProjectIdArgType = string +type ProjectCostsWithDetailedServicesGetProjectIdRetType = string + +/* + types and functions for projectName +*/ + +// isNotNullableString +type ProjectCostsWithDetailedServicesGetProjectNameAttributeType = *string + +func getProjectCostsWithDetailedServicesGetProjectNameAttributeTypeOk(arg ProjectCostsWithDetailedServicesGetProjectNameAttributeType) (ret ProjectCostsWithDetailedServicesGetProjectNameRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setProjectCostsWithDetailedServicesGetProjectNameAttributeType(arg *ProjectCostsWithDetailedServicesGetProjectNameAttributeType, val ProjectCostsWithDetailedServicesGetProjectNameRetType) { + *arg = &val +} + +type ProjectCostsWithDetailedServicesGetProjectNameArgType = string +type ProjectCostsWithDetailedServicesGetProjectNameRetType = string + +/* + types and functions for services +*/ + +// isArray +type ProjectCostsWithDetailedServicesGetServicesAttributeType = *[]DetailedServiceCosts +type ProjectCostsWithDetailedServicesGetServicesArgType = []DetailedServiceCosts +type ProjectCostsWithDetailedServicesGetServicesRetType = []DetailedServiceCosts + +func getProjectCostsWithDetailedServicesGetServicesAttributeTypeOk(arg ProjectCostsWithDetailedServicesGetServicesAttributeType) (ret ProjectCostsWithDetailedServicesGetServicesRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setProjectCostsWithDetailedServicesGetServicesAttributeType(arg *ProjectCostsWithDetailedServicesGetServicesAttributeType, val ProjectCostsWithDetailedServicesGetServicesRetType) { + *arg = &val +} + +/* + types and functions for totalCharge +*/ + +// isDouble +type ProjectCostsWithDetailedServicesGetTotalChargeAttributeType = *float64 +type ProjectCostsWithDetailedServicesGetTotalChargeArgType = float64 +type ProjectCostsWithDetailedServicesGetTotalChargeRetType = float64 + +func getProjectCostsWithDetailedServicesGetTotalChargeAttributeTypeOk(arg ProjectCostsWithDetailedServicesGetTotalChargeAttributeType) (ret ProjectCostsWithDetailedServicesGetTotalChargeRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setProjectCostsWithDetailedServicesGetTotalChargeAttributeType(arg *ProjectCostsWithDetailedServicesGetTotalChargeAttributeType, val ProjectCostsWithDetailedServicesGetTotalChargeRetType) { + *arg = &val +} + +/* + types and functions for totalDiscount +*/ + +// isDouble +type ProjectCostsWithDetailedServicesGetTotalDiscountAttributeType = *float64 +type ProjectCostsWithDetailedServicesGetTotalDiscountArgType = float64 +type ProjectCostsWithDetailedServicesGetTotalDiscountRetType = float64 + +func getProjectCostsWithDetailedServicesGetTotalDiscountAttributeTypeOk(arg ProjectCostsWithDetailedServicesGetTotalDiscountAttributeType) (ret ProjectCostsWithDetailedServicesGetTotalDiscountRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setProjectCostsWithDetailedServicesGetTotalDiscountAttributeType(arg *ProjectCostsWithDetailedServicesGetTotalDiscountAttributeType, val ProjectCostsWithDetailedServicesGetTotalDiscountRetType) { + *arg = &val +} + +// ProjectCostsWithDetailedServices Detailed costs for a project including service costs +type ProjectCostsWithDetailedServices struct { + // REQUIRED + CustomerAccountId ProjectCostsWithDetailedServicesGetCustomerAccountIdAttributeType `json:"customerAccountId" required:"true"` + // REQUIRED + ProjectId ProjectCostsWithDetailedServicesGetProjectIdAttributeType `json:"projectId" required:"true"` + // REQUIRED + ProjectName ProjectCostsWithDetailedServicesGetProjectNameAttributeType `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 ProjectCostsWithDetailedServicesGetServicesAttributeType `json:"services,omitempty"` + // Total charge for all services and the whole requested date range (value in cents) + // REQUIRED + TotalCharge ProjectCostsWithDetailedServicesGetTotalChargeAttributeType `json:"totalCharge" required:"true"` + // Total discount rounded for all services and the whole requested date range (value in cents) + // REQUIRED + TotalDiscount ProjectCostsWithDetailedServicesGetTotalDiscountAttributeType `json:"totalDiscount" required:"true"` +} + +type _ProjectCostsWithDetailedServices ProjectCostsWithDetailedServices + +// NewProjectCostsWithDetailedServices instantiates a new ProjectCostsWithDetailedServices 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 NewProjectCostsWithDetailedServices(customerAccountId ProjectCostsWithDetailedServicesGetCustomerAccountIdArgType, projectId ProjectCostsWithDetailedServicesGetProjectIdArgType, projectName ProjectCostsWithDetailedServicesGetProjectNameArgType, totalCharge ProjectCostsWithDetailedServicesGetTotalChargeArgType, totalDiscount ProjectCostsWithDetailedServicesGetTotalDiscountArgType) *ProjectCostsWithDetailedServices { + this := ProjectCostsWithDetailedServices{} + setProjectCostsWithDetailedServicesGetCustomerAccountIdAttributeType(&this.CustomerAccountId, customerAccountId) + setProjectCostsWithDetailedServicesGetProjectIdAttributeType(&this.ProjectId, projectId) + setProjectCostsWithDetailedServicesGetProjectNameAttributeType(&this.ProjectName, projectName) + setProjectCostsWithDetailedServicesGetTotalChargeAttributeType(&this.TotalCharge, totalCharge) + setProjectCostsWithDetailedServicesGetTotalDiscountAttributeType(&this.TotalDiscount, totalDiscount) + return &this +} + +// NewProjectCostsWithDetailedServicesWithDefaults instantiates a new ProjectCostsWithDetailedServices 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 NewProjectCostsWithDetailedServicesWithDefaults() *ProjectCostsWithDetailedServices { + this := ProjectCostsWithDetailedServices{} + return &this +} + +// GetCustomerAccountId returns the CustomerAccountId field value +func (o *ProjectCostsWithDetailedServices) GetCustomerAccountId() (ret ProjectCostsWithDetailedServicesGetCustomerAccountIdRetType) { + 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 *ProjectCostsWithDetailedServices) GetCustomerAccountIdOk() (ret ProjectCostsWithDetailedServicesGetCustomerAccountIdRetType, ok bool) { + return getProjectCostsWithDetailedServicesGetCustomerAccountIdAttributeTypeOk(o.CustomerAccountId) +} + +// SetCustomerAccountId sets field value +func (o *ProjectCostsWithDetailedServices) SetCustomerAccountId(v ProjectCostsWithDetailedServicesGetCustomerAccountIdRetType) { + setProjectCostsWithDetailedServicesGetCustomerAccountIdAttributeType(&o.CustomerAccountId, v) +} + +// GetProjectId returns the ProjectId field value +func (o *ProjectCostsWithDetailedServices) GetProjectId() (ret ProjectCostsWithDetailedServicesGetProjectIdRetType) { + 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 *ProjectCostsWithDetailedServices) GetProjectIdOk() (ret ProjectCostsWithDetailedServicesGetProjectIdRetType, ok bool) { + return getProjectCostsWithDetailedServicesGetProjectIdAttributeTypeOk(o.ProjectId) +} + +// SetProjectId sets field value +func (o *ProjectCostsWithDetailedServices) SetProjectId(v ProjectCostsWithDetailedServicesGetProjectIdRetType) { + setProjectCostsWithDetailedServicesGetProjectIdAttributeType(&o.ProjectId, v) +} + +// GetProjectName returns the ProjectName field value +func (o *ProjectCostsWithDetailedServices) GetProjectName() (ret ProjectCostsWithDetailedServicesGetProjectNameRetType) { + 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 *ProjectCostsWithDetailedServices) GetProjectNameOk() (ret ProjectCostsWithDetailedServicesGetProjectNameRetType, ok bool) { + return getProjectCostsWithDetailedServicesGetProjectNameAttributeTypeOk(o.ProjectName) +} + +// SetProjectName sets field value +func (o *ProjectCostsWithDetailedServices) SetProjectName(v ProjectCostsWithDetailedServicesGetProjectNameRetType) { + setProjectCostsWithDetailedServicesGetProjectNameAttributeType(&o.ProjectName, v) +} + +// GetServices returns the Services field value if set, zero value otherwise. +func (o *ProjectCostsWithDetailedServices) GetServices() (res ProjectCostsWithDetailedServicesGetServicesRetType) { + 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 *ProjectCostsWithDetailedServices) GetServicesOk() (ret ProjectCostsWithDetailedServicesGetServicesRetType, ok bool) { + return getProjectCostsWithDetailedServicesGetServicesAttributeTypeOk(o.Services) +} + +// HasServices returns a boolean if a field has been set. +func (o *ProjectCostsWithDetailedServices) HasServices() bool { + _, ok := o.GetServicesOk() + return ok +} + +// SetServices gets a reference to the given []DetailedServiceCosts and assigns it to the Services field. +func (o *ProjectCostsWithDetailedServices) SetServices(v ProjectCostsWithDetailedServicesGetServicesRetType) { + setProjectCostsWithDetailedServicesGetServicesAttributeType(&o.Services, v) +} + +// GetTotalCharge returns the TotalCharge field value +func (o *ProjectCostsWithDetailedServices) GetTotalCharge() (ret ProjectCostsWithDetailedServicesGetTotalChargeRetType) { + 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 *ProjectCostsWithDetailedServices) GetTotalChargeOk() (ret ProjectCostsWithDetailedServicesGetTotalChargeRetType, ok bool) { + return getProjectCostsWithDetailedServicesGetTotalChargeAttributeTypeOk(o.TotalCharge) +} + +// SetTotalCharge sets field value +func (o *ProjectCostsWithDetailedServices) SetTotalCharge(v ProjectCostsWithDetailedServicesGetTotalChargeRetType) { + setProjectCostsWithDetailedServicesGetTotalChargeAttributeType(&o.TotalCharge, v) +} + +// GetTotalDiscount returns the TotalDiscount field value +func (o *ProjectCostsWithDetailedServices) GetTotalDiscount() (ret ProjectCostsWithDetailedServicesGetTotalDiscountRetType) { + 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 *ProjectCostsWithDetailedServices) GetTotalDiscountOk() (ret ProjectCostsWithDetailedServicesGetTotalDiscountRetType, ok bool) { + return getProjectCostsWithDetailedServicesGetTotalDiscountAttributeTypeOk(o.TotalDiscount) +} + +// SetTotalDiscount sets field value +func (o *ProjectCostsWithDetailedServices) SetTotalDiscount(v ProjectCostsWithDetailedServicesGetTotalDiscountRetType) { + setProjectCostsWithDetailedServicesGetTotalDiscountAttributeType(&o.TotalDiscount, v) +} + +func (o ProjectCostsWithDetailedServices) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getProjectCostsWithDetailedServicesGetCustomerAccountIdAttributeTypeOk(o.CustomerAccountId); ok { + toSerialize["CustomerAccountId"] = val + } + if val, ok := getProjectCostsWithDetailedServicesGetProjectIdAttributeTypeOk(o.ProjectId); ok { + toSerialize["ProjectId"] = val + } + if val, ok := getProjectCostsWithDetailedServicesGetProjectNameAttributeTypeOk(o.ProjectName); ok { + toSerialize["ProjectName"] = val + } + if val, ok := getProjectCostsWithDetailedServicesGetServicesAttributeTypeOk(o.Services); ok { + toSerialize["Services"] = val + } + if val, ok := getProjectCostsWithDetailedServicesGetTotalChargeAttributeTypeOk(o.TotalCharge); ok { + toSerialize["TotalCharge"] = val + } + if val, ok := getProjectCostsWithDetailedServicesGetTotalDiscountAttributeTypeOk(o.TotalDiscount); ok { + toSerialize["TotalDiscount"] = val + } + return toSerialize, nil +} + +type NullableProjectCostsWithDetailedServices struct { + value *ProjectCostsWithDetailedServices + isSet bool +} + +func (v NullableProjectCostsWithDetailedServices) Get() *ProjectCostsWithDetailedServices { + return v.value +} + +func (v *NullableProjectCostsWithDetailedServices) Set(val *ProjectCostsWithDetailedServices) { + v.value = val + v.isSet = true +} + +func (v NullableProjectCostsWithDetailedServices) IsSet() bool { + return v.isSet +} + +func (v *NullableProjectCostsWithDetailedServices) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableProjectCostsWithDetailedServices(val *ProjectCostsWithDetailedServices) *NullableProjectCostsWithDetailedServices { + return &NullableProjectCostsWithDetailedServices{value: val, isSet: true} +} + +func (v NullableProjectCostsWithDetailedServices) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableProjectCostsWithDetailedServices) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cost/model_project_costs_with_detailed_services_test.go b/services/cost/model_project_costs_with_detailed_services_test.go new file mode 100644 index 000000000..16ddfd392 --- /dev/null +++ b/services/cost/model_project_costs_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_costs_with_reports.go b/services/cost/model_project_costs_with_reports.go new file mode 100644 index 000000000..ea2902731 --- /dev/null +++ b/services/cost/model_project_costs_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 ProjectCostsWithReports type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ProjectCostsWithReports{} + +/* + types and functions for customerAccountId +*/ + +// isNotNullableString +type ProjectCostsWithReportsGetCustomerAccountIdAttributeType = *string + +func getProjectCostsWithReportsGetCustomerAccountIdAttributeTypeOk(arg ProjectCostsWithReportsGetCustomerAccountIdAttributeType) (ret ProjectCostsWithReportsGetCustomerAccountIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setProjectCostsWithReportsGetCustomerAccountIdAttributeType(arg *ProjectCostsWithReportsGetCustomerAccountIdAttributeType, val ProjectCostsWithReportsGetCustomerAccountIdRetType) { + *arg = &val +} + +type ProjectCostsWithReportsGetCustomerAccountIdArgType = string +type ProjectCostsWithReportsGetCustomerAccountIdRetType = string + +/* + types and functions for projectId +*/ + +// isNotNullableString +type ProjectCostsWithReportsGetProjectIdAttributeType = *string + +func getProjectCostsWithReportsGetProjectIdAttributeTypeOk(arg ProjectCostsWithReportsGetProjectIdAttributeType) (ret ProjectCostsWithReportsGetProjectIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setProjectCostsWithReportsGetProjectIdAttributeType(arg *ProjectCostsWithReportsGetProjectIdAttributeType, val ProjectCostsWithReportsGetProjectIdRetType) { + *arg = &val +} + +type ProjectCostsWithReportsGetProjectIdArgType = string +type ProjectCostsWithReportsGetProjectIdRetType = string + +/* + types and functions for projectName +*/ + +// isNotNullableString +type ProjectCostsWithReportsGetProjectNameAttributeType = *string + +func getProjectCostsWithReportsGetProjectNameAttributeTypeOk(arg ProjectCostsWithReportsGetProjectNameAttributeType) (ret ProjectCostsWithReportsGetProjectNameRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setProjectCostsWithReportsGetProjectNameAttributeType(arg *ProjectCostsWithReportsGetProjectNameAttributeType, val ProjectCostsWithReportsGetProjectNameRetType) { + *arg = &val +} + +type ProjectCostsWithReportsGetProjectNameArgType = string +type ProjectCostsWithReportsGetProjectNameRetType = string + +/* + types and functions for reportData +*/ + +// isArray +type ProjectCostsWithReportsGetReportDataAttributeType = *[]ReportData +type ProjectCostsWithReportsGetReportDataArgType = []ReportData +type ProjectCostsWithReportsGetReportDataRetType = []ReportData + +func getProjectCostsWithReportsGetReportDataAttributeTypeOk(arg ProjectCostsWithReportsGetReportDataAttributeType) (ret ProjectCostsWithReportsGetReportDataRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setProjectCostsWithReportsGetReportDataAttributeType(arg *ProjectCostsWithReportsGetReportDataAttributeType, val ProjectCostsWithReportsGetReportDataRetType) { + *arg = &val +} + +/* + types and functions for totalCharge +*/ + +// isDouble +type ProjectCostsWithReportsGetTotalChargeAttributeType = *float64 +type ProjectCostsWithReportsGetTotalChargeArgType = float64 +type ProjectCostsWithReportsGetTotalChargeRetType = float64 + +func getProjectCostsWithReportsGetTotalChargeAttributeTypeOk(arg ProjectCostsWithReportsGetTotalChargeAttributeType) (ret ProjectCostsWithReportsGetTotalChargeRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setProjectCostsWithReportsGetTotalChargeAttributeType(arg *ProjectCostsWithReportsGetTotalChargeAttributeType, val ProjectCostsWithReportsGetTotalChargeRetType) { + *arg = &val +} + +/* + types and functions for totalDiscount +*/ + +// isDouble +type ProjectCostsWithReportsGetTotalDiscountAttributeType = *float64 +type ProjectCostsWithReportsGetTotalDiscountArgType = float64 +type ProjectCostsWithReportsGetTotalDiscountRetType = float64 + +func getProjectCostsWithReportsGetTotalDiscountAttributeTypeOk(arg ProjectCostsWithReportsGetTotalDiscountAttributeType) (ret ProjectCostsWithReportsGetTotalDiscountRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setProjectCostsWithReportsGetTotalDiscountAttributeType(arg *ProjectCostsWithReportsGetTotalDiscountAttributeType, val ProjectCostsWithReportsGetTotalDiscountRetType) { + *arg = &val +} + +// ProjectCostsWithReports Detailed costs for a project +type ProjectCostsWithReports struct { + // REQUIRED + CustomerAccountId ProjectCostsWithReportsGetCustomerAccountIdAttributeType `json:"customerAccountId" required:"true"` + // REQUIRED + ProjectId ProjectCostsWithReportsGetProjectIdAttributeType `json:"projectId" required:"true"` + // REQUIRED + ProjectName ProjectCostsWithReportsGetProjectNameAttributeType `json:"projectName" required:"true"` + // Detailed project costs which are ONLY included if granularity is provided AND depth is \"project\" + ReportData ProjectCostsWithReportsGetReportDataAttributeType `json:"reportData,omitempty"` + // Total charge for all services and the whole requested date range (value in cents) + // REQUIRED + TotalCharge ProjectCostsWithReportsGetTotalChargeAttributeType `json:"totalCharge" required:"true"` + // Total discount for all services and the whole requested date range (value in cents) + // REQUIRED + TotalDiscount ProjectCostsWithReportsGetTotalDiscountAttributeType `json:"totalDiscount" required:"true"` +} + +type _ProjectCostsWithReports ProjectCostsWithReports + +// NewProjectCostsWithReports instantiates a new ProjectCostsWithReports 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 NewProjectCostsWithReports(customerAccountId ProjectCostsWithReportsGetCustomerAccountIdArgType, projectId ProjectCostsWithReportsGetProjectIdArgType, projectName ProjectCostsWithReportsGetProjectNameArgType, totalCharge ProjectCostsWithReportsGetTotalChargeArgType, totalDiscount ProjectCostsWithReportsGetTotalDiscountArgType) *ProjectCostsWithReports { + this := ProjectCostsWithReports{} + setProjectCostsWithReportsGetCustomerAccountIdAttributeType(&this.CustomerAccountId, customerAccountId) + setProjectCostsWithReportsGetProjectIdAttributeType(&this.ProjectId, projectId) + setProjectCostsWithReportsGetProjectNameAttributeType(&this.ProjectName, projectName) + setProjectCostsWithReportsGetTotalChargeAttributeType(&this.TotalCharge, totalCharge) + setProjectCostsWithReportsGetTotalDiscountAttributeType(&this.TotalDiscount, totalDiscount) + return &this +} + +// NewProjectCostsWithReportsWithDefaults instantiates a new ProjectCostsWithReports 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 NewProjectCostsWithReportsWithDefaults() *ProjectCostsWithReports { + this := ProjectCostsWithReports{} + return &this +} + +// GetCustomerAccountId returns the CustomerAccountId field value +func (o *ProjectCostsWithReports) GetCustomerAccountId() (ret ProjectCostsWithReportsGetCustomerAccountIdRetType) { + 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 *ProjectCostsWithReports) GetCustomerAccountIdOk() (ret ProjectCostsWithReportsGetCustomerAccountIdRetType, ok bool) { + return getProjectCostsWithReportsGetCustomerAccountIdAttributeTypeOk(o.CustomerAccountId) +} + +// SetCustomerAccountId sets field value +func (o *ProjectCostsWithReports) SetCustomerAccountId(v ProjectCostsWithReportsGetCustomerAccountIdRetType) { + setProjectCostsWithReportsGetCustomerAccountIdAttributeType(&o.CustomerAccountId, v) +} + +// GetProjectId returns the ProjectId field value +func (o *ProjectCostsWithReports) GetProjectId() (ret ProjectCostsWithReportsGetProjectIdRetType) { + 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 *ProjectCostsWithReports) GetProjectIdOk() (ret ProjectCostsWithReportsGetProjectIdRetType, ok bool) { + return getProjectCostsWithReportsGetProjectIdAttributeTypeOk(o.ProjectId) +} + +// SetProjectId sets field value +func (o *ProjectCostsWithReports) SetProjectId(v ProjectCostsWithReportsGetProjectIdRetType) { + setProjectCostsWithReportsGetProjectIdAttributeType(&o.ProjectId, v) +} + +// GetProjectName returns the ProjectName field value +func (o *ProjectCostsWithReports) GetProjectName() (ret ProjectCostsWithReportsGetProjectNameRetType) { + 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 *ProjectCostsWithReports) GetProjectNameOk() (ret ProjectCostsWithReportsGetProjectNameRetType, ok bool) { + return getProjectCostsWithReportsGetProjectNameAttributeTypeOk(o.ProjectName) +} + +// SetProjectName sets field value +func (o *ProjectCostsWithReports) SetProjectName(v ProjectCostsWithReportsGetProjectNameRetType) { + setProjectCostsWithReportsGetProjectNameAttributeType(&o.ProjectName, v) +} + +// GetReportData returns the ReportData field value if set, zero value otherwise. +func (o *ProjectCostsWithReports) GetReportData() (res ProjectCostsWithReportsGetReportDataRetType) { + 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 *ProjectCostsWithReports) GetReportDataOk() (ret ProjectCostsWithReportsGetReportDataRetType, ok bool) { + return getProjectCostsWithReportsGetReportDataAttributeTypeOk(o.ReportData) +} + +// HasReportData returns a boolean if a field has been set. +func (o *ProjectCostsWithReports) HasReportData() bool { + _, ok := o.GetReportDataOk() + return ok +} + +// SetReportData gets a reference to the given []ReportData and assigns it to the ReportData field. +func (o *ProjectCostsWithReports) SetReportData(v ProjectCostsWithReportsGetReportDataRetType) { + setProjectCostsWithReportsGetReportDataAttributeType(&o.ReportData, v) +} + +// GetTotalCharge returns the TotalCharge field value +func (o *ProjectCostsWithReports) GetTotalCharge() (ret ProjectCostsWithReportsGetTotalChargeRetType) { + 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 *ProjectCostsWithReports) GetTotalChargeOk() (ret ProjectCostsWithReportsGetTotalChargeRetType, ok bool) { + return getProjectCostsWithReportsGetTotalChargeAttributeTypeOk(o.TotalCharge) +} + +// SetTotalCharge sets field value +func (o *ProjectCostsWithReports) SetTotalCharge(v ProjectCostsWithReportsGetTotalChargeRetType) { + setProjectCostsWithReportsGetTotalChargeAttributeType(&o.TotalCharge, v) +} + +// GetTotalDiscount returns the TotalDiscount field value +func (o *ProjectCostsWithReports) GetTotalDiscount() (ret ProjectCostsWithReportsGetTotalDiscountRetType) { + 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 *ProjectCostsWithReports) GetTotalDiscountOk() (ret ProjectCostsWithReportsGetTotalDiscountRetType, ok bool) { + return getProjectCostsWithReportsGetTotalDiscountAttributeTypeOk(o.TotalDiscount) +} + +// SetTotalDiscount sets field value +func (o *ProjectCostsWithReports) SetTotalDiscount(v ProjectCostsWithReportsGetTotalDiscountRetType) { + setProjectCostsWithReportsGetTotalDiscountAttributeType(&o.TotalDiscount, v) +} + +func (o ProjectCostsWithReports) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getProjectCostsWithReportsGetCustomerAccountIdAttributeTypeOk(o.CustomerAccountId); ok { + toSerialize["CustomerAccountId"] = val + } + if val, ok := getProjectCostsWithReportsGetProjectIdAttributeTypeOk(o.ProjectId); ok { + toSerialize["ProjectId"] = val + } + if val, ok := getProjectCostsWithReportsGetProjectNameAttributeTypeOk(o.ProjectName); ok { + toSerialize["ProjectName"] = val + } + if val, ok := getProjectCostsWithReportsGetReportDataAttributeTypeOk(o.ReportData); ok { + toSerialize["ReportData"] = val + } + if val, ok := getProjectCostsWithReportsGetTotalChargeAttributeTypeOk(o.TotalCharge); ok { + toSerialize["TotalCharge"] = val + } + if val, ok := getProjectCostsWithReportsGetTotalDiscountAttributeTypeOk(o.TotalDiscount); ok { + toSerialize["TotalDiscount"] = val + } + return toSerialize, nil +} + +type NullableProjectCostsWithReports struct { + value *ProjectCostsWithReports + isSet bool +} + +func (v NullableProjectCostsWithReports) Get() *ProjectCostsWithReports { + return v.value +} + +func (v *NullableProjectCostsWithReports) Set(val *ProjectCostsWithReports) { + v.value = val + v.isSet = true +} + +func (v NullableProjectCostsWithReports) IsSet() bool { + return v.isSet +} + +func (v *NullableProjectCostsWithReports) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableProjectCostsWithReports(val *ProjectCostsWithReports) *NullableProjectCostsWithReports { + return &NullableProjectCostsWithReports{value: val, isSet: true} +} + +func (v NullableProjectCostsWithReports) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableProjectCostsWithReports) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cost/model_project_costs_with_reports_test.go b/services/cost/model_project_costs_with_reports_test.go new file mode 100644 index 000000000..16ddfd392 --- /dev/null +++ b/services/cost/model_project_costs_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_costs_with_summarized_services.go b/services/cost/model_project_costs_with_summarized_services.go new file mode 100644 index 000000000..ad40397c1 --- /dev/null +++ b/services/cost/model_project_costs_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 ProjectCostsWithSummarizedServices type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ProjectCostsWithSummarizedServices{} + +/* + types and functions for customerAccountId +*/ + +// isNotNullableString +type ProjectCostsWithSummarizedServicesGetCustomerAccountIdAttributeType = *string + +func getProjectCostsWithSummarizedServicesGetCustomerAccountIdAttributeTypeOk(arg ProjectCostsWithSummarizedServicesGetCustomerAccountIdAttributeType) (ret ProjectCostsWithSummarizedServicesGetCustomerAccountIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setProjectCostsWithSummarizedServicesGetCustomerAccountIdAttributeType(arg *ProjectCostsWithSummarizedServicesGetCustomerAccountIdAttributeType, val ProjectCostsWithSummarizedServicesGetCustomerAccountIdRetType) { + *arg = &val +} + +type ProjectCostsWithSummarizedServicesGetCustomerAccountIdArgType = string +type ProjectCostsWithSummarizedServicesGetCustomerAccountIdRetType = string + +/* + types and functions for projectId +*/ + +// isNotNullableString +type ProjectCostsWithSummarizedServicesGetProjectIdAttributeType = *string + +func getProjectCostsWithSummarizedServicesGetProjectIdAttributeTypeOk(arg ProjectCostsWithSummarizedServicesGetProjectIdAttributeType) (ret ProjectCostsWithSummarizedServicesGetProjectIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setProjectCostsWithSummarizedServicesGetProjectIdAttributeType(arg *ProjectCostsWithSummarizedServicesGetProjectIdAttributeType, val ProjectCostsWithSummarizedServicesGetProjectIdRetType) { + *arg = &val +} + +type ProjectCostsWithSummarizedServicesGetProjectIdArgType = string +type ProjectCostsWithSummarizedServicesGetProjectIdRetType = string + +/* + types and functions for projectName +*/ + +// isNotNullableString +type ProjectCostsWithSummarizedServicesGetProjectNameAttributeType = *string + +func getProjectCostsWithSummarizedServicesGetProjectNameAttributeTypeOk(arg ProjectCostsWithSummarizedServicesGetProjectNameAttributeType) (ret ProjectCostsWithSummarizedServicesGetProjectNameRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setProjectCostsWithSummarizedServicesGetProjectNameAttributeType(arg *ProjectCostsWithSummarizedServicesGetProjectNameAttributeType, val ProjectCostsWithSummarizedServicesGetProjectNameRetType) { + *arg = &val +} + +type ProjectCostsWithSummarizedServicesGetProjectNameArgType = string +type ProjectCostsWithSummarizedServicesGetProjectNameRetType = string + +/* + types and functions for services +*/ + +// isArray +type ProjectCostsWithSummarizedServicesGetServicesAttributeType = *[]SummarizedServiceCosts +type ProjectCostsWithSummarizedServicesGetServicesArgType = []SummarizedServiceCosts +type ProjectCostsWithSummarizedServicesGetServicesRetType = []SummarizedServiceCosts + +func getProjectCostsWithSummarizedServicesGetServicesAttributeTypeOk(arg ProjectCostsWithSummarizedServicesGetServicesAttributeType) (ret ProjectCostsWithSummarizedServicesGetServicesRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setProjectCostsWithSummarizedServicesGetServicesAttributeType(arg *ProjectCostsWithSummarizedServicesGetServicesAttributeType, val ProjectCostsWithSummarizedServicesGetServicesRetType) { + *arg = &val +} + +/* + types and functions for totalCharge +*/ + +// isDouble +type ProjectCostsWithSummarizedServicesGetTotalChargeAttributeType = *float64 +type ProjectCostsWithSummarizedServicesGetTotalChargeArgType = float64 +type ProjectCostsWithSummarizedServicesGetTotalChargeRetType = float64 + +func getProjectCostsWithSummarizedServicesGetTotalChargeAttributeTypeOk(arg ProjectCostsWithSummarizedServicesGetTotalChargeAttributeType) (ret ProjectCostsWithSummarizedServicesGetTotalChargeRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setProjectCostsWithSummarizedServicesGetTotalChargeAttributeType(arg *ProjectCostsWithSummarizedServicesGetTotalChargeAttributeType, val ProjectCostsWithSummarizedServicesGetTotalChargeRetType) { + *arg = &val +} + +/* + types and functions for totalDiscount +*/ + +// isDouble +type ProjectCostsWithSummarizedServicesGetTotalDiscountAttributeType = *float64 +type ProjectCostsWithSummarizedServicesGetTotalDiscountArgType = float64 +type ProjectCostsWithSummarizedServicesGetTotalDiscountRetType = float64 + +func getProjectCostsWithSummarizedServicesGetTotalDiscountAttributeTypeOk(arg ProjectCostsWithSummarizedServicesGetTotalDiscountAttributeType) (ret ProjectCostsWithSummarizedServicesGetTotalDiscountRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setProjectCostsWithSummarizedServicesGetTotalDiscountAttributeType(arg *ProjectCostsWithSummarizedServicesGetTotalDiscountAttributeType, val ProjectCostsWithSummarizedServicesGetTotalDiscountRetType) { + *arg = &val +} + +// ProjectCostsWithSummarizedServices Costs for a project including summarized service costs +type ProjectCostsWithSummarizedServices struct { + // REQUIRED + CustomerAccountId ProjectCostsWithSummarizedServicesGetCustomerAccountIdAttributeType `json:"customerAccountId" required:"true"` + // REQUIRED + ProjectId ProjectCostsWithSummarizedServicesGetProjectIdAttributeType `json:"projectId" required:"true"` + // REQUIRED + ProjectName ProjectCostsWithSummarizedServicesGetProjectNameAttributeType `json:"projectName" required:"true"` + // Summarized service costs + Services ProjectCostsWithSummarizedServicesGetServicesAttributeType `json:"services,omitempty"` + // Total charge for all services and the whole requested date range (value in cents) + // REQUIRED + TotalCharge ProjectCostsWithSummarizedServicesGetTotalChargeAttributeType `json:"totalCharge" required:"true"` + // Total discount for all services and the whole requested date range (value in cents) + // REQUIRED + TotalDiscount ProjectCostsWithSummarizedServicesGetTotalDiscountAttributeType `json:"totalDiscount" required:"true"` +} + +type _ProjectCostsWithSummarizedServices ProjectCostsWithSummarizedServices + +// NewProjectCostsWithSummarizedServices instantiates a new ProjectCostsWithSummarizedServices 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 NewProjectCostsWithSummarizedServices(customerAccountId ProjectCostsWithSummarizedServicesGetCustomerAccountIdArgType, projectId ProjectCostsWithSummarizedServicesGetProjectIdArgType, projectName ProjectCostsWithSummarizedServicesGetProjectNameArgType, totalCharge ProjectCostsWithSummarizedServicesGetTotalChargeArgType, totalDiscount ProjectCostsWithSummarizedServicesGetTotalDiscountArgType) *ProjectCostsWithSummarizedServices { + this := ProjectCostsWithSummarizedServices{} + setProjectCostsWithSummarizedServicesGetCustomerAccountIdAttributeType(&this.CustomerAccountId, customerAccountId) + setProjectCostsWithSummarizedServicesGetProjectIdAttributeType(&this.ProjectId, projectId) + setProjectCostsWithSummarizedServicesGetProjectNameAttributeType(&this.ProjectName, projectName) + setProjectCostsWithSummarizedServicesGetTotalChargeAttributeType(&this.TotalCharge, totalCharge) + setProjectCostsWithSummarizedServicesGetTotalDiscountAttributeType(&this.TotalDiscount, totalDiscount) + return &this +} + +// NewProjectCostsWithSummarizedServicesWithDefaults instantiates a new ProjectCostsWithSummarizedServices 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 NewProjectCostsWithSummarizedServicesWithDefaults() *ProjectCostsWithSummarizedServices { + this := ProjectCostsWithSummarizedServices{} + return &this +} + +// GetCustomerAccountId returns the CustomerAccountId field value +func (o *ProjectCostsWithSummarizedServices) GetCustomerAccountId() (ret ProjectCostsWithSummarizedServicesGetCustomerAccountIdRetType) { + 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 *ProjectCostsWithSummarizedServices) GetCustomerAccountIdOk() (ret ProjectCostsWithSummarizedServicesGetCustomerAccountIdRetType, ok bool) { + return getProjectCostsWithSummarizedServicesGetCustomerAccountIdAttributeTypeOk(o.CustomerAccountId) +} + +// SetCustomerAccountId sets field value +func (o *ProjectCostsWithSummarizedServices) SetCustomerAccountId(v ProjectCostsWithSummarizedServicesGetCustomerAccountIdRetType) { + setProjectCostsWithSummarizedServicesGetCustomerAccountIdAttributeType(&o.CustomerAccountId, v) +} + +// GetProjectId returns the ProjectId field value +func (o *ProjectCostsWithSummarizedServices) GetProjectId() (ret ProjectCostsWithSummarizedServicesGetProjectIdRetType) { + 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 *ProjectCostsWithSummarizedServices) GetProjectIdOk() (ret ProjectCostsWithSummarizedServicesGetProjectIdRetType, ok bool) { + return getProjectCostsWithSummarizedServicesGetProjectIdAttributeTypeOk(o.ProjectId) +} + +// SetProjectId sets field value +func (o *ProjectCostsWithSummarizedServices) SetProjectId(v ProjectCostsWithSummarizedServicesGetProjectIdRetType) { + setProjectCostsWithSummarizedServicesGetProjectIdAttributeType(&o.ProjectId, v) +} + +// GetProjectName returns the ProjectName field value +func (o *ProjectCostsWithSummarizedServices) GetProjectName() (ret ProjectCostsWithSummarizedServicesGetProjectNameRetType) { + 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 *ProjectCostsWithSummarizedServices) GetProjectNameOk() (ret ProjectCostsWithSummarizedServicesGetProjectNameRetType, ok bool) { + return getProjectCostsWithSummarizedServicesGetProjectNameAttributeTypeOk(o.ProjectName) +} + +// SetProjectName sets field value +func (o *ProjectCostsWithSummarizedServices) SetProjectName(v ProjectCostsWithSummarizedServicesGetProjectNameRetType) { + setProjectCostsWithSummarizedServicesGetProjectNameAttributeType(&o.ProjectName, v) +} + +// GetServices returns the Services field value if set, zero value otherwise. +func (o *ProjectCostsWithSummarizedServices) GetServices() (res ProjectCostsWithSummarizedServicesGetServicesRetType) { + 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 *ProjectCostsWithSummarizedServices) GetServicesOk() (ret ProjectCostsWithSummarizedServicesGetServicesRetType, ok bool) { + return getProjectCostsWithSummarizedServicesGetServicesAttributeTypeOk(o.Services) +} + +// HasServices returns a boolean if a field has been set. +func (o *ProjectCostsWithSummarizedServices) HasServices() bool { + _, ok := o.GetServicesOk() + return ok +} + +// SetServices gets a reference to the given []SummarizedServiceCosts and assigns it to the Services field. +func (o *ProjectCostsWithSummarizedServices) SetServices(v ProjectCostsWithSummarizedServicesGetServicesRetType) { + setProjectCostsWithSummarizedServicesGetServicesAttributeType(&o.Services, v) +} + +// GetTotalCharge returns the TotalCharge field value +func (o *ProjectCostsWithSummarizedServices) GetTotalCharge() (ret ProjectCostsWithSummarizedServicesGetTotalChargeRetType) { + 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 *ProjectCostsWithSummarizedServices) GetTotalChargeOk() (ret ProjectCostsWithSummarizedServicesGetTotalChargeRetType, ok bool) { + return getProjectCostsWithSummarizedServicesGetTotalChargeAttributeTypeOk(o.TotalCharge) +} + +// SetTotalCharge sets field value +func (o *ProjectCostsWithSummarizedServices) SetTotalCharge(v ProjectCostsWithSummarizedServicesGetTotalChargeRetType) { + setProjectCostsWithSummarizedServicesGetTotalChargeAttributeType(&o.TotalCharge, v) +} + +// GetTotalDiscount returns the TotalDiscount field value +func (o *ProjectCostsWithSummarizedServices) GetTotalDiscount() (ret ProjectCostsWithSummarizedServicesGetTotalDiscountRetType) { + 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 *ProjectCostsWithSummarizedServices) GetTotalDiscountOk() (ret ProjectCostsWithSummarizedServicesGetTotalDiscountRetType, ok bool) { + return getProjectCostsWithSummarizedServicesGetTotalDiscountAttributeTypeOk(o.TotalDiscount) +} + +// SetTotalDiscount sets field value +func (o *ProjectCostsWithSummarizedServices) SetTotalDiscount(v ProjectCostsWithSummarizedServicesGetTotalDiscountRetType) { + setProjectCostsWithSummarizedServicesGetTotalDiscountAttributeType(&o.TotalDiscount, v) +} + +func (o ProjectCostsWithSummarizedServices) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getProjectCostsWithSummarizedServicesGetCustomerAccountIdAttributeTypeOk(o.CustomerAccountId); ok { + toSerialize["CustomerAccountId"] = val + } + if val, ok := getProjectCostsWithSummarizedServicesGetProjectIdAttributeTypeOk(o.ProjectId); ok { + toSerialize["ProjectId"] = val + } + if val, ok := getProjectCostsWithSummarizedServicesGetProjectNameAttributeTypeOk(o.ProjectName); ok { + toSerialize["ProjectName"] = val + } + if val, ok := getProjectCostsWithSummarizedServicesGetServicesAttributeTypeOk(o.Services); ok { + toSerialize["Services"] = val + } + if val, ok := getProjectCostsWithSummarizedServicesGetTotalChargeAttributeTypeOk(o.TotalCharge); ok { + toSerialize["TotalCharge"] = val + } + if val, ok := getProjectCostsWithSummarizedServicesGetTotalDiscountAttributeTypeOk(o.TotalDiscount); ok { + toSerialize["TotalDiscount"] = val + } + return toSerialize, nil +} + +type NullableProjectCostsWithSummarizedServices struct { + value *ProjectCostsWithSummarizedServices + isSet bool +} + +func (v NullableProjectCostsWithSummarizedServices) Get() *ProjectCostsWithSummarizedServices { + return v.value +} + +func (v *NullableProjectCostsWithSummarizedServices) Set(val *ProjectCostsWithSummarizedServices) { + v.value = val + v.isSet = true +} + +func (v NullableProjectCostsWithSummarizedServices) IsSet() bool { + return v.isSet +} + +func (v *NullableProjectCostsWithSummarizedServices) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableProjectCostsWithSummarizedServices(val *ProjectCostsWithSummarizedServices) *NullableProjectCostsWithSummarizedServices { + return &NullableProjectCostsWithSummarizedServices{value: val, isSet: true} +} + +func (v NullableProjectCostsWithSummarizedServices) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableProjectCostsWithSummarizedServices) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cost/model_project_costs_with_summarized_services_test.go b/services/cost/model_project_costs_with_summarized_services_test.go new file mode 100644 index 000000000..16ddfd392 --- /dev/null +++ b/services/cost/model_project_costs_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..b3f23a857 --- /dev/null +++ b/services/cost/model_report_data_time_period.go @@ -0,0 +1,175 @@ +/* +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" + "time" +) + +// checks if the ReportDataTimePeriod type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ReportDataTimePeriod{} + +/* + types and functions for end +*/ + +// isDate +type ReportDataTimePeriodGetEndAttributeType = *time.Time +type ReportDataTimePeriodGetEndArgType = time.Time +type ReportDataTimePeriodGetEndRetType = time.Time + +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 = *time.Time +type ReportDataTimePeriodGetStartArgType = time.Time +type ReportDataTimePeriodGetStartRetType = time.Time + +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_costs.go b/services/cost/model_summarized_project_costs.go new file mode 100644 index 000000000..bccc42a4e --- /dev/null +++ b/services/cost/model_summarized_project_costs.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 SummarizedProjectCosts type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &SummarizedProjectCosts{} + +/* + types and functions for customerAccountId +*/ + +// isNotNullableString +type SummarizedProjectCostsGetCustomerAccountIdAttributeType = *string + +func getSummarizedProjectCostsGetCustomerAccountIdAttributeTypeOk(arg SummarizedProjectCostsGetCustomerAccountIdAttributeType) (ret SummarizedProjectCostsGetCustomerAccountIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setSummarizedProjectCostsGetCustomerAccountIdAttributeType(arg *SummarizedProjectCostsGetCustomerAccountIdAttributeType, val SummarizedProjectCostsGetCustomerAccountIdRetType) { + *arg = &val +} + +type SummarizedProjectCostsGetCustomerAccountIdArgType = string +type SummarizedProjectCostsGetCustomerAccountIdRetType = string + +/* + types and functions for projectId +*/ + +// isNotNullableString +type SummarizedProjectCostsGetProjectIdAttributeType = *string + +func getSummarizedProjectCostsGetProjectIdAttributeTypeOk(arg SummarizedProjectCostsGetProjectIdAttributeType) (ret SummarizedProjectCostsGetProjectIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setSummarizedProjectCostsGetProjectIdAttributeType(arg *SummarizedProjectCostsGetProjectIdAttributeType, val SummarizedProjectCostsGetProjectIdRetType) { + *arg = &val +} + +type SummarizedProjectCostsGetProjectIdArgType = string +type SummarizedProjectCostsGetProjectIdRetType = string + +/* + types and functions for projectName +*/ + +// isNotNullableString +type SummarizedProjectCostsGetProjectNameAttributeType = *string + +func getSummarizedProjectCostsGetProjectNameAttributeTypeOk(arg SummarizedProjectCostsGetProjectNameAttributeType) (ret SummarizedProjectCostsGetProjectNameRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setSummarizedProjectCostsGetProjectNameAttributeType(arg *SummarizedProjectCostsGetProjectNameAttributeType, val SummarizedProjectCostsGetProjectNameRetType) { + *arg = &val +} + +type SummarizedProjectCostsGetProjectNameArgType = string +type SummarizedProjectCostsGetProjectNameRetType = string + +/* + types and functions for totalCharge +*/ + +// isDouble +type SummarizedProjectCostsGetTotalChargeAttributeType = *float64 +type SummarizedProjectCostsGetTotalChargeArgType = float64 +type SummarizedProjectCostsGetTotalChargeRetType = float64 + +func getSummarizedProjectCostsGetTotalChargeAttributeTypeOk(arg SummarizedProjectCostsGetTotalChargeAttributeType) (ret SummarizedProjectCostsGetTotalChargeRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setSummarizedProjectCostsGetTotalChargeAttributeType(arg *SummarizedProjectCostsGetTotalChargeAttributeType, val SummarizedProjectCostsGetTotalChargeRetType) { + *arg = &val +} + +/* + types and functions for totalDiscount +*/ + +// isDouble +type SummarizedProjectCostsGetTotalDiscountAttributeType = *float64 +type SummarizedProjectCostsGetTotalDiscountArgType = float64 +type SummarizedProjectCostsGetTotalDiscountRetType = float64 + +func getSummarizedProjectCostsGetTotalDiscountAttributeTypeOk(arg SummarizedProjectCostsGetTotalDiscountAttributeType) (ret SummarizedProjectCostsGetTotalDiscountRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setSummarizedProjectCostsGetTotalDiscountAttributeType(arg *SummarizedProjectCostsGetTotalDiscountAttributeType, val SummarizedProjectCostsGetTotalDiscountRetType) { + *arg = &val +} + +// SummarizedProjectCosts Summarized costs for a project +type SummarizedProjectCosts struct { + // REQUIRED + CustomerAccountId SummarizedProjectCostsGetCustomerAccountIdAttributeType `json:"customerAccountId" required:"true"` + // REQUIRED + ProjectId SummarizedProjectCostsGetProjectIdAttributeType `json:"projectId" required:"true"` + // REQUIRED + ProjectName SummarizedProjectCostsGetProjectNameAttributeType `json:"projectName" required:"true"` + // Total charge for all services and the whole requested date range (value in cents) + // REQUIRED + TotalCharge SummarizedProjectCostsGetTotalChargeAttributeType `json:"totalCharge" required:"true"` + // Total discount for all services and the whole requested date range (value in cents) + // REQUIRED + TotalDiscount SummarizedProjectCostsGetTotalDiscountAttributeType `json:"totalDiscount" required:"true"` +} + +type _SummarizedProjectCosts SummarizedProjectCosts + +// NewSummarizedProjectCosts instantiates a new SummarizedProjectCosts 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 NewSummarizedProjectCosts(customerAccountId SummarizedProjectCostsGetCustomerAccountIdArgType, projectId SummarizedProjectCostsGetProjectIdArgType, projectName SummarizedProjectCostsGetProjectNameArgType, totalCharge SummarizedProjectCostsGetTotalChargeArgType, totalDiscount SummarizedProjectCostsGetTotalDiscountArgType) *SummarizedProjectCosts { + this := SummarizedProjectCosts{} + setSummarizedProjectCostsGetCustomerAccountIdAttributeType(&this.CustomerAccountId, customerAccountId) + setSummarizedProjectCostsGetProjectIdAttributeType(&this.ProjectId, projectId) + setSummarizedProjectCostsGetProjectNameAttributeType(&this.ProjectName, projectName) + setSummarizedProjectCostsGetTotalChargeAttributeType(&this.TotalCharge, totalCharge) + setSummarizedProjectCostsGetTotalDiscountAttributeType(&this.TotalDiscount, totalDiscount) + return &this +} + +// NewSummarizedProjectCostsWithDefaults instantiates a new SummarizedProjectCosts 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 NewSummarizedProjectCostsWithDefaults() *SummarizedProjectCosts { + this := SummarizedProjectCosts{} + return &this +} + +// GetCustomerAccountId returns the CustomerAccountId field value +func (o *SummarizedProjectCosts) GetCustomerAccountId() (ret SummarizedProjectCostsGetCustomerAccountIdRetType) { + 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 *SummarizedProjectCosts) GetCustomerAccountIdOk() (ret SummarizedProjectCostsGetCustomerAccountIdRetType, ok bool) { + return getSummarizedProjectCostsGetCustomerAccountIdAttributeTypeOk(o.CustomerAccountId) +} + +// SetCustomerAccountId sets field value +func (o *SummarizedProjectCosts) SetCustomerAccountId(v SummarizedProjectCostsGetCustomerAccountIdRetType) { + setSummarizedProjectCostsGetCustomerAccountIdAttributeType(&o.CustomerAccountId, v) +} + +// GetProjectId returns the ProjectId field value +func (o *SummarizedProjectCosts) GetProjectId() (ret SummarizedProjectCostsGetProjectIdRetType) { + 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 *SummarizedProjectCosts) GetProjectIdOk() (ret SummarizedProjectCostsGetProjectIdRetType, ok bool) { + return getSummarizedProjectCostsGetProjectIdAttributeTypeOk(o.ProjectId) +} + +// SetProjectId sets field value +func (o *SummarizedProjectCosts) SetProjectId(v SummarizedProjectCostsGetProjectIdRetType) { + setSummarizedProjectCostsGetProjectIdAttributeType(&o.ProjectId, v) +} + +// GetProjectName returns the ProjectName field value +func (o *SummarizedProjectCosts) GetProjectName() (ret SummarizedProjectCostsGetProjectNameRetType) { + 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 *SummarizedProjectCosts) GetProjectNameOk() (ret SummarizedProjectCostsGetProjectNameRetType, ok bool) { + return getSummarizedProjectCostsGetProjectNameAttributeTypeOk(o.ProjectName) +} + +// SetProjectName sets field value +func (o *SummarizedProjectCosts) SetProjectName(v SummarizedProjectCostsGetProjectNameRetType) { + setSummarizedProjectCostsGetProjectNameAttributeType(&o.ProjectName, v) +} + +// GetTotalCharge returns the TotalCharge field value +func (o *SummarizedProjectCosts) GetTotalCharge() (ret SummarizedProjectCostsGetTotalChargeRetType) { + 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 *SummarizedProjectCosts) GetTotalChargeOk() (ret SummarizedProjectCostsGetTotalChargeRetType, ok bool) { + return getSummarizedProjectCostsGetTotalChargeAttributeTypeOk(o.TotalCharge) +} + +// SetTotalCharge sets field value +func (o *SummarizedProjectCosts) SetTotalCharge(v SummarizedProjectCostsGetTotalChargeRetType) { + setSummarizedProjectCostsGetTotalChargeAttributeType(&o.TotalCharge, v) +} + +// GetTotalDiscount returns the TotalDiscount field value +func (o *SummarizedProjectCosts) GetTotalDiscount() (ret SummarizedProjectCostsGetTotalDiscountRetType) { + 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 *SummarizedProjectCosts) GetTotalDiscountOk() (ret SummarizedProjectCostsGetTotalDiscountRetType, ok bool) { + return getSummarizedProjectCostsGetTotalDiscountAttributeTypeOk(o.TotalDiscount) +} + +// SetTotalDiscount sets field value +func (o *SummarizedProjectCosts) SetTotalDiscount(v SummarizedProjectCostsGetTotalDiscountRetType) { + setSummarizedProjectCostsGetTotalDiscountAttributeType(&o.TotalDiscount, v) +} + +func (o SummarizedProjectCosts) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getSummarizedProjectCostsGetCustomerAccountIdAttributeTypeOk(o.CustomerAccountId); ok { + toSerialize["CustomerAccountId"] = val + } + if val, ok := getSummarizedProjectCostsGetProjectIdAttributeTypeOk(o.ProjectId); ok { + toSerialize["ProjectId"] = val + } + if val, ok := getSummarizedProjectCostsGetProjectNameAttributeTypeOk(o.ProjectName); ok { + toSerialize["ProjectName"] = val + } + if val, ok := getSummarizedProjectCostsGetTotalChargeAttributeTypeOk(o.TotalCharge); ok { + toSerialize["TotalCharge"] = val + } + if val, ok := getSummarizedProjectCostsGetTotalDiscountAttributeTypeOk(o.TotalDiscount); ok { + toSerialize["TotalDiscount"] = val + } + return toSerialize, nil +} + +type NullableSummarizedProjectCosts struct { + value *SummarizedProjectCosts + isSet bool +} + +func (v NullableSummarizedProjectCosts) Get() *SummarizedProjectCosts { + return v.value +} + +func (v *NullableSummarizedProjectCosts) Set(val *SummarizedProjectCosts) { + v.value = val + v.isSet = true +} + +func (v NullableSummarizedProjectCosts) IsSet() bool { + return v.isSet +} + +func (v *NullableSummarizedProjectCosts) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableSummarizedProjectCosts(val *SummarizedProjectCosts) *NullableSummarizedProjectCosts { + return &NullableSummarizedProjectCosts{value: val, isSet: true} +} + +func (v NullableSummarizedProjectCosts) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableSummarizedProjectCosts) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cost/model_summarized_project_costs_test.go b/services/cost/model_summarized_project_costs_test.go new file mode 100644 index 000000000..16ddfd392 --- /dev/null +++ b/services/cost/model_summarized_project_costs_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_costs.go b/services/cost/model_summarized_service_costs.go new file mode 100644 index 000000000..831b9e620 --- /dev/null +++ b/services/cost/model_summarized_service_costs.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 SummarizedServiceCosts type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &SummarizedServiceCosts{} + +/* + types and functions for customerAccountId +*/ + +// isNotNullableString +type SummarizedServiceCostsGetCustomerAccountIdAttributeType = *string + +func getSummarizedServiceCostsGetCustomerAccountIdAttributeTypeOk(arg SummarizedServiceCostsGetCustomerAccountIdAttributeType) (ret SummarizedServiceCostsGetCustomerAccountIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setSummarizedServiceCostsGetCustomerAccountIdAttributeType(arg *SummarizedServiceCostsGetCustomerAccountIdAttributeType, val SummarizedServiceCostsGetCustomerAccountIdRetType) { + *arg = &val +} + +type SummarizedServiceCostsGetCustomerAccountIdArgType = string +type SummarizedServiceCostsGetCustomerAccountIdRetType = string + +/* + types and functions for projectId +*/ + +// isNotNullableString +type SummarizedServiceCostsGetProjectIdAttributeType = *string + +func getSummarizedServiceCostsGetProjectIdAttributeTypeOk(arg SummarizedServiceCostsGetProjectIdAttributeType) (ret SummarizedServiceCostsGetProjectIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setSummarizedServiceCostsGetProjectIdAttributeType(arg *SummarizedServiceCostsGetProjectIdAttributeType, val SummarizedServiceCostsGetProjectIdRetType) { + *arg = &val +} + +type SummarizedServiceCostsGetProjectIdArgType = string +type SummarizedServiceCostsGetProjectIdRetType = string + +/* + types and functions for projectName +*/ + +// isNotNullableString +type SummarizedServiceCostsGetProjectNameAttributeType = *string + +func getSummarizedServiceCostsGetProjectNameAttributeTypeOk(arg SummarizedServiceCostsGetProjectNameAttributeType) (ret SummarizedServiceCostsGetProjectNameRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setSummarizedServiceCostsGetProjectNameAttributeType(arg *SummarizedServiceCostsGetProjectNameAttributeType, val SummarizedServiceCostsGetProjectNameRetType) { + *arg = &val +} + +type SummarizedServiceCostsGetProjectNameArgType = string +type SummarizedServiceCostsGetProjectNameRetType = string + +/* + types and functions for totalCharge +*/ + +// isDouble +type SummarizedServiceCostsGetTotalChargeAttributeType = *float64 +type SummarizedServiceCostsGetTotalChargeArgType = float64 +type SummarizedServiceCostsGetTotalChargeRetType = float64 + +func getSummarizedServiceCostsGetTotalChargeAttributeTypeOk(arg SummarizedServiceCostsGetTotalChargeAttributeType) (ret SummarizedServiceCostsGetTotalChargeRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setSummarizedServiceCostsGetTotalChargeAttributeType(arg *SummarizedServiceCostsGetTotalChargeAttributeType, val SummarizedServiceCostsGetTotalChargeRetType) { + *arg = &val +} + +/* + types and functions for totalDiscount +*/ + +// isDouble +type SummarizedServiceCostsGetTotalDiscountAttributeType = *float64 +type SummarizedServiceCostsGetTotalDiscountArgType = float64 +type SummarizedServiceCostsGetTotalDiscountRetType = float64 + +func getSummarizedServiceCostsGetTotalDiscountAttributeTypeOk(arg SummarizedServiceCostsGetTotalDiscountAttributeType) (ret SummarizedServiceCostsGetTotalDiscountRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setSummarizedServiceCostsGetTotalDiscountAttributeType(arg *SummarizedServiceCostsGetTotalDiscountAttributeType, val SummarizedServiceCostsGetTotalDiscountRetType) { + *arg = &val +} + +// SummarizedServiceCosts Summarized costs for a project +type SummarizedServiceCosts struct { + // REQUIRED + CustomerAccountId SummarizedServiceCostsGetCustomerAccountIdAttributeType `json:"customerAccountId" required:"true"` + // REQUIRED + ProjectId SummarizedServiceCostsGetProjectIdAttributeType `json:"projectId" required:"true"` + // REQUIRED + ProjectName SummarizedServiceCostsGetProjectNameAttributeType `json:"projectName" required:"true"` + // Total charge for all services and the whole requested date range (value in cents) + // REQUIRED + TotalCharge SummarizedServiceCostsGetTotalChargeAttributeType `json:"totalCharge" required:"true"` + // Total discount for all services and the whole requested date range (value in cents) + // REQUIRED + TotalDiscount SummarizedServiceCostsGetTotalDiscountAttributeType `json:"totalDiscount" required:"true"` +} + +type _SummarizedServiceCosts SummarizedServiceCosts + +// NewSummarizedServiceCosts instantiates a new SummarizedServiceCosts 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 NewSummarizedServiceCosts(customerAccountId SummarizedServiceCostsGetCustomerAccountIdArgType, projectId SummarizedServiceCostsGetProjectIdArgType, projectName SummarizedServiceCostsGetProjectNameArgType, totalCharge SummarizedServiceCostsGetTotalChargeArgType, totalDiscount SummarizedServiceCostsGetTotalDiscountArgType) *SummarizedServiceCosts { + this := SummarizedServiceCosts{} + setSummarizedServiceCostsGetCustomerAccountIdAttributeType(&this.CustomerAccountId, customerAccountId) + setSummarizedServiceCostsGetProjectIdAttributeType(&this.ProjectId, projectId) + setSummarizedServiceCostsGetProjectNameAttributeType(&this.ProjectName, projectName) + setSummarizedServiceCostsGetTotalChargeAttributeType(&this.TotalCharge, totalCharge) + setSummarizedServiceCostsGetTotalDiscountAttributeType(&this.TotalDiscount, totalDiscount) + return &this +} + +// NewSummarizedServiceCostsWithDefaults instantiates a new SummarizedServiceCosts 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 NewSummarizedServiceCostsWithDefaults() *SummarizedServiceCosts { + this := SummarizedServiceCosts{} + return &this +} + +// GetCustomerAccountId returns the CustomerAccountId field value +func (o *SummarizedServiceCosts) GetCustomerAccountId() (ret SummarizedServiceCostsGetCustomerAccountIdRetType) { + 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 *SummarizedServiceCosts) GetCustomerAccountIdOk() (ret SummarizedServiceCostsGetCustomerAccountIdRetType, ok bool) { + return getSummarizedServiceCostsGetCustomerAccountIdAttributeTypeOk(o.CustomerAccountId) +} + +// SetCustomerAccountId sets field value +func (o *SummarizedServiceCosts) SetCustomerAccountId(v SummarizedServiceCostsGetCustomerAccountIdRetType) { + setSummarizedServiceCostsGetCustomerAccountIdAttributeType(&o.CustomerAccountId, v) +} + +// GetProjectId returns the ProjectId field value +func (o *SummarizedServiceCosts) GetProjectId() (ret SummarizedServiceCostsGetProjectIdRetType) { + 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 *SummarizedServiceCosts) GetProjectIdOk() (ret SummarizedServiceCostsGetProjectIdRetType, ok bool) { + return getSummarizedServiceCostsGetProjectIdAttributeTypeOk(o.ProjectId) +} + +// SetProjectId sets field value +func (o *SummarizedServiceCosts) SetProjectId(v SummarizedServiceCostsGetProjectIdRetType) { + setSummarizedServiceCostsGetProjectIdAttributeType(&o.ProjectId, v) +} + +// GetProjectName returns the ProjectName field value +func (o *SummarizedServiceCosts) GetProjectName() (ret SummarizedServiceCostsGetProjectNameRetType) { + 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 *SummarizedServiceCosts) GetProjectNameOk() (ret SummarizedServiceCostsGetProjectNameRetType, ok bool) { + return getSummarizedServiceCostsGetProjectNameAttributeTypeOk(o.ProjectName) +} + +// SetProjectName sets field value +func (o *SummarizedServiceCosts) SetProjectName(v SummarizedServiceCostsGetProjectNameRetType) { + setSummarizedServiceCostsGetProjectNameAttributeType(&o.ProjectName, v) +} + +// GetTotalCharge returns the TotalCharge field value +func (o *SummarizedServiceCosts) GetTotalCharge() (ret SummarizedServiceCostsGetTotalChargeRetType) { + 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 *SummarizedServiceCosts) GetTotalChargeOk() (ret SummarizedServiceCostsGetTotalChargeRetType, ok bool) { + return getSummarizedServiceCostsGetTotalChargeAttributeTypeOk(o.TotalCharge) +} + +// SetTotalCharge sets field value +func (o *SummarizedServiceCosts) SetTotalCharge(v SummarizedServiceCostsGetTotalChargeRetType) { + setSummarizedServiceCostsGetTotalChargeAttributeType(&o.TotalCharge, v) +} + +// GetTotalDiscount returns the TotalDiscount field value +func (o *SummarizedServiceCosts) GetTotalDiscount() (ret SummarizedServiceCostsGetTotalDiscountRetType) { + 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 *SummarizedServiceCosts) GetTotalDiscountOk() (ret SummarizedServiceCostsGetTotalDiscountRetType, ok bool) { + return getSummarizedServiceCostsGetTotalDiscountAttributeTypeOk(o.TotalDiscount) +} + +// SetTotalDiscount sets field value +func (o *SummarizedServiceCosts) SetTotalDiscount(v SummarizedServiceCostsGetTotalDiscountRetType) { + setSummarizedServiceCostsGetTotalDiscountAttributeType(&o.TotalDiscount, v) +} + +func (o SummarizedServiceCosts) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getSummarizedServiceCostsGetCustomerAccountIdAttributeTypeOk(o.CustomerAccountId); ok { + toSerialize["CustomerAccountId"] = val + } + if val, ok := getSummarizedServiceCostsGetProjectIdAttributeTypeOk(o.ProjectId); ok { + toSerialize["ProjectId"] = val + } + if val, ok := getSummarizedServiceCostsGetProjectNameAttributeTypeOk(o.ProjectName); ok { + toSerialize["ProjectName"] = val + } + if val, ok := getSummarizedServiceCostsGetTotalChargeAttributeTypeOk(o.TotalCharge); ok { + toSerialize["TotalCharge"] = val + } + if val, ok := getSummarizedServiceCostsGetTotalDiscountAttributeTypeOk(o.TotalDiscount); ok { + toSerialize["TotalDiscount"] = val + } + return toSerialize, nil +} + +type NullableSummarizedServiceCosts struct { + value *SummarizedServiceCosts + isSet bool +} + +func (v NullableSummarizedServiceCosts) Get() *SummarizedServiceCosts { + return v.value +} + +func (v *NullableSummarizedServiceCosts) Set(val *SummarizedServiceCosts) { + v.value = val + v.isSet = true +} + +func (v NullableSummarizedServiceCosts) IsSet() bool { + return v.isSet +} + +func (v *NullableSummarizedServiceCosts) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableSummarizedServiceCosts(val *SummarizedServiceCosts) *NullableSummarizedServiceCosts { + return &NullableSummarizedServiceCosts{value: val, isSet: true} +} + +func (v NullableSummarizedServiceCosts) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableSummarizedServiceCosts) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cost/model_summarized_service_costs_test.go b/services/cost/model_summarized_service_costs_test.go new file mode 100644 index 000000000..16ddfd392 --- /dev/null +++ b/services/cost/model_summarized_service_costs_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) +}