From 463b790eab387ee81b156938da0e38ee404c976b Mon Sep 17 00:00:00 2001 From: SDK Generator Bot Date: Wed, 11 Jun 2025 12:50:58 +0000 Subject: [PATCH] Generate auditlog --- go.work | 1 + services/auditlog/.openapi-generator/VERSION | 1 + services/auditlog/api_default.go | 727 +++++++++ services/auditlog/api_default_test.go | 190 +++ services/auditlog/client.go | 631 ++++++++ services/auditlog/configuration.go | 38 + services/auditlog/go.mod | 10 + services/auditlog/go.sum | 8 + services/auditlog/model_audit_log_entry.go | 1356 +++++++++++++++++ .../auditlog/model_audit_log_entry_test.go | 151 ++ services/auditlog/model_context.go | 227 +++ services/auditlog/model_context_test.go | 11 + .../auditlog/model_delegation_principal.go | 176 +++ .../model_delegation_principal_test.go | 11 + ...nload_folder_audit_entries_200_response.go | 226 +++ ..._folder_audit_entries_200_response_test.go | 11 + services/auditlog/model_error.go | 276 ++++ services/auditlog/model_error_test.go | 11 + services/auditlog/model_initiator.go | 176 +++ services/auditlog/model_initiator_test.go | 11 + services/auditlog/model_request.go | 271 ++++ services/auditlog/model_request_test.go | 11 + .../model_service_account_delegation_info.go | 126 ++ ...el_service_account_delegation_info_test.go | 11 + services/auditlog/utils.go | 385 +++++ 25 files changed, 5053 insertions(+) create mode 100644 services/auditlog/.openapi-generator/VERSION create mode 100644 services/auditlog/api_default.go create mode 100644 services/auditlog/api_default_test.go create mode 100644 services/auditlog/client.go create mode 100644 services/auditlog/configuration.go create mode 100644 services/auditlog/go.mod create mode 100644 services/auditlog/go.sum create mode 100644 services/auditlog/model_audit_log_entry.go create mode 100644 services/auditlog/model_audit_log_entry_test.go create mode 100644 services/auditlog/model_context.go create mode 100644 services/auditlog/model_context_test.go create mode 100644 services/auditlog/model_delegation_principal.go create mode 100644 services/auditlog/model_delegation_principal_test.go create mode 100644 services/auditlog/model_download_folder_audit_entries_200_response.go create mode 100644 services/auditlog/model_download_folder_audit_entries_200_response_test.go create mode 100644 services/auditlog/model_error.go create mode 100644 services/auditlog/model_error_test.go create mode 100644 services/auditlog/model_initiator.go create mode 100644 services/auditlog/model_initiator_test.go create mode 100644 services/auditlog/model_request.go create mode 100644 services/auditlog/model_request_test.go create mode 100644 services/auditlog/model_service_account_delegation_info.go create mode 100644 services/auditlog/model_service_account_delegation_info_test.go create mode 100644 services/auditlog/utils.go diff --git a/go.work b/go.work index 94bb9b90..f0109db2 100644 --- a/go.work +++ b/go.work @@ -33,6 +33,7 @@ use ( ./scripts ./services/alb ./services/archiving + ./services/auditlog ./services/authorization ./services/cdn ./services/certificates diff --git a/services/auditlog/.openapi-generator/VERSION b/services/auditlog/.openapi-generator/VERSION new file mode 100644 index 00000000..cd802a1e --- /dev/null +++ b/services/auditlog/.openapi-generator/VERSION @@ -0,0 +1 @@ +6.6.0 \ No newline at end of file diff --git a/services/auditlog/api_default.go b/services/auditlog/api_default.go new file mode 100644 index 00000000..9a0cb801 --- /dev/null +++ b/services/auditlog/api_default.go @@ -0,0 +1,727 @@ +/* +Audit Log API + +API Endpoints to retrieve recorded actions and resulting changes in the system. ### Audit Logging Changes on organizations, folders and projects and respective cloud resources are logged and collected in the audit log. ### API Constraints The audit log API allows to download messages from the last 90 days. The maximum duration that can be queried at once is 24 hours. Requests are rate limited - the current maximum is 1 request per second. + +API version: 2.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package auditlog + +import ( + "bytes" + "context" + "fmt" + "io" + "net/http" + "net/url" + "strings" + "time" + + "github.com/stackitcloud/stackit-sdk-go/core/config" + "github.com/stackitcloud/stackit-sdk-go/core/oapierror" +) + +type DefaultApi interface { + /* + DownloadFolderAuditEntries Folder - Download audit log entries + Returns all audit log entries of the folder for the specified period. \ + Period must not be longer than 24 hours within the last 90 days. + + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param folderId ID of the folder for which entries should be returned. + @return ApiDownloadFolderAuditEntriesRequest + */ + DownloadFolderAuditEntries(ctx context.Context, folderId string) ApiDownloadFolderAuditEntriesRequest + /* + DownloadFolderAuditEntriesExecute executes the request + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param folderId ID of the folder for which entries should be returned. + @return DownloadFolderAuditEntries200Response + + */ + DownloadFolderAuditEntriesExecute(ctx context.Context, folderId string) (*DownloadFolderAuditEntries200Response, error) + /* + DownloadOrganizationAuditEntries Organization - Download audit log entries + Returns all audit log entries of the organization for the specified period. \ + Period must not be longer than 24 hours within the last 90 days. + + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param organizationId ID of the organization for which entries should be returned. + @return ApiDownloadOrganizationAuditEntriesRequest + */ + DownloadOrganizationAuditEntries(ctx context.Context, organizationId string) ApiDownloadOrganizationAuditEntriesRequest + /* + DownloadOrganizationAuditEntriesExecute executes the request + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param organizationId ID of the organization for which entries should be returned. + @return DownloadFolderAuditEntries200Response + + */ + DownloadOrganizationAuditEntriesExecute(ctx context.Context, organizationId string) (*DownloadFolderAuditEntries200Response, error) + /* + DownloadProjectAuditEntries Project - Download audit log entries + Returns all audit log entries of the project for the specified period. \ + Period must not be longer than 24 hours within the last 90 days. + + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId ID of the project for which entries should be returned. + @return ApiDownloadProjectAuditEntriesRequest + */ + DownloadProjectAuditEntries(ctx context.Context, projectId string) ApiDownloadProjectAuditEntriesRequest + /* + DownloadProjectAuditEntriesExecute executes the request + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId ID of the project for which entries should be returned. + @return DownloadFolderAuditEntries200Response + + */ + DownloadProjectAuditEntriesExecute(ctx context.Context, projectId string) (*DownloadFolderAuditEntries200Response, error) +} + +type ApiDownloadFolderAuditEntriesRequest interface { + // An ISO timestamp to specify the beginning of the time range from which entries should be returned, based on the eventTimeStamp. If not given, defaults to the beginning of time. + StartTimeRange(startTimeRange time.Time) ApiDownloadFolderAuditEntriesRequest + // An ISO timestamp to specify the end of the time range up until which entries should be returned, based on the eventTimeStamp. If not given, defaults to the time this request was received. + EndTimeRange(endTimeRange time.Time) ApiDownloadFolderAuditEntriesRequest + // The maximum number of entries to return. If the value exceeds the allowed maximum, the maximum value will be used instead. + Limit(limit float32) ApiDownloadFolderAuditEntriesRequest + // A pagination cursor to load further audit log entries for. May be included in the response of previous calls of the API. + Cursor(cursor string) ApiDownloadFolderAuditEntriesRequest + Execute() (*DownloadFolderAuditEntries200Response, error) +} + +type ApiDownloadOrganizationAuditEntriesRequest interface { + // An ISO timestamp to specify the beginning of the time range from which entries should be returned, based on the eventTimeStamp. If not given, defaults to the beginning of time. + StartTimeRange(startTimeRange time.Time) ApiDownloadOrganizationAuditEntriesRequest + // An ISO timestamp to specify the end of the time range up until which entries should be returned, based on the eventTimeStamp. If not given, defaults to the time this request was received. + EndTimeRange(endTimeRange time.Time) ApiDownloadOrganizationAuditEntriesRequest + // The maximum number of entries to return. If the value exceeds the allowed maximum, the maximum value will be used instead. + Limit(limit float32) ApiDownloadOrganizationAuditEntriesRequest + // A pagination cursor to load further audit log entries for. May be included in the response of previous calls of the API. + Cursor(cursor string) ApiDownloadOrganizationAuditEntriesRequest + Execute() (*DownloadFolderAuditEntries200Response, error) +} + +type ApiDownloadProjectAuditEntriesRequest interface { + // An ISO timestamp to specify the beginning of the time range from which entries should be returned, based on the eventTimeStamp. If not given, defaults to the beginning of time. + StartTimeRange(startTimeRange time.Time) ApiDownloadProjectAuditEntriesRequest + // An ISO timestamp to specify the end of the time range up until which entries should be returned, based on the eventTimeStamp. If not given, defaults to the time this request was received. + EndTimeRange(endTimeRange time.Time) ApiDownloadProjectAuditEntriesRequest + // The maximum number of entries to return. If the value exceeds the allowed maximum, the maximum value will be used instead. + Limit(limit float32) ApiDownloadProjectAuditEntriesRequest + // A pagination cursor to load further audit log entries for. May be included in the response of previous calls of the API. + Cursor(cursor string) ApiDownloadProjectAuditEntriesRequest + Execute() (*DownloadFolderAuditEntries200Response, error) +} + +// DefaultApiService DefaultApi service +type DefaultApiService service + +type DownloadFolderAuditEntriesRequest struct { + ctx context.Context + apiService *DefaultApiService + folderId string + startTimeRange *time.Time + endTimeRange *time.Time + limit *float32 + cursor *string +} + +// An ISO timestamp to specify the beginning of the time range from which entries should be returned, based on the eventTimeStamp. If not given, defaults to the beginning of time. + +func (r DownloadFolderAuditEntriesRequest) StartTimeRange(startTimeRange time.Time) ApiDownloadFolderAuditEntriesRequest { + r.startTimeRange = &startTimeRange + return r +} + +// An ISO timestamp to specify the end of the time range up until which entries should be returned, based on the eventTimeStamp. If not given, defaults to the time this request was received. + +func (r DownloadFolderAuditEntriesRequest) EndTimeRange(endTimeRange time.Time) ApiDownloadFolderAuditEntriesRequest { + r.endTimeRange = &endTimeRange + return r +} + +// The maximum number of entries to return. If the value exceeds the allowed maximum, the maximum value will be used instead. + +func (r DownloadFolderAuditEntriesRequest) Limit(limit float32) ApiDownloadFolderAuditEntriesRequest { + r.limit = &limit + return r +} + +// A pagination cursor to load further audit log entries for. May be included in the response of previous calls of the API. + +func (r DownloadFolderAuditEntriesRequest) Cursor(cursor string) ApiDownloadFolderAuditEntriesRequest { + r.cursor = &cursor + return r +} + +func (r DownloadFolderAuditEntriesRequest) Execute() (*DownloadFolderAuditEntries200Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *DownloadFolderAuditEntries200Response + ) + 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.DownloadFolderAuditEntries") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v2/folders/{folderId}" + localVarPath = strings.Replace(localVarPath, "{"+"folderId"+"}", url.PathEscape(ParameterValueToString(r.folderId, "folderId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.startTimeRange == nil { + return localVarReturnValue, fmt.Errorf("startTimeRange is required and must be specified") + } + if r.endTimeRange == nil { + return localVarReturnValue, fmt.Errorf("endTimeRange is required and must be specified") + } + + parameterAddToHeaderOrQuery(localVarQueryParams, "start-time-range", r.startTimeRange, "") + parameterAddToHeaderOrQuery(localVarQueryParams, "end-time-range", r.endTimeRange, "") + if r.limit != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "limit", r.limit, "") + } + if r.cursor != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "cursor", r.cursor, "") + } + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := 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 == 400 { + var v ModelError + 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 + } + if localVarHTTPResponse.StatusCode == 401 { + var v ModelError + 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 + } + if localVarHTTPResponse.StatusCode == 404 { + var v ModelError + 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 +} + +/* +DownloadFolderAuditEntries: Folder - Download audit log entries + +Returns all audit log entries of the folder for the specified period. \ +Period must not be longer than 24 hours within the last 90 days. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param folderId ID of the folder for which entries should be returned. + @return ApiDownloadFolderAuditEntriesRequest +*/ +func (a *APIClient) DownloadFolderAuditEntries(ctx context.Context, folderId string) ApiDownloadFolderAuditEntriesRequest { + return DownloadFolderAuditEntriesRequest{ + apiService: a.defaultApi, + ctx: ctx, + folderId: folderId, + } +} + +func (a *APIClient) DownloadFolderAuditEntriesExecute(ctx context.Context, folderId string) (*DownloadFolderAuditEntries200Response, error) { + r := DownloadFolderAuditEntriesRequest{ + apiService: a.defaultApi, + ctx: ctx, + folderId: folderId, + } + return r.Execute() +} + +type DownloadOrganizationAuditEntriesRequest struct { + ctx context.Context + apiService *DefaultApiService + organizationId string + startTimeRange *time.Time + endTimeRange *time.Time + limit *float32 + cursor *string +} + +// An ISO timestamp to specify the beginning of the time range from which entries should be returned, based on the eventTimeStamp. If not given, defaults to the beginning of time. + +func (r DownloadOrganizationAuditEntriesRequest) StartTimeRange(startTimeRange time.Time) ApiDownloadOrganizationAuditEntriesRequest { + r.startTimeRange = &startTimeRange + return r +} + +// An ISO timestamp to specify the end of the time range up until which entries should be returned, based on the eventTimeStamp. If not given, defaults to the time this request was received. + +func (r DownloadOrganizationAuditEntriesRequest) EndTimeRange(endTimeRange time.Time) ApiDownloadOrganizationAuditEntriesRequest { + r.endTimeRange = &endTimeRange + return r +} + +// The maximum number of entries to return. If the value exceeds the allowed maximum, the maximum value will be used instead. + +func (r DownloadOrganizationAuditEntriesRequest) Limit(limit float32) ApiDownloadOrganizationAuditEntriesRequest { + r.limit = &limit + return r +} + +// A pagination cursor to load further audit log entries for. May be included in the response of previous calls of the API. + +func (r DownloadOrganizationAuditEntriesRequest) Cursor(cursor string) ApiDownloadOrganizationAuditEntriesRequest { + r.cursor = &cursor + return r +} + +func (r DownloadOrganizationAuditEntriesRequest) Execute() (*DownloadFolderAuditEntries200Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *DownloadFolderAuditEntries200Response + ) + 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.DownloadOrganizationAuditEntries") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v2/organizations/{organizationId}" + localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(ParameterValueToString(r.organizationId, "organizationId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.startTimeRange == nil { + return localVarReturnValue, fmt.Errorf("startTimeRange is required and must be specified") + } + if r.endTimeRange == nil { + return localVarReturnValue, fmt.Errorf("endTimeRange is required and must be specified") + } + + parameterAddToHeaderOrQuery(localVarQueryParams, "start-time-range", r.startTimeRange, "") + parameterAddToHeaderOrQuery(localVarQueryParams, "end-time-range", r.endTimeRange, "") + if r.limit != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "limit", r.limit, "") + } + if r.cursor != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "cursor", r.cursor, "") + } + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := 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 == 400 { + var v ModelError + 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 + } + if localVarHTTPResponse.StatusCode == 401 { + var v ModelError + 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 + } + if localVarHTTPResponse.StatusCode == 404 { + var v ModelError + 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 +} + +/* +DownloadOrganizationAuditEntries: Organization - Download audit log entries + +Returns all audit log entries of the organization for the specified period. \ +Period must not be longer than 24 hours within the last 90 days. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param organizationId ID of the organization for which entries should be returned. + @return ApiDownloadOrganizationAuditEntriesRequest +*/ +func (a *APIClient) DownloadOrganizationAuditEntries(ctx context.Context, organizationId string) ApiDownloadOrganizationAuditEntriesRequest { + return DownloadOrganizationAuditEntriesRequest{ + apiService: a.defaultApi, + ctx: ctx, + organizationId: organizationId, + } +} + +func (a *APIClient) DownloadOrganizationAuditEntriesExecute(ctx context.Context, organizationId string) (*DownloadFolderAuditEntries200Response, error) { + r := DownloadOrganizationAuditEntriesRequest{ + apiService: a.defaultApi, + ctx: ctx, + organizationId: organizationId, + } + return r.Execute() +} + +type DownloadProjectAuditEntriesRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + startTimeRange *time.Time + endTimeRange *time.Time + limit *float32 + cursor *string +} + +// An ISO timestamp to specify the beginning of the time range from which entries should be returned, based on the eventTimeStamp. If not given, defaults to the beginning of time. + +func (r DownloadProjectAuditEntriesRequest) StartTimeRange(startTimeRange time.Time) ApiDownloadProjectAuditEntriesRequest { + r.startTimeRange = &startTimeRange + return r +} + +// An ISO timestamp to specify the end of the time range up until which entries should be returned, based on the eventTimeStamp. If not given, defaults to the time this request was received. + +func (r DownloadProjectAuditEntriesRequest) EndTimeRange(endTimeRange time.Time) ApiDownloadProjectAuditEntriesRequest { + r.endTimeRange = &endTimeRange + return r +} + +// The maximum number of entries to return. If the value exceeds the allowed maximum, the maximum value will be used instead. + +func (r DownloadProjectAuditEntriesRequest) Limit(limit float32) ApiDownloadProjectAuditEntriesRequest { + r.limit = &limit + return r +} + +// A pagination cursor to load further audit log entries for. May be included in the response of previous calls of the API. + +func (r DownloadProjectAuditEntriesRequest) Cursor(cursor string) ApiDownloadProjectAuditEntriesRequest { + r.cursor = &cursor + return r +} + +func (r DownloadProjectAuditEntriesRequest) Execute() (*DownloadFolderAuditEntries200Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *DownloadFolderAuditEntries200Response + ) + 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.DownloadProjectAuditEntries") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v2/projects/{projectId}" + 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.startTimeRange == nil { + return localVarReturnValue, fmt.Errorf("startTimeRange is required and must be specified") + } + if r.endTimeRange == nil { + return localVarReturnValue, fmt.Errorf("endTimeRange is required and must be specified") + } + + parameterAddToHeaderOrQuery(localVarQueryParams, "start-time-range", r.startTimeRange, "") + parameterAddToHeaderOrQuery(localVarQueryParams, "end-time-range", r.endTimeRange, "") + if r.limit != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "limit", r.limit, "") + } + if r.cursor != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "cursor", r.cursor, "") + } + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := 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 == 400 { + var v ModelError + 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 + } + if localVarHTTPResponse.StatusCode == 401 { + var v ModelError + 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 + } + if localVarHTTPResponse.StatusCode == 404 { + var v ModelError + 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 +} + +/* +DownloadProjectAuditEntries: Project - Download audit log entries + +Returns all audit log entries of the project for the specified period. \ +Period must not be longer than 24 hours within the last 90 days. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId ID of the project for which entries should be returned. + @return ApiDownloadProjectAuditEntriesRequest +*/ +func (a *APIClient) DownloadProjectAuditEntries(ctx context.Context, projectId string) ApiDownloadProjectAuditEntriesRequest { + return DownloadProjectAuditEntriesRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + } +} + +func (a *APIClient) DownloadProjectAuditEntriesExecute(ctx context.Context, projectId string) (*DownloadFolderAuditEntries200Response, error) { + r := DownloadProjectAuditEntriesRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + } + return r.Execute() +} diff --git a/services/auditlog/api_default_test.go b/services/auditlog/api_default_test.go new file mode 100644 index 00000000..80a035e5 --- /dev/null +++ b/services/auditlog/api_default_test.go @@ -0,0 +1,190 @@ +/* +Audit Log API + +Testing DefaultApiService + +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); + +package auditlog + +import ( + "context" + "encoding/json" + "net/http" + "net/http/httptest" + "net/url" + "strings" + "testing" + "time" + + "github.com/google/uuid" + "github.com/stackitcloud/stackit-sdk-go/core/config" +) + +func Test_auditlog_DefaultApiService(t *testing.T) { + + t.Run("Test DefaultApiService DownloadFolderAuditEntries", func(t *testing.T) { + _apiUrlPath := "/v2/folders/{folderId}" + folderIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"folderId"+"}", url.PathEscape(ParameterValueToString(folderIdValue, "folderId")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + data := DownloadFolderAuditEntries200Response{} + 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 auditlog_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) + } + + folderId := folderIdValue + var startTimeRange time.Time + var endTimeRange time.Time + + resp, reqErr := apiClient.DownloadFolderAuditEntries(context.Background(), folderId).StartTimeRange(startTimeRange).EndTimeRange(endTimeRange).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if IsNil(resp) { + t.Fatalf("response not present") + } + }) + + t.Run("Test DefaultApiService DownloadOrganizationAuditEntries", func(t *testing.T) { + _apiUrlPath := "/v2/organizations/{organizationId}" + organizationIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"organizationId"+"}", url.PathEscape(ParameterValueToString(organizationIdValue, "organizationId")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + data := DownloadFolderAuditEntries200Response{} + 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 auditlog_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) + } + + organizationId := organizationIdValue + var startTimeRange time.Time + var endTimeRange time.Time + + resp, reqErr := apiClient.DownloadOrganizationAuditEntries(context.Background(), organizationId).StartTimeRange(startTimeRange).EndTimeRange(endTimeRange).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if IsNil(resp) { + t.Fatalf("response not present") + } + }) + + t.Run("Test DefaultApiService DownloadProjectAuditEntries", func(t *testing.T) { + _apiUrlPath := "/v2/projects/{projectId}" + 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 := DownloadFolderAuditEntries200Response{} + 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 auditlog_DefaultApi", + Variables: map[string]config.ServerVariable{ + "region": { + DefaultValue: "test_region.", + EnumValues: []string{ + "test_region.", + }, + }, + }, + }, + }, + OperationServers: map[string]config.ServerConfigurations{}, + } + apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication()) + if err != nil { + t.Fatalf("creating API client: %v", err) + } + + projectId := projectIdValue + var startTimeRange time.Time + var endTimeRange time.Time + + resp, reqErr := apiClient.DownloadProjectAuditEntries(context.Background(), projectId).StartTimeRange(startTimeRange).EndTimeRange(endTimeRange).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if IsNil(resp) { + t.Fatalf("response not present") + } + }) + +} diff --git a/services/auditlog/client.go b/services/auditlog/client.go new file mode 100644 index 00000000..3afbe9fa --- /dev/null +++ b/services/auditlog/client.go @@ -0,0 +1,631 @@ +/* +Audit Log API + +API Endpoints to retrieve recorded actions and resulting changes in the system. ### Audit Logging Changes on organizations, folders and projects and respective cloud resources are logged and collected in the audit log. ### API Constraints The audit log API allows to download messages from the last 90 days. The maximum duration that can be queried at once is 24 hours. Requests are rate limited - the current maximum is 1 request per second. + +API version: 2.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package auditlog + +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 Audit Log API API v2.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/auditlog/configuration.go b/services/auditlog/configuration.go new file mode 100644 index 00000000..737f278d --- /dev/null +++ b/services/auditlog/configuration.go @@ -0,0 +1,38 @@ +/* +Audit Log API + +API Endpoints to retrieve recorded actions and resulting changes in the system. ### Audit Logging Changes on organizations, folders and projects and respective cloud resources are logged and collected in the audit log. ### API Constraints The audit log API allows to download messages from the last 90 days. The maximum duration that can be queried at once is 24 hours. Requests are rate limited - the current maximum is 1 request per second. + +API version: 2.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package auditlog + +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/auditlog", + Debug: false, + Servers: config.ServerConfigurations{ + { + URL: "https://auditlog.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/auditlog/go.mod b/services/auditlog/go.mod new file mode 100644 index 00000000..6990bd80 --- /dev/null +++ b/services/auditlog/go.mod @@ -0,0 +1,10 @@ +module github.com/stackitcloud/stackit-sdk-go/services/auditlog + +go 1.21 + +require ( + github.com/google/uuid v1.6.0 + github.com/stackitcloud/stackit-sdk-go/core v0.17.2 +) + +require github.com/golang-jwt/jwt/v5 v5.2.2 // indirect diff --git a/services/auditlog/go.sum b/services/auditlog/go.sum new file mode 100644 index 00000000..f4cb3055 --- /dev/null +++ b/services/auditlog/go.sum @@ -0,0 +1,8 @@ +github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8= +github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/stackitcloud/stackit-sdk-go/core v0.17.2 h1:jPyn+i8rkp2hM80+hOg0B/1EVRbMt778Tr5RWyK1m2E= +github.com/stackitcloud/stackit-sdk-go/core v0.17.2/go.mod h1:8KIw3czdNJ9sdil9QQimxjR6vHjeINFrRv0iZ67wfn0= diff --git a/services/auditlog/model_audit_log_entry.go b/services/auditlog/model_audit_log_entry.go new file mode 100644 index 00000000..a4d50e21 --- /dev/null +++ b/services/auditlog/model_audit_log_entry.go @@ -0,0 +1,1356 @@ +/* +Audit Log API + +API Endpoints to retrieve recorded actions and resulting changes in the system. ### Audit Logging Changes on organizations, folders and projects and respective cloud resources are logged and collected in the audit log. ### API Constraints The audit log API allows to download messages from the last 90 days. The maximum duration that can be queried at once is 24 hours. Requests are rate limited - the current maximum is 1 request per second. + +API version: 2.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package auditlog + +import ( + "encoding/json" + "fmt" + "time" +) + +// checks if the AuditLogEntry type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &AuditLogEntry{} + +/* + types and functions for context +*/ + +// isModel +type AuditLogEntryGetContextAttributeType = *Context +type AuditLogEntryGetContextArgType = Context +type AuditLogEntryGetContextRetType = Context + +func getAuditLogEntryGetContextAttributeTypeOk(arg AuditLogEntryGetContextAttributeType) (ret AuditLogEntryGetContextRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setAuditLogEntryGetContextAttributeType(arg *AuditLogEntryGetContextAttributeType, val AuditLogEntryGetContextRetType) { + *arg = &val +} + +/* + types and functions for correlationId +*/ + +// isNotNullableString +type AuditLogEntryGetCorrelationIdAttributeType = *string + +func getAuditLogEntryGetCorrelationIdAttributeTypeOk(arg AuditLogEntryGetCorrelationIdAttributeType) (ret AuditLogEntryGetCorrelationIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setAuditLogEntryGetCorrelationIdAttributeType(arg *AuditLogEntryGetCorrelationIdAttributeType, val AuditLogEntryGetCorrelationIdRetType) { + *arg = &val +} + +type AuditLogEntryGetCorrelationIdArgType = string +type AuditLogEntryGetCorrelationIdRetType = string + +/* + types and functions for details +*/ + +// isFreeform +type AuditLogEntryGetDetailsAttributeType = *map[string]interface{} +type AuditLogEntryGetDetailsArgType = map[string]interface{} +type AuditLogEntryGetDetailsRetType = map[string]interface{} + +func getAuditLogEntryGetDetailsAttributeTypeOk(arg AuditLogEntryGetDetailsAttributeType) (ret AuditLogEntryGetDetailsRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setAuditLogEntryGetDetailsAttributeType(arg *AuditLogEntryGetDetailsAttributeType, val AuditLogEntryGetDetailsRetType) { + *arg = &val +} + +/* + types and functions for eventName +*/ + +// isNotNullableString +type AuditLogEntryGetEventNameAttributeType = *string + +func getAuditLogEntryGetEventNameAttributeTypeOk(arg AuditLogEntryGetEventNameAttributeType) (ret AuditLogEntryGetEventNameRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setAuditLogEntryGetEventNameAttributeType(arg *AuditLogEntryGetEventNameAttributeType, val AuditLogEntryGetEventNameRetType) { + *arg = &val +} + +type AuditLogEntryGetEventNameArgType = string +type AuditLogEntryGetEventNameRetType = string + +/* + types and functions for eventSource +*/ + +// isNotNullableString +type AuditLogEntryGetEventSourceAttributeType = *string + +func getAuditLogEntryGetEventSourceAttributeTypeOk(arg AuditLogEntryGetEventSourceAttributeType) (ret AuditLogEntryGetEventSourceRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setAuditLogEntryGetEventSourceAttributeType(arg *AuditLogEntryGetEventSourceAttributeType, val AuditLogEntryGetEventSourceRetType) { + *arg = &val +} + +type AuditLogEntryGetEventSourceArgType = string +type AuditLogEntryGetEventSourceRetType = string + +/* + types and functions for eventTimeStamp +*/ + +// isDateTime +type AuditLogEntryGetEventTimeStampAttributeType = *time.Time +type AuditLogEntryGetEventTimeStampArgType = time.Time +type AuditLogEntryGetEventTimeStampRetType = time.Time + +func getAuditLogEntryGetEventTimeStampAttributeTypeOk(arg AuditLogEntryGetEventTimeStampAttributeType) (ret AuditLogEntryGetEventTimeStampRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setAuditLogEntryGetEventTimeStampAttributeType(arg *AuditLogEntryGetEventTimeStampAttributeType, val AuditLogEntryGetEventTimeStampRetType) { + *arg = &val +} + +/* + types and functions for eventType +*/ + +// isEnum + +// AuditLogEntryEventType Type that can be assigned to the event. For example, an event \"Organization created\" can be assigned to the type ADMIN_EVENT +// value type for enums +type AuditLogEntryEventType string + +// List of EventType +const ( + AUDITLOGENTRYEVENT_TYPE_ADMIN_ACTIVITY AuditLogEntryEventType = "ADMIN_ACTIVITY" + AUDITLOGENTRYEVENT_TYPE_SYSTEM_EVENT AuditLogEntryEventType = "SYSTEM_EVENT" + AUDITLOGENTRYEVENT_TYPE_POLICY_DENIED AuditLogEntryEventType = "POLICY_DENIED" +) + +// All allowed values of AuditLogEntry enum +var AllowedAuditLogEntryEventTypeEnumValues = []AuditLogEntryEventType{ + "ADMIN_ACTIVITY", + "SYSTEM_EVENT", + "POLICY_DENIED", +} + +func (v *AuditLogEntryEventType) UnmarshalJSON(src []byte) error { + // use a type alias to prevent infinite recursion during unmarshal, + // see https://biscuit.ninja/posts/go-avoid-an-infitine-loop-with-custom-json-unmarshallers + type TmpJson AuditLogEntryEventType + var value TmpJson + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + // Allow unmarshalling zero value for testing purposes + var zeroValue TmpJson + if value == zeroValue { + return nil + } + enumTypeValue := AuditLogEntryEventType(value) + for _, existing := range AllowedAuditLogEntryEventTypeEnumValues { + if existing == enumTypeValue { + *v = enumTypeValue + return nil + } + } + + return fmt.Errorf("%+v is not a valid AuditLogEntry", value) +} + +// NewAuditLogEntryEventTypeFromValue returns a pointer to a valid AuditLogEntryEventType +// for the value passed as argument, or an error if the value passed is not allowed by the enum +func NewAuditLogEntryEventTypeFromValue(v AuditLogEntryEventType) (*AuditLogEntryEventType, error) { + ev := AuditLogEntryEventType(v) + if ev.IsValid() { + return &ev, nil + } else { + return nil, fmt.Errorf("invalid value '%v' for AuditLogEntryEventType: valid values are %v", v, AllowedAuditLogEntryEventTypeEnumValues) + } +} + +// IsValid return true if the value is valid for the enum, false otherwise +func (v AuditLogEntryEventType) IsValid() bool { + for _, existing := range AllowedAuditLogEntryEventTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to EventTypeEventType value +func (v AuditLogEntryEventType) Ptr() *AuditLogEntryEventType { + return &v +} + +type NullableAuditLogEntryEventType struct { + value *AuditLogEntryEventType + isSet bool +} + +func (v NullableAuditLogEntryEventType) Get() *AuditLogEntryEventType { + return v.value +} + +func (v *NullableAuditLogEntryEventType) Set(val *AuditLogEntryEventType) { + v.value = val + v.isSet = true +} + +func (v NullableAuditLogEntryEventType) IsSet() bool { + return v.isSet +} + +func (v *NullableAuditLogEntryEventType) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableAuditLogEntryEventType(val *AuditLogEntryEventType) *NullableAuditLogEntryEventType { + return &NullableAuditLogEntryEventType{value: val, isSet: true} +} + +func (v NullableAuditLogEntryEventType) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableAuditLogEntryEventType) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type AuditLogEntryGetEventTypeAttributeType = *AuditLogEntryEventType +type AuditLogEntryGetEventTypeArgType = AuditLogEntryEventType +type AuditLogEntryGetEventTypeRetType = AuditLogEntryEventType + +func getAuditLogEntryGetEventTypeAttributeTypeOk(arg AuditLogEntryGetEventTypeAttributeType) (ret AuditLogEntryGetEventTypeRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setAuditLogEntryGetEventTypeAttributeType(arg *AuditLogEntryGetEventTypeAttributeType, val AuditLogEntryGetEventTypeRetType) { + *arg = &val +} + +/* + types and functions for eventVersion +*/ + +// isNotNullableString +type AuditLogEntryGetEventVersionAttributeType = *string + +func getAuditLogEntryGetEventVersionAttributeTypeOk(arg AuditLogEntryGetEventVersionAttributeType) (ret AuditLogEntryGetEventVersionRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setAuditLogEntryGetEventVersionAttributeType(arg *AuditLogEntryGetEventVersionAttributeType, val AuditLogEntryGetEventVersionRetType) { + *arg = &val +} + +type AuditLogEntryGetEventVersionArgType = string +type AuditLogEntryGetEventVersionRetType = string + +/* + types and functions for id +*/ + +// isNotNullableString +type AuditLogEntryGetIdAttributeType = *string + +func getAuditLogEntryGetIdAttributeTypeOk(arg AuditLogEntryGetIdAttributeType) (ret AuditLogEntryGetIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setAuditLogEntryGetIdAttributeType(arg *AuditLogEntryGetIdAttributeType, val AuditLogEntryGetIdRetType) { + *arg = &val +} + +type AuditLogEntryGetIdArgType = string +type AuditLogEntryGetIdRetType = string + +/* + types and functions for initiator +*/ + +// isModel +type AuditLogEntryGetInitiatorAttributeType = *Initiator +type AuditLogEntryGetInitiatorArgType = Initiator +type AuditLogEntryGetInitiatorRetType = Initiator + +func getAuditLogEntryGetInitiatorAttributeTypeOk(arg AuditLogEntryGetInitiatorAttributeType) (ret AuditLogEntryGetInitiatorRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setAuditLogEntryGetInitiatorAttributeType(arg *AuditLogEntryGetInitiatorAttributeType, val AuditLogEntryGetInitiatorRetType) { + *arg = &val +} + +/* + types and functions for receivedTimeStamp +*/ + +// isDateTime +type AuditLogEntryGetReceivedTimeStampAttributeType = *time.Time +type AuditLogEntryGetReceivedTimeStampArgType = time.Time +type AuditLogEntryGetReceivedTimeStampRetType = time.Time + +func getAuditLogEntryGetReceivedTimeStampAttributeTypeOk(arg AuditLogEntryGetReceivedTimeStampAttributeType) (ret AuditLogEntryGetReceivedTimeStampRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setAuditLogEntryGetReceivedTimeStampAttributeType(arg *AuditLogEntryGetReceivedTimeStampAttributeType, val AuditLogEntryGetReceivedTimeStampRetType) { + *arg = &val +} + +/* + types and functions for region +*/ + +// isNotNullableString +type AuditLogEntryGetRegionAttributeType = *string + +func getAuditLogEntryGetRegionAttributeTypeOk(arg AuditLogEntryGetRegionAttributeType) (ret AuditLogEntryGetRegionRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setAuditLogEntryGetRegionAttributeType(arg *AuditLogEntryGetRegionAttributeType, val AuditLogEntryGetRegionRetType) { + *arg = &val +} + +type AuditLogEntryGetRegionArgType = string +type AuditLogEntryGetRegionRetType = string + +/* + types and functions for request +*/ + +// isModel +type AuditLogEntryGetRequestAttributeType = *Request +type AuditLogEntryGetRequestArgType = Request +type AuditLogEntryGetRequestRetType = Request + +func getAuditLogEntryGetRequestAttributeTypeOk(arg AuditLogEntryGetRequestAttributeType) (ret AuditLogEntryGetRequestRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setAuditLogEntryGetRequestAttributeType(arg *AuditLogEntryGetRequestAttributeType, val AuditLogEntryGetRequestRetType) { + *arg = &val +} + +/* + types and functions for resourceId +*/ + +// isNotNullableString +type AuditLogEntryGetResourceIdAttributeType = *string + +func getAuditLogEntryGetResourceIdAttributeTypeOk(arg AuditLogEntryGetResourceIdAttributeType) (ret AuditLogEntryGetResourceIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setAuditLogEntryGetResourceIdAttributeType(arg *AuditLogEntryGetResourceIdAttributeType, val AuditLogEntryGetResourceIdRetType) { + *arg = &val +} + +type AuditLogEntryGetResourceIdArgType = string +type AuditLogEntryGetResourceIdRetType = string + +/* + types and functions for resourceName +*/ + +// isNotNullableString +type AuditLogEntryGetResourceNameAttributeType = *string + +func getAuditLogEntryGetResourceNameAttributeTypeOk(arg AuditLogEntryGetResourceNameAttributeType) (ret AuditLogEntryGetResourceNameRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setAuditLogEntryGetResourceNameAttributeType(arg *AuditLogEntryGetResourceNameAttributeType, val AuditLogEntryGetResourceNameRetType) { + *arg = &val +} + +type AuditLogEntryGetResourceNameArgType = string +type AuditLogEntryGetResourceNameRetType = string + +/* + types and functions for result +*/ + +// isFreeform +type AuditLogEntryGetResultAttributeType = *map[string]interface{} +type AuditLogEntryGetResultArgType = map[string]interface{} +type AuditLogEntryGetResultRetType = map[string]interface{} + +func getAuditLogEntryGetResultAttributeTypeOk(arg AuditLogEntryGetResultAttributeType) (ret AuditLogEntryGetResultRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setAuditLogEntryGetResultAttributeType(arg *AuditLogEntryGetResultAttributeType, val AuditLogEntryGetResultRetType) { + *arg = &val +} + +/* + types and functions for serviceAccountDelegationInfo +*/ + +// isModel +type AuditLogEntryGetServiceAccountDelegationInfoAttributeType = *ServiceAccountDelegationInfo +type AuditLogEntryGetServiceAccountDelegationInfoArgType = ServiceAccountDelegationInfo +type AuditLogEntryGetServiceAccountDelegationInfoRetType = ServiceAccountDelegationInfo + +func getAuditLogEntryGetServiceAccountDelegationInfoAttributeTypeOk(arg AuditLogEntryGetServiceAccountDelegationInfoAttributeType) (ret AuditLogEntryGetServiceAccountDelegationInfoRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setAuditLogEntryGetServiceAccountDelegationInfoAttributeType(arg *AuditLogEntryGetServiceAccountDelegationInfoAttributeType, val AuditLogEntryGetServiceAccountDelegationInfoRetType) { + *arg = &val +} + +/* + types and functions for severity +*/ + +// isEnum + +// AuditLogEntrySeverity The severity of this request. +// value type for enums +type AuditLogEntrySeverity string + +// List of Severity +const ( + AUDITLOGENTRYSEVERITY_INFO AuditLogEntrySeverity = "INFO" + AUDITLOGENTRYSEVERITY_ERROR AuditLogEntrySeverity = "ERROR" +) + +// All allowed values of AuditLogEntry enum +var AllowedAuditLogEntrySeverityEnumValues = []AuditLogEntrySeverity{ + "INFO", + "ERROR", +} + +func (v *AuditLogEntrySeverity) UnmarshalJSON(src []byte) error { + // use a type alias to prevent infinite recursion during unmarshal, + // see https://biscuit.ninja/posts/go-avoid-an-infitine-loop-with-custom-json-unmarshallers + type TmpJson AuditLogEntrySeverity + var value TmpJson + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + // Allow unmarshalling zero value for testing purposes + var zeroValue TmpJson + if value == zeroValue { + return nil + } + enumTypeValue := AuditLogEntrySeverity(value) + for _, existing := range AllowedAuditLogEntrySeverityEnumValues { + if existing == enumTypeValue { + *v = enumTypeValue + return nil + } + } + + return fmt.Errorf("%+v is not a valid AuditLogEntry", value) +} + +// NewAuditLogEntrySeverityFromValue returns a pointer to a valid AuditLogEntrySeverity +// for the value passed as argument, or an error if the value passed is not allowed by the enum +func NewAuditLogEntrySeverityFromValue(v AuditLogEntrySeverity) (*AuditLogEntrySeverity, error) { + ev := AuditLogEntrySeverity(v) + if ev.IsValid() { + return &ev, nil + } else { + return nil, fmt.Errorf("invalid value '%v' for AuditLogEntrySeverity: valid values are %v", v, AllowedAuditLogEntrySeverityEnumValues) + } +} + +// IsValid return true if the value is valid for the enum, false otherwise +func (v AuditLogEntrySeverity) IsValid() bool { + for _, existing := range AllowedAuditLogEntrySeverityEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to SeveritySeverity value +func (v AuditLogEntrySeverity) Ptr() *AuditLogEntrySeverity { + return &v +} + +type NullableAuditLogEntrySeverity struct { + value *AuditLogEntrySeverity + isSet bool +} + +func (v NullableAuditLogEntrySeverity) Get() *AuditLogEntrySeverity { + return v.value +} + +func (v *NullableAuditLogEntrySeverity) Set(val *AuditLogEntrySeverity) { + v.value = val + v.isSet = true +} + +func (v NullableAuditLogEntrySeverity) IsSet() bool { + return v.isSet +} + +func (v *NullableAuditLogEntrySeverity) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableAuditLogEntrySeverity(val *AuditLogEntrySeverity) *NullableAuditLogEntrySeverity { + return &NullableAuditLogEntrySeverity{value: val, isSet: true} +} + +func (v NullableAuditLogEntrySeverity) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableAuditLogEntrySeverity) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type AuditLogEntryGetSeverityAttributeType = *AuditLogEntrySeverity +type AuditLogEntryGetSeverityArgType = AuditLogEntrySeverity +type AuditLogEntryGetSeverityRetType = AuditLogEntrySeverity + +func getAuditLogEntryGetSeverityAttributeTypeOk(arg AuditLogEntryGetSeverityAttributeType) (ret AuditLogEntryGetSeverityRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setAuditLogEntryGetSeverityAttributeType(arg *AuditLogEntryGetSeverityAttributeType, val AuditLogEntryGetSeverityRetType) { + *arg = &val +} + +/* + types and functions for sourceIpAddress +*/ + +// isNotNullableString +type AuditLogEntryGetSourceIpAddressAttributeType = *string + +func getAuditLogEntryGetSourceIpAddressAttributeTypeOk(arg AuditLogEntryGetSourceIpAddressAttributeType) (ret AuditLogEntryGetSourceIpAddressRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setAuditLogEntryGetSourceIpAddressAttributeType(arg *AuditLogEntryGetSourceIpAddressAttributeType, val AuditLogEntryGetSourceIpAddressRetType) { + *arg = &val +} + +type AuditLogEntryGetSourceIpAddressArgType = string +type AuditLogEntryGetSourceIpAddressRetType = string + +/* + types and functions for userAgent +*/ + +// isNotNullableString +type AuditLogEntryGetUserAgentAttributeType = *string + +func getAuditLogEntryGetUserAgentAttributeTypeOk(arg AuditLogEntryGetUserAgentAttributeType) (ret AuditLogEntryGetUserAgentRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setAuditLogEntryGetUserAgentAttributeType(arg *AuditLogEntryGetUserAgentAttributeType, val AuditLogEntryGetUserAgentRetType) { + *arg = &val +} + +type AuditLogEntryGetUserAgentArgType = string +type AuditLogEntryGetUserAgentRetType = string + +/* + types and functions for visibility +*/ + +// isEnum + +// AuditLogEntryVisibility PUBLIC for entries that are intended for end users, while PRIVATE entries can only be viewed with system privileges. +// value type for enums +type AuditLogEntryVisibility string + +// List of Visibility +const ( + AUDITLOGENTRYVISIBILITY_PUBLIC AuditLogEntryVisibility = "PUBLIC" + AUDITLOGENTRYVISIBILITY_PRIVATE AuditLogEntryVisibility = "PRIVATE" +) + +// All allowed values of AuditLogEntry enum +var AllowedAuditLogEntryVisibilityEnumValues = []AuditLogEntryVisibility{ + "PUBLIC", + "PRIVATE", +} + +func (v *AuditLogEntryVisibility) UnmarshalJSON(src []byte) error { + // use a type alias to prevent infinite recursion during unmarshal, + // see https://biscuit.ninja/posts/go-avoid-an-infitine-loop-with-custom-json-unmarshallers + type TmpJson AuditLogEntryVisibility + var value TmpJson + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + // Allow unmarshalling zero value for testing purposes + var zeroValue TmpJson + if value == zeroValue { + return nil + } + enumTypeValue := AuditLogEntryVisibility(value) + for _, existing := range AllowedAuditLogEntryVisibilityEnumValues { + if existing == enumTypeValue { + *v = enumTypeValue + return nil + } + } + + return fmt.Errorf("%+v is not a valid AuditLogEntry", value) +} + +// NewAuditLogEntryVisibilityFromValue returns a pointer to a valid AuditLogEntryVisibility +// for the value passed as argument, or an error if the value passed is not allowed by the enum +func NewAuditLogEntryVisibilityFromValue(v AuditLogEntryVisibility) (*AuditLogEntryVisibility, error) { + ev := AuditLogEntryVisibility(v) + if ev.IsValid() { + return &ev, nil + } else { + return nil, fmt.Errorf("invalid value '%v' for AuditLogEntryVisibility: valid values are %v", v, AllowedAuditLogEntryVisibilityEnumValues) + } +} + +// IsValid return true if the value is valid for the enum, false otherwise +func (v AuditLogEntryVisibility) IsValid() bool { + for _, existing := range AllowedAuditLogEntryVisibilityEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to VisibilityVisibility value +func (v AuditLogEntryVisibility) Ptr() *AuditLogEntryVisibility { + return &v +} + +type NullableAuditLogEntryVisibility struct { + value *AuditLogEntryVisibility + isSet bool +} + +func (v NullableAuditLogEntryVisibility) Get() *AuditLogEntryVisibility { + return v.value +} + +func (v *NullableAuditLogEntryVisibility) Set(val *AuditLogEntryVisibility) { + v.value = val + v.isSet = true +} + +func (v NullableAuditLogEntryVisibility) IsSet() bool { + return v.isSet +} + +func (v *NullableAuditLogEntryVisibility) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableAuditLogEntryVisibility(val *AuditLogEntryVisibility) *NullableAuditLogEntryVisibility { + return &NullableAuditLogEntryVisibility{value: val, isSet: true} +} + +func (v NullableAuditLogEntryVisibility) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableAuditLogEntryVisibility) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type AuditLogEntryGetVisibilityAttributeType = *AuditLogEntryVisibility +type AuditLogEntryGetVisibilityArgType = AuditLogEntryVisibility +type AuditLogEntryGetVisibilityRetType = AuditLogEntryVisibility + +func getAuditLogEntryGetVisibilityAttributeTypeOk(arg AuditLogEntryGetVisibilityAttributeType) (ret AuditLogEntryGetVisibilityRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setAuditLogEntryGetVisibilityAttributeType(arg *AuditLogEntryGetVisibilityAttributeType, val AuditLogEntryGetVisibilityRetType) { + *arg = &val +} + +// AuditLogEntry struct for AuditLogEntry +type AuditLogEntry struct { + Context AuditLogEntryGetContextAttributeType `json:"context,omitempty"` + // Unique ID which identifies the request from the sender point of view. + CorrelationId AuditLogEntryGetCorrelationIdAttributeType `json:"correlationId,omitempty"` + // Additional information about the event that is not part of the request or response. May contain arbitrary data. + Details AuditLogEntryGetDetailsAttributeType `json:"details,omitempty"` + // Name of the operation this event represents. + // REQUIRED + EventName AuditLogEntryGetEventNameAttributeType `json:"eventName"` + // The service in which the causing event was handled. + // REQUIRED + EventSource AuditLogEntryGetEventSourceAttributeType `json:"eventSource"` + // Timestamp at which the event was triggered. + // REQUIRED + EventTimeStamp AuditLogEntryGetEventTimeStampAttributeType `json:"eventTimeStamp"` + // Type that can be assigned to the event. For example, an event \"Organization created\" can be assigned to the type ADMIN_EVENT + // REQUIRED + EventType AuditLogEntryGetEventTypeAttributeType `json:"eventType"` + // Version of the log event format. + // REQUIRED + EventVersion AuditLogEntryGetEventVersionAttributeType `json:"eventVersion"` + // Unique ID generated by the audit log. + // REQUIRED + Id AuditLogEntryGetIdAttributeType `json:"id"` + // REQUIRED + Initiator AuditLogEntryGetInitiatorAttributeType `json:"initiator"` + // Timestamp at which the event was received by the audit log. + // REQUIRED + ReceivedTimeStamp AuditLogEntryGetReceivedTimeStampAttributeType `json:"receivedTimeStamp"` + // Region from which the event has been emitted. + // REQUIRED + Region AuditLogEntryGetRegionAttributeType `json:"region"` + // REQUIRED + Request AuditLogEntryGetRequestAttributeType `json:"request"` + // Unique id of the resource that is target of the operation + ResourceId AuditLogEntryGetResourceIdAttributeType `json:"resourceId,omitempty"` + // Name of the resource that is target of the operation + ResourceName AuditLogEntryGetResourceNameAttributeType `json:"resourceName,omitempty"` + // Object representing the change resulting from this event. May be omitted if no change has been applied. May contain arbitrary data. + Result AuditLogEntryGetResultAttributeType `json:"result,omitempty"` + ServiceAccountDelegationInfo AuditLogEntryGetServiceAccountDelegationInfoAttributeType `json:"serviceAccountDelegationInfo,omitempty"` + // The severity of this request. + // REQUIRED + Severity AuditLogEntryGetSeverityAttributeType `json:"severity"` + // IP address that the request was made from + // REQUIRED + SourceIpAddress AuditLogEntryGetSourceIpAddressAttributeType `json:"sourceIpAddress"` + // Agent through which the request was made from (e.g. Portal, CLI, SDK, ...) + // REQUIRED + UserAgent AuditLogEntryGetUserAgentAttributeType `json:"userAgent"` + // PUBLIC for entries that are intended for end users, while PRIVATE entries can only be viewed with system privileges. + // REQUIRED + Visibility AuditLogEntryGetVisibilityAttributeType `json:"visibility"` +} + +type _AuditLogEntry AuditLogEntry + +// NewAuditLogEntry instantiates a new AuditLogEntry 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 NewAuditLogEntry(eventName AuditLogEntryGetEventNameArgType, eventSource AuditLogEntryGetEventSourceArgType, eventTimeStamp AuditLogEntryGetEventTimeStampArgType, eventType AuditLogEntryGetEventTypeArgType, eventVersion AuditLogEntryGetEventVersionArgType, id AuditLogEntryGetIdArgType, initiator AuditLogEntryGetInitiatorArgType, receivedTimeStamp AuditLogEntryGetReceivedTimeStampArgType, region AuditLogEntryGetRegionArgType, request AuditLogEntryGetRequestArgType, severity AuditLogEntryGetSeverityArgType, sourceIpAddress AuditLogEntryGetSourceIpAddressArgType, userAgent AuditLogEntryGetUserAgentArgType, visibility AuditLogEntryGetVisibilityArgType) *AuditLogEntry { + this := AuditLogEntry{} + setAuditLogEntryGetEventNameAttributeType(&this.EventName, eventName) + setAuditLogEntryGetEventSourceAttributeType(&this.EventSource, eventSource) + setAuditLogEntryGetEventTimeStampAttributeType(&this.EventTimeStamp, eventTimeStamp) + setAuditLogEntryGetEventTypeAttributeType(&this.EventType, eventType) + setAuditLogEntryGetEventVersionAttributeType(&this.EventVersion, eventVersion) + setAuditLogEntryGetIdAttributeType(&this.Id, id) + setAuditLogEntryGetInitiatorAttributeType(&this.Initiator, initiator) + setAuditLogEntryGetReceivedTimeStampAttributeType(&this.ReceivedTimeStamp, receivedTimeStamp) + setAuditLogEntryGetRegionAttributeType(&this.Region, region) + setAuditLogEntryGetRequestAttributeType(&this.Request, request) + setAuditLogEntryGetSeverityAttributeType(&this.Severity, severity) + setAuditLogEntryGetSourceIpAddressAttributeType(&this.SourceIpAddress, sourceIpAddress) + setAuditLogEntryGetUserAgentAttributeType(&this.UserAgent, userAgent) + setAuditLogEntryGetVisibilityAttributeType(&this.Visibility, visibility) + return &this +} + +// NewAuditLogEntryWithDefaults instantiates a new AuditLogEntry 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 NewAuditLogEntryWithDefaults() *AuditLogEntry { + this := AuditLogEntry{} + return &this +} + +// GetContext returns the Context field value if set, zero value otherwise. +func (o *AuditLogEntry) GetContext() (res AuditLogEntryGetContextRetType) { + res, _ = o.GetContextOk() + return +} + +// GetContextOk returns a tuple with the Context field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AuditLogEntry) GetContextOk() (ret AuditLogEntryGetContextRetType, ok bool) { + return getAuditLogEntryGetContextAttributeTypeOk(o.Context) +} + +// HasContext returns a boolean if a field has been set. +func (o *AuditLogEntry) HasContext() bool { + _, ok := o.GetContextOk() + return ok +} + +// SetContext gets a reference to the given Context and assigns it to the Context field. +func (o *AuditLogEntry) SetContext(v AuditLogEntryGetContextRetType) { + setAuditLogEntryGetContextAttributeType(&o.Context, v) +} + +// GetCorrelationId returns the CorrelationId field value if set, zero value otherwise. +func (o *AuditLogEntry) GetCorrelationId() (res AuditLogEntryGetCorrelationIdRetType) { + res, _ = o.GetCorrelationIdOk() + return +} + +// GetCorrelationIdOk returns a tuple with the CorrelationId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AuditLogEntry) GetCorrelationIdOk() (ret AuditLogEntryGetCorrelationIdRetType, ok bool) { + return getAuditLogEntryGetCorrelationIdAttributeTypeOk(o.CorrelationId) +} + +// HasCorrelationId returns a boolean if a field has been set. +func (o *AuditLogEntry) HasCorrelationId() bool { + _, ok := o.GetCorrelationIdOk() + return ok +} + +// SetCorrelationId gets a reference to the given string and assigns it to the CorrelationId field. +func (o *AuditLogEntry) SetCorrelationId(v AuditLogEntryGetCorrelationIdRetType) { + setAuditLogEntryGetCorrelationIdAttributeType(&o.CorrelationId, v) +} + +// GetDetails returns the Details field value if set, zero value otherwise. +func (o *AuditLogEntry) GetDetails() (res AuditLogEntryGetDetailsRetType) { + res, _ = o.GetDetailsOk() + return +} + +// GetDetailsOk returns a tuple with the Details field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AuditLogEntry) GetDetailsOk() (ret AuditLogEntryGetDetailsRetType, ok bool) { + return getAuditLogEntryGetDetailsAttributeTypeOk(o.Details) +} + +// HasDetails returns a boolean if a field has been set. +func (o *AuditLogEntry) HasDetails() bool { + _, ok := o.GetDetailsOk() + return ok +} + +// SetDetails gets a reference to the given map[string]interface{} and assigns it to the Details field. +func (o *AuditLogEntry) SetDetails(v AuditLogEntryGetDetailsRetType) { + setAuditLogEntryGetDetailsAttributeType(&o.Details, v) +} + +// GetEventName returns the EventName field value +func (o *AuditLogEntry) GetEventName() (ret AuditLogEntryGetEventNameRetType) { + ret, _ = o.GetEventNameOk() + return ret +} + +// GetEventNameOk returns a tuple with the EventName field value +// and a boolean to check if the value has been set. +func (o *AuditLogEntry) GetEventNameOk() (ret AuditLogEntryGetEventNameRetType, ok bool) { + return getAuditLogEntryGetEventNameAttributeTypeOk(o.EventName) +} + +// SetEventName sets field value +func (o *AuditLogEntry) SetEventName(v AuditLogEntryGetEventNameRetType) { + setAuditLogEntryGetEventNameAttributeType(&o.EventName, v) +} + +// GetEventSource returns the EventSource field value +func (o *AuditLogEntry) GetEventSource() (ret AuditLogEntryGetEventSourceRetType) { + ret, _ = o.GetEventSourceOk() + return ret +} + +// GetEventSourceOk returns a tuple with the EventSource field value +// and a boolean to check if the value has been set. +func (o *AuditLogEntry) GetEventSourceOk() (ret AuditLogEntryGetEventSourceRetType, ok bool) { + return getAuditLogEntryGetEventSourceAttributeTypeOk(o.EventSource) +} + +// SetEventSource sets field value +func (o *AuditLogEntry) SetEventSource(v AuditLogEntryGetEventSourceRetType) { + setAuditLogEntryGetEventSourceAttributeType(&o.EventSource, v) +} + +// GetEventTimeStamp returns the EventTimeStamp field value +func (o *AuditLogEntry) GetEventTimeStamp() (ret AuditLogEntryGetEventTimeStampRetType) { + ret, _ = o.GetEventTimeStampOk() + return ret +} + +// GetEventTimeStampOk returns a tuple with the EventTimeStamp field value +// and a boolean to check if the value has been set. +func (o *AuditLogEntry) GetEventTimeStampOk() (ret AuditLogEntryGetEventTimeStampRetType, ok bool) { + return getAuditLogEntryGetEventTimeStampAttributeTypeOk(o.EventTimeStamp) +} + +// SetEventTimeStamp sets field value +func (o *AuditLogEntry) SetEventTimeStamp(v AuditLogEntryGetEventTimeStampRetType) { + setAuditLogEntryGetEventTimeStampAttributeType(&o.EventTimeStamp, v) +} + +// GetEventType returns the EventType field value +func (o *AuditLogEntry) GetEventType() (ret AuditLogEntryGetEventTypeRetType) { + ret, _ = o.GetEventTypeOk() + return ret +} + +// GetEventTypeOk returns a tuple with the EventType field value +// and a boolean to check if the value has been set. +func (o *AuditLogEntry) GetEventTypeOk() (ret AuditLogEntryGetEventTypeRetType, ok bool) { + return getAuditLogEntryGetEventTypeAttributeTypeOk(o.EventType) +} + +// SetEventType sets field value +func (o *AuditLogEntry) SetEventType(v AuditLogEntryGetEventTypeRetType) { + setAuditLogEntryGetEventTypeAttributeType(&o.EventType, v) +} + +// GetEventVersion returns the EventVersion field value +func (o *AuditLogEntry) GetEventVersion() (ret AuditLogEntryGetEventVersionRetType) { + ret, _ = o.GetEventVersionOk() + return ret +} + +// GetEventVersionOk returns a tuple with the EventVersion field value +// and a boolean to check if the value has been set. +func (o *AuditLogEntry) GetEventVersionOk() (ret AuditLogEntryGetEventVersionRetType, ok bool) { + return getAuditLogEntryGetEventVersionAttributeTypeOk(o.EventVersion) +} + +// SetEventVersion sets field value +func (o *AuditLogEntry) SetEventVersion(v AuditLogEntryGetEventVersionRetType) { + setAuditLogEntryGetEventVersionAttributeType(&o.EventVersion, v) +} + +// GetId returns the Id field value +func (o *AuditLogEntry) GetId() (ret AuditLogEntryGetIdRetType) { + ret, _ = o.GetIdOk() + return ret +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *AuditLogEntry) GetIdOk() (ret AuditLogEntryGetIdRetType, ok bool) { + return getAuditLogEntryGetIdAttributeTypeOk(o.Id) +} + +// SetId sets field value +func (o *AuditLogEntry) SetId(v AuditLogEntryGetIdRetType) { + setAuditLogEntryGetIdAttributeType(&o.Id, v) +} + +// GetInitiator returns the Initiator field value +func (o *AuditLogEntry) GetInitiator() (ret AuditLogEntryGetInitiatorRetType) { + ret, _ = o.GetInitiatorOk() + return ret +} + +// GetInitiatorOk returns a tuple with the Initiator field value +// and a boolean to check if the value has been set. +func (o *AuditLogEntry) GetInitiatorOk() (ret AuditLogEntryGetInitiatorRetType, ok bool) { + return getAuditLogEntryGetInitiatorAttributeTypeOk(o.Initiator) +} + +// SetInitiator sets field value +func (o *AuditLogEntry) SetInitiator(v AuditLogEntryGetInitiatorRetType) { + setAuditLogEntryGetInitiatorAttributeType(&o.Initiator, v) +} + +// GetReceivedTimeStamp returns the ReceivedTimeStamp field value +func (o *AuditLogEntry) GetReceivedTimeStamp() (ret AuditLogEntryGetReceivedTimeStampRetType) { + ret, _ = o.GetReceivedTimeStampOk() + return ret +} + +// GetReceivedTimeStampOk returns a tuple with the ReceivedTimeStamp field value +// and a boolean to check if the value has been set. +func (o *AuditLogEntry) GetReceivedTimeStampOk() (ret AuditLogEntryGetReceivedTimeStampRetType, ok bool) { + return getAuditLogEntryGetReceivedTimeStampAttributeTypeOk(o.ReceivedTimeStamp) +} + +// SetReceivedTimeStamp sets field value +func (o *AuditLogEntry) SetReceivedTimeStamp(v AuditLogEntryGetReceivedTimeStampRetType) { + setAuditLogEntryGetReceivedTimeStampAttributeType(&o.ReceivedTimeStamp, v) +} + +// GetRegion returns the Region field value +func (o *AuditLogEntry) GetRegion() (ret AuditLogEntryGetRegionRetType) { + ret, _ = o.GetRegionOk() + return ret +} + +// GetRegionOk returns a tuple with the Region field value +// and a boolean to check if the value has been set. +func (o *AuditLogEntry) GetRegionOk() (ret AuditLogEntryGetRegionRetType, ok bool) { + return getAuditLogEntryGetRegionAttributeTypeOk(o.Region) +} + +// SetRegion sets field value +func (o *AuditLogEntry) SetRegion(v AuditLogEntryGetRegionRetType) { + setAuditLogEntryGetRegionAttributeType(&o.Region, v) +} + +// GetRequest returns the Request field value +func (o *AuditLogEntry) GetRequest() (ret AuditLogEntryGetRequestRetType) { + ret, _ = o.GetRequestOk() + return ret +} + +// GetRequestOk returns a tuple with the Request field value +// and a boolean to check if the value has been set. +func (o *AuditLogEntry) GetRequestOk() (ret AuditLogEntryGetRequestRetType, ok bool) { + return getAuditLogEntryGetRequestAttributeTypeOk(o.Request) +} + +// SetRequest sets field value +func (o *AuditLogEntry) SetRequest(v AuditLogEntryGetRequestRetType) { + setAuditLogEntryGetRequestAttributeType(&o.Request, v) +} + +// GetResourceId returns the ResourceId field value if set, zero value otherwise. +func (o *AuditLogEntry) GetResourceId() (res AuditLogEntryGetResourceIdRetType) { + res, _ = o.GetResourceIdOk() + return +} + +// GetResourceIdOk returns a tuple with the ResourceId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AuditLogEntry) GetResourceIdOk() (ret AuditLogEntryGetResourceIdRetType, ok bool) { + return getAuditLogEntryGetResourceIdAttributeTypeOk(o.ResourceId) +} + +// HasResourceId returns a boolean if a field has been set. +func (o *AuditLogEntry) HasResourceId() bool { + _, ok := o.GetResourceIdOk() + return ok +} + +// SetResourceId gets a reference to the given string and assigns it to the ResourceId field. +func (o *AuditLogEntry) SetResourceId(v AuditLogEntryGetResourceIdRetType) { + setAuditLogEntryGetResourceIdAttributeType(&o.ResourceId, v) +} + +// GetResourceName returns the ResourceName field value if set, zero value otherwise. +func (o *AuditLogEntry) GetResourceName() (res AuditLogEntryGetResourceNameRetType) { + res, _ = o.GetResourceNameOk() + return +} + +// GetResourceNameOk returns a tuple with the ResourceName field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AuditLogEntry) GetResourceNameOk() (ret AuditLogEntryGetResourceNameRetType, ok bool) { + return getAuditLogEntryGetResourceNameAttributeTypeOk(o.ResourceName) +} + +// HasResourceName returns a boolean if a field has been set. +func (o *AuditLogEntry) HasResourceName() bool { + _, ok := o.GetResourceNameOk() + return ok +} + +// SetResourceName gets a reference to the given string and assigns it to the ResourceName field. +func (o *AuditLogEntry) SetResourceName(v AuditLogEntryGetResourceNameRetType) { + setAuditLogEntryGetResourceNameAttributeType(&o.ResourceName, v) +} + +// GetResult returns the Result field value if set, zero value otherwise. +func (o *AuditLogEntry) GetResult() (res AuditLogEntryGetResultRetType) { + res, _ = o.GetResultOk() + return +} + +// GetResultOk returns a tuple with the Result field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AuditLogEntry) GetResultOk() (ret AuditLogEntryGetResultRetType, ok bool) { + return getAuditLogEntryGetResultAttributeTypeOk(o.Result) +} + +// HasResult returns a boolean if a field has been set. +func (o *AuditLogEntry) HasResult() bool { + _, ok := o.GetResultOk() + return ok +} + +// SetResult gets a reference to the given map[string]interface{} and assigns it to the Result field. +func (o *AuditLogEntry) SetResult(v AuditLogEntryGetResultRetType) { + setAuditLogEntryGetResultAttributeType(&o.Result, v) +} + +// GetServiceAccountDelegationInfo returns the ServiceAccountDelegationInfo field value if set, zero value otherwise. +func (o *AuditLogEntry) GetServiceAccountDelegationInfo() (res AuditLogEntryGetServiceAccountDelegationInfoRetType) { + res, _ = o.GetServiceAccountDelegationInfoOk() + return +} + +// GetServiceAccountDelegationInfoOk returns a tuple with the ServiceAccountDelegationInfo field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AuditLogEntry) GetServiceAccountDelegationInfoOk() (ret AuditLogEntryGetServiceAccountDelegationInfoRetType, ok bool) { + return getAuditLogEntryGetServiceAccountDelegationInfoAttributeTypeOk(o.ServiceAccountDelegationInfo) +} + +// HasServiceAccountDelegationInfo returns a boolean if a field has been set. +func (o *AuditLogEntry) HasServiceAccountDelegationInfo() bool { + _, ok := o.GetServiceAccountDelegationInfoOk() + return ok +} + +// SetServiceAccountDelegationInfo gets a reference to the given ServiceAccountDelegationInfo and assigns it to the ServiceAccountDelegationInfo field. +func (o *AuditLogEntry) SetServiceAccountDelegationInfo(v AuditLogEntryGetServiceAccountDelegationInfoRetType) { + setAuditLogEntryGetServiceAccountDelegationInfoAttributeType(&o.ServiceAccountDelegationInfo, v) +} + +// GetSeverity returns the Severity field value +func (o *AuditLogEntry) GetSeverity() (ret AuditLogEntryGetSeverityRetType) { + ret, _ = o.GetSeverityOk() + return ret +} + +// GetSeverityOk returns a tuple with the Severity field value +// and a boolean to check if the value has been set. +func (o *AuditLogEntry) GetSeverityOk() (ret AuditLogEntryGetSeverityRetType, ok bool) { + return getAuditLogEntryGetSeverityAttributeTypeOk(o.Severity) +} + +// SetSeverity sets field value +func (o *AuditLogEntry) SetSeverity(v AuditLogEntryGetSeverityRetType) { + setAuditLogEntryGetSeverityAttributeType(&o.Severity, v) +} + +// GetSourceIpAddress returns the SourceIpAddress field value +func (o *AuditLogEntry) GetSourceIpAddress() (ret AuditLogEntryGetSourceIpAddressRetType) { + ret, _ = o.GetSourceIpAddressOk() + return ret +} + +// GetSourceIpAddressOk returns a tuple with the SourceIpAddress field value +// and a boolean to check if the value has been set. +func (o *AuditLogEntry) GetSourceIpAddressOk() (ret AuditLogEntryGetSourceIpAddressRetType, ok bool) { + return getAuditLogEntryGetSourceIpAddressAttributeTypeOk(o.SourceIpAddress) +} + +// SetSourceIpAddress sets field value +func (o *AuditLogEntry) SetSourceIpAddress(v AuditLogEntryGetSourceIpAddressRetType) { + setAuditLogEntryGetSourceIpAddressAttributeType(&o.SourceIpAddress, v) +} + +// GetUserAgent returns the UserAgent field value +func (o *AuditLogEntry) GetUserAgent() (ret AuditLogEntryGetUserAgentRetType) { + ret, _ = o.GetUserAgentOk() + return ret +} + +// GetUserAgentOk returns a tuple with the UserAgent field value +// and a boolean to check if the value has been set. +func (o *AuditLogEntry) GetUserAgentOk() (ret AuditLogEntryGetUserAgentRetType, ok bool) { + return getAuditLogEntryGetUserAgentAttributeTypeOk(o.UserAgent) +} + +// SetUserAgent sets field value +func (o *AuditLogEntry) SetUserAgent(v AuditLogEntryGetUserAgentRetType) { + setAuditLogEntryGetUserAgentAttributeType(&o.UserAgent, v) +} + +// GetVisibility returns the Visibility field value +func (o *AuditLogEntry) GetVisibility() (ret AuditLogEntryGetVisibilityRetType) { + ret, _ = o.GetVisibilityOk() + return ret +} + +// GetVisibilityOk returns a tuple with the Visibility field value +// and a boolean to check if the value has been set. +func (o *AuditLogEntry) GetVisibilityOk() (ret AuditLogEntryGetVisibilityRetType, ok bool) { + return getAuditLogEntryGetVisibilityAttributeTypeOk(o.Visibility) +} + +// SetVisibility sets field value +func (o *AuditLogEntry) SetVisibility(v AuditLogEntryGetVisibilityRetType) { + setAuditLogEntryGetVisibilityAttributeType(&o.Visibility, v) +} + +func (o AuditLogEntry) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getAuditLogEntryGetContextAttributeTypeOk(o.Context); ok { + toSerialize["Context"] = val + } + if val, ok := getAuditLogEntryGetCorrelationIdAttributeTypeOk(o.CorrelationId); ok { + toSerialize["CorrelationId"] = val + } + if val, ok := getAuditLogEntryGetDetailsAttributeTypeOk(o.Details); ok { + toSerialize["Details"] = val + } + if val, ok := getAuditLogEntryGetEventNameAttributeTypeOk(o.EventName); ok { + toSerialize["EventName"] = val + } + if val, ok := getAuditLogEntryGetEventSourceAttributeTypeOk(o.EventSource); ok { + toSerialize["EventSource"] = val + } + if val, ok := getAuditLogEntryGetEventTimeStampAttributeTypeOk(o.EventTimeStamp); ok { + toSerialize["EventTimeStamp"] = val + } + if val, ok := getAuditLogEntryGetEventTypeAttributeTypeOk(o.EventType); ok { + toSerialize["EventType"] = val + } + if val, ok := getAuditLogEntryGetEventVersionAttributeTypeOk(o.EventVersion); ok { + toSerialize["EventVersion"] = val + } + if val, ok := getAuditLogEntryGetIdAttributeTypeOk(o.Id); ok { + toSerialize["Id"] = val + } + if val, ok := getAuditLogEntryGetInitiatorAttributeTypeOk(o.Initiator); ok { + toSerialize["Initiator"] = val + } + if val, ok := getAuditLogEntryGetReceivedTimeStampAttributeTypeOk(o.ReceivedTimeStamp); ok { + toSerialize["ReceivedTimeStamp"] = val + } + if val, ok := getAuditLogEntryGetRegionAttributeTypeOk(o.Region); ok { + toSerialize["Region"] = val + } + if val, ok := getAuditLogEntryGetRequestAttributeTypeOk(o.Request); ok { + toSerialize["Request"] = val + } + if val, ok := getAuditLogEntryGetResourceIdAttributeTypeOk(o.ResourceId); ok { + toSerialize["ResourceId"] = val + } + if val, ok := getAuditLogEntryGetResourceNameAttributeTypeOk(o.ResourceName); ok { + toSerialize["ResourceName"] = val + } + if val, ok := getAuditLogEntryGetResultAttributeTypeOk(o.Result); ok { + toSerialize["Result"] = val + } + if val, ok := getAuditLogEntryGetServiceAccountDelegationInfoAttributeTypeOk(o.ServiceAccountDelegationInfo); ok { + toSerialize["ServiceAccountDelegationInfo"] = val + } + if val, ok := getAuditLogEntryGetSeverityAttributeTypeOk(o.Severity); ok { + toSerialize["Severity"] = val + } + if val, ok := getAuditLogEntryGetSourceIpAddressAttributeTypeOk(o.SourceIpAddress); ok { + toSerialize["SourceIpAddress"] = val + } + if val, ok := getAuditLogEntryGetUserAgentAttributeTypeOk(o.UserAgent); ok { + toSerialize["UserAgent"] = val + } + if val, ok := getAuditLogEntryGetVisibilityAttributeTypeOk(o.Visibility); ok { + toSerialize["Visibility"] = val + } + return toSerialize, nil +} + +type NullableAuditLogEntry struct { + value *AuditLogEntry + isSet bool +} + +func (v NullableAuditLogEntry) Get() *AuditLogEntry { + return v.value +} + +func (v *NullableAuditLogEntry) Set(val *AuditLogEntry) { + v.value = val + v.isSet = true +} + +func (v NullableAuditLogEntry) IsSet() bool { + return v.isSet +} + +func (v *NullableAuditLogEntry) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableAuditLogEntry(val *AuditLogEntry) *NullableAuditLogEntry { + return &NullableAuditLogEntry{value: val, isSet: true} +} + +func (v NullableAuditLogEntry) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableAuditLogEntry) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/auditlog/model_audit_log_entry_test.go b/services/auditlog/model_audit_log_entry_test.go new file mode 100644 index 00000000..a90463b4 --- /dev/null +++ b/services/auditlog/model_audit_log_entry_test.go @@ -0,0 +1,151 @@ +/* +Audit Log API + +API Endpoints to retrieve recorded actions and resulting changes in the system. ### Audit Logging Changes on organizations, folders and projects and respective cloud resources are logged and collected in the audit log. ### API Constraints The audit log API allows to download messages from the last 90 days. The maximum duration that can be queried at once is 24 hours. Requests are rate limited - the current maximum is 1 request per second. + +API version: 2.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package auditlog + +import ( + "testing" +) + +// isEnum + +func TestAuditLogEntryEventType_UnmarshalJSON(t *testing.T) { + type args struct { + src []byte + } + tests := []struct { + name string + args args + wantErr bool + }{ + { + name: `success - possible enum value no. 1`, + args: args{ + src: []byte(`"ADMIN_ACTIVITY"`), + }, + wantErr: false, + }, + { + name: `success - possible enum value no. 2`, + args: args{ + src: []byte(`"SYSTEM_EVENT"`), + }, + wantErr: false, + }, + { + name: `success - possible enum value no. 3`, + args: args{ + src: []byte(`"POLICY_DENIED"`), + }, + wantErr: false, + }, + { + name: "fail", + args: args{ + src: []byte("\"FOOBAR\""), + }, + wantErr: true, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + v := AuditLogEntryEventType("") + if err := v.UnmarshalJSON(tt.args.src); (err != nil) != tt.wantErr { + t.Errorf("UnmarshalJSON() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +} + +// isEnum + +func TestAuditLogEntrySeverity_UnmarshalJSON(t *testing.T) { + type args struct { + src []byte + } + tests := []struct { + name string + args args + wantErr bool + }{ + { + name: `success - possible enum value no. 1`, + args: args{ + src: []byte(`"INFO"`), + }, + wantErr: false, + }, + { + name: `success - possible enum value no. 2`, + args: args{ + src: []byte(`"ERROR"`), + }, + wantErr: false, + }, + { + name: "fail", + args: args{ + src: []byte("\"FOOBAR\""), + }, + wantErr: true, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + v := AuditLogEntrySeverity("") + if err := v.UnmarshalJSON(tt.args.src); (err != nil) != tt.wantErr { + t.Errorf("UnmarshalJSON() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +} + +// isEnum + +func TestAuditLogEntryVisibility_UnmarshalJSON(t *testing.T) { + type args struct { + src []byte + } + tests := []struct { + name string + args args + wantErr bool + }{ + { + name: `success - possible enum value no. 1`, + args: args{ + src: []byte(`"PUBLIC"`), + }, + wantErr: false, + }, + { + name: `success - possible enum value no. 2`, + args: args{ + src: []byte(`"PRIVATE"`), + }, + wantErr: false, + }, + { + name: "fail", + args: args{ + src: []byte("\"FOOBAR\""), + }, + wantErr: true, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + v := AuditLogEntryVisibility("") + if err := v.UnmarshalJSON(tt.args.src); (err != nil) != tt.wantErr { + t.Errorf("UnmarshalJSON() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +} diff --git a/services/auditlog/model_context.go b/services/auditlog/model_context.go new file mode 100644 index 00000000..a9aa2e10 --- /dev/null +++ b/services/auditlog/model_context.go @@ -0,0 +1,227 @@ +/* +Audit Log API + +API Endpoints to retrieve recorded actions and resulting changes in the system. ### Audit Logging Changes on organizations, folders and projects and respective cloud resources are logged and collected in the audit log. ### API Constraints The audit log API allows to download messages from the last 90 days. The maximum duration that can be queried at once is 24 hours. Requests are rate limited - the current maximum is 1 request per second. + +API version: 2.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package auditlog + +import ( + "encoding/json" +) + +// checks if the Context type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &Context{} + +/* + types and functions for folderId +*/ + +// isNotNullableString +type ContextGetFolderIdAttributeType = *string + +func getContextGetFolderIdAttributeTypeOk(arg ContextGetFolderIdAttributeType) (ret ContextGetFolderIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setContextGetFolderIdAttributeType(arg *ContextGetFolderIdAttributeType, val ContextGetFolderIdRetType) { + *arg = &val +} + +type ContextGetFolderIdArgType = string +type ContextGetFolderIdRetType = string + +/* + types and functions for organizationId +*/ + +// isNotNullableString +type ContextGetOrganizationIdAttributeType = *string + +func getContextGetOrganizationIdAttributeTypeOk(arg ContextGetOrganizationIdAttributeType) (ret ContextGetOrganizationIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setContextGetOrganizationIdAttributeType(arg *ContextGetOrganizationIdAttributeType, val ContextGetOrganizationIdRetType) { + *arg = &val +} + +type ContextGetOrganizationIdArgType = string +type ContextGetOrganizationIdRetType = string + +/* + types and functions for projectId +*/ + +// isNotNullableString +type ContextGetProjectIdAttributeType = *string + +func getContextGetProjectIdAttributeTypeOk(arg ContextGetProjectIdAttributeType) (ret ContextGetProjectIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setContextGetProjectIdAttributeType(arg *ContextGetProjectIdAttributeType, val ContextGetProjectIdRetType) { + *arg = &val +} + +type ContextGetProjectIdArgType = string +type ContextGetProjectIdRetType = string + +// Context Request context +type Context struct { + // Folder id + FolderId ContextGetFolderIdAttributeType `json:"folderId,omitempty"` + // Organization id + OrganizationId ContextGetOrganizationIdAttributeType `json:"organizationId,omitempty"` + // Project id + ProjectId ContextGetProjectIdAttributeType `json:"projectId,omitempty"` +} + +// NewContext instantiates a new Context 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 NewContext() *Context { + this := Context{} + return &this +} + +// NewContextWithDefaults instantiates a new Context 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 NewContextWithDefaults() *Context { + this := Context{} + return &this +} + +// GetFolderId returns the FolderId field value if set, zero value otherwise. +func (o *Context) GetFolderId() (res ContextGetFolderIdRetType) { + res, _ = o.GetFolderIdOk() + return +} + +// GetFolderIdOk returns a tuple with the FolderId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Context) GetFolderIdOk() (ret ContextGetFolderIdRetType, ok bool) { + return getContextGetFolderIdAttributeTypeOk(o.FolderId) +} + +// HasFolderId returns a boolean if a field has been set. +func (o *Context) HasFolderId() bool { + _, ok := o.GetFolderIdOk() + return ok +} + +// SetFolderId gets a reference to the given string and assigns it to the FolderId field. +func (o *Context) SetFolderId(v ContextGetFolderIdRetType) { + setContextGetFolderIdAttributeType(&o.FolderId, v) +} + +// GetOrganizationId returns the OrganizationId field value if set, zero value otherwise. +func (o *Context) GetOrganizationId() (res ContextGetOrganizationIdRetType) { + res, _ = o.GetOrganizationIdOk() + return +} + +// GetOrganizationIdOk returns a tuple with the OrganizationId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Context) GetOrganizationIdOk() (ret ContextGetOrganizationIdRetType, ok bool) { + return getContextGetOrganizationIdAttributeTypeOk(o.OrganizationId) +} + +// HasOrganizationId returns a boolean if a field has been set. +func (o *Context) HasOrganizationId() bool { + _, ok := o.GetOrganizationIdOk() + return ok +} + +// SetOrganizationId gets a reference to the given string and assigns it to the OrganizationId field. +func (o *Context) SetOrganizationId(v ContextGetOrganizationIdRetType) { + setContextGetOrganizationIdAttributeType(&o.OrganizationId, v) +} + +// GetProjectId returns the ProjectId field value if set, zero value otherwise. +func (o *Context) GetProjectId() (res ContextGetProjectIdRetType) { + res, _ = o.GetProjectIdOk() + return +} + +// GetProjectIdOk returns a tuple with the ProjectId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Context) GetProjectIdOk() (ret ContextGetProjectIdRetType, ok bool) { + return getContextGetProjectIdAttributeTypeOk(o.ProjectId) +} + +// HasProjectId returns a boolean if a field has been set. +func (o *Context) HasProjectId() bool { + _, ok := o.GetProjectIdOk() + return ok +} + +// SetProjectId gets a reference to the given string and assigns it to the ProjectId field. +func (o *Context) SetProjectId(v ContextGetProjectIdRetType) { + setContextGetProjectIdAttributeType(&o.ProjectId, v) +} + +func (o Context) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getContextGetFolderIdAttributeTypeOk(o.FolderId); ok { + toSerialize["FolderId"] = val + } + if val, ok := getContextGetOrganizationIdAttributeTypeOk(o.OrganizationId); ok { + toSerialize["OrganizationId"] = val + } + if val, ok := getContextGetProjectIdAttributeTypeOk(o.ProjectId); ok { + toSerialize["ProjectId"] = val + } + return toSerialize, nil +} + +type NullableContext struct { + value *Context + isSet bool +} + +func (v NullableContext) Get() *Context { + return v.value +} + +func (v *NullableContext) Set(val *Context) { + v.value = val + v.isSet = true +} + +func (v NullableContext) IsSet() bool { + return v.isSet +} + +func (v *NullableContext) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableContext(val *Context) *NullableContext { + return &NullableContext{value: val, isSet: true} +} + +func (v NullableContext) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableContext) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/auditlog/model_context_test.go b/services/auditlog/model_context_test.go new file mode 100644 index 00000000..6ef23c25 --- /dev/null +++ b/services/auditlog/model_context_test.go @@ -0,0 +1,11 @@ +/* +Audit Log API + +API Endpoints to retrieve recorded actions and resulting changes in the system. ### Audit Logging Changes on organizations, folders and projects and respective cloud resources are logged and collected in the audit log. ### API Constraints The audit log API allows to download messages from the last 90 days. The maximum duration that can be queried at once is 24 hours. Requests are rate limited - the current maximum is 1 request per second. + +API version: 2.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package auditlog diff --git a/services/auditlog/model_delegation_principal.go b/services/auditlog/model_delegation_principal.go new file mode 100644 index 00000000..91bf00b6 --- /dev/null +++ b/services/auditlog/model_delegation_principal.go @@ -0,0 +1,176 @@ +/* +Audit Log API + +API Endpoints to retrieve recorded actions and resulting changes in the system. ### Audit Logging Changes on organizations, folders and projects and respective cloud resources are logged and collected in the audit log. ### API Constraints The audit log API allows to download messages from the last 90 days. The maximum duration that can be queried at once is 24 hours. Requests are rate limited - the current maximum is 1 request per second. + +API version: 2.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package auditlog + +import ( + "encoding/json" +) + +// checks if the DelegationPrincipal type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &DelegationPrincipal{} + +/* + types and functions for email +*/ + +// isNotNullableString +type DelegationPrincipalGetEmailAttributeType = *string + +func getDelegationPrincipalGetEmailAttributeTypeOk(arg DelegationPrincipalGetEmailAttributeType) (ret DelegationPrincipalGetEmailRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDelegationPrincipalGetEmailAttributeType(arg *DelegationPrincipalGetEmailAttributeType, val DelegationPrincipalGetEmailRetType) { + *arg = &val +} + +type DelegationPrincipalGetEmailArgType = string +type DelegationPrincipalGetEmailRetType = string + +/* + types and functions for id +*/ + +// isNotNullableString +type DelegationPrincipalGetIdAttributeType = *string + +func getDelegationPrincipalGetIdAttributeTypeOk(arg DelegationPrincipalGetIdAttributeType) (ret DelegationPrincipalGetIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDelegationPrincipalGetIdAttributeType(arg *DelegationPrincipalGetIdAttributeType, val DelegationPrincipalGetIdRetType) { + *arg = &val +} + +type DelegationPrincipalGetIdArgType = string +type DelegationPrincipalGetIdRetType = string + +// DelegationPrincipal Principal in delegation chain of a service account +type DelegationPrincipal struct { + // E-Mail of the subject + Email DelegationPrincipalGetEmailAttributeType `json:"email,omitempty"` + // Unique identifier of the subject + // REQUIRED + Id DelegationPrincipalGetIdAttributeType `json:"id"` +} + +type _DelegationPrincipal DelegationPrincipal + +// NewDelegationPrincipal instantiates a new DelegationPrincipal 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 NewDelegationPrincipal(id DelegationPrincipalGetIdArgType) *DelegationPrincipal { + this := DelegationPrincipal{} + setDelegationPrincipalGetIdAttributeType(&this.Id, id) + return &this +} + +// NewDelegationPrincipalWithDefaults instantiates a new DelegationPrincipal 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 NewDelegationPrincipalWithDefaults() *DelegationPrincipal { + this := DelegationPrincipal{} + return &this +} + +// GetEmail returns the Email field value if set, zero value otherwise. +func (o *DelegationPrincipal) GetEmail() (res DelegationPrincipalGetEmailRetType) { + res, _ = o.GetEmailOk() + return +} + +// GetEmailOk returns a tuple with the Email field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DelegationPrincipal) GetEmailOk() (ret DelegationPrincipalGetEmailRetType, ok bool) { + return getDelegationPrincipalGetEmailAttributeTypeOk(o.Email) +} + +// HasEmail returns a boolean if a field has been set. +func (o *DelegationPrincipal) HasEmail() bool { + _, ok := o.GetEmailOk() + return ok +} + +// SetEmail gets a reference to the given string and assigns it to the Email field. +func (o *DelegationPrincipal) SetEmail(v DelegationPrincipalGetEmailRetType) { + setDelegationPrincipalGetEmailAttributeType(&o.Email, v) +} + +// GetId returns the Id field value +func (o *DelegationPrincipal) GetId() (ret DelegationPrincipalGetIdRetType) { + ret, _ = o.GetIdOk() + return ret +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *DelegationPrincipal) GetIdOk() (ret DelegationPrincipalGetIdRetType, ok bool) { + return getDelegationPrincipalGetIdAttributeTypeOk(o.Id) +} + +// SetId sets field value +func (o *DelegationPrincipal) SetId(v DelegationPrincipalGetIdRetType) { + setDelegationPrincipalGetIdAttributeType(&o.Id, v) +} + +func (o DelegationPrincipal) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getDelegationPrincipalGetEmailAttributeTypeOk(o.Email); ok { + toSerialize["Email"] = val + } + if val, ok := getDelegationPrincipalGetIdAttributeTypeOk(o.Id); ok { + toSerialize["Id"] = val + } + return toSerialize, nil +} + +type NullableDelegationPrincipal struct { + value *DelegationPrincipal + isSet bool +} + +func (v NullableDelegationPrincipal) Get() *DelegationPrincipal { + return v.value +} + +func (v *NullableDelegationPrincipal) Set(val *DelegationPrincipal) { + v.value = val + v.isSet = true +} + +func (v NullableDelegationPrincipal) IsSet() bool { + return v.isSet +} + +func (v *NullableDelegationPrincipal) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableDelegationPrincipal(val *DelegationPrincipal) *NullableDelegationPrincipal { + return &NullableDelegationPrincipal{value: val, isSet: true} +} + +func (v NullableDelegationPrincipal) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableDelegationPrincipal) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/auditlog/model_delegation_principal_test.go b/services/auditlog/model_delegation_principal_test.go new file mode 100644 index 00000000..6ef23c25 --- /dev/null +++ b/services/auditlog/model_delegation_principal_test.go @@ -0,0 +1,11 @@ +/* +Audit Log API + +API Endpoints to retrieve recorded actions and resulting changes in the system. ### Audit Logging Changes on organizations, folders and projects and respective cloud resources are logged and collected in the audit log. ### API Constraints The audit log API allows to download messages from the last 90 days. The maximum duration that can be queried at once is 24 hours. Requests are rate limited - the current maximum is 1 request per second. + +API version: 2.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package auditlog diff --git a/services/auditlog/model_download_folder_audit_entries_200_response.go b/services/auditlog/model_download_folder_audit_entries_200_response.go new file mode 100644 index 00000000..2d541000 --- /dev/null +++ b/services/auditlog/model_download_folder_audit_entries_200_response.go @@ -0,0 +1,226 @@ +/* +Audit Log API + +API Endpoints to retrieve recorded actions and resulting changes in the system. ### Audit Logging Changes on organizations, folders and projects and respective cloud resources are logged and collected in the audit log. ### API Constraints The audit log API allows to download messages from the last 90 days. The maximum duration that can be queried at once is 24 hours. Requests are rate limited - the current maximum is 1 request per second. + +API version: 2.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package auditlog + +import ( + "encoding/json" +) + +// checks if the DownloadFolderAuditEntries200Response type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &DownloadFolderAuditEntries200Response{} + +/* + types and functions for cursor +*/ + +// isNotNullableString +type DownloadFolderAuditEntries200ResponseGetCursorAttributeType = *string + +func getDownloadFolderAuditEntries200ResponseGetCursorAttributeTypeOk(arg DownloadFolderAuditEntries200ResponseGetCursorAttributeType) (ret DownloadFolderAuditEntries200ResponseGetCursorRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDownloadFolderAuditEntries200ResponseGetCursorAttributeType(arg *DownloadFolderAuditEntries200ResponseGetCursorAttributeType, val DownloadFolderAuditEntries200ResponseGetCursorRetType) { + *arg = &val +} + +type DownloadFolderAuditEntries200ResponseGetCursorArgType = string +type DownloadFolderAuditEntries200ResponseGetCursorRetType = string + +/* + types and functions for items +*/ + +// isArray +type DownloadFolderAuditEntries200ResponseGetItemsAttributeType = *[]AuditLogEntry +type DownloadFolderAuditEntries200ResponseGetItemsArgType = []AuditLogEntry +type DownloadFolderAuditEntries200ResponseGetItemsRetType = []AuditLogEntry + +func getDownloadFolderAuditEntries200ResponseGetItemsAttributeTypeOk(arg DownloadFolderAuditEntries200ResponseGetItemsAttributeType) (ret DownloadFolderAuditEntries200ResponseGetItemsRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDownloadFolderAuditEntries200ResponseGetItemsAttributeType(arg *DownloadFolderAuditEntries200ResponseGetItemsAttributeType, val DownloadFolderAuditEntries200ResponseGetItemsRetType) { + *arg = &val +} + +/* + types and functions for limit +*/ + +// isNumber +type DownloadFolderAuditEntries200ResponseGetLimitAttributeType = *float64 +type DownloadFolderAuditEntries200ResponseGetLimitArgType = float64 +type DownloadFolderAuditEntries200ResponseGetLimitRetType = float64 + +func getDownloadFolderAuditEntries200ResponseGetLimitAttributeTypeOk(arg DownloadFolderAuditEntries200ResponseGetLimitAttributeType) (ret DownloadFolderAuditEntries200ResponseGetLimitRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setDownloadFolderAuditEntries200ResponseGetLimitAttributeType(arg *DownloadFolderAuditEntries200ResponseGetLimitAttributeType, val DownloadFolderAuditEntries200ResponseGetLimitRetType) { + *arg = &val +} + +// DownloadFolderAuditEntries200Response struct for DownloadFolderAuditEntries200Response +type DownloadFolderAuditEntries200Response struct { + // Optional cursor if more entries are available + Cursor DownloadFolderAuditEntries200ResponseGetCursorAttributeType `json:"cursor,omitempty"` + Items DownloadFolderAuditEntries200ResponseGetItemsAttributeType `json:"items,omitempty"` + // Maximum amount of entries requested. + Limit DownloadFolderAuditEntries200ResponseGetLimitAttributeType `json:"limit,omitempty"` +} + +// NewDownloadFolderAuditEntries200Response instantiates a new DownloadFolderAuditEntries200Response 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 NewDownloadFolderAuditEntries200Response() *DownloadFolderAuditEntries200Response { + this := DownloadFolderAuditEntries200Response{} + return &this +} + +// NewDownloadFolderAuditEntries200ResponseWithDefaults instantiates a new DownloadFolderAuditEntries200Response 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 NewDownloadFolderAuditEntries200ResponseWithDefaults() *DownloadFolderAuditEntries200Response { + this := DownloadFolderAuditEntries200Response{} + var limit float64 = 50 + this.Limit = &limit + return &this +} + +// GetCursor returns the Cursor field value if set, zero value otherwise. +func (o *DownloadFolderAuditEntries200Response) GetCursor() (res DownloadFolderAuditEntries200ResponseGetCursorRetType) { + res, _ = o.GetCursorOk() + return +} + +// GetCursorOk returns a tuple with the Cursor field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DownloadFolderAuditEntries200Response) GetCursorOk() (ret DownloadFolderAuditEntries200ResponseGetCursorRetType, ok bool) { + return getDownloadFolderAuditEntries200ResponseGetCursorAttributeTypeOk(o.Cursor) +} + +// HasCursor returns a boolean if a field has been set. +func (o *DownloadFolderAuditEntries200Response) HasCursor() bool { + _, ok := o.GetCursorOk() + return ok +} + +// SetCursor gets a reference to the given string and assigns it to the Cursor field. +func (o *DownloadFolderAuditEntries200Response) SetCursor(v DownloadFolderAuditEntries200ResponseGetCursorRetType) { + setDownloadFolderAuditEntries200ResponseGetCursorAttributeType(&o.Cursor, v) +} + +// GetItems returns the Items field value if set, zero value otherwise. +func (o *DownloadFolderAuditEntries200Response) GetItems() (res DownloadFolderAuditEntries200ResponseGetItemsRetType) { + res, _ = o.GetItemsOk() + return +} + +// GetItemsOk returns a tuple with the Items field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DownloadFolderAuditEntries200Response) GetItemsOk() (ret DownloadFolderAuditEntries200ResponseGetItemsRetType, ok bool) { + return getDownloadFolderAuditEntries200ResponseGetItemsAttributeTypeOk(o.Items) +} + +// HasItems returns a boolean if a field has been set. +func (o *DownloadFolderAuditEntries200Response) HasItems() bool { + _, ok := o.GetItemsOk() + return ok +} + +// SetItems gets a reference to the given []AuditLogEntry and assigns it to the Items field. +func (o *DownloadFolderAuditEntries200Response) SetItems(v DownloadFolderAuditEntries200ResponseGetItemsRetType) { + setDownloadFolderAuditEntries200ResponseGetItemsAttributeType(&o.Items, v) +} + +// GetLimit returns the Limit field value if set, zero value otherwise. +func (o *DownloadFolderAuditEntries200Response) GetLimit() (res DownloadFolderAuditEntries200ResponseGetLimitRetType) { + res, _ = o.GetLimitOk() + return +} + +// GetLimitOk returns a tuple with the Limit field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DownloadFolderAuditEntries200Response) GetLimitOk() (ret DownloadFolderAuditEntries200ResponseGetLimitRetType, ok bool) { + return getDownloadFolderAuditEntries200ResponseGetLimitAttributeTypeOk(o.Limit) +} + +// HasLimit returns a boolean if a field has been set. +func (o *DownloadFolderAuditEntries200Response) HasLimit() bool { + _, ok := o.GetLimitOk() + return ok +} + +// SetLimit gets a reference to the given float64 and assigns it to the Limit field. +func (o *DownloadFolderAuditEntries200Response) SetLimit(v DownloadFolderAuditEntries200ResponseGetLimitRetType) { + setDownloadFolderAuditEntries200ResponseGetLimitAttributeType(&o.Limit, v) +} + +func (o DownloadFolderAuditEntries200Response) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getDownloadFolderAuditEntries200ResponseGetCursorAttributeTypeOk(o.Cursor); ok { + toSerialize["Cursor"] = val + } + if val, ok := getDownloadFolderAuditEntries200ResponseGetItemsAttributeTypeOk(o.Items); ok { + toSerialize["Items"] = val + } + if val, ok := getDownloadFolderAuditEntries200ResponseGetLimitAttributeTypeOk(o.Limit); ok { + toSerialize["Limit"] = val + } + return toSerialize, nil +} + +type NullableDownloadFolderAuditEntries200Response struct { + value *DownloadFolderAuditEntries200Response + isSet bool +} + +func (v NullableDownloadFolderAuditEntries200Response) Get() *DownloadFolderAuditEntries200Response { + return v.value +} + +func (v *NullableDownloadFolderAuditEntries200Response) Set(val *DownloadFolderAuditEntries200Response) { + v.value = val + v.isSet = true +} + +func (v NullableDownloadFolderAuditEntries200Response) IsSet() bool { + return v.isSet +} + +func (v *NullableDownloadFolderAuditEntries200Response) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableDownloadFolderAuditEntries200Response(val *DownloadFolderAuditEntries200Response) *NullableDownloadFolderAuditEntries200Response { + return &NullableDownloadFolderAuditEntries200Response{value: val, isSet: true} +} + +func (v NullableDownloadFolderAuditEntries200Response) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableDownloadFolderAuditEntries200Response) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/auditlog/model_download_folder_audit_entries_200_response_test.go b/services/auditlog/model_download_folder_audit_entries_200_response_test.go new file mode 100644 index 00000000..6ef23c25 --- /dev/null +++ b/services/auditlog/model_download_folder_audit_entries_200_response_test.go @@ -0,0 +1,11 @@ +/* +Audit Log API + +API Endpoints to retrieve recorded actions and resulting changes in the system. ### Audit Logging Changes on organizations, folders and projects and respective cloud resources are logged and collected in the audit log. ### API Constraints The audit log API allows to download messages from the last 90 days. The maximum duration that can be queried at once is 24 hours. Requests are rate limited - the current maximum is 1 request per second. + +API version: 2.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package auditlog diff --git a/services/auditlog/model_error.go b/services/auditlog/model_error.go new file mode 100644 index 00000000..78bd5194 --- /dev/null +++ b/services/auditlog/model_error.go @@ -0,0 +1,276 @@ +/* +Audit Log API + +API Endpoints to retrieve recorded actions and resulting changes in the system. ### Audit Logging Changes on organizations, folders and projects and respective cloud resources are logged and collected in the audit log. ### API Constraints The audit log API allows to download messages from the last 90 days. The maximum duration that can be queried at once is 24 hours. Requests are rate limited - the current maximum is 1 request per second. + +API version: 2.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package auditlog + +import ( + "encoding/json" + "time" +) + +// checks if the ModelError type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ModelError{} + +/* + types and functions for message +*/ + +// isNotNullableString +type ModelErrorGetMessageAttributeType = *string + +func getModelErrorGetMessageAttributeTypeOk(arg ModelErrorGetMessageAttributeType) (ret ModelErrorGetMessageRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setModelErrorGetMessageAttributeType(arg *ModelErrorGetMessageAttributeType, val ModelErrorGetMessageRetType) { + *arg = &val +} + +type ModelErrorGetMessageArgType = string +type ModelErrorGetMessageRetType = string + +/* + types and functions for path +*/ + +// isNotNullableString +type ModelErrorGetPathAttributeType = *string + +func getModelErrorGetPathAttributeTypeOk(arg ModelErrorGetPathAttributeType) (ret ModelErrorGetPathRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setModelErrorGetPathAttributeType(arg *ModelErrorGetPathAttributeType, val ModelErrorGetPathRetType) { + *arg = &val +} + +type ModelErrorGetPathArgType = string +type ModelErrorGetPathRetType = string + +/* + types and functions for status +*/ + +// isNotNullableString +type ModelErrorGetStatusAttributeType = *string + +func getModelErrorGetStatusAttributeTypeOk(arg ModelErrorGetStatusAttributeType) (ret ModelErrorGetStatusRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setModelErrorGetStatusAttributeType(arg *ModelErrorGetStatusAttributeType, val ModelErrorGetStatusRetType) { + *arg = &val +} + +type ModelErrorGetStatusArgType = string +type ModelErrorGetStatusRetType = string + +/* + types and functions for timestamp +*/ + +// isDateTime +type ModelErrorGetTimestampAttributeType = *time.Time +type ModelErrorGetTimestampArgType = time.Time +type ModelErrorGetTimestampRetType = time.Time + +func getModelErrorGetTimestampAttributeTypeOk(arg ModelErrorGetTimestampAttributeType) (ret ModelErrorGetTimestampRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setModelErrorGetTimestampAttributeType(arg *ModelErrorGetTimestampAttributeType, val ModelErrorGetTimestampRetType) { + *arg = &val +} + +// ModelError struct for ModelError +type ModelError struct { + // Message describing the error that occured + Message ModelErrorGetMessageAttributeType `json:"message,omitempty"` + // Path that was called and where the error occurred + Path ModelErrorGetPathAttributeType `json:"path,omitempty"` + // Status Code in which the call resulted + Status ModelErrorGetStatusAttributeType `json:"status,omitempty"` + // Timestamp at which the error occurred + Timestamp ModelErrorGetTimestampAttributeType `json:"timestamp,omitempty"` +} + +// NewModelError instantiates a new ModelError 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 NewModelError() *ModelError { + this := ModelError{} + return &this +} + +// NewModelErrorWithDefaults instantiates a new ModelError 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 NewModelErrorWithDefaults() *ModelError { + this := ModelError{} + return &this +} + +// GetMessage returns the Message field value if set, zero value otherwise. +func (o *ModelError) GetMessage() (res ModelErrorGetMessageRetType) { + 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 *ModelError) GetMessageOk() (ret ModelErrorGetMessageRetType, ok bool) { + return getModelErrorGetMessageAttributeTypeOk(o.Message) +} + +// HasMessage returns a boolean if a field has been set. +func (o *ModelError) HasMessage() bool { + _, ok := o.GetMessageOk() + return ok +} + +// SetMessage gets a reference to the given string and assigns it to the Message field. +func (o *ModelError) SetMessage(v ModelErrorGetMessageRetType) { + setModelErrorGetMessageAttributeType(&o.Message, v) +} + +// GetPath returns the Path field value if set, zero value otherwise. +func (o *ModelError) GetPath() (res ModelErrorGetPathRetType) { + res, _ = o.GetPathOk() + return +} + +// GetPathOk returns a tuple with the Path field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ModelError) GetPathOk() (ret ModelErrorGetPathRetType, ok bool) { + return getModelErrorGetPathAttributeTypeOk(o.Path) +} + +// HasPath returns a boolean if a field has been set. +func (o *ModelError) HasPath() bool { + _, ok := o.GetPathOk() + return ok +} + +// SetPath gets a reference to the given string and assigns it to the Path field. +func (o *ModelError) SetPath(v ModelErrorGetPathRetType) { + setModelErrorGetPathAttributeType(&o.Path, v) +} + +// GetStatus returns the Status field value if set, zero value otherwise. +func (o *ModelError) GetStatus() (res ModelErrorGetStatusRetType) { + res, _ = o.GetStatusOk() + return +} + +// GetStatusOk returns a tuple with the Status field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ModelError) GetStatusOk() (ret ModelErrorGetStatusRetType, ok bool) { + return getModelErrorGetStatusAttributeTypeOk(o.Status) +} + +// HasStatus returns a boolean if a field has been set. +func (o *ModelError) HasStatus() bool { + _, ok := o.GetStatusOk() + return ok +} + +// SetStatus gets a reference to the given string and assigns it to the Status field. +func (o *ModelError) SetStatus(v ModelErrorGetStatusRetType) { + setModelErrorGetStatusAttributeType(&o.Status, v) +} + +// GetTimestamp returns the Timestamp field value if set, zero value otherwise. +func (o *ModelError) GetTimestamp() (res ModelErrorGetTimestampRetType) { + res, _ = o.GetTimestampOk() + return +} + +// GetTimestampOk returns a tuple with the Timestamp field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ModelError) GetTimestampOk() (ret ModelErrorGetTimestampRetType, ok bool) { + return getModelErrorGetTimestampAttributeTypeOk(o.Timestamp) +} + +// HasTimestamp returns a boolean if a field has been set. +func (o *ModelError) HasTimestamp() bool { + _, ok := o.GetTimestampOk() + return ok +} + +// SetTimestamp gets a reference to the given time.Time and assigns it to the Timestamp field. +func (o *ModelError) SetTimestamp(v ModelErrorGetTimestampRetType) { + setModelErrorGetTimestampAttributeType(&o.Timestamp, v) +} + +func (o ModelError) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getModelErrorGetMessageAttributeTypeOk(o.Message); ok { + toSerialize["Message"] = val + } + if val, ok := getModelErrorGetPathAttributeTypeOk(o.Path); ok { + toSerialize["Path"] = val + } + if val, ok := getModelErrorGetStatusAttributeTypeOk(o.Status); ok { + toSerialize["Status"] = val + } + if val, ok := getModelErrorGetTimestampAttributeTypeOk(o.Timestamp); ok { + toSerialize["Timestamp"] = val + } + return toSerialize, nil +} + +type NullableModelError struct { + value *ModelError + isSet bool +} + +func (v NullableModelError) Get() *ModelError { + return v.value +} + +func (v *NullableModelError) Set(val *ModelError) { + v.value = val + v.isSet = true +} + +func (v NullableModelError) IsSet() bool { + return v.isSet +} + +func (v *NullableModelError) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableModelError(val *ModelError) *NullableModelError { + return &NullableModelError{value: val, isSet: true} +} + +func (v NullableModelError) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableModelError) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/auditlog/model_error_test.go b/services/auditlog/model_error_test.go new file mode 100644 index 00000000..6ef23c25 --- /dev/null +++ b/services/auditlog/model_error_test.go @@ -0,0 +1,11 @@ +/* +Audit Log API + +API Endpoints to retrieve recorded actions and resulting changes in the system. ### Audit Logging Changes on organizations, folders and projects and respective cloud resources are logged and collected in the audit log. ### API Constraints The audit log API allows to download messages from the last 90 days. The maximum duration that can be queried at once is 24 hours. Requests are rate limited - the current maximum is 1 request per second. + +API version: 2.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package auditlog diff --git a/services/auditlog/model_initiator.go b/services/auditlog/model_initiator.go new file mode 100644 index 00000000..bdc46190 --- /dev/null +++ b/services/auditlog/model_initiator.go @@ -0,0 +1,176 @@ +/* +Audit Log API + +API Endpoints to retrieve recorded actions and resulting changes in the system. ### Audit Logging Changes on organizations, folders and projects and respective cloud resources are logged and collected in the audit log. ### API Constraints The audit log API allows to download messages from the last 90 days. The maximum duration that can be queried at once is 24 hours. Requests are rate limited - the current maximum is 1 request per second. + +API version: 2.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package auditlog + +import ( + "encoding/json" +) + +// checks if the Initiator type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &Initiator{} + +/* + types and functions for email +*/ + +// isNotNullableString +type InitiatorGetEmailAttributeType = *string + +func getInitiatorGetEmailAttributeTypeOk(arg InitiatorGetEmailAttributeType) (ret InitiatorGetEmailRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setInitiatorGetEmailAttributeType(arg *InitiatorGetEmailAttributeType, val InitiatorGetEmailRetType) { + *arg = &val +} + +type InitiatorGetEmailArgType = string +type InitiatorGetEmailRetType = string + +/* + types and functions for id +*/ + +// isNotNullableString +type InitiatorGetIdAttributeType = *string + +func getInitiatorGetIdAttributeTypeOk(arg InitiatorGetIdAttributeType) (ret InitiatorGetIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setInitiatorGetIdAttributeType(arg *InitiatorGetIdAttributeType, val InitiatorGetIdRetType) { + *arg = &val +} + +type InitiatorGetIdArgType = string +type InitiatorGetIdRetType = string + +// Initiator Information about who made the request. +type Initiator struct { + // E-Mail of the user or service account who triggered the request + Email InitiatorGetEmailAttributeType `json:"email,omitempty"` + // Unique identifier of the user + // REQUIRED + Id InitiatorGetIdAttributeType `json:"id"` +} + +type _Initiator Initiator + +// NewInitiator instantiates a new Initiator 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 NewInitiator(id InitiatorGetIdArgType) *Initiator { + this := Initiator{} + setInitiatorGetIdAttributeType(&this.Id, id) + return &this +} + +// NewInitiatorWithDefaults instantiates a new Initiator 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 NewInitiatorWithDefaults() *Initiator { + this := Initiator{} + return &this +} + +// GetEmail returns the Email field value if set, zero value otherwise. +func (o *Initiator) GetEmail() (res InitiatorGetEmailRetType) { + res, _ = o.GetEmailOk() + return +} + +// GetEmailOk returns a tuple with the Email field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Initiator) GetEmailOk() (ret InitiatorGetEmailRetType, ok bool) { + return getInitiatorGetEmailAttributeTypeOk(o.Email) +} + +// HasEmail returns a boolean if a field has been set. +func (o *Initiator) HasEmail() bool { + _, ok := o.GetEmailOk() + return ok +} + +// SetEmail gets a reference to the given string and assigns it to the Email field. +func (o *Initiator) SetEmail(v InitiatorGetEmailRetType) { + setInitiatorGetEmailAttributeType(&o.Email, v) +} + +// GetId returns the Id field value +func (o *Initiator) GetId() (ret InitiatorGetIdRetType) { + ret, _ = o.GetIdOk() + return ret +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *Initiator) GetIdOk() (ret InitiatorGetIdRetType, ok bool) { + return getInitiatorGetIdAttributeTypeOk(o.Id) +} + +// SetId sets field value +func (o *Initiator) SetId(v InitiatorGetIdRetType) { + setInitiatorGetIdAttributeType(&o.Id, v) +} + +func (o Initiator) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getInitiatorGetEmailAttributeTypeOk(o.Email); ok { + toSerialize["Email"] = val + } + if val, ok := getInitiatorGetIdAttributeTypeOk(o.Id); ok { + toSerialize["Id"] = val + } + return toSerialize, nil +} + +type NullableInitiator struct { + value *Initiator + isSet bool +} + +func (v NullableInitiator) Get() *Initiator { + return v.value +} + +func (v *NullableInitiator) Set(val *Initiator) { + v.value = val + v.isSet = true +} + +func (v NullableInitiator) IsSet() bool { + return v.isSet +} + +func (v *NullableInitiator) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableInitiator(val *Initiator) *NullableInitiator { + return &NullableInitiator{value: val, isSet: true} +} + +func (v NullableInitiator) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableInitiator) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/auditlog/model_initiator_test.go b/services/auditlog/model_initiator_test.go new file mode 100644 index 00000000..6ef23c25 --- /dev/null +++ b/services/auditlog/model_initiator_test.go @@ -0,0 +1,11 @@ +/* +Audit Log API + +API Endpoints to retrieve recorded actions and resulting changes in the system. ### Audit Logging Changes on organizations, folders and projects and respective cloud resources are logged and collected in the audit log. ### API Constraints The audit log API allows to download messages from the last 90 days. The maximum duration that can be queried at once is 24 hours. Requests are rate limited - the current maximum is 1 request per second. + +API version: 2.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package auditlog diff --git a/services/auditlog/model_request.go b/services/auditlog/model_request.go new file mode 100644 index 00000000..e13e34fe --- /dev/null +++ b/services/auditlog/model_request.go @@ -0,0 +1,271 @@ +/* +Audit Log API + +API Endpoints to retrieve recorded actions and resulting changes in the system. ### Audit Logging Changes on organizations, folders and projects and respective cloud resources are logged and collected in the audit log. ### API Constraints The audit log API allows to download messages from the last 90 days. The maximum duration that can be queried at once is 24 hours. Requests are rate limited - the current maximum is 1 request per second. + +API version: 2.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package auditlog + +import ( + "encoding/json" +) + +// checks if the Request type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &Request{} + +/* + types and functions for body +*/ + +// isFreeform +type RequestGetBodyAttributeType = *map[string]interface{} +type RequestGetBodyArgType = map[string]interface{} +type RequestGetBodyRetType = map[string]interface{} + +func getRequestGetBodyAttributeTypeOk(arg RequestGetBodyAttributeType) (ret RequestGetBodyRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setRequestGetBodyAttributeType(arg *RequestGetBodyAttributeType, val RequestGetBodyRetType) { + *arg = &val +} + +/* + types and functions for endpoint +*/ + +// isNotNullableString +type RequestGetEndpointAttributeType = *string + +func getRequestGetEndpointAttributeTypeOk(arg RequestGetEndpointAttributeType) (ret RequestGetEndpointRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setRequestGetEndpointAttributeType(arg *RequestGetEndpointAttributeType, val RequestGetEndpointRetType) { + *arg = &val +} + +type RequestGetEndpointArgType = string +type RequestGetEndpointRetType = string + +/* + types and functions for headers +*/ + +// isFreeform +type RequestGetHeadersAttributeType = *map[string]interface{} +type RequestGetHeadersArgType = map[string]interface{} +type RequestGetHeadersRetType = map[string]interface{} + +func getRequestGetHeadersAttributeTypeOk(arg RequestGetHeadersAttributeType) (ret RequestGetHeadersRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setRequestGetHeadersAttributeType(arg *RequestGetHeadersAttributeType, val RequestGetHeadersRetType) { + *arg = &val +} + +/* + types and functions for parameters +*/ + +// isFreeform +type RequestGetParametersAttributeType = *map[string]interface{} +type RequestGetParametersArgType = map[string]interface{} +type RequestGetParametersRetType = map[string]interface{} + +func getRequestGetParametersAttributeTypeOk(arg RequestGetParametersAttributeType) (ret RequestGetParametersRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setRequestGetParametersAttributeType(arg *RequestGetParametersAttributeType, val RequestGetParametersRetType) { + *arg = &val +} + +// Request Request, which mirrors the action of the user and the resulting changes within the system +type Request struct { + // Body used to make the request. + Body RequestGetBodyAttributeType `json:"body,omitempty"` + // Endpoint which received the request. + // REQUIRED + Endpoint RequestGetEndpointAttributeType `json:"endpoint"` + // Headers used to make the request. May only contain (string -> string) key-value pairs. + Headers RequestGetHeadersAttributeType `json:"headers,omitempty"` + // Parameters used to make the request. + Parameters RequestGetParametersAttributeType `json:"parameters,omitempty"` +} + +type _Request Request + +// NewRequest instantiates a new Request 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 NewRequest(endpoint RequestGetEndpointArgType) *Request { + this := Request{} + setRequestGetEndpointAttributeType(&this.Endpoint, endpoint) + return &this +} + +// NewRequestWithDefaults instantiates a new Request 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 NewRequestWithDefaults() *Request { + this := Request{} + return &this +} + +// GetBody returns the Body field value if set, zero value otherwise. +func (o *Request) GetBody() (res RequestGetBodyRetType) { + res, _ = o.GetBodyOk() + return +} + +// GetBodyOk returns a tuple with the Body field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Request) GetBodyOk() (ret RequestGetBodyRetType, ok bool) { + return getRequestGetBodyAttributeTypeOk(o.Body) +} + +// HasBody returns a boolean if a field has been set. +func (o *Request) HasBody() bool { + _, ok := o.GetBodyOk() + return ok +} + +// SetBody gets a reference to the given map[string]interface{} and assigns it to the Body field. +func (o *Request) SetBody(v RequestGetBodyRetType) { + setRequestGetBodyAttributeType(&o.Body, v) +} + +// GetEndpoint returns the Endpoint field value +func (o *Request) GetEndpoint() (ret RequestGetEndpointRetType) { + ret, _ = o.GetEndpointOk() + return ret +} + +// GetEndpointOk returns a tuple with the Endpoint field value +// and a boolean to check if the value has been set. +func (o *Request) GetEndpointOk() (ret RequestGetEndpointRetType, ok bool) { + return getRequestGetEndpointAttributeTypeOk(o.Endpoint) +} + +// SetEndpoint sets field value +func (o *Request) SetEndpoint(v RequestGetEndpointRetType) { + setRequestGetEndpointAttributeType(&o.Endpoint, v) +} + +// GetHeaders returns the Headers field value if set, zero value otherwise. +func (o *Request) GetHeaders() (res RequestGetHeadersRetType) { + res, _ = o.GetHeadersOk() + return +} + +// GetHeadersOk returns a tuple with the Headers field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Request) GetHeadersOk() (ret RequestGetHeadersRetType, ok bool) { + return getRequestGetHeadersAttributeTypeOk(o.Headers) +} + +// HasHeaders returns a boolean if a field has been set. +func (o *Request) HasHeaders() bool { + _, ok := o.GetHeadersOk() + return ok +} + +// SetHeaders gets a reference to the given map[string]interface{} and assigns it to the Headers field. +func (o *Request) SetHeaders(v RequestGetHeadersRetType) { + setRequestGetHeadersAttributeType(&o.Headers, v) +} + +// GetParameters returns the Parameters field value if set, zero value otherwise. +func (o *Request) GetParameters() (res RequestGetParametersRetType) { + res, _ = o.GetParametersOk() + return +} + +// GetParametersOk returns a tuple with the Parameters field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Request) GetParametersOk() (ret RequestGetParametersRetType, ok bool) { + return getRequestGetParametersAttributeTypeOk(o.Parameters) +} + +// HasParameters returns a boolean if a field has been set. +func (o *Request) HasParameters() bool { + _, ok := o.GetParametersOk() + return ok +} + +// SetParameters gets a reference to the given map[string]interface{} and assigns it to the Parameters field. +func (o *Request) SetParameters(v RequestGetParametersRetType) { + setRequestGetParametersAttributeType(&o.Parameters, v) +} + +func (o Request) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getRequestGetBodyAttributeTypeOk(o.Body); ok { + toSerialize["Body"] = val + } + if val, ok := getRequestGetEndpointAttributeTypeOk(o.Endpoint); ok { + toSerialize["Endpoint"] = val + } + if val, ok := getRequestGetHeadersAttributeTypeOk(o.Headers); ok { + toSerialize["Headers"] = val + } + if val, ok := getRequestGetParametersAttributeTypeOk(o.Parameters); ok { + toSerialize["Parameters"] = val + } + return toSerialize, nil +} + +type NullableRequest struct { + value *Request + isSet bool +} + +func (v NullableRequest) Get() *Request { + return v.value +} + +func (v *NullableRequest) Set(val *Request) { + v.value = val + v.isSet = true +} + +func (v NullableRequest) IsSet() bool { + return v.isSet +} + +func (v *NullableRequest) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableRequest(val *Request) *NullableRequest { + return &NullableRequest{value: val, isSet: true} +} + +func (v NullableRequest) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableRequest) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/auditlog/model_request_test.go b/services/auditlog/model_request_test.go new file mode 100644 index 00000000..6ef23c25 --- /dev/null +++ b/services/auditlog/model_request_test.go @@ -0,0 +1,11 @@ +/* +Audit Log API + +API Endpoints to retrieve recorded actions and resulting changes in the system. ### Audit Logging Changes on organizations, folders and projects and respective cloud resources are logged and collected in the audit log. ### API Constraints The audit log API allows to download messages from the last 90 days. The maximum duration that can be queried at once is 24 hours. Requests are rate limited - the current maximum is 1 request per second. + +API version: 2.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package auditlog diff --git a/services/auditlog/model_service_account_delegation_info.go b/services/auditlog/model_service_account_delegation_info.go new file mode 100644 index 00000000..9e01c39b --- /dev/null +++ b/services/auditlog/model_service_account_delegation_info.go @@ -0,0 +1,126 @@ +/* +Audit Log API + +API Endpoints to retrieve recorded actions and resulting changes in the system. ### Audit Logging Changes on organizations, folders and projects and respective cloud resources are logged and collected in the audit log. ### API Constraints The audit log API allows to download messages from the last 90 days. The maximum duration that can be queried at once is 24 hours. Requests are rate limited - the current maximum is 1 request per second. + +API version: 2.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package auditlog + +import ( + "encoding/json" +) + +// checks if the ServiceAccountDelegationInfo type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ServiceAccountDelegationInfo{} + +/* + types and functions for principals +*/ + +// isArray +type ServiceAccountDelegationInfoGetPrincipalsAttributeType = *[]DelegationPrincipal +type ServiceAccountDelegationInfoGetPrincipalsArgType = []DelegationPrincipal +type ServiceAccountDelegationInfoGetPrincipalsRetType = []DelegationPrincipal + +func getServiceAccountDelegationInfoGetPrincipalsAttributeTypeOk(arg ServiceAccountDelegationInfoGetPrincipalsAttributeType) (ret ServiceAccountDelegationInfoGetPrincipalsRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setServiceAccountDelegationInfoGetPrincipalsAttributeType(arg *ServiceAccountDelegationInfoGetPrincipalsAttributeType, val ServiceAccountDelegationInfoGetPrincipalsRetType) { + *arg = &val +} + +// ServiceAccountDelegationInfo Information about service account delegation +type ServiceAccountDelegationInfo struct { + // Delegation chain for the service account + // REQUIRED + Principals ServiceAccountDelegationInfoGetPrincipalsAttributeType `json:"principals"` +} + +type _ServiceAccountDelegationInfo ServiceAccountDelegationInfo + +// NewServiceAccountDelegationInfo instantiates a new ServiceAccountDelegationInfo 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 NewServiceAccountDelegationInfo(principals ServiceAccountDelegationInfoGetPrincipalsArgType) *ServiceAccountDelegationInfo { + this := ServiceAccountDelegationInfo{} + setServiceAccountDelegationInfoGetPrincipalsAttributeType(&this.Principals, principals) + return &this +} + +// NewServiceAccountDelegationInfoWithDefaults instantiates a new ServiceAccountDelegationInfo 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 NewServiceAccountDelegationInfoWithDefaults() *ServiceAccountDelegationInfo { + this := ServiceAccountDelegationInfo{} + return &this +} + +// GetPrincipals returns the Principals field value +func (o *ServiceAccountDelegationInfo) GetPrincipals() (ret ServiceAccountDelegationInfoGetPrincipalsRetType) { + ret, _ = o.GetPrincipalsOk() + return ret +} + +// GetPrincipalsOk returns a tuple with the Principals field value +// and a boolean to check if the value has been set. +func (o *ServiceAccountDelegationInfo) GetPrincipalsOk() (ret ServiceAccountDelegationInfoGetPrincipalsRetType, ok bool) { + return getServiceAccountDelegationInfoGetPrincipalsAttributeTypeOk(o.Principals) +} + +// SetPrincipals sets field value +func (o *ServiceAccountDelegationInfo) SetPrincipals(v ServiceAccountDelegationInfoGetPrincipalsRetType) { + setServiceAccountDelegationInfoGetPrincipalsAttributeType(&o.Principals, v) +} + +func (o ServiceAccountDelegationInfo) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getServiceAccountDelegationInfoGetPrincipalsAttributeTypeOk(o.Principals); ok { + toSerialize["Principals"] = val + } + return toSerialize, nil +} + +type NullableServiceAccountDelegationInfo struct { + value *ServiceAccountDelegationInfo + isSet bool +} + +func (v NullableServiceAccountDelegationInfo) Get() *ServiceAccountDelegationInfo { + return v.value +} + +func (v *NullableServiceAccountDelegationInfo) Set(val *ServiceAccountDelegationInfo) { + v.value = val + v.isSet = true +} + +func (v NullableServiceAccountDelegationInfo) IsSet() bool { + return v.isSet +} + +func (v *NullableServiceAccountDelegationInfo) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableServiceAccountDelegationInfo(val *ServiceAccountDelegationInfo) *NullableServiceAccountDelegationInfo { + return &NullableServiceAccountDelegationInfo{value: val, isSet: true} +} + +func (v NullableServiceAccountDelegationInfo) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableServiceAccountDelegationInfo) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/auditlog/model_service_account_delegation_info_test.go b/services/auditlog/model_service_account_delegation_info_test.go new file mode 100644 index 00000000..6ef23c25 --- /dev/null +++ b/services/auditlog/model_service_account_delegation_info_test.go @@ -0,0 +1,11 @@ +/* +Audit Log API + +API Endpoints to retrieve recorded actions and resulting changes in the system. ### Audit Logging Changes on organizations, folders and projects and respective cloud resources are logged and collected in the audit log. ### API Constraints The audit log API allows to download messages from the last 90 days. The maximum duration that can be queried at once is 24 hours. Requests are rate limited - the current maximum is 1 request per second. + +API version: 2.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package auditlog diff --git a/services/auditlog/utils.go b/services/auditlog/utils.go new file mode 100644 index 00000000..d3760ace --- /dev/null +++ b/services/auditlog/utils.go @@ -0,0 +1,385 @@ +/* +Audit Log API + +API Endpoints to retrieve recorded actions and resulting changes in the system. ### Audit Logging Changes on organizations, folders and projects and respective cloud resources are logged and collected in the audit log. ### API Constraints The audit log API allows to download messages from the last 90 days. The maximum duration that can be queried at once is 24 hours. Requests are rate limited - the current maximum is 1 request per second. + +API version: 2.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package auditlog + +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) +}