diff --git a/iamidentityv1/iam_identity_v1.go b/iamidentityv1/iam_identity_v1.go index 0419efda..ee09fa91 100644 --- a/iamidentityv1/iam_identity_v1.go +++ b/iamidentityv1/iam_identity_v1.go @@ -15,7 +15,7 @@ */ /* - * IBM OpenAPI SDK Code Generator Version: 3.72.0-5d70f2bb-20230511-203609 + * IBM OpenAPI SDK Code Generator Version: 3.74.0-89f1dbab-20230630-160213 */ // Package iamidentityv1 : Operations and models for the IamIdentityV1 service @@ -689,7 +689,7 @@ func (iamIdentity *IamIdentityV1) UnlockAPIKeyWithContext(ctx context.Context, u // ListServiceIds : List service IDs // Returns a list of service IDs. Users can manage user API keys for themself, or service ID API keys for service IDs // that are bound to an entity they have access to. Note: apikey details are only included in the response when creating -// a Service ID with an api key. +// a Service ID with an apikey. func (iamIdentity *IamIdentityV1) ListServiceIds(listServiceIdsOptions *ListServiceIdsOptions) (result *ServiceIDList, response *core.DetailedResponse, err error) { return iamIdentity.ListServiceIdsWithContext(context.Background(), listServiceIdsOptions) } @@ -847,7 +847,7 @@ func (iamIdentity *IamIdentityV1) CreateServiceIDWithContext(ctx context.Context // GetServiceID : Get details of a service ID // Returns the details of a service ID. Users can manage user API keys for themself, or service ID API keys for service // IDs that are bound to an entity they have access to. Note: apikey details are only included in the response when -// creating a Service ID with an api key. +// creating a Service ID with an apikey. func (iamIdentity *IamIdentityV1) GetServiceID(getServiceIDOptions *GetServiceIDOptions) (result *ServiceID, response *core.DetailedResponse, err error) { return iamIdentity.GetServiceIDWithContext(context.Background(), getServiceIDOptions) } @@ -1654,7 +1654,7 @@ func (iamIdentity *IamIdentityV1) GetClaimRuleWithContext(ctx context.Context, g pathParamsMap := map[string]string{ "profile-id": *getClaimRuleOptions.ProfileID, - "rule-id": *getClaimRuleOptions.RuleID, + "rule-id": *getClaimRuleOptions.RuleID, } builder := core.NewRequestBuilder(core.GET) @@ -1715,7 +1715,7 @@ func (iamIdentity *IamIdentityV1) UpdateClaimRuleWithContext(ctx context.Context pathParamsMap := map[string]string{ "profile-id": *updateClaimRuleOptions.ProfileID, - "rule-id": *updateClaimRuleOptions.RuleID, + "rule-id": *updateClaimRuleOptions.RuleID, } builder := core.NewRequestBuilder(core.PUT) @@ -1808,7 +1808,7 @@ func (iamIdentity *IamIdentityV1) DeleteClaimRuleWithContext(ctx context.Context pathParamsMap := map[string]string{ "profile-id": *deleteClaimRuleOptions.ProfileID, - "rule-id": *deleteClaimRuleOptions.RuleID, + "rule-id": *deleteClaimRuleOptions.RuleID, } builder := core.NewRequestBuilder(core.DELETE) @@ -1994,7 +1994,7 @@ func (iamIdentity *IamIdentityV1) GetLinkWithContext(ctx context.Context, getLin pathParamsMap := map[string]string{ "profile-id": *getLinkOptions.ProfileID, - "link-id": *getLinkOptions.LinkID, + "link-id": *getLinkOptions.LinkID, } builder := core.NewRequestBuilder(core.GET) @@ -2055,7 +2055,7 @@ func (iamIdentity *IamIdentityV1) DeleteLinkWithContext(ctx context.Context, del pathParamsMap := map[string]string{ "profile-id": *deleteLinkOptions.ProfileID, - "link-id": *deleteLinkOptions.LinkID, + "link-id": *deleteLinkOptions.LinkID, } builder := core.NewRequestBuilder(core.DELETE) @@ -2220,12 +2220,12 @@ func (iamIdentity *IamIdentityV1) SetProfileIdentitiesWithContext(ctx context.Co // SetProfileIdentity : Add a specific identity that can assume the trusted profile // Add a specific identity that can assume the trusted profile. -func (iamIdentity *IamIdentityV1) SetProfileIdentity(setProfileIdentityOptions *SetProfileIdentityOptions) (result *ProfileIdentity, response *core.DetailedResponse, err error) { +func (iamIdentity *IamIdentityV1) SetProfileIdentity(setProfileIdentityOptions *SetProfileIdentityOptions) (result *ProfileIdentityResponse, response *core.DetailedResponse, err error) { return iamIdentity.SetProfileIdentityWithContext(context.Background(), setProfileIdentityOptions) } // SetProfileIdentityWithContext is an alternate form of the SetProfileIdentity method which supports a Context parameter -func (iamIdentity *IamIdentityV1) SetProfileIdentityWithContext(ctx context.Context, setProfileIdentityOptions *SetProfileIdentityOptions) (result *ProfileIdentity, response *core.DetailedResponse, err error) { +func (iamIdentity *IamIdentityV1) SetProfileIdentityWithContext(ctx context.Context, setProfileIdentityOptions *SetProfileIdentityOptions) (result *ProfileIdentityResponse, response *core.DetailedResponse, err error) { err = core.ValidateNotNil(setProfileIdentityOptions, "setProfileIdentityOptions cannot be nil") if err != nil { return @@ -2236,7 +2236,7 @@ func (iamIdentity *IamIdentityV1) SetProfileIdentityWithContext(ctx context.Cont } pathParamsMap := map[string]string{ - "profile-id": *setProfileIdentityOptions.ProfileID, + "profile-id": *setProfileIdentityOptions.ProfileID, "identity-type": *setProfileIdentityOptions.IdentityType, } @@ -2266,9 +2266,6 @@ func (iamIdentity *IamIdentityV1) SetProfileIdentityWithContext(ctx context.Cont if setProfileIdentityOptions.Type != nil { body["type"] = setProfileIdentityOptions.Type } - if setProfileIdentityOptions.IamID != nil { - body["iam_id"] = setProfileIdentityOptions.IamID - } if setProfileIdentityOptions.Accounts != nil { body["accounts"] = setProfileIdentityOptions.Accounts } @@ -2291,7 +2288,7 @@ func (iamIdentity *IamIdentityV1) SetProfileIdentityWithContext(ctx context.Cont return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalProfileIdentity) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalProfileIdentityResponse) if err != nil { return } @@ -2303,12 +2300,12 @@ func (iamIdentity *IamIdentityV1) SetProfileIdentityWithContext(ctx context.Cont // GetProfileIdentity : Get the identity that can assume the trusted profile // Get the identity that can assume the trusted profile. -func (iamIdentity *IamIdentityV1) GetProfileIdentity(getProfileIdentityOptions *GetProfileIdentityOptions) (result *ProfileIdentity, response *core.DetailedResponse, err error) { +func (iamIdentity *IamIdentityV1) GetProfileIdentity(getProfileIdentityOptions *GetProfileIdentityOptions) (result *ProfileIdentityResponse, response *core.DetailedResponse, err error) { return iamIdentity.GetProfileIdentityWithContext(context.Background(), getProfileIdentityOptions) } // GetProfileIdentityWithContext is an alternate form of the GetProfileIdentity method which supports a Context parameter -func (iamIdentity *IamIdentityV1) GetProfileIdentityWithContext(ctx context.Context, getProfileIdentityOptions *GetProfileIdentityOptions) (result *ProfileIdentity, response *core.DetailedResponse, err error) { +func (iamIdentity *IamIdentityV1) GetProfileIdentityWithContext(ctx context.Context, getProfileIdentityOptions *GetProfileIdentityOptions) (result *ProfileIdentityResponse, response *core.DetailedResponse, err error) { err = core.ValidateNotNil(getProfileIdentityOptions, "getProfileIdentityOptions cannot be nil") if err != nil { return @@ -2319,7 +2316,7 @@ func (iamIdentity *IamIdentityV1) GetProfileIdentityWithContext(ctx context.Cont } pathParamsMap := map[string]string{ - "profile-id": *getProfileIdentityOptions.ProfileID, + "profile-id": *getProfileIdentityOptions.ProfileID, "identity-type": *getProfileIdentityOptions.IdentityType, "identifier-id": *getProfileIdentityOptions.IdentifierID, } @@ -2353,7 +2350,7 @@ func (iamIdentity *IamIdentityV1) GetProfileIdentityWithContext(ctx context.Cont return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalProfileIdentity) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalProfileIdentityResponse) if err != nil { return } @@ -2381,7 +2378,7 @@ func (iamIdentity *IamIdentityV1) DeleteProfileIdentityWithContext(ctx context.C } pathParamsMap := map[string]string{ - "profile-id": *deleteProfileIdentityOptions.ProfileID, + "profile-id": *deleteProfileIdentityOptions.ProfileID, "identity-type": *deleteProfileIdentityOptions.IdentityType, "identifier-id": *deleteProfileIdentityOptions.IdentifierID, } @@ -2725,7 +2722,7 @@ func (iamIdentity *IamIdentityV1) GetMfaReportWithContext(ctx context.Context, g pathParamsMap := map[string]string{ "account_id": *getMfaReportOptions.AccountID, - "reference": *getMfaReportOptions.Reference, + "reference": *getMfaReportOptions.Reference, } builder := core.NewRequestBuilder(core.GET) @@ -2767,51 +2764,66 @@ func (iamIdentity *IamIdentityV1) GetMfaReportWithContext(ctx context.Context, g return } -// CreateReport : Trigger activity report for the account -// Trigger activity report for the account by specifying the account ID. It can take a few minutes to generate the -// report for retrieval. -func (iamIdentity *IamIdentityV1) CreateReport(createReportOptions *CreateReportOptions) (result *ReportReference, response *core.DetailedResponse, err error) { - return iamIdentity.CreateReportWithContext(context.Background(), createReportOptions) +// ListAccountSettingsAssignments : List Assignments +// List Account Settings Template Assignments. +func (iamIdentity *IamIdentityV1) ListAccountSettingsAssignments(listAccountSettingsAssignmentsOptions *ListAccountSettingsAssignmentsOptions) (result *TemplateAssignmentListResponse, response *core.DetailedResponse, err error) { + return iamIdentity.ListAccountSettingsAssignmentsWithContext(context.Background(), listAccountSettingsAssignmentsOptions) } -// CreateReportWithContext is an alternate form of the CreateReport method which supports a Context parameter -func (iamIdentity *IamIdentityV1) CreateReportWithContext(ctx context.Context, createReportOptions *CreateReportOptions) (result *ReportReference, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(createReportOptions, "createReportOptions cannot be nil") - if err != nil { - return - } - err = core.ValidateStruct(createReportOptions, "createReportOptions") +// ListAccountSettingsAssignmentsWithContext is an alternate form of the ListAccountSettingsAssignments method which supports a Context parameter +func (iamIdentity *IamIdentityV1) ListAccountSettingsAssignmentsWithContext(ctx context.Context, listAccountSettingsAssignmentsOptions *ListAccountSettingsAssignmentsOptions) (result *TemplateAssignmentListResponse, response *core.DetailedResponse, err error) { + err = core.ValidateStruct(listAccountSettingsAssignmentsOptions, "listAccountSettingsAssignmentsOptions") if err != nil { return } - pathParamsMap := map[string]string{ - "account_id": *createReportOptions.AccountID, - } - - builder := core.NewRequestBuilder(core.POST) + builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = iamIdentity.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(iamIdentity.Service.Options.URL, `/v1/activity/accounts/{account_id}/report`, pathParamsMap) + _, err = builder.ResolveRequestURL(iamIdentity.Service.Options.URL, `/v1/account_settings_assignments/`, nil) if err != nil { return } - for headerName, headerValue := range createReportOptions.Headers { + for headerName, headerValue := range listAccountSettingsAssignmentsOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("iam_identity", "V1", "CreateReport") + sdkHeaders := common.GetSdkHeaders("iam_identity", "V1", "ListAccountSettingsAssignments") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") - if createReportOptions.Type != nil { - builder.AddQuery("type", fmt.Sprint(*createReportOptions.Type)) + if listAccountSettingsAssignmentsOptions.AccountID != nil { + builder.AddQuery("account_id", fmt.Sprint(*listAccountSettingsAssignmentsOptions.AccountID)) } - if createReportOptions.Duration != nil { - builder.AddQuery("duration", fmt.Sprint(*createReportOptions.Duration)) + if listAccountSettingsAssignmentsOptions.TemplateID != nil { + builder.AddQuery("template_id", fmt.Sprint(*listAccountSettingsAssignmentsOptions.TemplateID)) + } + if listAccountSettingsAssignmentsOptions.TemplateVersion != nil { + builder.AddQuery("template_version", fmt.Sprint(*listAccountSettingsAssignmentsOptions.TemplateVersion)) + } + if listAccountSettingsAssignmentsOptions.Target != nil { + builder.AddQuery("target", fmt.Sprint(*listAccountSettingsAssignmentsOptions.Target)) + } + if listAccountSettingsAssignmentsOptions.TargetType != nil { + builder.AddQuery("target_type", fmt.Sprint(*listAccountSettingsAssignmentsOptions.TargetType)) + } + if listAccountSettingsAssignmentsOptions.Limit != nil { + builder.AddQuery("limit", fmt.Sprint(*listAccountSettingsAssignmentsOptions.Limit)) + } + if listAccountSettingsAssignmentsOptions.Pagetoken != nil { + builder.AddQuery("pagetoken", fmt.Sprint(*listAccountSettingsAssignmentsOptions.Pagetoken)) + } + if listAccountSettingsAssignmentsOptions.Sort != nil { + builder.AddQuery("sort", fmt.Sprint(*listAccountSettingsAssignmentsOptions.Sort)) + } + if listAccountSettingsAssignmentsOptions.Order != nil { + builder.AddQuery("order", fmt.Sprint(*listAccountSettingsAssignmentsOptions.Order)) + } + if listAccountSettingsAssignmentsOptions.IncludeHistory != nil { + builder.AddQuery("include_history", fmt.Sprint(*listAccountSettingsAssignmentsOptions.IncludeHistory)) } request, err := builder.Build() @@ -2825,7 +2837,7 @@ func (iamIdentity *IamIdentityV1) CreateReportWithContext(ctx context.Context, c return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalReportReference) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalTemplateAssignmentListResponse) if err != nil { return } @@ -2835,46 +2847,59 @@ func (iamIdentity *IamIdentityV1) CreateReportWithContext(ctx context.Context, c return } -// GetReport : Get activity report for the account -// Get activity report for the account by specifying the account ID and the reference that is generated by triggering -// the report. Reports older than a day are deleted when generating a new report. -func (iamIdentity *IamIdentityV1) GetReport(getReportOptions *GetReportOptions) (result *Report, response *core.DetailedResponse, err error) { - return iamIdentity.GetReportWithContext(context.Background(), getReportOptions) +// CreateAccountSettingsAssignment : Create Assignment +// Create an assigment for an Account Settings Template. +func (iamIdentity *IamIdentityV1) CreateAccountSettingsAssignment(createAccountSettingsAssignmentOptions *CreateAccountSettingsAssignmentOptions) (result *TemplateAssignmentResponse, response *core.DetailedResponse, err error) { + return iamIdentity.CreateAccountSettingsAssignmentWithContext(context.Background(), createAccountSettingsAssignmentOptions) } -// GetReportWithContext is an alternate form of the GetReport method which supports a Context parameter -func (iamIdentity *IamIdentityV1) GetReportWithContext(ctx context.Context, getReportOptions *GetReportOptions) (result *Report, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(getReportOptions, "getReportOptions cannot be nil") +// CreateAccountSettingsAssignmentWithContext is an alternate form of the CreateAccountSettingsAssignment method which supports a Context parameter +func (iamIdentity *IamIdentityV1) CreateAccountSettingsAssignmentWithContext(ctx context.Context, createAccountSettingsAssignmentOptions *CreateAccountSettingsAssignmentOptions) (result *TemplateAssignmentResponse, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(createAccountSettingsAssignmentOptions, "createAccountSettingsAssignmentOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(getReportOptions, "getReportOptions") + err = core.ValidateStruct(createAccountSettingsAssignmentOptions, "createAccountSettingsAssignmentOptions") if err != nil { return } - pathParamsMap := map[string]string{ - "account_id": *getReportOptions.AccountID, - "reference": *getReportOptions.Reference, - } - - builder := core.NewRequestBuilder(core.GET) + builder := core.NewRequestBuilder(core.POST) builder = builder.WithContext(ctx) builder.EnableGzipCompression = iamIdentity.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(iamIdentity.Service.Options.URL, `/v1/activity/accounts/{account_id}/report/{reference}`, pathParamsMap) + _, err = builder.ResolveRequestURL(iamIdentity.Service.Options.URL, `/v1/account_settings_assignments/`, nil) if err != nil { return } - for headerName, headerValue := range getReportOptions.Headers { + for headerName, headerValue := range createAccountSettingsAssignmentOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("iam_identity", "V1", "GetReport") + sdkHeaders := common.GetSdkHeaders("iam_identity", "V1", "CreateAccountSettingsAssignment") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") + builder.AddHeader("Content-Type", "application/json") + + body := make(map[string]interface{}) + if createAccountSettingsAssignmentOptions.TemplateID != nil { + body["template_id"] = createAccountSettingsAssignmentOptions.TemplateID + } + if createAccountSettingsAssignmentOptions.TemplateVersion != nil { + body["template_version"] = createAccountSettingsAssignmentOptions.TemplateVersion + } + if createAccountSettingsAssignmentOptions.TargetType != nil { + body["target_type"] = createAccountSettingsAssignmentOptions.TargetType + } + if createAccountSettingsAssignmentOptions.Target != nil { + body["target"] = createAccountSettingsAssignmentOptions.Target + } + _, err = builder.SetBodyContentJSON(body) + if err != nil { + return + } request, err := builder.Build() if err != nil { @@ -2887,7 +2912,7 @@ func (iamIdentity *IamIdentityV1) GetReportWithContext(ctx context.Context, getR return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalReport) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalTemplateAssignmentResponse) if err != nil { return } @@ -2897,2025 +2922,6381 @@ func (iamIdentity *IamIdentityV1) GetReportWithContext(ctx context.Context, getR return } -// AccountBasedMfaEnrollment : AccountBasedMfaEnrollment struct -type AccountBasedMfaEnrollment struct { - SecurityQuestions *MfaEnrollmentTypeStatus `json:"security_questions" validate:"required"` - - Totp *MfaEnrollmentTypeStatus `json:"totp" validate:"required"` - - Verisign *MfaEnrollmentTypeStatus `json:"verisign" validate:"required"` - - // The enrollment complies to the effective requirement. - Complies *bool `json:"complies" validate:"required"` +// GetAccountSettingsAssignment : Get Assignment +// Get an assigment for an Account Settings Template. +func (iamIdentity *IamIdentityV1) GetAccountSettingsAssignment(getAccountSettingsAssignmentOptions *GetAccountSettingsAssignmentOptions) (result *TemplateAssignmentResponse, response *core.DetailedResponse, err error) { + return iamIdentity.GetAccountSettingsAssignmentWithContext(context.Background(), getAccountSettingsAssignmentOptions) } -// UnmarshalAccountBasedMfaEnrollment unmarshals an instance of AccountBasedMfaEnrollment from the specified map of raw messages. -func UnmarshalAccountBasedMfaEnrollment(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(AccountBasedMfaEnrollment) - err = core.UnmarshalModel(m, "security_questions", &obj.SecurityQuestions, UnmarshalMfaEnrollmentTypeStatus) +// GetAccountSettingsAssignmentWithContext is an alternate form of the GetAccountSettingsAssignment method which supports a Context parameter +func (iamIdentity *IamIdentityV1) GetAccountSettingsAssignmentWithContext(ctx context.Context, getAccountSettingsAssignmentOptions *GetAccountSettingsAssignmentOptions) (result *TemplateAssignmentResponse, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getAccountSettingsAssignmentOptions, "getAccountSettingsAssignmentOptions cannot be nil") if err != nil { return } - err = core.UnmarshalModel(m, "totp", &obj.Totp, UnmarshalMfaEnrollmentTypeStatus) + err = core.ValidateStruct(getAccountSettingsAssignmentOptions, "getAccountSettingsAssignmentOptions") if err != nil { return } - err = core.UnmarshalModel(m, "verisign", &obj.Verisign, UnmarshalMfaEnrollmentTypeStatus) - if err != nil { - return + + pathParamsMap := map[string]string{ + "assignment_id": *getAccountSettingsAssignmentOptions.AssignmentID, } - err = core.UnmarshalPrimitive(m, "complies", &obj.Complies) + + builder := core.NewRequestBuilder(core.GET) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = iamIdentity.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(iamIdentity.Service.Options.URL, `/v1/account_settings_assignments/{assignment_id}`, pathParamsMap) if err != nil { return } - reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) - return -} - -// AccountSettingsResponse : Response body format for Account Settings REST requests. -type AccountSettingsResponse struct { - // Context with key properties for problem determination. - Context *ResponseContext `json:"context,omitempty"` - - // Unique ID of the account. - AccountID *string `json:"account_id" validate:"required"` - - // Defines whether or not creating a Service Id is access controlled. Valid values: - // * RESTRICTED - to apply access control - // * NOT_RESTRICTED - to remove access control - // * NOT_SET - to 'unset' a previous set value. - RestrictCreateServiceID *string `json:"restrict_create_service_id" validate:"required"` - - // Defines whether or not creating platform API keys is access controlled. Valid values: - // * RESTRICTED - to apply access control - // * NOT_RESTRICTED - to remove access control - // * NOT_SET - to 'unset' a previous set value. - RestrictCreatePlatformApikey *string `json:"restrict_create_platform_apikey" validate:"required"` - - // Defines the IP addresses and subnets from which IAM tokens can be created for the account. - AllowedIPAddresses *string `json:"allowed_ip_addresses" validate:"required"` - - // Version of the account settings. - EntityTag *string `json:"entity_tag" validate:"required"` - - // Defines the MFA trait for the account. Valid values: - // * NONE - No MFA trait set - // * NONE_NO_ROPC- No MFA, disable CLI logins with only a password - // * TOTP - For all non-federated IBMId users - // * TOTP4ALL - For all users - // * LEVEL1 - Email-based MFA for all users - // * LEVEL2 - TOTP-based MFA for all users - // * LEVEL3 - U2F MFA for all users. - Mfa *string `json:"mfa" validate:"required"` - // List of users that are exempted from the MFA requirement of the account. - UserMfa []AccountSettingsUserMfa `json:"user_mfa" validate:"required"` - - // History of the Account Settings. - History []EnityHistoryRecord `json:"history,omitempty"` + for headerName, headerValue := range getAccountSettingsAssignmentOptions.Headers { + builder.AddHeader(headerName, headerValue) + } - // Defines the session expiration in seconds for the account. Valid values: - // * Any whole number between between '900' and '86400' - // * NOT_SET - To unset account setting and use service default. - SessionExpirationInSeconds *string `json:"session_expiration_in_seconds" validate:"required"` + sdkHeaders := common.GetSdkHeaders("iam_identity", "V1", "GetAccountSettingsAssignment") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") - // Defines the period of time in seconds in which a session will be invalidated due to inactivity. Valid values: - // * Any whole number between '900' and '7200' - // * NOT_SET - To unset account setting and use service default. - SessionInvalidationInSeconds *string `json:"session_invalidation_in_seconds" validate:"required"` + if getAccountSettingsAssignmentOptions.IncludeHistory != nil { + builder.AddQuery("include_history", fmt.Sprint(*getAccountSettingsAssignmentOptions.IncludeHistory)) + } - // Defines the max allowed sessions per identity required by the account. Valid values: - // * Any whole number greater than 0 - // * NOT_SET - To unset account setting and use service default. - MaxSessionsPerIdentity *string `json:"max_sessions_per_identity" validate:"required"` + request, err := builder.Build() + if err != nil { + return + } - // Defines the access token expiration in seconds. Valid values: - // * Any whole number between '900' and '3600' - // * NOT_SET - To unset account setting and use service default. - SystemAccessTokenExpirationInSeconds *string `json:"system_access_token_expiration_in_seconds" validate:"required"` + var rawResponse map[string]json.RawMessage + response, err = iamIdentity.Service.Request(request, &rawResponse) + if err != nil { + return + } + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalTemplateAssignmentResponse) + if err != nil { + return + } + response.Result = result + } - // Defines the refresh token expiration in seconds. Valid values: - // * Any whole number between '900' and '259200' - // * NOT_SET - To unset account setting and use service default. - SystemRefreshTokenExpirationInSeconds *string `json:"system_refresh_token_expiration_in_seconds" validate:"required"` + return } -// Constants associated with the AccountSettingsResponse.RestrictCreateServiceID property. -// Defines whether or not creating a Service Id is access controlled. Valid values: -// - RESTRICTED - to apply access control -// - NOT_RESTRICTED - to remove access control -// - NOT_SET - to 'unset' a previous set value. -const ( - AccountSettingsResponseRestrictCreateServiceIDNotRestrictedConst = "NOT_RESTRICTED" - AccountSettingsResponseRestrictCreateServiceIDNotSetConst = "NOT_SET" - AccountSettingsResponseRestrictCreateServiceIDRestrictedConst = "RESTRICTED" -) - -// Constants associated with the AccountSettingsResponse.RestrictCreatePlatformApikey property. -// Defines whether or not creating platform API keys is access controlled. Valid values: -// - RESTRICTED - to apply access control -// - NOT_RESTRICTED - to remove access control -// - NOT_SET - to 'unset' a previous set value. -const ( - AccountSettingsResponseRestrictCreatePlatformApikeyNotRestrictedConst = "NOT_RESTRICTED" - AccountSettingsResponseRestrictCreatePlatformApikeyNotSetConst = "NOT_SET" - AccountSettingsResponseRestrictCreatePlatformApikeyRestrictedConst = "RESTRICTED" -) - -// Constants associated with the AccountSettingsResponse.Mfa property. -// Defines the MFA trait for the account. Valid values: -// - NONE - No MFA trait set -// - NONE_NO_ROPC- No MFA, disable CLI logins with only a password -// - TOTP - For all non-federated IBMId users -// - TOTP4ALL - For all users -// - LEVEL1 - Email-based MFA for all users -// - LEVEL2 - TOTP-based MFA for all users -// - LEVEL3 - U2F MFA for all users. -const ( - AccountSettingsResponseMfaLevel1Const = "LEVEL1" - AccountSettingsResponseMfaLevel2Const = "LEVEL2" - AccountSettingsResponseMfaLevel3Const = "LEVEL3" - AccountSettingsResponseMfaNoneConst = "NONE" - AccountSettingsResponseMfaNoneNoRopcConst = "NONE_NO_ROPC" - AccountSettingsResponseMfaTotpConst = "TOTP" - AccountSettingsResponseMfaTotp4allConst = "TOTP4ALL" -) +// DeleteAccountSettingsAssignment : Delete Assignment +// Delete an Account Settings assignment. This will remove any resources created by this assignment. +func (iamIdentity *IamIdentityV1) DeleteAccountSettingsAssignment(deleteAccountSettingsAssignmentOptions *DeleteAccountSettingsAssignmentOptions) (result *ExceptionResponse, response *core.DetailedResponse, err error) { + return iamIdentity.DeleteAccountSettingsAssignmentWithContext(context.Background(), deleteAccountSettingsAssignmentOptions) +} -// UnmarshalAccountSettingsResponse unmarshals an instance of AccountSettingsResponse from the specified map of raw messages. -func UnmarshalAccountSettingsResponse(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(AccountSettingsResponse) - err = core.UnmarshalModel(m, "context", &obj.Context, UnmarshalResponseContext) +// DeleteAccountSettingsAssignmentWithContext is an alternate form of the DeleteAccountSettingsAssignment method which supports a Context parameter +func (iamIdentity *IamIdentityV1) DeleteAccountSettingsAssignmentWithContext(ctx context.Context, deleteAccountSettingsAssignmentOptions *DeleteAccountSettingsAssignmentOptions) (result *ExceptionResponse, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(deleteAccountSettingsAssignmentOptions, "deleteAccountSettingsAssignmentOptions cannot be nil") if err != nil { return } - err = core.UnmarshalPrimitive(m, "account_id", &obj.AccountID) + err = core.ValidateStruct(deleteAccountSettingsAssignmentOptions, "deleteAccountSettingsAssignmentOptions") if err != nil { return } - err = core.UnmarshalPrimitive(m, "restrict_create_service_id", &obj.RestrictCreateServiceID) - if err != nil { - return + + pathParamsMap := map[string]string{ + "assignment_id": *deleteAccountSettingsAssignmentOptions.AssignmentID, } - err = core.UnmarshalPrimitive(m, "restrict_create_platform_apikey", &obj.RestrictCreatePlatformApikey) + + builder := core.NewRequestBuilder(core.DELETE) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = iamIdentity.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(iamIdentity.Service.Options.URL, `/v1/account_settings_assignments/{assignment_id}`, pathParamsMap) if err != nil { return } - err = core.UnmarshalPrimitive(m, "allowed_ip_addresses", &obj.AllowedIPAddresses) - if err != nil { - return + + for headerName, headerValue := range deleteAccountSettingsAssignmentOptions.Headers { + builder.AddHeader(headerName, headerValue) } - err = core.UnmarshalPrimitive(m, "entity_tag", &obj.EntityTag) - if err != nil { - return + + sdkHeaders := common.GetSdkHeaders("iam_identity", "V1", "DeleteAccountSettingsAssignment") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) } - err = core.UnmarshalPrimitive(m, "mfa", &obj.Mfa) + builder.AddHeader("Accept", "application/json") + + request, err := builder.Build() if err != nil { return } - err = core.UnmarshalModel(m, "user_mfa", &obj.UserMfa, UnmarshalAccountSettingsUserMfa) + + var rawResponse map[string]json.RawMessage + response, err = iamIdentity.Service.Request(request, &rawResponse) if err != nil { return } - err = core.UnmarshalModel(m, "history", &obj.History, UnmarshalEnityHistoryRecord) - if err != nil { - return + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalExceptionResponse) + if err != nil { + return + } + response.Result = result } - err = core.UnmarshalPrimitive(m, "session_expiration_in_seconds", &obj.SessionExpirationInSeconds) + + return +} + +// UpdateAccountSettingsAssignment : Update Assignment +// Update an Account Settings assignment in order to retry failed assignments or migrate resources to a new version. +func (iamIdentity *IamIdentityV1) UpdateAccountSettingsAssignment(updateAccountSettingsAssignmentOptions *UpdateAccountSettingsAssignmentOptions) (result *TemplateAssignmentResponse, response *core.DetailedResponse, err error) { + return iamIdentity.UpdateAccountSettingsAssignmentWithContext(context.Background(), updateAccountSettingsAssignmentOptions) +} + +// UpdateAccountSettingsAssignmentWithContext is an alternate form of the UpdateAccountSettingsAssignment method which supports a Context parameter +func (iamIdentity *IamIdentityV1) UpdateAccountSettingsAssignmentWithContext(ctx context.Context, updateAccountSettingsAssignmentOptions *UpdateAccountSettingsAssignmentOptions) (result *TemplateAssignmentResponse, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(updateAccountSettingsAssignmentOptions, "updateAccountSettingsAssignmentOptions cannot be nil") if err != nil { return } - err = core.UnmarshalPrimitive(m, "session_invalidation_in_seconds", &obj.SessionInvalidationInSeconds) + err = core.ValidateStruct(updateAccountSettingsAssignmentOptions, "updateAccountSettingsAssignmentOptions") if err != nil { return } - err = core.UnmarshalPrimitive(m, "max_sessions_per_identity", &obj.MaxSessionsPerIdentity) - if err != nil { - return + + pathParamsMap := map[string]string{ + "assignment_id": *updateAccountSettingsAssignmentOptions.AssignmentID, } - err = core.UnmarshalPrimitive(m, "system_access_token_expiration_in_seconds", &obj.SystemAccessTokenExpirationInSeconds) + + builder := core.NewRequestBuilder(core.PATCH) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = iamIdentity.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(iamIdentity.Service.Options.URL, `/v1/account_settings_assignments/{assignment_id}`, pathParamsMap) if err != nil { return } - err = core.UnmarshalPrimitive(m, "system_refresh_token_expiration_in_seconds", &obj.SystemRefreshTokenExpirationInSeconds) - if err != nil { - return - } - reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) - return -} - -// AccountSettingsUserMfa : AccountSettingsUserMfa struct -type AccountSettingsUserMfa struct { - // The iam_id of the user. - IamID *string `json:"iam_id" validate:"required"` - // Defines the MFA requirement for the user. Valid values: - // * NONE - No MFA trait set - // * NONE_NO_ROPC- No MFA, disable CLI logins with only a password - // * TOTP - For all non-federated IBMId users - // * TOTP4ALL - For all users - // * LEVEL1 - Email-based MFA for all users - // * LEVEL2 - TOTP-based MFA for all users - // * LEVEL3 - U2F MFA for all users. - Mfa *string `json:"mfa" validate:"required"` -} + for headerName, headerValue := range updateAccountSettingsAssignmentOptions.Headers { + builder.AddHeader(headerName, headerValue) + } -// Constants associated with the AccountSettingsUserMfa.Mfa property. -// Defines the MFA requirement for the user. Valid values: -// - NONE - No MFA trait set -// - NONE_NO_ROPC- No MFA, disable CLI logins with only a password -// - TOTP - For all non-federated IBMId users -// - TOTP4ALL - For all users -// - LEVEL1 - Email-based MFA for all users -// - LEVEL2 - TOTP-based MFA for all users -// - LEVEL3 - U2F MFA for all users. -const ( - AccountSettingsUserMfaMfaLevel1Const = "LEVEL1" - AccountSettingsUserMfaMfaLevel2Const = "LEVEL2" - AccountSettingsUserMfaMfaLevel3Const = "LEVEL3" - AccountSettingsUserMfaMfaNoneConst = "NONE" - AccountSettingsUserMfaMfaNoneNoRopcConst = "NONE_NO_ROPC" - AccountSettingsUserMfaMfaTotpConst = "TOTP" - AccountSettingsUserMfaMfaTotp4allConst = "TOTP4ALL" -) + sdkHeaders := common.GetSdkHeaders("iam_identity", "V1", "UpdateAccountSettingsAssignment") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") + builder.AddHeader("Content-Type", "application/json") + if updateAccountSettingsAssignmentOptions.IfMatch != nil { + builder.AddHeader("If-Match", fmt.Sprint(*updateAccountSettingsAssignmentOptions.IfMatch)) + } -// NewAccountSettingsUserMfa : Instantiate AccountSettingsUserMfa (Generic Model Constructor) -func (*IamIdentityV1) NewAccountSettingsUserMfa(iamID string, mfa string) (_model *AccountSettingsUserMfa, err error) { - _model = &AccountSettingsUserMfa{ - IamID: core.StringPtr(iamID), - Mfa: core.StringPtr(mfa), + body := make(map[string]interface{}) + if updateAccountSettingsAssignmentOptions.TemplateVersion != nil { + body["template_version"] = updateAccountSettingsAssignmentOptions.TemplateVersion + } + _, err = builder.SetBodyContentJSON(body) + if err != nil { + return } - err = core.ValidateStruct(_model, "required parameters") - return -} -// UnmarshalAccountSettingsUserMfa unmarshals an instance of AccountSettingsUserMfa from the specified map of raw messages. -func UnmarshalAccountSettingsUserMfa(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(AccountSettingsUserMfa) - err = core.UnmarshalPrimitive(m, "iam_id", &obj.IamID) + request, err := builder.Build() if err != nil { return } - err = core.UnmarshalPrimitive(m, "mfa", &obj.Mfa) + + var rawResponse map[string]json.RawMessage + response, err = iamIdentity.Service.Request(request, &rawResponse) if err != nil { return } - reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalTemplateAssignmentResponse) + if err != nil { + return + } + response.Result = result + } + return } -// Activity : Activity struct -type Activity struct { - // Time when the entity was last authenticated. - LastAuthn *string `json:"last_authn,omitempty"` - - // Authentication count, number of times the entity was authenticated. - AuthnCount *int64 `json:"authn_count" validate:"required"` +// ListAccountSettingsTemplates : List Account Settings Templates +// List Account Settings Templates for an Enterprise Account. +func (iamIdentity *IamIdentityV1) ListAccountSettingsTemplates(listAccountSettingsTemplatesOptions *ListAccountSettingsTemplatesOptions) (result *AccountSettingsTemplateList, response *core.DetailedResponse, err error) { + return iamIdentity.ListAccountSettingsTemplatesWithContext(context.Background(), listAccountSettingsTemplatesOptions) } -// UnmarshalActivity unmarshals an instance of Activity from the specified map of raw messages. -func UnmarshalActivity(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(Activity) - err = core.UnmarshalPrimitive(m, "last_authn", &obj.LastAuthn) +// ListAccountSettingsTemplatesWithContext is an alternate form of the ListAccountSettingsTemplates method which supports a Context parameter +func (iamIdentity *IamIdentityV1) ListAccountSettingsTemplatesWithContext(ctx context.Context, listAccountSettingsTemplatesOptions *ListAccountSettingsTemplatesOptions) (result *AccountSettingsTemplateList, response *core.DetailedResponse, err error) { + err = core.ValidateStruct(listAccountSettingsTemplatesOptions, "listAccountSettingsTemplatesOptions") if err != nil { return } - err = core.UnmarshalPrimitive(m, "authn_count", &obj.AuthnCount) + + builder := core.NewRequestBuilder(core.GET) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = iamIdentity.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(iamIdentity.Service.Options.URL, `/v1/account_settings_templates`, nil) if err != nil { return } - reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) - return -} - -// APIKey : Response body format for API key V1 REST requests. -type APIKey struct { - // Context with key properties for problem determination. - Context *ResponseContext `json:"context,omitempty"` - - // Unique identifier of this API Key. - ID *string `json:"id" validate:"required"` - - // Version of the API Key details object. You need to specify this value when updating the API key to avoid stale - // updates. - EntityTag *string `json:"entity_tag,omitempty"` - - // Cloud Resource Name of the item. Example Cloud Resource Name: - // 'crn:v1:bluemix:public:iam-identity:us-south:a/myaccount::apikey:1234-9012-5678'. - CRN *string `json:"crn" validate:"required"` - // The API key cannot be changed if set to true. - Locked *bool `json:"locked" validate:"required"` - - // If set contains a date time string of the creation date in ISO format. - CreatedAt *strfmt.DateTime `json:"created_at,omitempty"` - - // IAM ID of the user or service which created the API key. - CreatedBy *string `json:"created_by" validate:"required"` - - // If set contains a date time string of the last modification date in ISO format. - ModifiedAt *strfmt.DateTime `json:"modified_at,omitempty"` - - // Name of the API key. The name is not checked for uniqueness. Therefore multiple names with the same value can exist. - // Access is done via the UUID of the API key. - Name *string `json:"name" validate:"required"` + for headerName, headerValue := range listAccountSettingsTemplatesOptions.Headers { + builder.AddHeader(headerName, headerValue) + } - // The optional description of the API key. The 'description' property is only available if a description was provided - // during a create of an API key. - Description *string `json:"description,omitempty"` + sdkHeaders := common.GetSdkHeaders("iam_identity", "V1", "ListAccountSettingsTemplates") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") - // The iam_id that this API key authenticates. - IamID *string `json:"iam_id" validate:"required"` + if listAccountSettingsTemplatesOptions.AccountID != nil { + builder.AddQuery("account_id", fmt.Sprint(*listAccountSettingsTemplatesOptions.AccountID)) + } + if listAccountSettingsTemplatesOptions.Limit != nil { + builder.AddQuery("limit", fmt.Sprint(*listAccountSettingsTemplatesOptions.Limit)) + } + if listAccountSettingsTemplatesOptions.Pagetoken != nil { + builder.AddQuery("pagetoken", fmt.Sprint(*listAccountSettingsTemplatesOptions.Pagetoken)) + } + if listAccountSettingsTemplatesOptions.Sort != nil { + builder.AddQuery("sort", fmt.Sprint(*listAccountSettingsTemplatesOptions.Sort)) + } + if listAccountSettingsTemplatesOptions.Order != nil { + builder.AddQuery("order", fmt.Sprint(*listAccountSettingsTemplatesOptions.Order)) + } + if listAccountSettingsTemplatesOptions.IncludeHistory != nil { + builder.AddQuery("include_history", fmt.Sprint(*listAccountSettingsTemplatesOptions.IncludeHistory)) + } - // ID of the account that this API key authenticates for. - AccountID *string `json:"account_id" validate:"required"` + request, err := builder.Build() + if err != nil { + return + } - // The API key value. This property only contains the API key value for the following cases: create an API key, update - // a service ID API key that stores the API key value as retrievable, or get a service ID API key that stores the API - // key value as retrievable. All other operations don't return the API key value, for example all user API key related - // operations, except for create, don't contain the API key value. - Apikey *string `json:"apikey" validate:"required"` + var rawResponse map[string]json.RawMessage + response, err = iamIdentity.Service.Request(request, &rawResponse) + if err != nil { + return + } + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalAccountSettingsTemplateList) + if err != nil { + return + } + response.Result = result + } - // History of the API key. - History []EnityHistoryRecord `json:"history,omitempty"` + return +} - Activity *Activity `json:"activity,omitempty"` +// CreateAccountSettingsTemplate : Create an Account Settings Template +// Create a new Account Settings Template for an Enterprise Account. +func (iamIdentity *IamIdentityV1) CreateAccountSettingsTemplate(createAccountSettingsTemplateOptions *CreateAccountSettingsTemplateOptions) (result *AccountSettingsTemplateResponse, response *core.DetailedResponse, err error) { + return iamIdentity.CreateAccountSettingsTemplateWithContext(context.Background(), createAccountSettingsTemplateOptions) } -// UnmarshalAPIKey unmarshals an instance of APIKey from the specified map of raw messages. -func UnmarshalAPIKey(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(APIKey) - err = core.UnmarshalModel(m, "context", &obj.Context, UnmarshalResponseContext) +// CreateAccountSettingsTemplateWithContext is an alternate form of the CreateAccountSettingsTemplate method which supports a Context parameter +func (iamIdentity *IamIdentityV1) CreateAccountSettingsTemplateWithContext(ctx context.Context, createAccountSettingsTemplateOptions *CreateAccountSettingsTemplateOptions) (result *AccountSettingsTemplateResponse, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(createAccountSettingsTemplateOptions, "createAccountSettingsTemplateOptions cannot be nil") if err != nil { return } - err = core.UnmarshalPrimitive(m, "id", &obj.ID) + err = core.ValidateStruct(createAccountSettingsTemplateOptions, "createAccountSettingsTemplateOptions") if err != nil { return } - err = core.UnmarshalPrimitive(m, "entity_tag", &obj.EntityTag) + + builder := core.NewRequestBuilder(core.POST) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = iamIdentity.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(iamIdentity.Service.Options.URL, `/v1/account_settings_templates`, nil) if err != nil { return } - err = core.UnmarshalPrimitive(m, "crn", &obj.CRN) - if err != nil { - return + + for headerName, headerValue := range createAccountSettingsTemplateOptions.Headers { + builder.AddHeader(headerName, headerValue) } - err = core.UnmarshalPrimitive(m, "locked", &obj.Locked) + + sdkHeaders := common.GetSdkHeaders("iam_identity", "V1", "CreateAccountSettingsTemplate") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") + builder.AddHeader("Content-Type", "application/json") + + body := make(map[string]interface{}) + if createAccountSettingsTemplateOptions.AccountID != nil { + body["account_id"] = createAccountSettingsTemplateOptions.AccountID + } + if createAccountSettingsTemplateOptions.Name != nil { + body["name"] = createAccountSettingsTemplateOptions.Name + } + if createAccountSettingsTemplateOptions.Description != nil { + body["description"] = createAccountSettingsTemplateOptions.Description + } + if createAccountSettingsTemplateOptions.AccountSettings != nil { + body["account_settings"] = createAccountSettingsTemplateOptions.AccountSettings + } + _, err = builder.SetBodyContentJSON(body) if err != nil { return } - err = core.UnmarshalPrimitive(m, "created_at", &obj.CreatedAt) + + request, err := builder.Build() if err != nil { return } - err = core.UnmarshalPrimitive(m, "created_by", &obj.CreatedBy) + + var rawResponse map[string]json.RawMessage + response, err = iamIdentity.Service.Request(request, &rawResponse) if err != nil { return } - err = core.UnmarshalPrimitive(m, "modified_at", &obj.ModifiedAt) + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalAccountSettingsTemplateResponse) + if err != nil { + return + } + response.Result = result + } + + return +} + +// GetLatestAccountSettingsTemplateVersion : Get latest version of an Account Settings Template +// Get latest version of an Account Settings Template for an Enterprise Account. +func (iamIdentity *IamIdentityV1) GetLatestAccountSettingsTemplateVersion(getLatestAccountSettingsTemplateVersionOptions *GetLatestAccountSettingsTemplateVersionOptions) (result *AccountSettingsTemplateResponse, response *core.DetailedResponse, err error) { + return iamIdentity.GetLatestAccountSettingsTemplateVersionWithContext(context.Background(), getLatestAccountSettingsTemplateVersionOptions) +} + +// GetLatestAccountSettingsTemplateVersionWithContext is an alternate form of the GetLatestAccountSettingsTemplateVersion method which supports a Context parameter +func (iamIdentity *IamIdentityV1) GetLatestAccountSettingsTemplateVersionWithContext(ctx context.Context, getLatestAccountSettingsTemplateVersionOptions *GetLatestAccountSettingsTemplateVersionOptions) (result *AccountSettingsTemplateResponse, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getLatestAccountSettingsTemplateVersionOptions, "getLatestAccountSettingsTemplateVersionOptions cannot be nil") if err != nil { return } - err = core.UnmarshalPrimitive(m, "name", &obj.Name) + err = core.ValidateStruct(getLatestAccountSettingsTemplateVersionOptions, "getLatestAccountSettingsTemplateVersionOptions") if err != nil { return } - err = core.UnmarshalPrimitive(m, "description", &obj.Description) + + pathParamsMap := map[string]string{ + "template_id": *getLatestAccountSettingsTemplateVersionOptions.TemplateID, + } + + builder := core.NewRequestBuilder(core.GET) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = iamIdentity.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(iamIdentity.Service.Options.URL, `/v1/account_settings_templates/{template_id}`, pathParamsMap) if err != nil { return } - err = core.UnmarshalPrimitive(m, "iam_id", &obj.IamID) + + for headerName, headerValue := range getLatestAccountSettingsTemplateVersionOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("iam_identity", "V1", "GetLatestAccountSettingsTemplateVersion") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") + + if getLatestAccountSettingsTemplateVersionOptions.IncludeHistory != nil { + builder.AddQuery("include_history", fmt.Sprint(*getLatestAccountSettingsTemplateVersionOptions.IncludeHistory)) + } + + request, err := builder.Build() if err != nil { return } - err = core.UnmarshalPrimitive(m, "account_id", &obj.AccountID) + + var rawResponse map[string]json.RawMessage + response, err = iamIdentity.Service.Request(request, &rawResponse) if err != nil { return } - err = core.UnmarshalPrimitive(m, "apikey", &obj.Apikey) + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalAccountSettingsTemplateResponse) + if err != nil { + return + } + response.Result = result + } + + return +} + +// DeleteAllVersionsOfAccountSettingsTemplate : Delete all versions of an Account Settings Template +// Delete all versions of an Account Settings Template for an Enterprise Account. +func (iamIdentity *IamIdentityV1) DeleteAllVersionsOfAccountSettingsTemplate(deleteAllVersionsOfAccountSettingsTemplateOptions *DeleteAllVersionsOfAccountSettingsTemplateOptions) (response *core.DetailedResponse, err error) { + return iamIdentity.DeleteAllVersionsOfAccountSettingsTemplateWithContext(context.Background(), deleteAllVersionsOfAccountSettingsTemplateOptions) +} + +// DeleteAllVersionsOfAccountSettingsTemplateWithContext is an alternate form of the DeleteAllVersionsOfAccountSettingsTemplate method which supports a Context parameter +func (iamIdentity *IamIdentityV1) DeleteAllVersionsOfAccountSettingsTemplateWithContext(ctx context.Context, deleteAllVersionsOfAccountSettingsTemplateOptions *DeleteAllVersionsOfAccountSettingsTemplateOptions) (response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(deleteAllVersionsOfAccountSettingsTemplateOptions, "deleteAllVersionsOfAccountSettingsTemplateOptions cannot be nil") if err != nil { return } - err = core.UnmarshalModel(m, "history", &obj.History, UnmarshalEnityHistoryRecord) + err = core.ValidateStruct(deleteAllVersionsOfAccountSettingsTemplateOptions, "deleteAllVersionsOfAccountSettingsTemplateOptions") if err != nil { return } - err = core.UnmarshalModel(m, "activity", &obj.Activity, UnmarshalActivity) + + pathParamsMap := map[string]string{ + "template_id": *deleteAllVersionsOfAccountSettingsTemplateOptions.TemplateID, + } + + builder := core.NewRequestBuilder(core.DELETE) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = iamIdentity.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(iamIdentity.Service.Options.URL, `/v1/account_settings_templates/{template_id}`, pathParamsMap) if err != nil { return } - reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) - return -} -// APIKeyInsideCreateServiceIDRequest : Parameters for the API key in the Create service Id V1 REST request. -type APIKeyInsideCreateServiceIDRequest struct { - // Name of the API key. The name is not checked for uniqueness. Therefore multiple names with the same value can exist. - // Access is done via the UUID of the API key. - Name *string `json:"name" validate:"required"` + for headerName, headerValue := range deleteAllVersionsOfAccountSettingsTemplateOptions.Headers { + builder.AddHeader(headerName, headerValue) + } - // The optional description of the API key. The 'description' property is only available if a description was provided - // during a create of an API key. - Description *string `json:"description,omitempty"` + sdkHeaders := common.GetSdkHeaders("iam_identity", "V1", "DeleteAllVersionsOfAccountSettingsTemplate") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } - // You can optionally passthrough the API key value for this API key. If passed, NO validation of that apiKey value is - // done, i.e. the value can be non-URL safe. If omitted, the API key management will create an URL safe opaque API key - // value. The value of the API key is checked for uniqueness. Please ensure enough variations when passing in this - // value. - Apikey *string `json:"apikey,omitempty"` + request, err := builder.Build() + if err != nil { + return + } - // Send true or false to set whether the API key value is retrievable in the future by using the Get details of an API - // key request. If you create an API key for a user, you must specify `false` or omit the value. We don't allow storing - // of API keys for users. - StoreValue *bool `json:"store_value,omitempty"` -} + response, err = iamIdentity.Service.Request(request, nil) -// NewAPIKeyInsideCreateServiceIDRequest : Instantiate APIKeyInsideCreateServiceIDRequest (Generic Model Constructor) -func (*IamIdentityV1) NewAPIKeyInsideCreateServiceIDRequest(name string) (_model *APIKeyInsideCreateServiceIDRequest, err error) { - _model = &APIKeyInsideCreateServiceIDRequest{ - Name: core.StringPtr(name), - } - err = core.ValidateStruct(_model, "required parameters") return } -// UnmarshalAPIKeyInsideCreateServiceIDRequest unmarshals an instance of APIKeyInsideCreateServiceIDRequest from the specified map of raw messages. -func UnmarshalAPIKeyInsideCreateServiceIDRequest(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(APIKeyInsideCreateServiceIDRequest) - err = core.UnmarshalPrimitive(m, "name", &obj.Name) +// ListVersionsOfAccountSettingsTemplate : List Account Settings Template versions +// List versions of an Account Settings Template in an Enterprise Account. +func (iamIdentity *IamIdentityV1) ListVersionsOfAccountSettingsTemplate(listVersionsOfAccountSettingsTemplateOptions *ListVersionsOfAccountSettingsTemplateOptions) (result *AccountSettingsTemplateList, response *core.DetailedResponse, err error) { + return iamIdentity.ListVersionsOfAccountSettingsTemplateWithContext(context.Background(), listVersionsOfAccountSettingsTemplateOptions) +} + +// ListVersionsOfAccountSettingsTemplateWithContext is an alternate form of the ListVersionsOfAccountSettingsTemplate method which supports a Context parameter +func (iamIdentity *IamIdentityV1) ListVersionsOfAccountSettingsTemplateWithContext(ctx context.Context, listVersionsOfAccountSettingsTemplateOptions *ListVersionsOfAccountSettingsTemplateOptions) (result *AccountSettingsTemplateList, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(listVersionsOfAccountSettingsTemplateOptions, "listVersionsOfAccountSettingsTemplateOptions cannot be nil") if err != nil { return } - err = core.UnmarshalPrimitive(m, "description", &obj.Description) + err = core.ValidateStruct(listVersionsOfAccountSettingsTemplateOptions, "listVersionsOfAccountSettingsTemplateOptions") if err != nil { return } - err = core.UnmarshalPrimitive(m, "apikey", &obj.Apikey) - if err != nil { - return + + pathParamsMap := map[string]string{ + "template_id": *listVersionsOfAccountSettingsTemplateOptions.TemplateID, } - err = core.UnmarshalPrimitive(m, "store_value", &obj.StoreValue) + + builder := core.NewRequestBuilder(core.GET) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = iamIdentity.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(iamIdentity.Service.Options.URL, `/v1/account_settings_templates/{template_id}/versions`, pathParamsMap) if err != nil { return } - reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) - return -} -// APIKeyList : Response body format for the List API keys V1 REST request. -type APIKeyList struct { - // Context with key properties for problem determination. - Context *ResponseContext `json:"context,omitempty"` + for headerName, headerValue := range listVersionsOfAccountSettingsTemplateOptions.Headers { + builder.AddHeader(headerName, headerValue) + } - // The offset of the current page. - Offset *int64 `json:"offset,omitempty"` + sdkHeaders := common.GetSdkHeaders("iam_identity", "V1", "ListVersionsOfAccountSettingsTemplate") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") - // Optional size of a single page. Default is 20 items per page. Valid range is 1 to 100. - Limit *int64 `json:"limit,omitempty"` + if listVersionsOfAccountSettingsTemplateOptions.Limit != nil { + builder.AddQuery("limit", fmt.Sprint(*listVersionsOfAccountSettingsTemplateOptions.Limit)) + } + if listVersionsOfAccountSettingsTemplateOptions.Pagetoken != nil { + builder.AddQuery("pagetoken", fmt.Sprint(*listVersionsOfAccountSettingsTemplateOptions.Pagetoken)) + } + if listVersionsOfAccountSettingsTemplateOptions.Sort != nil { + builder.AddQuery("sort", fmt.Sprint(*listVersionsOfAccountSettingsTemplateOptions.Sort)) + } + if listVersionsOfAccountSettingsTemplateOptions.Order != nil { + builder.AddQuery("order", fmt.Sprint(*listVersionsOfAccountSettingsTemplateOptions.Order)) + } + if listVersionsOfAccountSettingsTemplateOptions.IncludeHistory != nil { + builder.AddQuery("include_history", fmt.Sprint(*listVersionsOfAccountSettingsTemplateOptions.IncludeHistory)) + } - // Link to the first page. - First *string `json:"first,omitempty"` + request, err := builder.Build() + if err != nil { + return + } - // Link to the previous available page. If 'previous' property is not part of the response no previous page is - // available. - Previous *string `json:"previous,omitempty"` + var rawResponse map[string]json.RawMessage + response, err = iamIdentity.Service.Request(request, &rawResponse) + if err != nil { + return + } + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalAccountSettingsTemplateList) + if err != nil { + return + } + response.Result = result + } - // Link to the next available page. If 'next' property is not part of the response no next page is available. - Next *string `json:"next,omitempty"` + return +} - // List of API keys based on the query paramters and the page size. The apikeys array is always part of the response - // but might be empty depending on the query parameters values provided. - Apikeys []APIKey `json:"apikeys" validate:"required"` +// CreateAccountSettingsTemplateVersion : Create a new version of an Account Settings Template +// Create a new version of an Account Settings Template in an Enterprise Account. +func (iamIdentity *IamIdentityV1) CreateAccountSettingsTemplateVersion(createAccountSettingsTemplateVersionOptions *CreateAccountSettingsTemplateVersionOptions) (result *AccountSettingsTemplateResponse, response *core.DetailedResponse, err error) { + return iamIdentity.CreateAccountSettingsTemplateVersionWithContext(context.Background(), createAccountSettingsTemplateVersionOptions) } -// UnmarshalAPIKeyList unmarshals an instance of APIKeyList from the specified map of raw messages. -func UnmarshalAPIKeyList(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(APIKeyList) - err = core.UnmarshalModel(m, "context", &obj.Context, UnmarshalResponseContext) +// CreateAccountSettingsTemplateVersionWithContext is an alternate form of the CreateAccountSettingsTemplateVersion method which supports a Context parameter +func (iamIdentity *IamIdentityV1) CreateAccountSettingsTemplateVersionWithContext(ctx context.Context, createAccountSettingsTemplateVersionOptions *CreateAccountSettingsTemplateVersionOptions) (result *AccountSettingsTemplateResponse, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(createAccountSettingsTemplateVersionOptions, "createAccountSettingsTemplateVersionOptions cannot be nil") if err != nil { return } - err = core.UnmarshalPrimitive(m, "offset", &obj.Offset) + err = core.ValidateStruct(createAccountSettingsTemplateVersionOptions, "createAccountSettingsTemplateVersionOptions") if err != nil { return } - err = core.UnmarshalPrimitive(m, "limit", &obj.Limit) - if err != nil { - return + + pathParamsMap := map[string]string{ + "template_id": *createAccountSettingsTemplateVersionOptions.TemplateID, } - err = core.UnmarshalPrimitive(m, "first", &obj.First) + + builder := core.NewRequestBuilder(core.POST) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = iamIdentity.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(iamIdentity.Service.Options.URL, `/v1/account_settings_templates/{template_id}/versions`, pathParamsMap) if err != nil { return } - err = core.UnmarshalPrimitive(m, "previous", &obj.Previous) + + for headerName, headerValue := range createAccountSettingsTemplateVersionOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("iam_identity", "V1", "CreateAccountSettingsTemplateVersion") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") + builder.AddHeader("Content-Type", "application/json") + + body := make(map[string]interface{}) + if createAccountSettingsTemplateVersionOptions.AccountID != nil { + body["account_id"] = createAccountSettingsTemplateVersionOptions.AccountID + } + if createAccountSettingsTemplateVersionOptions.Name != nil { + body["name"] = createAccountSettingsTemplateVersionOptions.Name + } + if createAccountSettingsTemplateVersionOptions.Description != nil { + body["description"] = createAccountSettingsTemplateVersionOptions.Description + } + if createAccountSettingsTemplateVersionOptions.AccountSettings != nil { + body["account_settings"] = createAccountSettingsTemplateVersionOptions.AccountSettings + } + _, err = builder.SetBodyContentJSON(body) if err != nil { return } - err = core.UnmarshalPrimitive(m, "next", &obj.Next) + + request, err := builder.Build() if err != nil { return } - err = core.UnmarshalModel(m, "apikeys", &obj.Apikeys, UnmarshalAPIKey) + + var rawResponse map[string]json.RawMessage + response, err = iamIdentity.Service.Request(request, &rawResponse) if err != nil { return } - reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalAccountSettingsTemplateResponse) + if err != nil { + return + } + response.Result = result + } + return } -// ApikeyActivity : Apikeys activity details. -type ApikeyActivity struct { - // Unique id of the apikey. - ID *string `json:"id" validate:"required"` - - // Name provided during creation of the apikey. - Name *string `json:"name,omitempty"` - - // Type of the apikey. Supported values are `serviceid` and `user`. - Type *string `json:"type" validate:"required"` - - // serviceid details will be present if type is `serviceid`. - Serviceid *ApikeyActivityServiceid `json:"serviceid,omitempty"` - - // user details will be present if type is `user`. - User *ApikeyActivityUser `json:"user,omitempty"` - - // Time when the apikey was last authenticated. - LastAuthn *string `json:"last_authn,omitempty"` +// GetAccountSettingsTemplateVersion : Get version of an Account Settings Template +// Get a specific version of an Account Settings Template in an Enterprise Account. +func (iamIdentity *IamIdentityV1) GetAccountSettingsTemplateVersion(getAccountSettingsTemplateVersionOptions *GetAccountSettingsTemplateVersionOptions) (result *AccountSettingsTemplateResponse, response *core.DetailedResponse, err error) { + return iamIdentity.GetAccountSettingsTemplateVersionWithContext(context.Background(), getAccountSettingsTemplateVersionOptions) } -// UnmarshalApikeyActivity unmarshals an instance of ApikeyActivity from the specified map of raw messages. -func UnmarshalApikeyActivity(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(ApikeyActivity) - err = core.UnmarshalPrimitive(m, "id", &obj.ID) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "name", &obj.Name) +// GetAccountSettingsTemplateVersionWithContext is an alternate form of the GetAccountSettingsTemplateVersion method which supports a Context parameter +func (iamIdentity *IamIdentityV1) GetAccountSettingsTemplateVersionWithContext(ctx context.Context, getAccountSettingsTemplateVersionOptions *GetAccountSettingsTemplateVersionOptions) (result *AccountSettingsTemplateResponse, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getAccountSettingsTemplateVersionOptions, "getAccountSettingsTemplateVersionOptions cannot be nil") if err != nil { return } - err = core.UnmarshalPrimitive(m, "type", &obj.Type) + err = core.ValidateStruct(getAccountSettingsTemplateVersionOptions, "getAccountSettingsTemplateVersionOptions") if err != nil { return } - err = core.UnmarshalModel(m, "serviceid", &obj.Serviceid, UnmarshalApikeyActivityServiceid) - if err != nil { - return + + pathParamsMap := map[string]string{ + "template_id": *getAccountSettingsTemplateVersionOptions.TemplateID, + "version": *getAccountSettingsTemplateVersionOptions.Version, } - err = core.UnmarshalModel(m, "user", &obj.User, UnmarshalApikeyActivityUser) + + builder := core.NewRequestBuilder(core.GET) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = iamIdentity.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(iamIdentity.Service.Options.URL, `/v1/account_settings_templates/{template_id}/versions/{version}`, pathParamsMap) if err != nil { return } - err = core.UnmarshalPrimitive(m, "last_authn", &obj.LastAuthn) - if err != nil { - return + + for headerName, headerValue := range getAccountSettingsTemplateVersionOptions.Headers { + builder.AddHeader(headerName, headerValue) } - reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) - return -} -// ApikeyActivityServiceid : serviceid details will be present if type is `serviceid`. -type ApikeyActivityServiceid struct { - // Unique identifier of this Service Id. - ID *string `json:"id,omitempty"` + sdkHeaders := common.GetSdkHeaders("iam_identity", "V1", "GetAccountSettingsTemplateVersion") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") - // Name provided during creation of the serviceid. - Name *string `json:"name,omitempty"` -} + if getAccountSettingsTemplateVersionOptions.IncludeHistory != nil { + builder.AddQuery("include_history", fmt.Sprint(*getAccountSettingsTemplateVersionOptions.IncludeHistory)) + } -// UnmarshalApikeyActivityServiceid unmarshals an instance of ApikeyActivityServiceid from the specified map of raw messages. -func UnmarshalApikeyActivityServiceid(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(ApikeyActivityServiceid) - err = core.UnmarshalPrimitive(m, "id", &obj.ID) + request, err := builder.Build() if err != nil { return } - err = core.UnmarshalPrimitive(m, "name", &obj.Name) + + var rawResponse map[string]json.RawMessage + response, err = iamIdentity.Service.Request(request, &rawResponse) if err != nil { return } - reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalAccountSettingsTemplateResponse) + if err != nil { + return + } + response.Result = result + } + return } -// ApikeyActivityUser : user details will be present if type is `user`. -type ApikeyActivityUser struct { - // IAMid of the user. - IamID *string `json:"iam_id,omitempty"` - - // Name of the user. - Name *string `json:"name,omitempty"` - - // Username of the user. - Username *string `json:"username,omitempty"` - - // Email of the user. - Email *string `json:"email,omitempty"` +// UpdateAccountSettingsTemplateVersion : Update version of an Account Settings Template +// Update a specific version of an Account Settings Template in an Enterprise Account. +func (iamIdentity *IamIdentityV1) UpdateAccountSettingsTemplateVersion(updateAccountSettingsTemplateVersionOptions *UpdateAccountSettingsTemplateVersionOptions) (result *AccountSettingsTemplateResponse, response *core.DetailedResponse, err error) { + return iamIdentity.UpdateAccountSettingsTemplateVersionWithContext(context.Background(), updateAccountSettingsTemplateVersionOptions) } -// UnmarshalApikeyActivityUser unmarshals an instance of ApikeyActivityUser from the specified map of raw messages. -func UnmarshalApikeyActivityUser(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(ApikeyActivityUser) - err = core.UnmarshalPrimitive(m, "iam_id", &obj.IamID) +// UpdateAccountSettingsTemplateVersionWithContext is an alternate form of the UpdateAccountSettingsTemplateVersion method which supports a Context parameter +func (iamIdentity *IamIdentityV1) UpdateAccountSettingsTemplateVersionWithContext(ctx context.Context, updateAccountSettingsTemplateVersionOptions *UpdateAccountSettingsTemplateVersionOptions) (result *AccountSettingsTemplateResponse, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(updateAccountSettingsTemplateVersionOptions, "updateAccountSettingsTemplateVersionOptions cannot be nil") if err != nil { return } - err = core.UnmarshalPrimitive(m, "name", &obj.Name) + err = core.ValidateStruct(updateAccountSettingsTemplateVersionOptions, "updateAccountSettingsTemplateVersionOptions") if err != nil { return } - err = core.UnmarshalPrimitive(m, "username", &obj.Username) - if err != nil { - return + + pathParamsMap := map[string]string{ + "template_id": *updateAccountSettingsTemplateVersionOptions.TemplateID, + "version": *updateAccountSettingsTemplateVersionOptions.Version, } - err = core.UnmarshalPrimitive(m, "email", &obj.Email) + + builder := core.NewRequestBuilder(core.PUT) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = iamIdentity.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(iamIdentity.Service.Options.URL, `/v1/account_settings_templates/{template_id}/versions/{version}`, pathParamsMap) if err != nil { return } - reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) - return -} -// CreateAPIKeyOptions : The CreateAPIKey options. -type CreateAPIKeyOptions struct { - // Name of the API key. The name is not checked for uniqueness. Therefore multiple names with the same value can exist. - // Access is done via the UUID of the API key. - Name *string `json:"name" validate:"required"` - - // The iam_id that this API key authenticates. - IamID *string `json:"iam_id" validate:"required"` + for headerName, headerValue := range updateAccountSettingsTemplateVersionOptions.Headers { + builder.AddHeader(headerName, headerValue) + } - // The optional description of the API key. The 'description' property is only available if a description was provided - // during a create of an API key. - Description *string `json:"description,omitempty"` + sdkHeaders := common.GetSdkHeaders("iam_identity", "V1", "UpdateAccountSettingsTemplateVersion") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") + builder.AddHeader("Content-Type", "application/json") + if updateAccountSettingsTemplateVersionOptions.IfMatch != nil { + builder.AddHeader("If-Match", fmt.Sprint(*updateAccountSettingsTemplateVersionOptions.IfMatch)) + } - // The account ID of the API key. - AccountID *string `json:"account_id,omitempty"` + body := make(map[string]interface{}) + if updateAccountSettingsTemplateVersionOptions.AccountID != nil { + body["account_id"] = updateAccountSettingsTemplateVersionOptions.AccountID + } + if updateAccountSettingsTemplateVersionOptions.Name != nil { + body["name"] = updateAccountSettingsTemplateVersionOptions.Name + } + if updateAccountSettingsTemplateVersionOptions.Description != nil { + body["description"] = updateAccountSettingsTemplateVersionOptions.Description + } + if updateAccountSettingsTemplateVersionOptions.AccountSettings != nil { + body["account_settings"] = updateAccountSettingsTemplateVersionOptions.AccountSettings + } + _, err = builder.SetBodyContentJSON(body) + if err != nil { + return + } - // You can optionally passthrough the API key value for this API key. If passed, NO validation of that apiKey value is - // done, i.e. the value can be non-URL safe. If omitted, the API key management will create an URL safe opaque API key - // value. The value of the API key is checked for uniqueness. Please ensure enough variations when passing in this - // value. - Apikey *string `json:"apikey,omitempty"` + request, err := builder.Build() + if err != nil { + return + } - // Send true or false to set whether the API key value is retrievable in the future by using the Get details of an API - // key request. If you create an API key for a user, you must specify `false` or omit the value. We don't allow storing - // of API keys for users. - StoreValue *bool `json:"store_value,omitempty"` + var rawResponse map[string]json.RawMessage + response, err = iamIdentity.Service.Request(request, &rawResponse) + if err != nil { + return + } + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalAccountSettingsTemplateResponse) + if err != nil { + return + } + response.Result = result + } - // Indicates if the API key is locked for further write operations. False by default. - EntityLock *string `json:"Entity-Lock,omitempty"` + return +} - // Allows users to set headers on API requests - Headers map[string]string +// DeleteAccountSettingsTemplateVersion : Delete version of an Account Settings Template +// Delete a specific version of an Account Settings Template in an Enterprise Account. +func (iamIdentity *IamIdentityV1) DeleteAccountSettingsTemplateVersion(deleteAccountSettingsTemplateVersionOptions *DeleteAccountSettingsTemplateVersionOptions) (response *core.DetailedResponse, err error) { + return iamIdentity.DeleteAccountSettingsTemplateVersionWithContext(context.Background(), deleteAccountSettingsTemplateVersionOptions) } -// NewCreateAPIKeyOptions : Instantiate CreateAPIKeyOptions -func (*IamIdentityV1) NewCreateAPIKeyOptions(name string, iamID string) *CreateAPIKeyOptions { - return &CreateAPIKeyOptions{ - Name: core.StringPtr(name), - IamID: core.StringPtr(iamID), +// DeleteAccountSettingsTemplateVersionWithContext is an alternate form of the DeleteAccountSettingsTemplateVersion method which supports a Context parameter +func (iamIdentity *IamIdentityV1) DeleteAccountSettingsTemplateVersionWithContext(ctx context.Context, deleteAccountSettingsTemplateVersionOptions *DeleteAccountSettingsTemplateVersionOptions) (response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(deleteAccountSettingsTemplateVersionOptions, "deleteAccountSettingsTemplateVersionOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(deleteAccountSettingsTemplateVersionOptions, "deleteAccountSettingsTemplateVersionOptions") + if err != nil { + return } -} -// SetName : Allow user to set Name -func (_options *CreateAPIKeyOptions) SetName(name string) *CreateAPIKeyOptions { - _options.Name = core.StringPtr(name) - return _options -} + pathParamsMap := map[string]string{ + "template_id": *deleteAccountSettingsTemplateVersionOptions.TemplateID, + "version": *deleteAccountSettingsTemplateVersionOptions.Version, + } -// SetIamID : Allow user to set IamID -func (_options *CreateAPIKeyOptions) SetIamID(iamID string) *CreateAPIKeyOptions { - _options.IamID = core.StringPtr(iamID) - return _options -} + builder := core.NewRequestBuilder(core.DELETE) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = iamIdentity.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(iamIdentity.Service.Options.URL, `/v1/account_settings_templates/{template_id}/versions/{version}`, pathParamsMap) + if err != nil { + return + } -// SetDescription : Allow user to set Description -func (_options *CreateAPIKeyOptions) SetDescription(description string) *CreateAPIKeyOptions { - _options.Description = core.StringPtr(description) - return _options -} + for headerName, headerValue := range deleteAccountSettingsTemplateVersionOptions.Headers { + builder.AddHeader(headerName, headerValue) + } -// SetAccountID : Allow user to set AccountID -func (_options *CreateAPIKeyOptions) SetAccountID(accountID string) *CreateAPIKeyOptions { - _options.AccountID = core.StringPtr(accountID) - return _options -} + sdkHeaders := common.GetSdkHeaders("iam_identity", "V1", "DeleteAccountSettingsTemplateVersion") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } -// SetApikey : Allow user to set Apikey -func (_options *CreateAPIKeyOptions) SetApikey(apikey string) *CreateAPIKeyOptions { - _options.Apikey = core.StringPtr(apikey) - return _options -} + request, err := builder.Build() + if err != nil { + return + } -// SetStoreValue : Allow user to set StoreValue -func (_options *CreateAPIKeyOptions) SetStoreValue(storeValue bool) *CreateAPIKeyOptions { - _options.StoreValue = core.BoolPtr(storeValue) - return _options -} + response, err = iamIdentity.Service.Request(request, nil) -// SetEntityLock : Allow user to set EntityLock -func (_options *CreateAPIKeyOptions) SetEntityLock(entityLock string) *CreateAPIKeyOptions { - _options.EntityLock = core.StringPtr(entityLock) - return _options + return } -// SetHeaders : Allow user to set Headers -func (options *CreateAPIKeyOptions) SetHeaders(param map[string]string) *CreateAPIKeyOptions { - options.Headers = param - return options +// CommitAccountSettingsTemplate : Commit a template version +// Commit a specific version of an Account Settings Template in an Enterprise Account. A Template must be committed +// before being assigned, and once committed, can no longer be modified. +func (iamIdentity *IamIdentityV1) CommitAccountSettingsTemplate(commitAccountSettingsTemplateOptions *CommitAccountSettingsTemplateOptions) (response *core.DetailedResponse, err error) { + return iamIdentity.CommitAccountSettingsTemplateWithContext(context.Background(), commitAccountSettingsTemplateOptions) } -// CreateClaimRuleOptions : The CreateClaimRule options. -type CreateClaimRuleOptions struct { - // ID of the trusted profile to create a claim rule. - ProfileID *string `json:"profile-id" validate:"required,ne="` - - // Type of the claim rule, either 'Profile-SAML' or 'Profile-CR'. - Type *string `json:"type" validate:"required"` +// CommitAccountSettingsTemplateWithContext is an alternate form of the CommitAccountSettingsTemplate method which supports a Context parameter +func (iamIdentity *IamIdentityV1) CommitAccountSettingsTemplateWithContext(ctx context.Context, commitAccountSettingsTemplateOptions *CommitAccountSettingsTemplateOptions) (response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(commitAccountSettingsTemplateOptions, "commitAccountSettingsTemplateOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(commitAccountSettingsTemplateOptions, "commitAccountSettingsTemplateOptions") + if err != nil { + return + } - // Conditions of this claim rule. - Conditions []ProfileClaimRuleConditions `json:"conditions" validate:"required"` + pathParamsMap := map[string]string{ + "template_id": *commitAccountSettingsTemplateOptions.TemplateID, + "version": *commitAccountSettingsTemplateOptions.Version, + } - // Context with key properties for problem determination. - Context *ResponseContext `json:"context,omitempty"` + builder := core.NewRequestBuilder(core.POST) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = iamIdentity.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(iamIdentity.Service.Options.URL, `/v1/account_settings_templates/{template_id}/versions/{version}/commit`, pathParamsMap) + if err != nil { + return + } - // Name of the claim rule to be created or updated. - Name *string `json:"name,omitempty"` + for headerName, headerValue := range commitAccountSettingsTemplateOptions.Headers { + builder.AddHeader(headerName, headerValue) + } - // The realm name of the Idp this claim rule applies to. This field is required only if the type is specified as - // 'Profile-SAML'. - RealmName *string `json:"realm_name,omitempty"` + sdkHeaders := common.GetSdkHeaders("iam_identity", "V1", "CommitAccountSettingsTemplate") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } - // The compute resource type the rule applies to, required only if type is specified as 'Profile-CR'. Valid values are - // VSI, IKS_SA, ROKS_SA. - CrType *string `json:"cr_type,omitempty"` + request, err := builder.Build() + if err != nil { + return + } - // Session expiration in seconds, only required if type is 'Profile-SAML'. - Expiration *int64 `json:"expiration,omitempty"` + response, err = iamIdentity.Service.Request(request, nil) - // Allows users to set headers on API requests - Headers map[string]string + return } -// NewCreateClaimRuleOptions : Instantiate CreateClaimRuleOptions -func (*IamIdentityV1) NewCreateClaimRuleOptions(profileID string, typeVar string, conditions []ProfileClaimRuleConditions) *CreateClaimRuleOptions { - return &CreateClaimRuleOptions{ - ProfileID: core.StringPtr(profileID), - Type: core.StringPtr(typeVar), - Conditions: conditions, - } +// CreateReport : Trigger activity report for the account +// Trigger activity report for the account by specifying the account ID. It can take a few minutes to generate the +// report for retrieval. +func (iamIdentity *IamIdentityV1) CreateReport(createReportOptions *CreateReportOptions) (result *ReportReference, response *core.DetailedResponse, err error) { + return iamIdentity.CreateReportWithContext(context.Background(), createReportOptions) } -// SetProfileID : Allow user to set ProfileID -func (_options *CreateClaimRuleOptions) SetProfileID(profileID string) *CreateClaimRuleOptions { - _options.ProfileID = core.StringPtr(profileID) - return _options -} +// CreateReportWithContext is an alternate form of the CreateReport method which supports a Context parameter +func (iamIdentity *IamIdentityV1) CreateReportWithContext(ctx context.Context, createReportOptions *CreateReportOptions) (result *ReportReference, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(createReportOptions, "createReportOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(createReportOptions, "createReportOptions") + if err != nil { + return + } -// SetType : Allow user to set Type -func (_options *CreateClaimRuleOptions) SetType(typeVar string) *CreateClaimRuleOptions { - _options.Type = core.StringPtr(typeVar) - return _options -} + pathParamsMap := map[string]string{ + "account_id": *createReportOptions.AccountID, + } -// SetConditions : Allow user to set Conditions -func (_options *CreateClaimRuleOptions) SetConditions(conditions []ProfileClaimRuleConditions) *CreateClaimRuleOptions { - _options.Conditions = conditions - return _options -} + builder := core.NewRequestBuilder(core.POST) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = iamIdentity.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(iamIdentity.Service.Options.URL, `/v1/activity/accounts/{account_id}/report`, pathParamsMap) + if err != nil { + return + } -// SetContext : Allow user to set Context -func (_options *CreateClaimRuleOptions) SetContext(context *ResponseContext) *CreateClaimRuleOptions { - _options.Context = context - return _options -} + for headerName, headerValue := range createReportOptions.Headers { + builder.AddHeader(headerName, headerValue) + } -// SetName : Allow user to set Name -func (_options *CreateClaimRuleOptions) SetName(name string) *CreateClaimRuleOptions { - _options.Name = core.StringPtr(name) - return _options -} + sdkHeaders := common.GetSdkHeaders("iam_identity", "V1", "CreateReport") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") -// SetRealmName : Allow user to set RealmName -func (_options *CreateClaimRuleOptions) SetRealmName(realmName string) *CreateClaimRuleOptions { - _options.RealmName = core.StringPtr(realmName) - return _options -} + if createReportOptions.Type != nil { + builder.AddQuery("type", fmt.Sprint(*createReportOptions.Type)) + } + if createReportOptions.Duration != nil { + builder.AddQuery("duration", fmt.Sprint(*createReportOptions.Duration)) + } -// SetCrType : Allow user to set CrType -func (_options *CreateClaimRuleOptions) SetCrType(crType string) *CreateClaimRuleOptions { - _options.CrType = core.StringPtr(crType) - return _options -} + request, err := builder.Build() + if err != nil { + return + } -// SetExpiration : Allow user to set Expiration -func (_options *CreateClaimRuleOptions) SetExpiration(expiration int64) *CreateClaimRuleOptions { - _options.Expiration = core.Int64Ptr(expiration) - return _options + var rawResponse map[string]json.RawMessage + response, err = iamIdentity.Service.Request(request, &rawResponse) + if err != nil { + return + } + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalReportReference) + if err != nil { + return + } + response.Result = result + } + + return } -// SetHeaders : Allow user to set Headers -func (options *CreateClaimRuleOptions) SetHeaders(param map[string]string) *CreateClaimRuleOptions { - options.Headers = param - return options +// GetReport : Get activity report across on account scope +// Get activity report for the account by specifying the account ID and the reference that is generated by triggering +// the report. Reports older than a day are deleted when generating a new report. +func (iamIdentity *IamIdentityV1) GetReport(getReportOptions *GetReportOptions) (result *Report, response *core.DetailedResponse, err error) { + return iamIdentity.GetReportWithContext(context.Background(), getReportOptions) } -// CreateLinkOptions : The CreateLink options. -type CreateLinkOptions struct { - // ID of the trusted profile. - ProfileID *string `json:"profile-id" validate:"required,ne="` +// GetReportWithContext is an alternate form of the GetReport method which supports a Context parameter +func (iamIdentity *IamIdentityV1) GetReportWithContext(ctx context.Context, getReportOptions *GetReportOptions) (result *Report, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getReportOptions, "getReportOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(getReportOptions, "getReportOptions") + if err != nil { + return + } - // The compute resource type. Valid values are VSI, IKS_SA, ROKS_SA. - CrType *string `json:"cr_type" validate:"required"` + pathParamsMap := map[string]string{ + "account_id": *getReportOptions.AccountID, + "reference": *getReportOptions.Reference, + } - // Link details. - Link *CreateProfileLinkRequestLink `json:"link" validate:"required"` + builder := core.NewRequestBuilder(core.GET) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = iamIdentity.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(iamIdentity.Service.Options.URL, `/v1/activity/accounts/{account_id}/report/{reference}`, pathParamsMap) + if err != nil { + return + } - // Optional name of the Link. - Name *string `json:"name,omitempty"` + for headerName, headerValue := range getReportOptions.Headers { + builder.AddHeader(headerName, headerValue) + } - // Allows users to set headers on API requests - Headers map[string]string -} + sdkHeaders := common.GetSdkHeaders("iam_identity", "V1", "GetReport") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") -// NewCreateLinkOptions : Instantiate CreateLinkOptions -func (*IamIdentityV1) NewCreateLinkOptions(profileID string, crType string, link *CreateProfileLinkRequestLink) *CreateLinkOptions { - return &CreateLinkOptions{ - ProfileID: core.StringPtr(profileID), - CrType: core.StringPtr(crType), - Link: link, + request, err := builder.Build() + if err != nil { + return } -} -// SetProfileID : Allow user to set ProfileID -func (_options *CreateLinkOptions) SetProfileID(profileID string) *CreateLinkOptions { - _options.ProfileID = core.StringPtr(profileID) - return _options -} + var rawResponse map[string]json.RawMessage + response, err = iamIdentity.Service.Request(request, &rawResponse) + if err != nil { + return + } + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalReport) + if err != nil { + return + } + response.Result = result + } -// SetCrType : Allow user to set CrType -func (_options *CreateLinkOptions) SetCrType(crType string) *CreateLinkOptions { - _options.CrType = core.StringPtr(crType) - return _options + return } -// SetLink : Allow user to set Link -func (_options *CreateLinkOptions) SetLink(link *CreateProfileLinkRequestLink) *CreateLinkOptions { - _options.Link = link - return _options +// ListTrustedProfileAssignments : List Assignments +// List Trusted Profile Template Assignments. +func (iamIdentity *IamIdentityV1) ListTrustedProfileAssignments(listTrustedProfileAssignmentsOptions *ListTrustedProfileAssignmentsOptions) (result *TemplateAssignmentListResponse, response *core.DetailedResponse, err error) { + return iamIdentity.ListTrustedProfileAssignmentsWithContext(context.Background(), listTrustedProfileAssignmentsOptions) } -// SetName : Allow user to set Name -func (_options *CreateLinkOptions) SetName(name string) *CreateLinkOptions { - _options.Name = core.StringPtr(name) - return _options -} +// ListTrustedProfileAssignmentsWithContext is an alternate form of the ListTrustedProfileAssignments method which supports a Context parameter +func (iamIdentity *IamIdentityV1) ListTrustedProfileAssignmentsWithContext(ctx context.Context, listTrustedProfileAssignmentsOptions *ListTrustedProfileAssignmentsOptions) (result *TemplateAssignmentListResponse, response *core.DetailedResponse, err error) { + err = core.ValidateStruct(listTrustedProfileAssignmentsOptions, "listTrustedProfileAssignmentsOptions") + if err != nil { + return + } -// SetHeaders : Allow user to set Headers -func (options *CreateLinkOptions) SetHeaders(param map[string]string) *CreateLinkOptions { - options.Headers = param - return options -} + builder := core.NewRequestBuilder(core.GET) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = iamIdentity.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(iamIdentity.Service.Options.URL, `/v1/profile_assignments/`, nil) + if err != nil { + return + } -// CreateMfaReportOptions : The CreateMfaReport options. -type CreateMfaReportOptions struct { - // ID of the account. - AccountID *string `json:"account_id" validate:"required,ne="` + for headerName, headerValue := range listTrustedProfileAssignmentsOptions.Headers { + builder.AddHeader(headerName, headerValue) + } - // Optional report type. The supported value is 'mfa_status'. List MFA enrollment status for all the identities. - Type *string `json:"type,omitempty"` + sdkHeaders := common.GetSdkHeaders("iam_identity", "V1", "ListTrustedProfileAssignments") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") - // Allows users to set headers on API requests - Headers map[string]string -} + if listTrustedProfileAssignmentsOptions.AccountID != nil { + builder.AddQuery("account_id", fmt.Sprint(*listTrustedProfileAssignmentsOptions.AccountID)) + } + if listTrustedProfileAssignmentsOptions.TemplateID != nil { + builder.AddQuery("template_id", fmt.Sprint(*listTrustedProfileAssignmentsOptions.TemplateID)) + } + if listTrustedProfileAssignmentsOptions.TemplateVersion != nil { + builder.AddQuery("template_version", fmt.Sprint(*listTrustedProfileAssignmentsOptions.TemplateVersion)) + } + if listTrustedProfileAssignmentsOptions.Target != nil { + builder.AddQuery("target", fmt.Sprint(*listTrustedProfileAssignmentsOptions.Target)) + } + if listTrustedProfileAssignmentsOptions.TargetType != nil { + builder.AddQuery("target_type", fmt.Sprint(*listTrustedProfileAssignmentsOptions.TargetType)) + } + if listTrustedProfileAssignmentsOptions.Limit != nil { + builder.AddQuery("limit", fmt.Sprint(*listTrustedProfileAssignmentsOptions.Limit)) + } + if listTrustedProfileAssignmentsOptions.Pagetoken != nil { + builder.AddQuery("pagetoken", fmt.Sprint(*listTrustedProfileAssignmentsOptions.Pagetoken)) + } + if listTrustedProfileAssignmentsOptions.Sort != nil { + builder.AddQuery("sort", fmt.Sprint(*listTrustedProfileAssignmentsOptions.Sort)) + } + if listTrustedProfileAssignmentsOptions.Order != nil { + builder.AddQuery("order", fmt.Sprint(*listTrustedProfileAssignmentsOptions.Order)) + } + if listTrustedProfileAssignmentsOptions.IncludeHistory != nil { + builder.AddQuery("include_history", fmt.Sprint(*listTrustedProfileAssignmentsOptions.IncludeHistory)) + } -// NewCreateMfaReportOptions : Instantiate CreateMfaReportOptions -func (*IamIdentityV1) NewCreateMfaReportOptions(accountID string) *CreateMfaReportOptions { - return &CreateMfaReportOptions{ - AccountID: core.StringPtr(accountID), + request, err := builder.Build() + if err != nil { + return } -} -// SetAccountID : Allow user to set AccountID -func (_options *CreateMfaReportOptions) SetAccountID(accountID string) *CreateMfaReportOptions { - _options.AccountID = core.StringPtr(accountID) - return _options -} + var rawResponse map[string]json.RawMessage + response, err = iamIdentity.Service.Request(request, &rawResponse) + if err != nil { + return + } + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalTemplateAssignmentListResponse) + if err != nil { + return + } + response.Result = result + } -// SetType : Allow user to set Type -func (_options *CreateMfaReportOptions) SetType(typeVar string) *CreateMfaReportOptions { - _options.Type = core.StringPtr(typeVar) - return _options + return } -// SetHeaders : Allow user to set Headers -func (options *CreateMfaReportOptions) SetHeaders(param map[string]string) *CreateMfaReportOptions { - options.Headers = param - return options +// CreateTrustedProfileAssignment : Create Assignment +// Create an assigment for a Trusted Profile Template. +func (iamIdentity *IamIdentityV1) CreateTrustedProfileAssignment(createTrustedProfileAssignmentOptions *CreateTrustedProfileAssignmentOptions) (result *TemplateAssignmentResponse, response *core.DetailedResponse, err error) { + return iamIdentity.CreateTrustedProfileAssignmentWithContext(context.Background(), createTrustedProfileAssignmentOptions) } -// CreateProfileLinkRequestLink : Link details. -type CreateProfileLinkRequestLink struct { - // The CRN of the compute resource. - CRN *string `json:"crn" validate:"required"` +// CreateTrustedProfileAssignmentWithContext is an alternate form of the CreateTrustedProfileAssignment method which supports a Context parameter +func (iamIdentity *IamIdentityV1) CreateTrustedProfileAssignmentWithContext(ctx context.Context, createTrustedProfileAssignmentOptions *CreateTrustedProfileAssignmentOptions) (result *TemplateAssignmentResponse, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(createTrustedProfileAssignmentOptions, "createTrustedProfileAssignmentOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(createTrustedProfileAssignmentOptions, "createTrustedProfileAssignmentOptions") + if err != nil { + return + } - // The compute resource namespace, only required if cr_type is IKS_SA or ROKS_SA. - Namespace *string `json:"namespace" validate:"required"` + builder := core.NewRequestBuilder(core.POST) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = iamIdentity.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(iamIdentity.Service.Options.URL, `/v1/profile_assignments/`, nil) + if err != nil { + return + } - // Name of the compute resource, only required if cr_type is IKS_SA or ROKS_SA. - Name *string `json:"name,omitempty"` -} + for headerName, headerValue := range createTrustedProfileAssignmentOptions.Headers { + builder.AddHeader(headerName, headerValue) + } -// NewCreateProfileLinkRequestLink : Instantiate CreateProfileLinkRequestLink (Generic Model Constructor) -func (*IamIdentityV1) NewCreateProfileLinkRequestLink(crn string, namespace string) (_model *CreateProfileLinkRequestLink, err error) { - _model = &CreateProfileLinkRequestLink{ - CRN: core.StringPtr(crn), - Namespace: core.StringPtr(namespace), + sdkHeaders := common.GetSdkHeaders("iam_identity", "V1", "CreateTrustedProfileAssignment") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) } - err = core.ValidateStruct(_model, "required parameters") - return -} + builder.AddHeader("Accept", "application/json") + builder.AddHeader("Content-Type", "application/json") -// UnmarshalCreateProfileLinkRequestLink unmarshals an instance of CreateProfileLinkRequestLink from the specified map of raw messages. -func UnmarshalCreateProfileLinkRequestLink(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(CreateProfileLinkRequestLink) - err = core.UnmarshalPrimitive(m, "crn", &obj.CRN) + body := make(map[string]interface{}) + if createTrustedProfileAssignmentOptions.TemplateID != nil { + body["template_id"] = createTrustedProfileAssignmentOptions.TemplateID + } + if createTrustedProfileAssignmentOptions.TemplateVersion != nil { + body["template_version"] = createTrustedProfileAssignmentOptions.TemplateVersion + } + if createTrustedProfileAssignmentOptions.TargetType != nil { + body["target_type"] = createTrustedProfileAssignmentOptions.TargetType + } + if createTrustedProfileAssignmentOptions.Target != nil { + body["target"] = createTrustedProfileAssignmentOptions.Target + } + _, err = builder.SetBodyContentJSON(body) if err != nil { return } - err = core.UnmarshalPrimitive(m, "namespace", &obj.Namespace) + + request, err := builder.Build() if err != nil { return } - err = core.UnmarshalPrimitive(m, "name", &obj.Name) + + var rawResponse map[string]json.RawMessage + response, err = iamIdentity.Service.Request(request, &rawResponse) if err != nil { return } - reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalTemplateAssignmentResponse) + if err != nil { + return + } + response.Result = result + } + return } -// CreateProfileOptions : The CreateProfile options. -type CreateProfileOptions struct { - // Name of the trusted profile. The name is checked for uniqueness. Therefore trusted profiles with the same names can - // not exist in the same account. - Name *string `json:"name" validate:"required"` - - // The account ID of the trusted profile. - AccountID *string `json:"account_id" validate:"required"` - - // The optional description of the trusted profile. The 'description' property is only available if a description was - // provided during creation of trusted profile. - Description *string `json:"description,omitempty"` - - // Allows users to set headers on API requests - Headers map[string]string +// GetTrustedProfileAssignment : Get Assignment +// Get an assigment for a Trusted Profile Template. +func (iamIdentity *IamIdentityV1) GetTrustedProfileAssignment(getTrustedProfileAssignmentOptions *GetTrustedProfileAssignmentOptions) (result *TemplateAssignmentResponse, response *core.DetailedResponse, err error) { + return iamIdentity.GetTrustedProfileAssignmentWithContext(context.Background(), getTrustedProfileAssignmentOptions) } -// NewCreateProfileOptions : Instantiate CreateProfileOptions -func (*IamIdentityV1) NewCreateProfileOptions(name string, accountID string) *CreateProfileOptions { - return &CreateProfileOptions{ - Name: core.StringPtr(name), - AccountID: core.StringPtr(accountID), +// GetTrustedProfileAssignmentWithContext is an alternate form of the GetTrustedProfileAssignment method which supports a Context parameter +func (iamIdentity *IamIdentityV1) GetTrustedProfileAssignmentWithContext(ctx context.Context, getTrustedProfileAssignmentOptions *GetTrustedProfileAssignmentOptions) (result *TemplateAssignmentResponse, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getTrustedProfileAssignmentOptions, "getTrustedProfileAssignmentOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(getTrustedProfileAssignmentOptions, "getTrustedProfileAssignmentOptions") + if err != nil { + return } -} - -// SetName : Allow user to set Name -func (_options *CreateProfileOptions) SetName(name string) *CreateProfileOptions { - _options.Name = core.StringPtr(name) - return _options -} - -// SetAccountID : Allow user to set AccountID -func (_options *CreateProfileOptions) SetAccountID(accountID string) *CreateProfileOptions { - _options.AccountID = core.StringPtr(accountID) - return _options -} - -// SetDescription : Allow user to set Description -func (_options *CreateProfileOptions) SetDescription(description string) *CreateProfileOptions { - _options.Description = core.StringPtr(description) - return _options -} - -// SetHeaders : Allow user to set Headers -func (options *CreateProfileOptions) SetHeaders(param map[string]string) *CreateProfileOptions { - options.Headers = param - return options -} -// CreateReportOptions : The CreateReport options. -type CreateReportOptions struct { - // ID of the account. - AccountID *string `json:"account_id" validate:"required,ne="` + pathParamsMap := map[string]string{ + "assignment_id": *getTrustedProfileAssignmentOptions.AssignmentID, + } - // Optional report type. The supported value is 'inactive'. List all identities that have not authenticated within the - // time indicated by duration. - Type *string `json:"type,omitempty"` + builder := core.NewRequestBuilder(core.GET) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = iamIdentity.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(iamIdentity.Service.Options.URL, `/v1/profile_assignments/{assignment_id}`, pathParamsMap) + if err != nil { + return + } - // Optional duration of the report. The supported unit of duration is hours. - Duration *string `json:"duration,omitempty"` + for headerName, headerValue := range getTrustedProfileAssignmentOptions.Headers { + builder.AddHeader(headerName, headerValue) + } - // Allows users to set headers on API requests - Headers map[string]string -} + sdkHeaders := common.GetSdkHeaders("iam_identity", "V1", "GetTrustedProfileAssignment") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") -// NewCreateReportOptions : Instantiate CreateReportOptions -func (*IamIdentityV1) NewCreateReportOptions(accountID string) *CreateReportOptions { - return &CreateReportOptions{ - AccountID: core.StringPtr(accountID), + if getTrustedProfileAssignmentOptions.IncludeHistory != nil { + builder.AddQuery("include_history", fmt.Sprint(*getTrustedProfileAssignmentOptions.IncludeHistory)) } -} -// SetAccountID : Allow user to set AccountID -func (_options *CreateReportOptions) SetAccountID(accountID string) *CreateReportOptions { - _options.AccountID = core.StringPtr(accountID) - return _options -} + request, err := builder.Build() + if err != nil { + return + } -// SetType : Allow user to set Type -func (_options *CreateReportOptions) SetType(typeVar string) *CreateReportOptions { - _options.Type = core.StringPtr(typeVar) - return _options -} + var rawResponse map[string]json.RawMessage + response, err = iamIdentity.Service.Request(request, &rawResponse) + if err != nil { + return + } + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalTemplateAssignmentResponse) + if err != nil { + return + } + response.Result = result + } -// SetDuration : Allow user to set Duration -func (_options *CreateReportOptions) SetDuration(duration string) *CreateReportOptions { - _options.Duration = core.StringPtr(duration) - return _options + return } -// SetHeaders : Allow user to set Headers -func (options *CreateReportOptions) SetHeaders(param map[string]string) *CreateReportOptions { - options.Headers = param - return options +// DeleteTrustedProfileAssignment : Delete Assignment +// Delete a Trusted Profile assignment. This will remove any resources created by this assignment. +func (iamIdentity *IamIdentityV1) DeleteTrustedProfileAssignment(deleteTrustedProfileAssignmentOptions *DeleteTrustedProfileAssignmentOptions) (result *ExceptionResponse, response *core.DetailedResponse, err error) { + return iamIdentity.DeleteTrustedProfileAssignmentWithContext(context.Background(), deleteTrustedProfileAssignmentOptions) } -// CreateServiceIDOptions : The CreateServiceID options. -type CreateServiceIDOptions struct { - // ID of the account the service ID belongs to. - AccountID *string `json:"account_id" validate:"required"` - - // Name of the Service Id. The name is not checked for uniqueness. Therefore multiple names with the same value can - // exist. Access is done via the UUID of the Service Id. - Name *string `json:"name" validate:"required"` +// DeleteTrustedProfileAssignmentWithContext is an alternate form of the DeleteTrustedProfileAssignment method which supports a Context parameter +func (iamIdentity *IamIdentityV1) DeleteTrustedProfileAssignmentWithContext(ctx context.Context, deleteTrustedProfileAssignmentOptions *DeleteTrustedProfileAssignmentOptions) (result *ExceptionResponse, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(deleteTrustedProfileAssignmentOptions, "deleteTrustedProfileAssignmentOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(deleteTrustedProfileAssignmentOptions, "deleteTrustedProfileAssignmentOptions") + if err != nil { + return + } - // The optional description of the Service Id. The 'description' property is only available if a description was - // provided during a create of a Service Id. - Description *string `json:"description,omitempty"` + pathParamsMap := map[string]string{ + "assignment_id": *deleteTrustedProfileAssignmentOptions.AssignmentID, + } - // Optional list of CRNs (string array) which point to the services connected to the service ID. - UniqueInstanceCrns []string `json:"unique_instance_crns,omitempty"` + builder := core.NewRequestBuilder(core.DELETE) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = iamIdentity.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(iamIdentity.Service.Options.URL, `/v1/profile_assignments/{assignment_id}`, pathParamsMap) + if err != nil { + return + } - // Parameters for the API key in the Create service Id V1 REST request. - Apikey *APIKeyInsideCreateServiceIDRequest `json:"apikey,omitempty"` + for headerName, headerValue := range deleteTrustedProfileAssignmentOptions.Headers { + builder.AddHeader(headerName, headerValue) + } - // Indicates if the service ID is locked for further write operations. False by default. - EntityLock *string `json:"Entity-Lock,omitempty"` + sdkHeaders := common.GetSdkHeaders("iam_identity", "V1", "DeleteTrustedProfileAssignment") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") - // Allows users to set headers on API requests - Headers map[string]string -} + request, err := builder.Build() + if err != nil { + return + } -// NewCreateServiceIDOptions : Instantiate CreateServiceIDOptions -func (*IamIdentityV1) NewCreateServiceIDOptions(accountID string, name string) *CreateServiceIDOptions { - return &CreateServiceIDOptions{ - AccountID: core.StringPtr(accountID), - Name: core.StringPtr(name), + var rawResponse map[string]json.RawMessage + response, err = iamIdentity.Service.Request(request, &rawResponse) + if err != nil { + return + } + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalExceptionResponse) + if err != nil { + return + } + response.Result = result } -} -// SetAccountID : Allow user to set AccountID -func (_options *CreateServiceIDOptions) SetAccountID(accountID string) *CreateServiceIDOptions { - _options.AccountID = core.StringPtr(accountID) - return _options + return } -// SetName : Allow user to set Name -func (_options *CreateServiceIDOptions) SetName(name string) *CreateServiceIDOptions { - _options.Name = core.StringPtr(name) - return _options +// UpdateTrustedProfileAssignment : Update Assignment +// Update a Trusted Profile assignment in order to retry failed assignments or migrate resources to a new version. +func (iamIdentity *IamIdentityV1) UpdateTrustedProfileAssignment(updateTrustedProfileAssignmentOptions *UpdateTrustedProfileAssignmentOptions) (result *TemplateAssignmentResponse, response *core.DetailedResponse, err error) { + return iamIdentity.UpdateTrustedProfileAssignmentWithContext(context.Background(), updateTrustedProfileAssignmentOptions) } -// SetDescription : Allow user to set Description -func (_options *CreateServiceIDOptions) SetDescription(description string) *CreateServiceIDOptions { - _options.Description = core.StringPtr(description) - return _options -} +// UpdateTrustedProfileAssignmentWithContext is an alternate form of the UpdateTrustedProfileAssignment method which supports a Context parameter +func (iamIdentity *IamIdentityV1) UpdateTrustedProfileAssignmentWithContext(ctx context.Context, updateTrustedProfileAssignmentOptions *UpdateTrustedProfileAssignmentOptions) (result *TemplateAssignmentResponse, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(updateTrustedProfileAssignmentOptions, "updateTrustedProfileAssignmentOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(updateTrustedProfileAssignmentOptions, "updateTrustedProfileAssignmentOptions") + if err != nil { + return + } -// SetUniqueInstanceCrns : Allow user to set UniqueInstanceCrns -func (_options *CreateServiceIDOptions) SetUniqueInstanceCrns(uniqueInstanceCrns []string) *CreateServiceIDOptions { - _options.UniqueInstanceCrns = uniqueInstanceCrns - return _options -} + pathParamsMap := map[string]string{ + "assignment_id": *updateTrustedProfileAssignmentOptions.AssignmentID, + } -// SetApikey : Allow user to set Apikey -func (_options *CreateServiceIDOptions) SetApikey(apikey *APIKeyInsideCreateServiceIDRequest) *CreateServiceIDOptions { - _options.Apikey = apikey - return _options -} + builder := core.NewRequestBuilder(core.PATCH) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = iamIdentity.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(iamIdentity.Service.Options.URL, `/v1/profile_assignments/{assignment_id}`, pathParamsMap) + if err != nil { + return + } -// SetEntityLock : Allow user to set EntityLock -func (_options *CreateServiceIDOptions) SetEntityLock(entityLock string) *CreateServiceIDOptions { - _options.EntityLock = core.StringPtr(entityLock) - return _options -} + for headerName, headerValue := range updateTrustedProfileAssignmentOptions.Headers { + builder.AddHeader(headerName, headerValue) + } -// SetHeaders : Allow user to set Headers -func (options *CreateServiceIDOptions) SetHeaders(param map[string]string) *CreateServiceIDOptions { - options.Headers = param - return options -} + sdkHeaders := common.GetSdkHeaders("iam_identity", "V1", "UpdateTrustedProfileAssignment") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") + builder.AddHeader("Content-Type", "application/json") + if updateTrustedProfileAssignmentOptions.IfMatch != nil { + builder.AddHeader("If-Match", fmt.Sprint(*updateTrustedProfileAssignmentOptions.IfMatch)) + } -// DeleteAPIKeyOptions : The DeleteAPIKey options. -type DeleteAPIKeyOptions struct { - // Unique ID of the API key. - ID *string `json:"id" validate:"required,ne="` + body := make(map[string]interface{}) + if updateTrustedProfileAssignmentOptions.TemplateVersion != nil { + body["template_version"] = updateTrustedProfileAssignmentOptions.TemplateVersion + } + _, err = builder.SetBodyContentJSON(body) + if err != nil { + return + } - // Allows users to set headers on API requests - Headers map[string]string -} + request, err := builder.Build() + if err != nil { + return + } -// NewDeleteAPIKeyOptions : Instantiate DeleteAPIKeyOptions -func (*IamIdentityV1) NewDeleteAPIKeyOptions(id string) *DeleteAPIKeyOptions { - return &DeleteAPIKeyOptions{ - ID: core.StringPtr(id), + var rawResponse map[string]json.RawMessage + response, err = iamIdentity.Service.Request(request, &rawResponse) + if err != nil { + return + } + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalTemplateAssignmentResponse) + if err != nil { + return + } + response.Result = result } -} -// SetID : Allow user to set ID -func (_options *DeleteAPIKeyOptions) SetID(id string) *DeleteAPIKeyOptions { - _options.ID = core.StringPtr(id) - return _options + return } -// SetHeaders : Allow user to set Headers -func (options *DeleteAPIKeyOptions) SetHeaders(param map[string]string) *DeleteAPIKeyOptions { - options.Headers = param - return options +// ListProfileTemplates : List Profile Templates +// List Trusted Profile Templates for an Enterprise Account. +func (iamIdentity *IamIdentityV1) ListProfileTemplates(listProfileTemplatesOptions *ListProfileTemplatesOptions) (result *TrustedProfileTemplateList, response *core.DetailedResponse, err error) { + return iamIdentity.ListProfileTemplatesWithContext(context.Background(), listProfileTemplatesOptions) } -// DeleteClaimRuleOptions : The DeleteClaimRule options. -type DeleteClaimRuleOptions struct { - // ID of the trusted profile. - ProfileID *string `json:"profile-id" validate:"required,ne="` +// ListProfileTemplatesWithContext is an alternate form of the ListProfileTemplates method which supports a Context parameter +func (iamIdentity *IamIdentityV1) ListProfileTemplatesWithContext(ctx context.Context, listProfileTemplatesOptions *ListProfileTemplatesOptions) (result *TrustedProfileTemplateList, response *core.DetailedResponse, err error) { + err = core.ValidateStruct(listProfileTemplatesOptions, "listProfileTemplatesOptions") + if err != nil { + return + } - // ID of the claim rule to delete. - RuleID *string `json:"rule-id" validate:"required,ne="` + builder := core.NewRequestBuilder(core.GET) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = iamIdentity.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(iamIdentity.Service.Options.URL, `/v1/profile_templates`, nil) + if err != nil { + return + } - // Allows users to set headers on API requests - Headers map[string]string -} + for headerName, headerValue := range listProfileTemplatesOptions.Headers { + builder.AddHeader(headerName, headerValue) + } -// NewDeleteClaimRuleOptions : Instantiate DeleteClaimRuleOptions -func (*IamIdentityV1) NewDeleteClaimRuleOptions(profileID string, ruleID string) *DeleteClaimRuleOptions { - return &DeleteClaimRuleOptions{ - ProfileID: core.StringPtr(profileID), - RuleID: core.StringPtr(ruleID), + sdkHeaders := common.GetSdkHeaders("iam_identity", "V1", "ListProfileTemplates") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) } -} + builder.AddHeader("Accept", "application/json") -// SetProfileID : Allow user to set ProfileID -func (_options *DeleteClaimRuleOptions) SetProfileID(profileID string) *DeleteClaimRuleOptions { - _options.ProfileID = core.StringPtr(profileID) - return _options -} + if listProfileTemplatesOptions.AccountID != nil { + builder.AddQuery("account_id", fmt.Sprint(*listProfileTemplatesOptions.AccountID)) + } + if listProfileTemplatesOptions.Limit != nil { + builder.AddQuery("limit", fmt.Sprint(*listProfileTemplatesOptions.Limit)) + } + if listProfileTemplatesOptions.Pagetoken != nil { + builder.AddQuery("pagetoken", fmt.Sprint(*listProfileTemplatesOptions.Pagetoken)) + } + if listProfileTemplatesOptions.Sort != nil { + builder.AddQuery("sort", fmt.Sprint(*listProfileTemplatesOptions.Sort)) + } + if listProfileTemplatesOptions.Order != nil { + builder.AddQuery("order", fmt.Sprint(*listProfileTemplatesOptions.Order)) + } + if listProfileTemplatesOptions.IncludeHistory != nil { + builder.AddQuery("include_history", fmt.Sprint(*listProfileTemplatesOptions.IncludeHistory)) + } -// SetRuleID : Allow user to set RuleID -func (_options *DeleteClaimRuleOptions) SetRuleID(ruleID string) *DeleteClaimRuleOptions { - _options.RuleID = core.StringPtr(ruleID) - return _options + request, err := builder.Build() + if err != nil { + return + } + + var rawResponse map[string]json.RawMessage + response, err = iamIdentity.Service.Request(request, &rawResponse) + if err != nil { + return + } + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalTrustedProfileTemplateList) + if err != nil { + return + } + response.Result = result + } + + return } -// SetHeaders : Allow user to set Headers -func (options *DeleteClaimRuleOptions) SetHeaders(param map[string]string) *DeleteClaimRuleOptions { - options.Headers = param - return options +// CreateProfileTemplate : Create a Profile Template +// Create a new Trusted Profile Template for an Enterprise Account. +func (iamIdentity *IamIdentityV1) CreateProfileTemplate(createProfileTemplateOptions *CreateProfileTemplateOptions) (result *TrustedProfileTemplateResponse, response *core.DetailedResponse, err error) { + return iamIdentity.CreateProfileTemplateWithContext(context.Background(), createProfileTemplateOptions) } -// DeleteLinkOptions : The DeleteLink options. -type DeleteLinkOptions struct { - // ID of the trusted profile. - ProfileID *string `json:"profile-id" validate:"required,ne="` +// CreateProfileTemplateWithContext is an alternate form of the CreateProfileTemplate method which supports a Context parameter +func (iamIdentity *IamIdentityV1) CreateProfileTemplateWithContext(ctx context.Context, createProfileTemplateOptions *CreateProfileTemplateOptions) (result *TrustedProfileTemplateResponse, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(createProfileTemplateOptions, "createProfileTemplateOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(createProfileTemplateOptions, "createProfileTemplateOptions") + if err != nil { + return + } - // ID of the link. - LinkID *string `json:"link-id" validate:"required,ne="` + builder := core.NewRequestBuilder(core.POST) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = iamIdentity.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(iamIdentity.Service.Options.URL, `/v1/profile_templates`, nil) + if err != nil { + return + } - // Allows users to set headers on API requests - Headers map[string]string -} + for headerName, headerValue := range createProfileTemplateOptions.Headers { + builder.AddHeader(headerName, headerValue) + } -// NewDeleteLinkOptions : Instantiate DeleteLinkOptions -func (*IamIdentityV1) NewDeleteLinkOptions(profileID string, linkID string) *DeleteLinkOptions { - return &DeleteLinkOptions{ - ProfileID: core.StringPtr(profileID), - LinkID: core.StringPtr(linkID), + sdkHeaders := common.GetSdkHeaders("iam_identity", "V1", "CreateProfileTemplate") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) } -} + builder.AddHeader("Accept", "application/json") + builder.AddHeader("Content-Type", "application/json") -// SetProfileID : Allow user to set ProfileID -func (_options *DeleteLinkOptions) SetProfileID(profileID string) *DeleteLinkOptions { - _options.ProfileID = core.StringPtr(profileID) - return _options -} + body := make(map[string]interface{}) + if createProfileTemplateOptions.AccountID != nil { + body["account_id"] = createProfileTemplateOptions.AccountID + } + if createProfileTemplateOptions.Name != nil { + body["name"] = createProfileTemplateOptions.Name + } + if createProfileTemplateOptions.Description != nil { + body["description"] = createProfileTemplateOptions.Description + } + if createProfileTemplateOptions.Profile != nil { + body["profile"] = createProfileTemplateOptions.Profile + } + if createProfileTemplateOptions.PolicyTemplateReferences != nil { + body["policy_template_references"] = createProfileTemplateOptions.PolicyTemplateReferences + } + _, err = builder.SetBodyContentJSON(body) + if err != nil { + return + } -// SetLinkID : Allow user to set LinkID -func (_options *DeleteLinkOptions) SetLinkID(linkID string) *DeleteLinkOptions { - _options.LinkID = core.StringPtr(linkID) - return _options + request, err := builder.Build() + if err != nil { + return + } + + var rawResponse map[string]json.RawMessage + response, err = iamIdentity.Service.Request(request, &rawResponse) + if err != nil { + return + } + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalTrustedProfileTemplateResponse) + if err != nil { + return + } + response.Result = result + } + + return } -// SetHeaders : Allow user to set Headers -func (options *DeleteLinkOptions) SetHeaders(param map[string]string) *DeleteLinkOptions { - options.Headers = param - return options +// GetLatestProfileTemplateVersion : Get latest version of a Profile Template +// Get latest version of a Trusted Profile Template for an Enterprise Account. +func (iamIdentity *IamIdentityV1) GetLatestProfileTemplateVersion(getLatestProfileTemplateVersionOptions *GetLatestProfileTemplateVersionOptions) (result *TrustedProfileTemplateResponse, response *core.DetailedResponse, err error) { + return iamIdentity.GetLatestProfileTemplateVersionWithContext(context.Background(), getLatestProfileTemplateVersionOptions) } -// DeleteProfileIdentityOptions : The DeleteProfileIdentity options. -type DeleteProfileIdentityOptions struct { - // ID of the trusted profile. - ProfileID *string `json:"profile-id" validate:"required,ne="` +// GetLatestProfileTemplateVersionWithContext is an alternate form of the GetLatestProfileTemplateVersion method which supports a Context parameter +func (iamIdentity *IamIdentityV1) GetLatestProfileTemplateVersionWithContext(ctx context.Context, getLatestProfileTemplateVersionOptions *GetLatestProfileTemplateVersionOptions) (result *TrustedProfileTemplateResponse, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getLatestProfileTemplateVersionOptions, "getLatestProfileTemplateVersionOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(getLatestProfileTemplateVersionOptions, "getLatestProfileTemplateVersionOptions") + if err != nil { + return + } - // Type of the identity. - IdentityType *string `json:"identity-type" validate:"required,ne="` + pathParamsMap := map[string]string{ + "template_id": *getLatestProfileTemplateVersionOptions.TemplateID, + } - // Identifier of the identity that can assume the trusted profiles. - IdentifierID *string `json:"identifier-id" validate:"required,ne="` + builder := core.NewRequestBuilder(core.GET) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = iamIdentity.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(iamIdentity.Service.Options.URL, `/v1/profile_templates/{template_id}`, pathParamsMap) + if err != nil { + return + } - // Allows users to set headers on API requests - Headers map[string]string -} + for headerName, headerValue := range getLatestProfileTemplateVersionOptions.Headers { + builder.AddHeader(headerName, headerValue) + } -// Constants associated with the DeleteProfileIdentityOptions.IdentityType property. -// Type of the identity. -const ( - DeleteProfileIdentityOptionsIdentityTypeCRNConst = "crn" - DeleteProfileIdentityOptionsIdentityTypeServiceidConst = "serviceid" - DeleteProfileIdentityOptionsIdentityTypeUserConst = "user" -) + sdkHeaders := common.GetSdkHeaders("iam_identity", "V1", "GetLatestProfileTemplateVersion") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") -// NewDeleteProfileIdentityOptions : Instantiate DeleteProfileIdentityOptions -func (*IamIdentityV1) NewDeleteProfileIdentityOptions(profileID string, identityType string, identifierID string) *DeleteProfileIdentityOptions { - return &DeleteProfileIdentityOptions{ - ProfileID: core.StringPtr(profileID), - IdentityType: core.StringPtr(identityType), - IdentifierID: core.StringPtr(identifierID), + if getLatestProfileTemplateVersionOptions.IncludeHistory != nil { + builder.AddQuery("include_history", fmt.Sprint(*getLatestProfileTemplateVersionOptions.IncludeHistory)) } -} -// SetProfileID : Allow user to set ProfileID -func (_options *DeleteProfileIdentityOptions) SetProfileID(profileID string) *DeleteProfileIdentityOptions { - _options.ProfileID = core.StringPtr(profileID) - return _options -} + request, err := builder.Build() + if err != nil { + return + } -// SetIdentityType : Allow user to set IdentityType -func (_options *DeleteProfileIdentityOptions) SetIdentityType(identityType string) *DeleteProfileIdentityOptions { - _options.IdentityType = core.StringPtr(identityType) - return _options -} + var rawResponse map[string]json.RawMessage + response, err = iamIdentity.Service.Request(request, &rawResponse) + if err != nil { + return + } + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalTrustedProfileTemplateResponse) + if err != nil { + return + } + response.Result = result + } -// SetIdentifierID : Allow user to set IdentifierID -func (_options *DeleteProfileIdentityOptions) SetIdentifierID(identifierID string) *DeleteProfileIdentityOptions { - _options.IdentifierID = core.StringPtr(identifierID) - return _options + return } -// SetHeaders : Allow user to set Headers -func (options *DeleteProfileIdentityOptions) SetHeaders(param map[string]string) *DeleteProfileIdentityOptions { - options.Headers = param - return options +// DeleteAllVersionsOfProfileTemplate : Delete all versions of a Profile Template +// Delete all versions of a Trusted Profile Template for an Enterprise Account. +func (iamIdentity *IamIdentityV1) DeleteAllVersionsOfProfileTemplate(deleteAllVersionsOfProfileTemplateOptions *DeleteAllVersionsOfProfileTemplateOptions) (response *core.DetailedResponse, err error) { + return iamIdentity.DeleteAllVersionsOfProfileTemplateWithContext(context.Background(), deleteAllVersionsOfProfileTemplateOptions) } -// DeleteProfileOptions : The DeleteProfile options. -type DeleteProfileOptions struct { - // ID of the trusted profile. - ProfileID *string `json:"profile-id" validate:"required,ne="` +// DeleteAllVersionsOfProfileTemplateWithContext is an alternate form of the DeleteAllVersionsOfProfileTemplate method which supports a Context parameter +func (iamIdentity *IamIdentityV1) DeleteAllVersionsOfProfileTemplateWithContext(ctx context.Context, deleteAllVersionsOfProfileTemplateOptions *DeleteAllVersionsOfProfileTemplateOptions) (response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(deleteAllVersionsOfProfileTemplateOptions, "deleteAllVersionsOfProfileTemplateOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(deleteAllVersionsOfProfileTemplateOptions, "deleteAllVersionsOfProfileTemplateOptions") + if err != nil { + return + } - // Allows users to set headers on API requests - Headers map[string]string -} + pathParamsMap := map[string]string{ + "template_id": *deleteAllVersionsOfProfileTemplateOptions.TemplateID, + } -// NewDeleteProfileOptions : Instantiate DeleteProfileOptions -func (*IamIdentityV1) NewDeleteProfileOptions(profileID string) *DeleteProfileOptions { - return &DeleteProfileOptions{ - ProfileID: core.StringPtr(profileID), + builder := core.NewRequestBuilder(core.DELETE) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = iamIdentity.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(iamIdentity.Service.Options.URL, `/v1/profile_templates/{template_id}`, pathParamsMap) + if err != nil { + return } -} -// SetProfileID : Allow user to set ProfileID -func (_options *DeleteProfileOptions) SetProfileID(profileID string) *DeleteProfileOptions { - _options.ProfileID = core.StringPtr(profileID) - return _options + for headerName, headerValue := range deleteAllVersionsOfProfileTemplateOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("iam_identity", "V1", "DeleteAllVersionsOfProfileTemplate") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + + request, err := builder.Build() + if err != nil { + return + } + + response, err = iamIdentity.Service.Request(request, nil) + + return } -// SetHeaders : Allow user to set Headers -func (options *DeleteProfileOptions) SetHeaders(param map[string]string) *DeleteProfileOptions { - options.Headers = param - return options +// ListVersionsOfProfileTemplate : List Profile Template versions +// List versions of a Trusted Profile Template in an Enterprise Account. +func (iamIdentity *IamIdentityV1) ListVersionsOfProfileTemplate(listVersionsOfProfileTemplateOptions *ListVersionsOfProfileTemplateOptions) (result *TrustedProfileTemplateList, response *core.DetailedResponse, err error) { + return iamIdentity.ListVersionsOfProfileTemplateWithContext(context.Background(), listVersionsOfProfileTemplateOptions) } -// DeleteServiceIDOptions : The DeleteServiceID options. -type DeleteServiceIDOptions struct { - // Unique ID of the service ID. - ID *string `json:"id" validate:"required,ne="` - - // Allows users to set headers on API requests - Headers map[string]string -} +// ListVersionsOfProfileTemplateWithContext is an alternate form of the ListVersionsOfProfileTemplate method which supports a Context parameter +func (iamIdentity *IamIdentityV1) ListVersionsOfProfileTemplateWithContext(ctx context.Context, listVersionsOfProfileTemplateOptions *ListVersionsOfProfileTemplateOptions) (result *TrustedProfileTemplateList, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(listVersionsOfProfileTemplateOptions, "listVersionsOfProfileTemplateOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(listVersionsOfProfileTemplateOptions, "listVersionsOfProfileTemplateOptions") + if err != nil { + return + } -// NewDeleteServiceIDOptions : Instantiate DeleteServiceIDOptions -func (*IamIdentityV1) NewDeleteServiceIDOptions(id string) *DeleteServiceIDOptions { - return &DeleteServiceIDOptions{ - ID: core.StringPtr(id), + pathParamsMap := map[string]string{ + "template_id": *listVersionsOfProfileTemplateOptions.TemplateID, } -} -// SetID : Allow user to set ID -func (_options *DeleteServiceIDOptions) SetID(id string) *DeleteServiceIDOptions { - _options.ID = core.StringPtr(id) - return _options -} + builder := core.NewRequestBuilder(core.GET) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = iamIdentity.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(iamIdentity.Service.Options.URL, `/v1/profile_templates/{template_id}/versions`, pathParamsMap) + if err != nil { + return + } -// SetHeaders : Allow user to set Headers -func (options *DeleteServiceIDOptions) SetHeaders(param map[string]string) *DeleteServiceIDOptions { - options.Headers = param - return options -} + for headerName, headerValue := range listVersionsOfProfileTemplateOptions.Headers { + builder.AddHeader(headerName, headerValue) + } -// EnityHistoryRecord : Response body format for an entity history record. -type EnityHistoryRecord struct { - // Timestamp when the action was triggered. - Timestamp *string `json:"timestamp" validate:"required"` + sdkHeaders := common.GetSdkHeaders("iam_identity", "V1", "ListVersionsOfProfileTemplate") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") - // IAM ID of the identity which triggered the action. - IamID *string `json:"iam_id" validate:"required"` + if listVersionsOfProfileTemplateOptions.Limit != nil { + builder.AddQuery("limit", fmt.Sprint(*listVersionsOfProfileTemplateOptions.Limit)) + } + if listVersionsOfProfileTemplateOptions.Pagetoken != nil { + builder.AddQuery("pagetoken", fmt.Sprint(*listVersionsOfProfileTemplateOptions.Pagetoken)) + } + if listVersionsOfProfileTemplateOptions.Sort != nil { + builder.AddQuery("sort", fmt.Sprint(*listVersionsOfProfileTemplateOptions.Sort)) + } + if listVersionsOfProfileTemplateOptions.Order != nil { + builder.AddQuery("order", fmt.Sprint(*listVersionsOfProfileTemplateOptions.Order)) + } + if listVersionsOfProfileTemplateOptions.IncludeHistory != nil { + builder.AddQuery("include_history", fmt.Sprint(*listVersionsOfProfileTemplateOptions.IncludeHistory)) + } - // Account of the identity which triggered the action. - IamIDAccount *string `json:"iam_id_account" validate:"required"` + request, err := builder.Build() + if err != nil { + return + } - // Action of the history entry. - Action *string `json:"action" validate:"required"` + var rawResponse map[string]json.RawMessage + response, err = iamIdentity.Service.Request(request, &rawResponse) + if err != nil { + return + } + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalTrustedProfileTemplateList) + if err != nil { + return + } + response.Result = result + } - // Params of the history entry. - Params []string `json:"params" validate:"required"` + return +} - // Message which summarizes the executed action. - Message *string `json:"message" validate:"required"` +// CreateProfileTemplateVersion : Create a new version of a Profile Template +// Create a new version of a Trusted Profile Template in an Enterprise Account. +func (iamIdentity *IamIdentityV1) CreateProfileTemplateVersion(createProfileTemplateVersionOptions *CreateProfileTemplateVersionOptions) (result *TrustedProfileTemplateResponse, response *core.DetailedResponse, err error) { + return iamIdentity.CreateProfileTemplateVersionWithContext(context.Background(), createProfileTemplateVersionOptions) } -// UnmarshalEnityHistoryRecord unmarshals an instance of EnityHistoryRecord from the specified map of raw messages. -func UnmarshalEnityHistoryRecord(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(EnityHistoryRecord) - err = core.UnmarshalPrimitive(m, "timestamp", &obj.Timestamp) +// CreateProfileTemplateVersionWithContext is an alternate form of the CreateProfileTemplateVersion method which supports a Context parameter +func (iamIdentity *IamIdentityV1) CreateProfileTemplateVersionWithContext(ctx context.Context, createProfileTemplateVersionOptions *CreateProfileTemplateVersionOptions) (result *TrustedProfileTemplateResponse, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(createProfileTemplateVersionOptions, "createProfileTemplateVersionOptions cannot be nil") if err != nil { return } - err = core.UnmarshalPrimitive(m, "iam_id", &obj.IamID) + err = core.ValidateStruct(createProfileTemplateVersionOptions, "createProfileTemplateVersionOptions") if err != nil { return } - err = core.UnmarshalPrimitive(m, "iam_id_account", &obj.IamIDAccount) + + pathParamsMap := map[string]string{ + "template_id": *createProfileTemplateVersionOptions.TemplateID, + } + + builder := core.NewRequestBuilder(core.POST) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = iamIdentity.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(iamIdentity.Service.Options.URL, `/v1/profile_templates/{template_id}/versions`, pathParamsMap) if err != nil { return } - err = core.UnmarshalPrimitive(m, "action", &obj.Action) + + for headerName, headerValue := range createProfileTemplateVersionOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("iam_identity", "V1", "CreateProfileTemplateVersion") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") + builder.AddHeader("Content-Type", "application/json") + + body := make(map[string]interface{}) + if createProfileTemplateVersionOptions.AccountID != nil { + body["account_id"] = createProfileTemplateVersionOptions.AccountID + } + if createProfileTemplateVersionOptions.Name != nil { + body["name"] = createProfileTemplateVersionOptions.Name + } + if createProfileTemplateVersionOptions.Description != nil { + body["description"] = createProfileTemplateVersionOptions.Description + } + if createProfileTemplateVersionOptions.Profile != nil { + body["profile"] = createProfileTemplateVersionOptions.Profile + } + if createProfileTemplateVersionOptions.PolicyTemplateReferences != nil { + body["policy_template_references"] = createProfileTemplateVersionOptions.PolicyTemplateReferences + } + _, err = builder.SetBodyContentJSON(body) if err != nil { return } - err = core.UnmarshalPrimitive(m, "params", &obj.Params) + + request, err := builder.Build() if err != nil { return } - err = core.UnmarshalPrimitive(m, "message", &obj.Message) + + var rawResponse map[string]json.RawMessage + response, err = iamIdentity.Service.Request(request, &rawResponse) if err != nil { return } - reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalTrustedProfileTemplateResponse) + if err != nil { + return + } + response.Result = result + } + return } -// EntityActivity : EntityActivity struct -type EntityActivity struct { - // Unique id of the entity. - ID *string `json:"id" validate:"required"` - - // Name provided during creation of the entity. - Name *string `json:"name,omitempty"` - - // Time when the entity was last authenticated. - LastAuthn *string `json:"last_authn,omitempty"` +// GetProfileTemplateVersion : Get version of a Profile Template +// Get a specific version of a Trusted Profile Template in an Enterprise Account. +func (iamIdentity *IamIdentityV1) GetProfileTemplateVersion(getProfileTemplateVersionOptions *GetProfileTemplateVersionOptions) (result *TrustedProfileTemplateResponse, response *core.DetailedResponse, err error) { + return iamIdentity.GetProfileTemplateVersionWithContext(context.Background(), getProfileTemplateVersionOptions) } -// UnmarshalEntityActivity unmarshals an instance of EntityActivity from the specified map of raw messages. -func UnmarshalEntityActivity(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(EntityActivity) - err = core.UnmarshalPrimitive(m, "id", &obj.ID) +// GetProfileTemplateVersionWithContext is an alternate form of the GetProfileTemplateVersion method which supports a Context parameter +func (iamIdentity *IamIdentityV1) GetProfileTemplateVersionWithContext(ctx context.Context, getProfileTemplateVersionOptions *GetProfileTemplateVersionOptions) (result *TrustedProfileTemplateResponse, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getProfileTemplateVersionOptions, "getProfileTemplateVersionOptions cannot be nil") if err != nil { return } - err = core.UnmarshalPrimitive(m, "name", &obj.Name) + err = core.ValidateStruct(getProfileTemplateVersionOptions, "getProfileTemplateVersionOptions") if err != nil { return } - err = core.UnmarshalPrimitive(m, "last_authn", &obj.LastAuthn) + + pathParamsMap := map[string]string{ + "template_id": *getProfileTemplateVersionOptions.TemplateID, + "version": *getProfileTemplateVersionOptions.Version, + } + + builder := core.NewRequestBuilder(core.GET) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = iamIdentity.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(iamIdentity.Service.Options.URL, `/v1/profile_templates/{template_id}/versions/{version}`, pathParamsMap) if err != nil { return } - reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) - return -} -// GetAccountSettingsOptions : The GetAccountSettings options. -type GetAccountSettingsOptions struct { - // Unique ID of the account. - AccountID *string `json:"account_id" validate:"required,ne="` + for headerName, headerValue := range getProfileTemplateVersionOptions.Headers { + builder.AddHeader(headerName, headerValue) + } - // Defines if the entity history is included in the response. - IncludeHistory *bool `json:"include_history,omitempty"` + sdkHeaders := common.GetSdkHeaders("iam_identity", "V1", "GetProfileTemplateVersion") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") - // Allows users to set headers on API requests - Headers map[string]string -} + if getProfileTemplateVersionOptions.IncludeHistory != nil { + builder.AddQuery("include_history", fmt.Sprint(*getProfileTemplateVersionOptions.IncludeHistory)) + } -// NewGetAccountSettingsOptions : Instantiate GetAccountSettingsOptions -func (*IamIdentityV1) NewGetAccountSettingsOptions(accountID string) *GetAccountSettingsOptions { - return &GetAccountSettingsOptions{ - AccountID: core.StringPtr(accountID), + request, err := builder.Build() + if err != nil { + return } -} -// SetAccountID : Allow user to set AccountID -func (_options *GetAccountSettingsOptions) SetAccountID(accountID string) *GetAccountSettingsOptions { - _options.AccountID = core.StringPtr(accountID) - return _options -} + var rawResponse map[string]json.RawMessage + response, err = iamIdentity.Service.Request(request, &rawResponse) + if err != nil { + return + } + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalTrustedProfileTemplateResponse) + if err != nil { + return + } + response.Result = result + } -// SetIncludeHistory : Allow user to set IncludeHistory -func (_options *GetAccountSettingsOptions) SetIncludeHistory(includeHistory bool) *GetAccountSettingsOptions { - _options.IncludeHistory = core.BoolPtr(includeHistory) - return _options + return } -// SetHeaders : Allow user to set Headers -func (options *GetAccountSettingsOptions) SetHeaders(param map[string]string) *GetAccountSettingsOptions { - options.Headers = param - return options +// UpdateProfileTemplateVersion : Update version of a Profile Template +// Update a specific version of a Trusted Profile Template in an Enterprise Account. +func (iamIdentity *IamIdentityV1) UpdateProfileTemplateVersion(updateProfileTemplateVersionOptions *UpdateProfileTemplateVersionOptions) (result *TrustedProfileTemplateResponse, response *core.DetailedResponse, err error) { + return iamIdentity.UpdateProfileTemplateVersionWithContext(context.Background(), updateProfileTemplateVersionOptions) } -// GetAPIKeyOptions : The GetAPIKey options. -type GetAPIKeyOptions struct { - // Unique ID of the API key. - ID *string `json:"id" validate:"required,ne="` - - // Defines if the entity history is included in the response. - IncludeHistory *bool `json:"include_history,omitempty"` +// UpdateProfileTemplateVersionWithContext is an alternate form of the UpdateProfileTemplateVersion method which supports a Context parameter +func (iamIdentity *IamIdentityV1) UpdateProfileTemplateVersionWithContext(ctx context.Context, updateProfileTemplateVersionOptions *UpdateProfileTemplateVersionOptions) (result *TrustedProfileTemplateResponse, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(updateProfileTemplateVersionOptions, "updateProfileTemplateVersionOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(updateProfileTemplateVersionOptions, "updateProfileTemplateVersionOptions") + if err != nil { + return + } - // Defines if the entity's activity is included in the response. Retrieving activity data is an expensive operation, so - // please only request this when needed. - IncludeActivity *bool `json:"include_activity,omitempty"` + pathParamsMap := map[string]string{ + "template_id": *updateProfileTemplateVersionOptions.TemplateID, + "version": *updateProfileTemplateVersionOptions.Version, + } - // Allows users to set headers on API requests - Headers map[string]string -} + builder := core.NewRequestBuilder(core.PUT) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = iamIdentity.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(iamIdentity.Service.Options.URL, `/v1/profile_templates/{template_id}/versions/{version}`, pathParamsMap) + if err != nil { + return + } -// NewGetAPIKeyOptions : Instantiate GetAPIKeyOptions -func (*IamIdentityV1) NewGetAPIKeyOptions(id string) *GetAPIKeyOptions { - return &GetAPIKeyOptions{ - ID: core.StringPtr(id), + for headerName, headerValue := range updateProfileTemplateVersionOptions.Headers { + builder.AddHeader(headerName, headerValue) } -} -// SetID : Allow user to set ID -func (_options *GetAPIKeyOptions) SetID(id string) *GetAPIKeyOptions { - _options.ID = core.StringPtr(id) - return _options -} + sdkHeaders := common.GetSdkHeaders("iam_identity", "V1", "UpdateProfileTemplateVersion") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") + builder.AddHeader("Content-Type", "application/json") + if updateProfileTemplateVersionOptions.IfMatch != nil { + builder.AddHeader("If-Match", fmt.Sprint(*updateProfileTemplateVersionOptions.IfMatch)) + } -// SetIncludeHistory : Allow user to set IncludeHistory -func (_options *GetAPIKeyOptions) SetIncludeHistory(includeHistory bool) *GetAPIKeyOptions { - _options.IncludeHistory = core.BoolPtr(includeHistory) - return _options -} + body := make(map[string]interface{}) + if updateProfileTemplateVersionOptions.AccountID != nil { + body["account_id"] = updateProfileTemplateVersionOptions.AccountID + } + if updateProfileTemplateVersionOptions.Name != nil { + body["name"] = updateProfileTemplateVersionOptions.Name + } + if updateProfileTemplateVersionOptions.Description != nil { + body["description"] = updateProfileTemplateVersionOptions.Description + } + if updateProfileTemplateVersionOptions.Profile != nil { + body["profile"] = updateProfileTemplateVersionOptions.Profile + } + if updateProfileTemplateVersionOptions.PolicyTemplateReferences != nil { + body["policy_template_references"] = updateProfileTemplateVersionOptions.PolicyTemplateReferences + } + _, err = builder.SetBodyContentJSON(body) + if err != nil { + return + } -// SetIncludeActivity : Allow user to set IncludeActivity -func (_options *GetAPIKeyOptions) SetIncludeActivity(includeActivity bool) *GetAPIKeyOptions { - _options.IncludeActivity = core.BoolPtr(includeActivity) - return _options -} - -// SetHeaders : Allow user to set Headers -func (options *GetAPIKeyOptions) SetHeaders(param map[string]string) *GetAPIKeyOptions { - options.Headers = param - return options -} - -// GetAPIKeysDetailsOptions : The GetAPIKeysDetails options. -type GetAPIKeysDetailsOptions struct { - // API key value. - IamAPIKey *string `json:"IAM-ApiKey,omitempty"` - - // Defines if the entity history is included in the response. - IncludeHistory *bool `json:"include_history,omitempty"` + request, err := builder.Build() + if err != nil { + return + } - // Allows users to set headers on API requests - Headers map[string]string -} + var rawResponse map[string]json.RawMessage + response, err = iamIdentity.Service.Request(request, &rawResponse) + if err != nil { + return + } + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalTrustedProfileTemplateResponse) + if err != nil { + return + } + response.Result = result + } -// NewGetAPIKeysDetailsOptions : Instantiate GetAPIKeysDetailsOptions -func (*IamIdentityV1) NewGetAPIKeysDetailsOptions() *GetAPIKeysDetailsOptions { - return &GetAPIKeysDetailsOptions{} + return } -// SetIamAPIKey : Allow user to set IamAPIKey -func (_options *GetAPIKeysDetailsOptions) SetIamAPIKey(iamAPIKey string) *GetAPIKeysDetailsOptions { - _options.IamAPIKey = core.StringPtr(iamAPIKey) - return _options +// DeleteProfileTemplateVersion : Delete version of a Profile Template +// Delete a specific version of a Trusted Profile Template in an Enterprise Account. +func (iamIdentity *IamIdentityV1) DeleteProfileTemplateVersion(deleteProfileTemplateVersionOptions *DeleteProfileTemplateVersionOptions) (response *core.DetailedResponse, err error) { + return iamIdentity.DeleteProfileTemplateVersionWithContext(context.Background(), deleteProfileTemplateVersionOptions) } -// SetIncludeHistory : Allow user to set IncludeHistory -func (_options *GetAPIKeysDetailsOptions) SetIncludeHistory(includeHistory bool) *GetAPIKeysDetailsOptions { - _options.IncludeHistory = core.BoolPtr(includeHistory) - return _options -} +// DeleteProfileTemplateVersionWithContext is an alternate form of the DeleteProfileTemplateVersion method which supports a Context parameter +func (iamIdentity *IamIdentityV1) DeleteProfileTemplateVersionWithContext(ctx context.Context, deleteProfileTemplateVersionOptions *DeleteProfileTemplateVersionOptions) (response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(deleteProfileTemplateVersionOptions, "deleteProfileTemplateVersionOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(deleteProfileTemplateVersionOptions, "deleteProfileTemplateVersionOptions") + if err != nil { + return + } -// SetHeaders : Allow user to set Headers -func (options *GetAPIKeysDetailsOptions) SetHeaders(param map[string]string) *GetAPIKeysDetailsOptions { - options.Headers = param - return options -} + pathParamsMap := map[string]string{ + "template_id": *deleteProfileTemplateVersionOptions.TemplateID, + "version": *deleteProfileTemplateVersionOptions.Version, + } -// GetClaimRuleOptions : The GetClaimRule options. -type GetClaimRuleOptions struct { - // ID of the trusted profile. - ProfileID *string `json:"profile-id" validate:"required,ne="` + builder := core.NewRequestBuilder(core.DELETE) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = iamIdentity.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(iamIdentity.Service.Options.URL, `/v1/profile_templates/{template_id}/versions/{version}`, pathParamsMap) + if err != nil { + return + } - // ID of the claim rule to get. - RuleID *string `json:"rule-id" validate:"required,ne="` + for headerName, headerValue := range deleteProfileTemplateVersionOptions.Headers { + builder.AddHeader(headerName, headerValue) + } - // Allows users to set headers on API requests - Headers map[string]string -} + sdkHeaders := common.GetSdkHeaders("iam_identity", "V1", "DeleteProfileTemplateVersion") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } -// NewGetClaimRuleOptions : Instantiate GetClaimRuleOptions -func (*IamIdentityV1) NewGetClaimRuleOptions(profileID string, ruleID string) *GetClaimRuleOptions { - return &GetClaimRuleOptions{ - ProfileID: core.StringPtr(profileID), - RuleID: core.StringPtr(ruleID), + request, err := builder.Build() + if err != nil { + return } -} -// SetProfileID : Allow user to set ProfileID -func (_options *GetClaimRuleOptions) SetProfileID(profileID string) *GetClaimRuleOptions { - _options.ProfileID = core.StringPtr(profileID) - return _options -} + response, err = iamIdentity.Service.Request(request, nil) -// SetRuleID : Allow user to set RuleID -func (_options *GetClaimRuleOptions) SetRuleID(ruleID string) *GetClaimRuleOptions { - _options.RuleID = core.StringPtr(ruleID) - return _options + return } -// SetHeaders : Allow user to set Headers -func (options *GetClaimRuleOptions) SetHeaders(param map[string]string) *GetClaimRuleOptions { - options.Headers = param - return options +// CommitProfileTemplate : Commit a template version +// Commit a specific version of a Trusted Profile Template in an Enterprise Account. A Template must be committed before +// being assigned, and once committed, can no longer be modified. +func (iamIdentity *IamIdentityV1) CommitProfileTemplate(commitProfileTemplateOptions *CommitProfileTemplateOptions) (response *core.DetailedResponse, err error) { + return iamIdentity.CommitProfileTemplateWithContext(context.Background(), commitProfileTemplateOptions) } -// GetLinkOptions : The GetLink options. -type GetLinkOptions struct { - // ID of the trusted profile. - ProfileID *string `json:"profile-id" validate:"required,ne="` +// CommitProfileTemplateWithContext is an alternate form of the CommitProfileTemplate method which supports a Context parameter +func (iamIdentity *IamIdentityV1) CommitProfileTemplateWithContext(ctx context.Context, commitProfileTemplateOptions *CommitProfileTemplateOptions) (response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(commitProfileTemplateOptions, "commitProfileTemplateOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(commitProfileTemplateOptions, "commitProfileTemplateOptions") + if err != nil { + return + } - // ID of the link. - LinkID *string `json:"link-id" validate:"required,ne="` + pathParamsMap := map[string]string{ + "template_id": *commitProfileTemplateOptions.TemplateID, + "version": *commitProfileTemplateOptions.Version, + } - // Allows users to set headers on API requests - Headers map[string]string -} + builder := core.NewRequestBuilder(core.POST) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = iamIdentity.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(iamIdentity.Service.Options.URL, `/v1/profile_templates/{template_id}/versions/{version}/commit`, pathParamsMap) + if err != nil { + return + } -// NewGetLinkOptions : Instantiate GetLinkOptions -func (*IamIdentityV1) NewGetLinkOptions(profileID string, linkID string) *GetLinkOptions { - return &GetLinkOptions{ - ProfileID: core.StringPtr(profileID), - LinkID: core.StringPtr(linkID), + for headerName, headerValue := range commitProfileTemplateOptions.Headers { + builder.AddHeader(headerName, headerValue) } -} -// SetProfileID : Allow user to set ProfileID -func (_options *GetLinkOptions) SetProfileID(profileID string) *GetLinkOptions { - _options.ProfileID = core.StringPtr(profileID) - return _options -} + sdkHeaders := common.GetSdkHeaders("iam_identity", "V1", "CommitProfileTemplate") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } -// SetLinkID : Allow user to set LinkID -func (_options *GetLinkOptions) SetLinkID(linkID string) *GetLinkOptions { - _options.LinkID = core.StringPtr(linkID) - return _options -} + request, err := builder.Build() + if err != nil { + return + } -// SetHeaders : Allow user to set Headers -func (options *GetLinkOptions) SetHeaders(param map[string]string) *GetLinkOptions { - options.Headers = param - return options + response, err = iamIdentity.Service.Request(request, nil) + + return } -// GetMfaReportOptions : The GetMfaReport options. -type GetMfaReportOptions struct { - // ID of the account. - AccountID *string `json:"account_id" validate:"required,ne="` +// AccountBasedMfaEnrollment : AccountBasedMfaEnrollment struct +type AccountBasedMfaEnrollment struct { + SecurityQuestions *MfaEnrollmentTypeStatus `json:"security_questions" validate:"required"` - // Reference for the report to be generated, You can use 'latest' to get the latest report for the given account. - Reference *string `json:"reference" validate:"required,ne="` + Totp *MfaEnrollmentTypeStatus `json:"totp" validate:"required"` - // Allows users to set headers on API requests - Headers map[string]string -} + Verisign *MfaEnrollmentTypeStatus `json:"verisign" validate:"required"` -// NewGetMfaReportOptions : Instantiate GetMfaReportOptions -func (*IamIdentityV1) NewGetMfaReportOptions(accountID string, reference string) *GetMfaReportOptions { - return &GetMfaReportOptions{ - AccountID: core.StringPtr(accountID), - Reference: core.StringPtr(reference), - } + // The enrollment complies to the effective requirement. + Complies *bool `json:"complies" validate:"required"` } -// SetAccountID : Allow user to set AccountID -func (_options *GetMfaReportOptions) SetAccountID(accountID string) *GetMfaReportOptions { - _options.AccountID = core.StringPtr(accountID) - return _options +// UnmarshalAccountBasedMfaEnrollment unmarshals an instance of AccountBasedMfaEnrollment from the specified map of raw messages. +func UnmarshalAccountBasedMfaEnrollment(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(AccountBasedMfaEnrollment) + err = core.UnmarshalModel(m, "security_questions", &obj.SecurityQuestions, UnmarshalMfaEnrollmentTypeStatus) + if err != nil { + return + } + err = core.UnmarshalModel(m, "totp", &obj.Totp, UnmarshalMfaEnrollmentTypeStatus) + if err != nil { + return + } + err = core.UnmarshalModel(m, "verisign", &obj.Verisign, UnmarshalMfaEnrollmentTypeStatus) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "complies", &obj.Complies) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return } -// SetReference : Allow user to set Reference -func (_options *GetMfaReportOptions) SetReference(reference string) *GetMfaReportOptions { - _options.Reference = core.StringPtr(reference) - return _options -} +// AccountSettingsComponent : AccountSettingsComponent struct +type AccountSettingsComponent struct { + // Defines whether or not creating a Service Id is access controlled. Valid values: + // * RESTRICTED - to apply access control + // * NOT_RESTRICTED - to remove access control + // * NOT_SET - to 'unset' a previous set value. + RestrictCreateServiceID *string `json:"restrict_create_service_id,omitempty"` -// SetHeaders : Allow user to set Headers -func (options *GetMfaReportOptions) SetHeaders(param map[string]string) *GetMfaReportOptions { - options.Headers = param - return options -} + // Defines whether or not creating platform API keys is access controlled. Valid values: + // * RESTRICTED - to apply access control + // * NOT_RESTRICTED - to remove access control + // * NOT_SET - to 'unset' a previous set value. + RestrictCreatePlatformApikey *string `json:"restrict_create_platform_apikey,omitempty"` -// GetMfaStatusOptions : The GetMfaStatus options. -type GetMfaStatusOptions struct { - // ID of the account. - AccountID *string `json:"account_id" validate:"required,ne="` + // Defines the IP addresses and subnets from which IAM tokens can be created for the account. + AllowedIPAddresses *string `json:"allowed_ip_addresses,omitempty"` - // iam_id of the user. This user must be the member of the account. - IamID *string `json:"iam_id" validate:"required"` + // Defines the MFA trait for the account. Valid values: + // * NONE - No MFA trait set + // * TOTP - For all non-federated IBMId users + // * TOTP4ALL - For all users + // * LEVEL1 - Email-based MFA for all users + // * LEVEL2 - TOTP-based MFA for all users + // * LEVEL3 - U2F MFA for all users. + Mfa *string `json:"mfa,omitempty"` - // Allows users to set headers on API requests - Headers map[string]string -} + // List of users that are exempted from the MFA requirement of the account. + UserMfa []AccountSettingsUserMfa `json:"user_mfa,omitempty"` -// NewGetMfaStatusOptions : Instantiate GetMfaStatusOptions -func (*IamIdentityV1) NewGetMfaStatusOptions(accountID string, iamID string) *GetMfaStatusOptions { - return &GetMfaStatusOptions{ - AccountID: core.StringPtr(accountID), - IamID: core.StringPtr(iamID), - } -} + // Defines the session expiration in seconds for the account. Valid values: + // * Any whole number between between '900' and '86400' + // * NOT_SET - To unset account setting and use service default. + SessionExpirationInSeconds *string `json:"session_expiration_in_seconds,omitempty"` + + // Defines the period of time in seconds in which a session will be invalidated due to inactivity. Valid values: + // * Any whole number between '900' and '7200' + // * NOT_SET - To unset account setting and use service default. + SessionInvalidationInSeconds *string `json:"session_invalidation_in_seconds,omitempty"` + + // Defines the max allowed sessions per identity required by the account. Valid values: + // * Any whole number greater than 0 + // * NOT_SET - To unset account setting and use service default. + MaxSessionsPerIdentity *string `json:"max_sessions_per_identity,omitempty"` + + // Defines the access token expiration in seconds. Valid values: + // * Any whole number between '900' and '3600' + // * NOT_SET - To unset account setting and use service default. + SystemAccessTokenExpirationInSeconds *string `json:"system_access_token_expiration_in_seconds,omitempty"` + + // Defines the refresh token expiration in seconds. Valid values: + // * Any whole number between '900' and '259200' + // * NOT_SET - To unset account setting and use service default. + SystemRefreshTokenExpirationInSeconds *string `json:"system_refresh_token_expiration_in_seconds,omitempty"` +} + +// Constants associated with the AccountSettingsComponent.RestrictCreateServiceID property. +// Defines whether or not creating a Service Id is access controlled. Valid values: +// * RESTRICTED - to apply access control +// * NOT_RESTRICTED - to remove access control +// * NOT_SET - to 'unset' a previous set value. +const ( + AccountSettingsComponentRestrictCreateServiceIDNotRestrictedConst = "NOT_RESTRICTED" + AccountSettingsComponentRestrictCreateServiceIDNotSetConst = "NOT_SET" + AccountSettingsComponentRestrictCreateServiceIDRestrictedConst = "RESTRICTED" +) + +// Constants associated with the AccountSettingsComponent.RestrictCreatePlatformApikey property. +// Defines whether or not creating platform API keys is access controlled. Valid values: +// * RESTRICTED - to apply access control +// * NOT_RESTRICTED - to remove access control +// * NOT_SET - to 'unset' a previous set value. +const ( + AccountSettingsComponentRestrictCreatePlatformApikeyNotRestrictedConst = "NOT_RESTRICTED" + AccountSettingsComponentRestrictCreatePlatformApikeyNotSetConst = "NOT_SET" + AccountSettingsComponentRestrictCreatePlatformApikeyRestrictedConst = "RESTRICTED" +) + +// Constants associated with the AccountSettingsComponent.Mfa property. +// Defines the MFA trait for the account. Valid values: +// * NONE - No MFA trait set +// * TOTP - For all non-federated IBMId users +// * TOTP4ALL - For all users +// * LEVEL1 - Email-based MFA for all users +// * LEVEL2 - TOTP-based MFA for all users +// * LEVEL3 - U2F MFA for all users. +const ( + AccountSettingsComponentMfaLevel1Const = "LEVEL1" + AccountSettingsComponentMfaLevel2Const = "LEVEL2" + AccountSettingsComponentMfaLevel3Const = "LEVEL3" + AccountSettingsComponentMfaNoneConst = "NONE" + AccountSettingsComponentMfaTotpConst = "TOTP" + AccountSettingsComponentMfaTotp4allConst = "TOTP4ALL" +) + +// UnmarshalAccountSettingsComponent unmarshals an instance of AccountSettingsComponent from the specified map of raw messages. +func UnmarshalAccountSettingsComponent(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(AccountSettingsComponent) + err = core.UnmarshalPrimitive(m, "restrict_create_service_id", &obj.RestrictCreateServiceID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "restrict_create_platform_apikey", &obj.RestrictCreatePlatformApikey) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "allowed_ip_addresses", &obj.AllowedIPAddresses) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "mfa", &obj.Mfa) + if err != nil { + return + } + err = core.UnmarshalModel(m, "user_mfa", &obj.UserMfa, UnmarshalAccountSettingsUserMfa) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "session_expiration_in_seconds", &obj.SessionExpirationInSeconds) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "session_invalidation_in_seconds", &obj.SessionInvalidationInSeconds) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "max_sessions_per_identity", &obj.MaxSessionsPerIdentity) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "system_access_token_expiration_in_seconds", &obj.SystemAccessTokenExpirationInSeconds) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "system_refresh_token_expiration_in_seconds", &obj.SystemRefreshTokenExpirationInSeconds) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// AccountSettingsResponse : Response body format for Account Settings REST requests. +type AccountSettingsResponse struct { + // Context with key properties for problem determination. + Context *ResponseContext `json:"context,omitempty"` + + // Unique ID of the account. + AccountID *string `json:"account_id" validate:"required"` + + // Defines whether or not creating a Service Id is access controlled. Valid values: + // * RESTRICTED - to apply access control + // * NOT_RESTRICTED - to remove access control + // * NOT_SET - to 'unset' a previous set value. + RestrictCreateServiceID *string `json:"restrict_create_service_id" validate:"required"` + + // Defines whether or not creating platform API keys is access controlled. Valid values: + // * RESTRICTED - to apply access control + // * NOT_RESTRICTED - to remove access control + // * NOT_SET - to 'unset' a previous set value. + RestrictCreatePlatformApikey *string `json:"restrict_create_platform_apikey" validate:"required"` + + // Defines the IP addresses and subnets from which IAM tokens can be created for the account. + AllowedIPAddresses *string `json:"allowed_ip_addresses" validate:"required"` + + // Version of the account settings. + EntityTag *string `json:"entity_tag" validate:"required"` + + // Defines the MFA trait for the account. Valid values: + // * NONE - No MFA trait set + // * NONE_NO_ROPC- No MFA, disable CLI logins with only a password + // * TOTP - For all non-federated IBMId users + // * TOTP4ALL - For all users + // * LEVEL1 - Email-based MFA for all users + // * LEVEL2 - TOTP-based MFA for all users + // * LEVEL3 - U2F MFA for all users. + Mfa *string `json:"mfa" validate:"required"` + + // List of users that are exempted from the MFA requirement of the account. + UserMfa []AccountSettingsUserMfa `json:"user_mfa" validate:"required"` + + // History of the Account Settings. + History []EnityHistoryRecord `json:"history,omitempty"` + + // Defines the session expiration in seconds for the account. Valid values: + // * Any whole number between between '900' and '86400' + // * NOT_SET - To unset account setting and use service default. + SessionExpirationInSeconds *string `json:"session_expiration_in_seconds" validate:"required"` + + // Defines the period of time in seconds in which a session will be invalidated due to inactivity. Valid values: + // * Any whole number between '900' and '7200' + // * NOT_SET - To unset account setting and use service default. + SessionInvalidationInSeconds *string `json:"session_invalidation_in_seconds" validate:"required"` + + // Defines the max allowed sessions per identity required by the account. Valid values: + // * Any whole number greater than 0 + // * NOT_SET - To unset account setting and use service default. + MaxSessionsPerIdentity *string `json:"max_sessions_per_identity" validate:"required"` + + // Defines the access token expiration in seconds. Valid values: + // * Any whole number between '900' and '3600' + // * NOT_SET - To unset account setting and use service default. + SystemAccessTokenExpirationInSeconds *string `json:"system_access_token_expiration_in_seconds" validate:"required"` + + // Defines the refresh token expiration in seconds. Valid values: + // * Any whole number between '900' and '259200' + // * NOT_SET - To unset account setting and use service default. + SystemRefreshTokenExpirationInSeconds *string `json:"system_refresh_token_expiration_in_seconds" validate:"required"` +} + +// Constants associated with the AccountSettingsResponse.RestrictCreateServiceID property. +// Defines whether or not creating a Service Id is access controlled. Valid values: +// * RESTRICTED - to apply access control +// * NOT_RESTRICTED - to remove access control +// * NOT_SET - to 'unset' a previous set value. +const ( + AccountSettingsResponseRestrictCreateServiceIDNotRestrictedConst = "NOT_RESTRICTED" + AccountSettingsResponseRestrictCreateServiceIDNotSetConst = "NOT_SET" + AccountSettingsResponseRestrictCreateServiceIDRestrictedConst = "RESTRICTED" +) + +// Constants associated with the AccountSettingsResponse.RestrictCreatePlatformApikey property. +// Defines whether or not creating platform API keys is access controlled. Valid values: +// * RESTRICTED - to apply access control +// * NOT_RESTRICTED - to remove access control +// * NOT_SET - to 'unset' a previous set value. +const ( + AccountSettingsResponseRestrictCreatePlatformApikeyNotRestrictedConst = "NOT_RESTRICTED" + AccountSettingsResponseRestrictCreatePlatformApikeyNotSetConst = "NOT_SET" + AccountSettingsResponseRestrictCreatePlatformApikeyRestrictedConst = "RESTRICTED" +) + +// Constants associated with the AccountSettingsResponse.Mfa property. +// Defines the MFA trait for the account. Valid values: +// * NONE - No MFA trait set +// * NONE_NO_ROPC- No MFA, disable CLI logins with only a password +// * TOTP - For all non-federated IBMId users +// * TOTP4ALL - For all users +// * LEVEL1 - Email-based MFA for all users +// * LEVEL2 - TOTP-based MFA for all users +// * LEVEL3 - U2F MFA for all users. +const ( + AccountSettingsResponseMfaLevel1Const = "LEVEL1" + AccountSettingsResponseMfaLevel2Const = "LEVEL2" + AccountSettingsResponseMfaLevel3Const = "LEVEL3" + AccountSettingsResponseMfaNoneConst = "NONE" + AccountSettingsResponseMfaNoneNoRopcConst = "NONE_NO_ROPC" + AccountSettingsResponseMfaTotpConst = "TOTP" + AccountSettingsResponseMfaTotp4allConst = "TOTP4ALL" +) + +// UnmarshalAccountSettingsResponse unmarshals an instance of AccountSettingsResponse from the specified map of raw messages. +func UnmarshalAccountSettingsResponse(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(AccountSettingsResponse) + err = core.UnmarshalModel(m, "context", &obj.Context, UnmarshalResponseContext) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "account_id", &obj.AccountID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "restrict_create_service_id", &obj.RestrictCreateServiceID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "restrict_create_platform_apikey", &obj.RestrictCreatePlatformApikey) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "allowed_ip_addresses", &obj.AllowedIPAddresses) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "entity_tag", &obj.EntityTag) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "mfa", &obj.Mfa) + if err != nil { + return + } + err = core.UnmarshalModel(m, "user_mfa", &obj.UserMfa, UnmarshalAccountSettingsUserMfa) + if err != nil { + return + } + err = core.UnmarshalModel(m, "history", &obj.History, UnmarshalEnityHistoryRecord) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "session_expiration_in_seconds", &obj.SessionExpirationInSeconds) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "session_invalidation_in_seconds", &obj.SessionInvalidationInSeconds) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "max_sessions_per_identity", &obj.MaxSessionsPerIdentity) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "system_access_token_expiration_in_seconds", &obj.SystemAccessTokenExpirationInSeconds) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "system_refresh_token_expiration_in_seconds", &obj.SystemRefreshTokenExpirationInSeconds) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// AccountSettingsTemplateList : AccountSettingsTemplateList struct +type AccountSettingsTemplateList struct { + // Context with key properties for problem determination. + Context *ResponseContext `json:"context,omitempty"` + + // The offset of the current page. + Offset *int64 `json:"offset,omitempty"` + + // Optional size of a single page. + Limit *int64 `json:"limit,omitempty"` + + // Link to the first page. + First *string `json:"first,omitempty"` + + // Link to the previous available page. If 'previous' property is not part of the response no previous page is + // available. + Previous *string `json:"previous,omitempty"` + + // Link to the next available page. If 'next' property is not part of the response no next page is available. + Next *string `json:"next,omitempty"` + + // List of Account Settings Templates based on the query paramters and the page size. The account_settings_templates + // array is always part of the response but might be empty depending on the query parameter values provided. + AccountSettingsTemplates []AccountSettingsTemplateResponse `json:"account_settings_templates" validate:"required"` +} + +// UnmarshalAccountSettingsTemplateList unmarshals an instance of AccountSettingsTemplateList from the specified map of raw messages. +func UnmarshalAccountSettingsTemplateList(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(AccountSettingsTemplateList) + err = core.UnmarshalModel(m, "context", &obj.Context, UnmarshalResponseContext) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "offset", &obj.Offset) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "limit", &obj.Limit) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "first", &obj.First) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "previous", &obj.Previous) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "next", &obj.Next) + if err != nil { + return + } + err = core.UnmarshalModel(m, "account_settings_templates", &obj.AccountSettingsTemplates, UnmarshalAccountSettingsTemplateResponse) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// AccountSettingsTemplateResponse : Response body format for Account Settings Template REST requests. +type AccountSettingsTemplateResponse struct { + // ID of the the template. + ID *string `json:"id" validate:"required"` + + // Version of the the template. + Version *int64 `json:"version" validate:"required"` + + // ID of the account where the template resides. + AccountID *string `json:"account_id" validate:"required"` + + // Name of the Template. + Name *string `json:"name" validate:"required"` + + // Description of the Template. + Description *string `json:"description,omitempty"` + + // Committed flag determines if the template is ready for assignment. + Committed *bool `json:"committed" validate:"required"` + + AccountSettings *AccountSettingsComponent `json:"account_settings" validate:"required"` + + // History of the Template. + History []EnityHistoryRecord `json:"history,omitempty"` + + // Entity tag for this templateId-version combination. + EntityTag *string `json:"entity_tag" validate:"required"` + + // Cloud resource name. + CRN *string `json:"crn" validate:"required"` + + // Template Created At. + CreatedAt *string `json:"created_at,omitempty"` + + // IAMid of the creator. + CreatedByID *string `json:"created_by_id,omitempty"` + + // Template last modified at. + LastModifiedAt *string `json:"last_modified_at,omitempty"` + + // IAMid of the identity that made the latest modification. + LastModifiedByID *string `json:"last_modified_by_id,omitempty"` +} + +// UnmarshalAccountSettingsTemplateResponse unmarshals an instance of AccountSettingsTemplateResponse from the specified map of raw messages. +func UnmarshalAccountSettingsTemplateResponse(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(AccountSettingsTemplateResponse) + err = core.UnmarshalPrimitive(m, "id", &obj.ID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "version", &obj.Version) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "account_id", &obj.AccountID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "name", &obj.Name) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "description", &obj.Description) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "committed", &obj.Committed) + if err != nil { + return + } + err = core.UnmarshalModel(m, "account_settings", &obj.AccountSettings, UnmarshalAccountSettingsComponent) + if err != nil { + return + } + err = core.UnmarshalModel(m, "history", &obj.History, UnmarshalEnityHistoryRecord) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "entity_tag", &obj.EntityTag) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "crn", &obj.CRN) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "created_at", &obj.CreatedAt) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "created_by_id", &obj.CreatedByID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "last_modified_at", &obj.LastModifiedAt) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "last_modified_by_id", &obj.LastModifiedByID) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// AccountSettingsUserMfa : AccountSettingsUserMfa struct +type AccountSettingsUserMfa struct { + // The iam_id of the user. + IamID *string `json:"iam_id" validate:"required"` + + // Defines the MFA requirement for the user. Valid values: + // * NONE - No MFA trait set + // * NONE_NO_ROPC- No MFA, disable CLI logins with only a password + // * TOTP - For all non-federated IBMId users + // * TOTP4ALL - For all users + // * LEVEL1 - Email-based MFA for all users + // * LEVEL2 - TOTP-based MFA for all users + // * LEVEL3 - U2F MFA for all users. + Mfa *string `json:"mfa" validate:"required"` +} + +// Constants associated with the AccountSettingsUserMfa.Mfa property. +// Defines the MFA requirement for the user. Valid values: +// * NONE - No MFA trait set +// * NONE_NO_ROPC- No MFA, disable CLI logins with only a password +// * TOTP - For all non-federated IBMId users +// * TOTP4ALL - For all users +// * LEVEL1 - Email-based MFA for all users +// * LEVEL2 - TOTP-based MFA for all users +// * LEVEL3 - U2F MFA for all users. +const ( + AccountSettingsUserMfaMfaLevel1Const = "LEVEL1" + AccountSettingsUserMfaMfaLevel2Const = "LEVEL2" + AccountSettingsUserMfaMfaLevel3Const = "LEVEL3" + AccountSettingsUserMfaMfaNoneConst = "NONE" + AccountSettingsUserMfaMfaNoneNoRopcConst = "NONE_NO_ROPC" + AccountSettingsUserMfaMfaTotpConst = "TOTP" + AccountSettingsUserMfaMfaTotp4allConst = "TOTP4ALL" +) + +// NewAccountSettingsUserMfa : Instantiate AccountSettingsUserMfa (Generic Model Constructor) +func (*IamIdentityV1) NewAccountSettingsUserMfa(iamID string, mfa string) (_model *AccountSettingsUserMfa, err error) { + _model = &AccountSettingsUserMfa{ + IamID: core.StringPtr(iamID), + Mfa: core.StringPtr(mfa), + } + err = core.ValidateStruct(_model, "required parameters") + return +} + +// UnmarshalAccountSettingsUserMfa unmarshals an instance of AccountSettingsUserMfa from the specified map of raw messages. +func UnmarshalAccountSettingsUserMfa(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(AccountSettingsUserMfa) + err = core.UnmarshalPrimitive(m, "iam_id", &obj.IamID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "mfa", &obj.Mfa) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// Activity : Activity struct +type Activity struct { + // Time when the entity was last authenticated. + LastAuthn *string `json:"last_authn,omitempty"` + + // Authentication count, number of times the entity was authenticated. + AuthnCount *int64 `json:"authn_count" validate:"required"` +} + +// UnmarshalActivity unmarshals an instance of Activity from the specified map of raw messages. +func UnmarshalActivity(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(Activity) + err = core.UnmarshalPrimitive(m, "last_authn", &obj.LastAuthn) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "authn_count", &obj.AuthnCount) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// APIKey : Response body format for API key V1 REST requests. +type APIKey struct { + // Context with key properties for problem determination. + Context *ResponseContext `json:"context,omitempty"` + + // Unique identifier of this API Key. + ID *string `json:"id" validate:"required"` + + // Version of the API Key details object. You need to specify this value when updating the API key to avoid stale + // updates. + EntityTag *string `json:"entity_tag,omitempty"` + + // Cloud Resource Name of the item. Example Cloud Resource Name: + // 'crn:v1:bluemix:public:iam-identity:us-south:a/myaccount::apikey:1234-9012-5678'. + CRN *string `json:"crn" validate:"required"` + + // The API key cannot be changed if set to true. + Locked *bool `json:"locked" validate:"required"` + + // If set contains a date time string of the creation date in ISO format. + CreatedAt *strfmt.DateTime `json:"created_at,omitempty"` + + // IAM ID of the user or service which created the API key. + CreatedBy *string `json:"created_by" validate:"required"` + + // If set contains a date time string of the last modification date in ISO format. + ModifiedAt *strfmt.DateTime `json:"modified_at,omitempty"` + + // Name of the API key. The name is not checked for uniqueness. Therefore multiple names with the same value can exist. + // Access is done via the UUID of the API key. + Name *string `json:"name" validate:"required"` + + // The optional description of the API key. The 'description' property is only available if a description was provided + // during a create of an API key. + Description *string `json:"description,omitempty"` + + // The iam_id that this API key authenticates. + IamID *string `json:"iam_id" validate:"required"` + + // ID of the account that this API key authenticates for. + AccountID *string `json:"account_id" validate:"required"` + + // The API key value. This property only contains the API key value for the following cases: create an API key, update + // a service ID API key that stores the API key value as retrievable, or get a service ID API key that stores the API + // key value as retrievable. All other operations don't return the API key value, for example all user API key related + // operations, except for create, don't contain the API key value. + Apikey *string `json:"apikey" validate:"required"` + + // History of the API key. + History []EnityHistoryRecord `json:"history,omitempty"` + + Activity *Activity `json:"activity,omitempty"` +} + +// UnmarshalAPIKey unmarshals an instance of APIKey from the specified map of raw messages. +func UnmarshalAPIKey(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(APIKey) + err = core.UnmarshalModel(m, "context", &obj.Context, UnmarshalResponseContext) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "id", &obj.ID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "entity_tag", &obj.EntityTag) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "crn", &obj.CRN) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "locked", &obj.Locked) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "created_at", &obj.CreatedAt) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "created_by", &obj.CreatedBy) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "modified_at", &obj.ModifiedAt) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "name", &obj.Name) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "description", &obj.Description) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "iam_id", &obj.IamID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "account_id", &obj.AccountID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "apikey", &obj.Apikey) + if err != nil { + return + } + err = core.UnmarshalModel(m, "history", &obj.History, UnmarshalEnityHistoryRecord) + if err != nil { + return + } + err = core.UnmarshalModel(m, "activity", &obj.Activity, UnmarshalActivity) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// APIKeyInsideCreateServiceIDRequest : Parameters for the API key in the Create service Id V1 REST request. +type APIKeyInsideCreateServiceIDRequest struct { + // Name of the API key. The name is not checked for uniqueness. Therefore multiple names with the same value can exist. + // Access is done via the UUID of the API key. + Name *string `json:"name" validate:"required"` + + // The optional description of the API key. The 'description' property is only available if a description was provided + // during a create of an API key. + Description *string `json:"description,omitempty"` + + // You can optionally passthrough the API key value for this API key. If passed, NO validation of that apiKey value is + // done, i.e. the value can be non-URL safe. If omitted, the API key management will create an URL safe opaque API key + // value. The value of the API key is checked for uniqueness. Please ensure enough variations when passing in this + // value. + Apikey *string `json:"apikey,omitempty"` + + // Send true or false to set whether the API key value is retrievable in the future by using the Get details of an API + // key request. If you create an API key for a user, you must specify `false` or omit the value. We don't allow storing + // of API keys for users. + StoreValue *bool `json:"store_value,omitempty"` +} + +// NewAPIKeyInsideCreateServiceIDRequest : Instantiate APIKeyInsideCreateServiceIDRequest (Generic Model Constructor) +func (*IamIdentityV1) NewAPIKeyInsideCreateServiceIDRequest(name string) (_model *APIKeyInsideCreateServiceIDRequest, err error) { + _model = &APIKeyInsideCreateServiceIDRequest{ + Name: core.StringPtr(name), + } + err = core.ValidateStruct(_model, "required parameters") + return +} + +// UnmarshalAPIKeyInsideCreateServiceIDRequest unmarshals an instance of APIKeyInsideCreateServiceIDRequest from the specified map of raw messages. +func UnmarshalAPIKeyInsideCreateServiceIDRequest(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(APIKeyInsideCreateServiceIDRequest) + err = core.UnmarshalPrimitive(m, "name", &obj.Name) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "description", &obj.Description) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "apikey", &obj.Apikey) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "store_value", &obj.StoreValue) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// APIKeyList : Response body format for the List API keys V1 REST request. +type APIKeyList struct { + // Context with key properties for problem determination. + Context *ResponseContext `json:"context,omitempty"` + + // The offset of the current page. + Offset *int64 `json:"offset,omitempty"` + + // Optional size of a single page. Default is 20 items per page. Valid range is 1 to 100. + Limit *int64 `json:"limit,omitempty"` + + // Link to the first page. + First *string `json:"first,omitempty"` + + // Link to the previous available page. If 'previous' property is not part of the response no previous page is + // available. + Previous *string `json:"previous,omitempty"` + + // Link to the next available page. If 'next' property is not part of the response no next page is available. + Next *string `json:"next,omitempty"` + + // List of API keys based on the query paramters and the page size. The apikeys array is always part of the response + // but might be empty depending on the query parameters values provided. + Apikeys []APIKey `json:"apikeys" validate:"required"` +} + +// UnmarshalAPIKeyList unmarshals an instance of APIKeyList from the specified map of raw messages. +func UnmarshalAPIKeyList(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(APIKeyList) + err = core.UnmarshalModel(m, "context", &obj.Context, UnmarshalResponseContext) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "offset", &obj.Offset) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "limit", &obj.Limit) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "first", &obj.First) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "previous", &obj.Previous) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "next", &obj.Next) + if err != nil { + return + } + err = core.UnmarshalModel(m, "apikeys", &obj.Apikeys, UnmarshalAPIKey) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// ApikeyActivity : Apikeys activity details. +type ApikeyActivity struct { + // Unique id of the apikey. + ID *string `json:"id" validate:"required"` + + // Name provided during creation of the apikey. + Name *string `json:"name,omitempty"` + + // Type of the apikey. Supported values are `serviceid` and `user`. + Type *string `json:"type" validate:"required"` + + // serviceid details will be present if type is `serviceid`. + Serviceid *ApikeyActivityServiceid `json:"serviceid,omitempty"` + + // user details will be present if type is `user`. + User *ApikeyActivityUser `json:"user,omitempty"` + + // Time when the apikey was last authenticated. + LastAuthn *string `json:"last_authn,omitempty"` +} + +// UnmarshalApikeyActivity unmarshals an instance of ApikeyActivity from the specified map of raw messages. +func UnmarshalApikeyActivity(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(ApikeyActivity) + err = core.UnmarshalPrimitive(m, "id", &obj.ID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "name", &obj.Name) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "type", &obj.Type) + if err != nil { + return + } + err = core.UnmarshalModel(m, "serviceid", &obj.Serviceid, UnmarshalApikeyActivityServiceid) + if err != nil { + return + } + err = core.UnmarshalModel(m, "user", &obj.User, UnmarshalApikeyActivityUser) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "last_authn", &obj.LastAuthn) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// ApikeyActivityServiceid : serviceid details will be present if type is `serviceid`. +type ApikeyActivityServiceid struct { + // Unique identifier of this Service Id. + ID *string `json:"id,omitempty"` + + // Name provided during creation of the serviceid. + Name *string `json:"name,omitempty"` +} + +// UnmarshalApikeyActivityServiceid unmarshals an instance of ApikeyActivityServiceid from the specified map of raw messages. +func UnmarshalApikeyActivityServiceid(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(ApikeyActivityServiceid) + err = core.UnmarshalPrimitive(m, "id", &obj.ID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "name", &obj.Name) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// ApikeyActivityUser : user details will be present if type is `user`. +type ApikeyActivityUser struct { + // IAMid of the user. + IamID *string `json:"iam_id,omitempty"` + + // Name of the user. + Name *string `json:"name,omitempty"` + + // Username of the user. + Username *string `json:"username,omitempty"` + + // Email of the user. + Email *string `json:"email,omitempty"` +} + +// UnmarshalApikeyActivityUser unmarshals an instance of ApikeyActivityUser from the specified map of raw messages. +func UnmarshalApikeyActivityUser(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(ApikeyActivityUser) + err = core.UnmarshalPrimitive(m, "iam_id", &obj.IamID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "name", &obj.Name) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "username", &obj.Username) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "email", &obj.Email) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// CommitAccountSettingsTemplateOptions : The CommitAccountSettingsTemplate options. +type CommitAccountSettingsTemplateOptions struct { + // ID of the Account Settings Template. + TemplateID *string `json:"template_id" validate:"required,ne="` + + // Version of the Account Settings Template. + Version *string `json:"version" validate:"required,ne="` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewCommitAccountSettingsTemplateOptions : Instantiate CommitAccountSettingsTemplateOptions +func (*IamIdentityV1) NewCommitAccountSettingsTemplateOptions(templateID string, version string) *CommitAccountSettingsTemplateOptions { + return &CommitAccountSettingsTemplateOptions{ + TemplateID: core.StringPtr(templateID), + Version: core.StringPtr(version), + } +} + +// SetTemplateID : Allow user to set TemplateID +func (_options *CommitAccountSettingsTemplateOptions) SetTemplateID(templateID string) *CommitAccountSettingsTemplateOptions { + _options.TemplateID = core.StringPtr(templateID) + return _options +} + +// SetVersion : Allow user to set Version +func (_options *CommitAccountSettingsTemplateOptions) SetVersion(version string) *CommitAccountSettingsTemplateOptions { + _options.Version = core.StringPtr(version) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *CommitAccountSettingsTemplateOptions) SetHeaders(param map[string]string) *CommitAccountSettingsTemplateOptions { + options.Headers = param + return options +} + +// CommitProfileTemplateOptions : The CommitProfileTemplate options. +type CommitProfileTemplateOptions struct { + // ID of the Profile Template. + TemplateID *string `json:"template_id" validate:"required,ne="` + + // Version of the Profile Template. + Version *string `json:"version" validate:"required,ne="` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewCommitProfileTemplateOptions : Instantiate CommitProfileTemplateOptions +func (*IamIdentityV1) NewCommitProfileTemplateOptions(templateID string, version string) *CommitProfileTemplateOptions { + return &CommitProfileTemplateOptions{ + TemplateID: core.StringPtr(templateID), + Version: core.StringPtr(version), + } +} + +// SetTemplateID : Allow user to set TemplateID +func (_options *CommitProfileTemplateOptions) SetTemplateID(templateID string) *CommitProfileTemplateOptions { + _options.TemplateID = core.StringPtr(templateID) + return _options +} + +// SetVersion : Allow user to set Version +func (_options *CommitProfileTemplateOptions) SetVersion(version string) *CommitProfileTemplateOptions { + _options.Version = core.StringPtr(version) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *CommitProfileTemplateOptions) SetHeaders(param map[string]string) *CommitProfileTemplateOptions { + options.Headers = param + return options +} + +// CreateAccountSettingsAssignmentOptions : The CreateAccountSettingsAssignment options. +type CreateAccountSettingsAssignmentOptions struct { + // ID of the template to assign. + TemplateID *string `json:"template_id" validate:"required"` + + // Version of the template to assign. + TemplateVersion *int64 `json:"template_version" validate:"required"` + + // Type of target to deploy to. + TargetType *string `json:"target_type" validate:"required"` + + // Identifier of target to deploy to. + Target *string `json:"target" validate:"required"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// Constants associated with the CreateAccountSettingsAssignmentOptions.TargetType property. +// Type of target to deploy to. +const ( + CreateAccountSettingsAssignmentOptionsTargetTypeAccountConst = "Account" + CreateAccountSettingsAssignmentOptionsTargetTypeAccountgroupConst = "AccountGroup" +) + +// NewCreateAccountSettingsAssignmentOptions : Instantiate CreateAccountSettingsAssignmentOptions +func (*IamIdentityV1) NewCreateAccountSettingsAssignmentOptions(templateID string, templateVersion int64, targetType string, target string) *CreateAccountSettingsAssignmentOptions { + return &CreateAccountSettingsAssignmentOptions{ + TemplateID: core.StringPtr(templateID), + TemplateVersion: core.Int64Ptr(templateVersion), + TargetType: core.StringPtr(targetType), + Target: core.StringPtr(target), + } +} + +// SetTemplateID : Allow user to set TemplateID +func (_options *CreateAccountSettingsAssignmentOptions) SetTemplateID(templateID string) *CreateAccountSettingsAssignmentOptions { + _options.TemplateID = core.StringPtr(templateID) + return _options +} + +// SetTemplateVersion : Allow user to set TemplateVersion +func (_options *CreateAccountSettingsAssignmentOptions) SetTemplateVersion(templateVersion int64) *CreateAccountSettingsAssignmentOptions { + _options.TemplateVersion = core.Int64Ptr(templateVersion) + return _options +} + +// SetTargetType : Allow user to set TargetType +func (_options *CreateAccountSettingsAssignmentOptions) SetTargetType(targetType string) *CreateAccountSettingsAssignmentOptions { + _options.TargetType = core.StringPtr(targetType) + return _options +} + +// SetTarget : Allow user to set Target +func (_options *CreateAccountSettingsAssignmentOptions) SetTarget(target string) *CreateAccountSettingsAssignmentOptions { + _options.Target = core.StringPtr(target) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *CreateAccountSettingsAssignmentOptions) SetHeaders(param map[string]string) *CreateAccountSettingsAssignmentOptions { + options.Headers = param + return options +} + +// CreateAccountSettingsTemplateOptions : The CreateAccountSettingsTemplate options. +type CreateAccountSettingsTemplateOptions struct { + // ID of the account where the template resides. + AccountID *string `json:"account_id,omitempty"` + + // Name of the Template. + Name *string `json:"name,omitempty"` + + // Description of the Template. + Description *string `json:"description,omitempty"` + + AccountSettings *AccountSettingsComponent `json:"account_settings,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewCreateAccountSettingsTemplateOptions : Instantiate CreateAccountSettingsTemplateOptions +func (*IamIdentityV1) NewCreateAccountSettingsTemplateOptions() *CreateAccountSettingsTemplateOptions { + return &CreateAccountSettingsTemplateOptions{} +} + +// SetAccountID : Allow user to set AccountID +func (_options *CreateAccountSettingsTemplateOptions) SetAccountID(accountID string) *CreateAccountSettingsTemplateOptions { + _options.AccountID = core.StringPtr(accountID) + return _options +} + +// SetName : Allow user to set Name +func (_options *CreateAccountSettingsTemplateOptions) SetName(name string) *CreateAccountSettingsTemplateOptions { + _options.Name = core.StringPtr(name) + return _options +} + +// SetDescription : Allow user to set Description +func (_options *CreateAccountSettingsTemplateOptions) SetDescription(description string) *CreateAccountSettingsTemplateOptions { + _options.Description = core.StringPtr(description) + return _options +} + +// SetAccountSettings : Allow user to set AccountSettings +func (_options *CreateAccountSettingsTemplateOptions) SetAccountSettings(accountSettings *AccountSettingsComponent) *CreateAccountSettingsTemplateOptions { + _options.AccountSettings = accountSettings + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *CreateAccountSettingsTemplateOptions) SetHeaders(param map[string]string) *CreateAccountSettingsTemplateOptions { + options.Headers = param + return options +} + +// CreateAccountSettingsTemplateVersionOptions : The CreateAccountSettingsTemplateVersion options. +type CreateAccountSettingsTemplateVersionOptions struct { + // ID of the Account Settings Template. + TemplateID *string `json:"template_id" validate:"required,ne="` + + // ID of the account where the template resides. + AccountID *string `json:"account_id,omitempty"` + + // Name of the Template. + Name *string `json:"name,omitempty"` + + // Description of the Template. + Description *string `json:"description,omitempty"` + + AccountSettings *AccountSettingsComponent `json:"account_settings,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewCreateAccountSettingsTemplateVersionOptions : Instantiate CreateAccountSettingsTemplateVersionOptions +func (*IamIdentityV1) NewCreateAccountSettingsTemplateVersionOptions(templateID string) *CreateAccountSettingsTemplateVersionOptions { + return &CreateAccountSettingsTemplateVersionOptions{ + TemplateID: core.StringPtr(templateID), + } +} + +// SetTemplateID : Allow user to set TemplateID +func (_options *CreateAccountSettingsTemplateVersionOptions) SetTemplateID(templateID string) *CreateAccountSettingsTemplateVersionOptions { + _options.TemplateID = core.StringPtr(templateID) + return _options +} + +// SetAccountID : Allow user to set AccountID +func (_options *CreateAccountSettingsTemplateVersionOptions) SetAccountID(accountID string) *CreateAccountSettingsTemplateVersionOptions { + _options.AccountID = core.StringPtr(accountID) + return _options +} + +// SetName : Allow user to set Name +func (_options *CreateAccountSettingsTemplateVersionOptions) SetName(name string) *CreateAccountSettingsTemplateVersionOptions { + _options.Name = core.StringPtr(name) + return _options +} + +// SetDescription : Allow user to set Description +func (_options *CreateAccountSettingsTemplateVersionOptions) SetDescription(description string) *CreateAccountSettingsTemplateVersionOptions { + _options.Description = core.StringPtr(description) + return _options +} + +// SetAccountSettings : Allow user to set AccountSettings +func (_options *CreateAccountSettingsTemplateVersionOptions) SetAccountSettings(accountSettings *AccountSettingsComponent) *CreateAccountSettingsTemplateVersionOptions { + _options.AccountSettings = accountSettings + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *CreateAccountSettingsTemplateVersionOptions) SetHeaders(param map[string]string) *CreateAccountSettingsTemplateVersionOptions { + options.Headers = param + return options +} + +// CreateAPIKeyOptions : The CreateAPIKey options. +type CreateAPIKeyOptions struct { + // Name of the API key. The name is not checked for uniqueness. Therefore multiple names with the same value can exist. + // Access is done via the UUID of the API key. + Name *string `json:"name" validate:"required"` + + // The iam_id that this API key authenticates. + IamID *string `json:"iam_id" validate:"required"` + + // The optional description of the API key. The 'description' property is only available if a description was provided + // during a create of an API key. + Description *string `json:"description,omitempty"` + + // The account ID of the API key. + AccountID *string `json:"account_id,omitempty"` + + // You can optionally passthrough the API key value for this API key. If passed, NO validation of that apiKey value is + // done, i.e. the value can be non-URL safe. If omitted, the API key management will create an URL safe opaque API key + // value. The value of the API key is checked for uniqueness. Please ensure enough variations when passing in this + // value. + Apikey *string `json:"apikey,omitempty"` + + // Send true or false to set whether the API key value is retrievable in the future by using the Get details of an API + // key request. If you create an API key for a user, you must specify `false` or omit the value. We don't allow storing + // of API keys for users. + StoreValue *bool `json:"store_value,omitempty"` + + // Indicates if the API key is locked for further write operations. False by default. + EntityLock *string `json:"Entity-Lock,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewCreateAPIKeyOptions : Instantiate CreateAPIKeyOptions +func (*IamIdentityV1) NewCreateAPIKeyOptions(name string, iamID string) *CreateAPIKeyOptions { + return &CreateAPIKeyOptions{ + Name: core.StringPtr(name), + IamID: core.StringPtr(iamID), + } +} + +// SetName : Allow user to set Name +func (_options *CreateAPIKeyOptions) SetName(name string) *CreateAPIKeyOptions { + _options.Name = core.StringPtr(name) + return _options +} + +// SetIamID : Allow user to set IamID +func (_options *CreateAPIKeyOptions) SetIamID(iamID string) *CreateAPIKeyOptions { + _options.IamID = core.StringPtr(iamID) + return _options +} + +// SetDescription : Allow user to set Description +func (_options *CreateAPIKeyOptions) SetDescription(description string) *CreateAPIKeyOptions { + _options.Description = core.StringPtr(description) + return _options +} + +// SetAccountID : Allow user to set AccountID +func (_options *CreateAPIKeyOptions) SetAccountID(accountID string) *CreateAPIKeyOptions { + _options.AccountID = core.StringPtr(accountID) + return _options +} + +// SetApikey : Allow user to set Apikey +func (_options *CreateAPIKeyOptions) SetApikey(apikey string) *CreateAPIKeyOptions { + _options.Apikey = core.StringPtr(apikey) + return _options +} + +// SetStoreValue : Allow user to set StoreValue +func (_options *CreateAPIKeyOptions) SetStoreValue(storeValue bool) *CreateAPIKeyOptions { + _options.StoreValue = core.BoolPtr(storeValue) + return _options +} + +// SetEntityLock : Allow user to set EntityLock +func (_options *CreateAPIKeyOptions) SetEntityLock(entityLock string) *CreateAPIKeyOptions { + _options.EntityLock = core.StringPtr(entityLock) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *CreateAPIKeyOptions) SetHeaders(param map[string]string) *CreateAPIKeyOptions { + options.Headers = param + return options +} + +// CreateClaimRuleOptions : The CreateClaimRule options. +type CreateClaimRuleOptions struct { + // ID of the trusted profile to create a claim rule. + ProfileID *string `json:"profile-id" validate:"required,ne="` + + // Type of the claim rule, either 'Profile-SAML' or 'Profile-CR'. + Type *string `json:"type" validate:"required"` + + // Conditions of this claim rule. + Conditions []ProfileClaimRuleConditions `json:"conditions" validate:"required"` + + // Context with key properties for problem determination. + Context *ResponseContext `json:"context,omitempty"` + + // Name of the claim rule to be created or updated. + Name *string `json:"name,omitempty"` + + // The realm name of the Idp this claim rule applies to. This field is required only if the type is specified as + // 'Profile-SAML'. + RealmName *string `json:"realm_name,omitempty"` + + // The compute resource type the rule applies to, required only if type is specified as 'Profile-CR'. Valid values are + // VSI, IKS_SA, ROKS_SA. + CrType *string `json:"cr_type,omitempty"` + + // Session expiration in seconds, only required if type is 'Profile-SAML'. + Expiration *int64 `json:"expiration,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewCreateClaimRuleOptions : Instantiate CreateClaimRuleOptions +func (*IamIdentityV1) NewCreateClaimRuleOptions(profileID string, typeVar string, conditions []ProfileClaimRuleConditions) *CreateClaimRuleOptions { + return &CreateClaimRuleOptions{ + ProfileID: core.StringPtr(profileID), + Type: core.StringPtr(typeVar), + Conditions: conditions, + } +} + +// SetProfileID : Allow user to set ProfileID +func (_options *CreateClaimRuleOptions) SetProfileID(profileID string) *CreateClaimRuleOptions { + _options.ProfileID = core.StringPtr(profileID) + return _options +} + +// SetType : Allow user to set Type +func (_options *CreateClaimRuleOptions) SetType(typeVar string) *CreateClaimRuleOptions { + _options.Type = core.StringPtr(typeVar) + return _options +} + +// SetConditions : Allow user to set Conditions +func (_options *CreateClaimRuleOptions) SetConditions(conditions []ProfileClaimRuleConditions) *CreateClaimRuleOptions { + _options.Conditions = conditions + return _options +} + +// SetContext : Allow user to set Context +func (_options *CreateClaimRuleOptions) SetContext(context *ResponseContext) *CreateClaimRuleOptions { + _options.Context = context + return _options +} + +// SetName : Allow user to set Name +func (_options *CreateClaimRuleOptions) SetName(name string) *CreateClaimRuleOptions { + _options.Name = core.StringPtr(name) + return _options +} + +// SetRealmName : Allow user to set RealmName +func (_options *CreateClaimRuleOptions) SetRealmName(realmName string) *CreateClaimRuleOptions { + _options.RealmName = core.StringPtr(realmName) + return _options +} + +// SetCrType : Allow user to set CrType +func (_options *CreateClaimRuleOptions) SetCrType(crType string) *CreateClaimRuleOptions { + _options.CrType = core.StringPtr(crType) + return _options +} + +// SetExpiration : Allow user to set Expiration +func (_options *CreateClaimRuleOptions) SetExpiration(expiration int64) *CreateClaimRuleOptions { + _options.Expiration = core.Int64Ptr(expiration) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *CreateClaimRuleOptions) SetHeaders(param map[string]string) *CreateClaimRuleOptions { + options.Headers = param + return options +} + +// CreateLinkOptions : The CreateLink options. +type CreateLinkOptions struct { + // ID of the trusted profile. + ProfileID *string `json:"profile-id" validate:"required,ne="` + + // The compute resource type. Valid values are VSI, IKS_SA, ROKS_SA. + CrType *string `json:"cr_type" validate:"required"` + + // Link details. + Link *CreateProfileLinkRequestLink `json:"link" validate:"required"` + + // Optional name of the Link. + Name *string `json:"name,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewCreateLinkOptions : Instantiate CreateLinkOptions +func (*IamIdentityV1) NewCreateLinkOptions(profileID string, crType string, link *CreateProfileLinkRequestLink) *CreateLinkOptions { + return &CreateLinkOptions{ + ProfileID: core.StringPtr(profileID), + CrType: core.StringPtr(crType), + Link: link, + } +} + +// SetProfileID : Allow user to set ProfileID +func (_options *CreateLinkOptions) SetProfileID(profileID string) *CreateLinkOptions { + _options.ProfileID = core.StringPtr(profileID) + return _options +} + +// SetCrType : Allow user to set CrType +func (_options *CreateLinkOptions) SetCrType(crType string) *CreateLinkOptions { + _options.CrType = core.StringPtr(crType) + return _options +} + +// SetLink : Allow user to set Link +func (_options *CreateLinkOptions) SetLink(link *CreateProfileLinkRequestLink) *CreateLinkOptions { + _options.Link = link + return _options +} + +// SetName : Allow user to set Name +func (_options *CreateLinkOptions) SetName(name string) *CreateLinkOptions { + _options.Name = core.StringPtr(name) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *CreateLinkOptions) SetHeaders(param map[string]string) *CreateLinkOptions { + options.Headers = param + return options +} + +// CreateMfaReportOptions : The CreateMfaReport options. +type CreateMfaReportOptions struct { + // ID of the account. + AccountID *string `json:"account_id" validate:"required,ne="` + + // Optional report type. The supported value is 'mfa_status'. List MFA enrollment status for all the identities. + Type *string `json:"type,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewCreateMfaReportOptions : Instantiate CreateMfaReportOptions +func (*IamIdentityV1) NewCreateMfaReportOptions(accountID string) *CreateMfaReportOptions { + return &CreateMfaReportOptions{ + AccountID: core.StringPtr(accountID), + } +} + +// SetAccountID : Allow user to set AccountID +func (_options *CreateMfaReportOptions) SetAccountID(accountID string) *CreateMfaReportOptions { + _options.AccountID = core.StringPtr(accountID) + return _options +} + +// SetType : Allow user to set Type +func (_options *CreateMfaReportOptions) SetType(typeVar string) *CreateMfaReportOptions { + _options.Type = core.StringPtr(typeVar) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *CreateMfaReportOptions) SetHeaders(param map[string]string) *CreateMfaReportOptions { + options.Headers = param + return options +} + +// CreateProfileLinkRequestLink : Link details. +type CreateProfileLinkRequestLink struct { + // The CRN of the compute resource. + CRN *string `json:"crn" validate:"required"` + + // The compute resource namespace, only required if cr_type is IKS_SA or ROKS_SA. + Namespace *string `json:"namespace" validate:"required"` + + // Name of the compute resource, only required if cr_type is IKS_SA or ROKS_SA. + Name *string `json:"name,omitempty"` +} + +// NewCreateProfileLinkRequestLink : Instantiate CreateProfileLinkRequestLink (Generic Model Constructor) +func (*IamIdentityV1) NewCreateProfileLinkRequestLink(crn string, namespace string) (_model *CreateProfileLinkRequestLink, err error) { + _model = &CreateProfileLinkRequestLink{ + CRN: core.StringPtr(crn), + Namespace: core.StringPtr(namespace), + } + err = core.ValidateStruct(_model, "required parameters") + return +} + +// UnmarshalCreateProfileLinkRequestLink unmarshals an instance of CreateProfileLinkRequestLink from the specified map of raw messages. +func UnmarshalCreateProfileLinkRequestLink(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(CreateProfileLinkRequestLink) + err = core.UnmarshalPrimitive(m, "crn", &obj.CRN) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "namespace", &obj.Namespace) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "name", &obj.Name) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// CreateProfileOptions : The CreateProfile options. +type CreateProfileOptions struct { + // Name of the trusted profile. The name is checked for uniqueness. Therefore trusted profiles with the same names can + // not exist in the same account. + Name *string `json:"name" validate:"required"` + + // The account ID of the trusted profile. + AccountID *string `json:"account_id" validate:"required"` + + // The optional description of the trusted profile. The 'description' property is only available if a description was + // provided during creation of trusted profile. + Description *string `json:"description,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewCreateProfileOptions : Instantiate CreateProfileOptions +func (*IamIdentityV1) NewCreateProfileOptions(name string, accountID string) *CreateProfileOptions { + return &CreateProfileOptions{ + Name: core.StringPtr(name), + AccountID: core.StringPtr(accountID), + } +} + +// SetName : Allow user to set Name +func (_options *CreateProfileOptions) SetName(name string) *CreateProfileOptions { + _options.Name = core.StringPtr(name) + return _options +} + +// SetAccountID : Allow user to set AccountID +func (_options *CreateProfileOptions) SetAccountID(accountID string) *CreateProfileOptions { + _options.AccountID = core.StringPtr(accountID) + return _options +} + +// SetDescription : Allow user to set Description +func (_options *CreateProfileOptions) SetDescription(description string) *CreateProfileOptions { + _options.Description = core.StringPtr(description) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *CreateProfileOptions) SetHeaders(param map[string]string) *CreateProfileOptions { + options.Headers = param + return options +} + +// CreateProfileTemplateOptions : The CreateProfileTemplate options. +type CreateProfileTemplateOptions struct { + // ID of the account where the template resides. + AccountID *string `json:"account_id,omitempty"` + + // Name of the Template. + Name *string `json:"name,omitempty"` + + // Description of the Template. + Description *string `json:"description,omitempty"` + + // Input body parameters for the TemplateProfileComponent. + Profile *TemplateProfileComponentRequest `json:"profile,omitempty"` + + // Policy templates to be deployed for the Profile component. + PolicyTemplateReferences []PolicyTemplateReference `json:"policy_template_references,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewCreateProfileTemplateOptions : Instantiate CreateProfileTemplateOptions +func (*IamIdentityV1) NewCreateProfileTemplateOptions() *CreateProfileTemplateOptions { + return &CreateProfileTemplateOptions{} +} + +// SetAccountID : Allow user to set AccountID +func (_options *CreateProfileTemplateOptions) SetAccountID(accountID string) *CreateProfileTemplateOptions { + _options.AccountID = core.StringPtr(accountID) + return _options +} + +// SetName : Allow user to set Name +func (_options *CreateProfileTemplateOptions) SetName(name string) *CreateProfileTemplateOptions { + _options.Name = core.StringPtr(name) + return _options +} + +// SetDescription : Allow user to set Description +func (_options *CreateProfileTemplateOptions) SetDescription(description string) *CreateProfileTemplateOptions { + _options.Description = core.StringPtr(description) + return _options +} + +// SetProfile : Allow user to set Profile +func (_options *CreateProfileTemplateOptions) SetProfile(profile *TemplateProfileComponentRequest) *CreateProfileTemplateOptions { + _options.Profile = profile + return _options +} + +// SetPolicyTemplateReferences : Allow user to set PolicyTemplateReferences +func (_options *CreateProfileTemplateOptions) SetPolicyTemplateReferences(policyTemplateReferences []PolicyTemplateReference) *CreateProfileTemplateOptions { + _options.PolicyTemplateReferences = policyTemplateReferences + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *CreateProfileTemplateOptions) SetHeaders(param map[string]string) *CreateProfileTemplateOptions { + options.Headers = param + return options +} + +// CreateProfileTemplateVersionOptions : The CreateProfileTemplateVersion options. +type CreateProfileTemplateVersionOptions struct { + // ID of the Profile Template. + TemplateID *string `json:"template_id" validate:"required,ne="` + + // ID of the account where the template resides. + AccountID *string `json:"account_id,omitempty"` + + // Name of the Template. + Name *string `json:"name,omitempty"` + + // Description of the Template. + Description *string `json:"description,omitempty"` + + // Input body parameters for the TemplateProfileComponent. + Profile *TemplateProfileComponentRequest `json:"profile,omitempty"` + + // Policy templates to be deployed for the Profile component. + PolicyTemplateReferences []PolicyTemplateReference `json:"policy_template_references,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewCreateProfileTemplateVersionOptions : Instantiate CreateProfileTemplateVersionOptions +func (*IamIdentityV1) NewCreateProfileTemplateVersionOptions(templateID string) *CreateProfileTemplateVersionOptions { + return &CreateProfileTemplateVersionOptions{ + TemplateID: core.StringPtr(templateID), + } +} + +// SetTemplateID : Allow user to set TemplateID +func (_options *CreateProfileTemplateVersionOptions) SetTemplateID(templateID string) *CreateProfileTemplateVersionOptions { + _options.TemplateID = core.StringPtr(templateID) + return _options +} + +// SetAccountID : Allow user to set AccountID +func (_options *CreateProfileTemplateVersionOptions) SetAccountID(accountID string) *CreateProfileTemplateVersionOptions { + _options.AccountID = core.StringPtr(accountID) + return _options +} + +// SetName : Allow user to set Name +func (_options *CreateProfileTemplateVersionOptions) SetName(name string) *CreateProfileTemplateVersionOptions { + _options.Name = core.StringPtr(name) + return _options +} + +// SetDescription : Allow user to set Description +func (_options *CreateProfileTemplateVersionOptions) SetDescription(description string) *CreateProfileTemplateVersionOptions { + _options.Description = core.StringPtr(description) + return _options +} + +// SetProfile : Allow user to set Profile +func (_options *CreateProfileTemplateVersionOptions) SetProfile(profile *TemplateProfileComponentRequest) *CreateProfileTemplateVersionOptions { + _options.Profile = profile + return _options +} + +// SetPolicyTemplateReferences : Allow user to set PolicyTemplateReferences +func (_options *CreateProfileTemplateVersionOptions) SetPolicyTemplateReferences(policyTemplateReferences []PolicyTemplateReference) *CreateProfileTemplateVersionOptions { + _options.PolicyTemplateReferences = policyTemplateReferences + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *CreateProfileTemplateVersionOptions) SetHeaders(param map[string]string) *CreateProfileTemplateVersionOptions { + options.Headers = param + return options +} + +// CreateReportOptions : The CreateReport options. +type CreateReportOptions struct { + // ID of the account. + AccountID *string `json:"account_id" validate:"required,ne="` + + // Optional report type. The supported value is 'inactive'. List all identities that have not authenticated within the + // time indicated by duration. + Type *string `json:"type,omitempty"` + + // Optional duration of the report, supported unit of duration is hours. + Duration *string `json:"duration,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewCreateReportOptions : Instantiate CreateReportOptions +func (*IamIdentityV1) NewCreateReportOptions(accountID string) *CreateReportOptions { + return &CreateReportOptions{ + AccountID: core.StringPtr(accountID), + } +} + +// SetAccountID : Allow user to set AccountID +func (_options *CreateReportOptions) SetAccountID(accountID string) *CreateReportOptions { + _options.AccountID = core.StringPtr(accountID) + return _options +} + +// SetType : Allow user to set Type +func (_options *CreateReportOptions) SetType(typeVar string) *CreateReportOptions { + _options.Type = core.StringPtr(typeVar) + return _options +} + +// SetDuration : Allow user to set Duration +func (_options *CreateReportOptions) SetDuration(duration string) *CreateReportOptions { + _options.Duration = core.StringPtr(duration) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *CreateReportOptions) SetHeaders(param map[string]string) *CreateReportOptions { + options.Headers = param + return options +} + +// CreateServiceIDOptions : The CreateServiceID options. +type CreateServiceIDOptions struct { + // ID of the account the service ID belongs to. + AccountID *string `json:"account_id" validate:"required"` + + // Name of the Service Id. The name is not checked for uniqueness. Therefore multiple names with the same value can + // exist. Access is done via the UUID of the Service Id. + Name *string `json:"name" validate:"required"` + + // The optional description of the Service Id. The 'description' property is only available if a description was + // provided during a create of a Service Id. + Description *string `json:"description,omitempty"` + + // Optional list of CRNs (string array) which point to the services connected to the service ID. + UniqueInstanceCrns []string `json:"unique_instance_crns,omitempty"` + + // Parameters for the API key in the Create service Id V1 REST request. + Apikey *APIKeyInsideCreateServiceIDRequest `json:"apikey,omitempty"` + + // Indicates if the service ID is locked for further write operations. False by default. + EntityLock *string `json:"Entity-Lock,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewCreateServiceIDOptions : Instantiate CreateServiceIDOptions +func (*IamIdentityV1) NewCreateServiceIDOptions(accountID string, name string) *CreateServiceIDOptions { + return &CreateServiceIDOptions{ + AccountID: core.StringPtr(accountID), + Name: core.StringPtr(name), + } +} + +// SetAccountID : Allow user to set AccountID +func (_options *CreateServiceIDOptions) SetAccountID(accountID string) *CreateServiceIDOptions { + _options.AccountID = core.StringPtr(accountID) + return _options +} + +// SetName : Allow user to set Name +func (_options *CreateServiceIDOptions) SetName(name string) *CreateServiceIDOptions { + _options.Name = core.StringPtr(name) + return _options +} + +// SetDescription : Allow user to set Description +func (_options *CreateServiceIDOptions) SetDescription(description string) *CreateServiceIDOptions { + _options.Description = core.StringPtr(description) + return _options +} + +// SetUniqueInstanceCrns : Allow user to set UniqueInstanceCrns +func (_options *CreateServiceIDOptions) SetUniqueInstanceCrns(uniqueInstanceCrns []string) *CreateServiceIDOptions { + _options.UniqueInstanceCrns = uniqueInstanceCrns + return _options +} + +// SetApikey : Allow user to set Apikey +func (_options *CreateServiceIDOptions) SetApikey(apikey *APIKeyInsideCreateServiceIDRequest) *CreateServiceIDOptions { + _options.Apikey = apikey + return _options +} + +// SetEntityLock : Allow user to set EntityLock +func (_options *CreateServiceIDOptions) SetEntityLock(entityLock string) *CreateServiceIDOptions { + _options.EntityLock = core.StringPtr(entityLock) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *CreateServiceIDOptions) SetHeaders(param map[string]string) *CreateServiceIDOptions { + options.Headers = param + return options +} + +// CreateTrustedProfileAssignmentOptions : The CreateTrustedProfileAssignment options. +type CreateTrustedProfileAssignmentOptions struct { + // ID of the template to assign. + TemplateID *string `json:"template_id" validate:"required"` + + // Version of the template to assign. + TemplateVersion *int64 `json:"template_version" validate:"required"` + + // Type of target to deploy to. + TargetType *string `json:"target_type" validate:"required"` + + // Identifier of target to deploy to. + Target *string `json:"target" validate:"required"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// Constants associated with the CreateTrustedProfileAssignmentOptions.TargetType property. +// Type of target to deploy to. +const ( + CreateTrustedProfileAssignmentOptionsTargetTypeAccountConst = "Account" + CreateTrustedProfileAssignmentOptionsTargetTypeAccountgroupConst = "AccountGroup" +) + +// NewCreateTrustedProfileAssignmentOptions : Instantiate CreateTrustedProfileAssignmentOptions +func (*IamIdentityV1) NewCreateTrustedProfileAssignmentOptions(templateID string, templateVersion int64, targetType string, target string) *CreateTrustedProfileAssignmentOptions { + return &CreateTrustedProfileAssignmentOptions{ + TemplateID: core.StringPtr(templateID), + TemplateVersion: core.Int64Ptr(templateVersion), + TargetType: core.StringPtr(targetType), + Target: core.StringPtr(target), + } +} + +// SetTemplateID : Allow user to set TemplateID +func (_options *CreateTrustedProfileAssignmentOptions) SetTemplateID(templateID string) *CreateTrustedProfileAssignmentOptions { + _options.TemplateID = core.StringPtr(templateID) + return _options +} + +// SetTemplateVersion : Allow user to set TemplateVersion +func (_options *CreateTrustedProfileAssignmentOptions) SetTemplateVersion(templateVersion int64) *CreateTrustedProfileAssignmentOptions { + _options.TemplateVersion = core.Int64Ptr(templateVersion) + return _options +} + +// SetTargetType : Allow user to set TargetType +func (_options *CreateTrustedProfileAssignmentOptions) SetTargetType(targetType string) *CreateTrustedProfileAssignmentOptions { + _options.TargetType = core.StringPtr(targetType) + return _options +} + +// SetTarget : Allow user to set Target +func (_options *CreateTrustedProfileAssignmentOptions) SetTarget(target string) *CreateTrustedProfileAssignmentOptions { + _options.Target = core.StringPtr(target) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *CreateTrustedProfileAssignmentOptions) SetHeaders(param map[string]string) *CreateTrustedProfileAssignmentOptions { + options.Headers = param + return options +} + +// DeleteAccountSettingsAssignmentOptions : The DeleteAccountSettingsAssignment options. +type DeleteAccountSettingsAssignmentOptions struct { + // ID of the Assignment Record. + AssignmentID *string `json:"assignment_id" validate:"required,ne="` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewDeleteAccountSettingsAssignmentOptions : Instantiate DeleteAccountSettingsAssignmentOptions +func (*IamIdentityV1) NewDeleteAccountSettingsAssignmentOptions(assignmentID string) *DeleteAccountSettingsAssignmentOptions { + return &DeleteAccountSettingsAssignmentOptions{ + AssignmentID: core.StringPtr(assignmentID), + } +} + +// SetAssignmentID : Allow user to set AssignmentID +func (_options *DeleteAccountSettingsAssignmentOptions) SetAssignmentID(assignmentID string) *DeleteAccountSettingsAssignmentOptions { + _options.AssignmentID = core.StringPtr(assignmentID) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *DeleteAccountSettingsAssignmentOptions) SetHeaders(param map[string]string) *DeleteAccountSettingsAssignmentOptions { + options.Headers = param + return options +} + +// DeleteAccountSettingsTemplateVersionOptions : The DeleteAccountSettingsTemplateVersion options. +type DeleteAccountSettingsTemplateVersionOptions struct { + // ID of the Account Settings Template. + TemplateID *string `json:"template_id" validate:"required,ne="` + + // Version of the Account Settings Template. + Version *string `json:"version" validate:"required,ne="` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewDeleteAccountSettingsTemplateVersionOptions : Instantiate DeleteAccountSettingsTemplateVersionOptions +func (*IamIdentityV1) NewDeleteAccountSettingsTemplateVersionOptions(templateID string, version string) *DeleteAccountSettingsTemplateVersionOptions { + return &DeleteAccountSettingsTemplateVersionOptions{ + TemplateID: core.StringPtr(templateID), + Version: core.StringPtr(version), + } +} + +// SetTemplateID : Allow user to set TemplateID +func (_options *DeleteAccountSettingsTemplateVersionOptions) SetTemplateID(templateID string) *DeleteAccountSettingsTemplateVersionOptions { + _options.TemplateID = core.StringPtr(templateID) + return _options +} + +// SetVersion : Allow user to set Version +func (_options *DeleteAccountSettingsTemplateVersionOptions) SetVersion(version string) *DeleteAccountSettingsTemplateVersionOptions { + _options.Version = core.StringPtr(version) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *DeleteAccountSettingsTemplateVersionOptions) SetHeaders(param map[string]string) *DeleteAccountSettingsTemplateVersionOptions { + options.Headers = param + return options +} + +// DeleteAllVersionsOfAccountSettingsTemplateOptions : The DeleteAllVersionsOfAccountSettingsTemplate options. +type DeleteAllVersionsOfAccountSettingsTemplateOptions struct { + // ID of the Account Settings Template. + TemplateID *string `json:"template_id" validate:"required,ne="` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewDeleteAllVersionsOfAccountSettingsTemplateOptions : Instantiate DeleteAllVersionsOfAccountSettingsTemplateOptions +func (*IamIdentityV1) NewDeleteAllVersionsOfAccountSettingsTemplateOptions(templateID string) *DeleteAllVersionsOfAccountSettingsTemplateOptions { + return &DeleteAllVersionsOfAccountSettingsTemplateOptions{ + TemplateID: core.StringPtr(templateID), + } +} + +// SetTemplateID : Allow user to set TemplateID +func (_options *DeleteAllVersionsOfAccountSettingsTemplateOptions) SetTemplateID(templateID string) *DeleteAllVersionsOfAccountSettingsTemplateOptions { + _options.TemplateID = core.StringPtr(templateID) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *DeleteAllVersionsOfAccountSettingsTemplateOptions) SetHeaders(param map[string]string) *DeleteAllVersionsOfAccountSettingsTemplateOptions { + options.Headers = param + return options +} + +// DeleteAllVersionsOfProfileTemplateOptions : The DeleteAllVersionsOfProfileTemplate options. +type DeleteAllVersionsOfProfileTemplateOptions struct { + // ID of the Profile Template. + TemplateID *string `json:"template_id" validate:"required,ne="` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewDeleteAllVersionsOfProfileTemplateOptions : Instantiate DeleteAllVersionsOfProfileTemplateOptions +func (*IamIdentityV1) NewDeleteAllVersionsOfProfileTemplateOptions(templateID string) *DeleteAllVersionsOfProfileTemplateOptions { + return &DeleteAllVersionsOfProfileTemplateOptions{ + TemplateID: core.StringPtr(templateID), + } +} + +// SetTemplateID : Allow user to set TemplateID +func (_options *DeleteAllVersionsOfProfileTemplateOptions) SetTemplateID(templateID string) *DeleteAllVersionsOfProfileTemplateOptions { + _options.TemplateID = core.StringPtr(templateID) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *DeleteAllVersionsOfProfileTemplateOptions) SetHeaders(param map[string]string) *DeleteAllVersionsOfProfileTemplateOptions { + options.Headers = param + return options +} + +// DeleteAPIKeyOptions : The DeleteAPIKey options. +type DeleteAPIKeyOptions struct { + // Unique ID of the API key. + ID *string `json:"id" validate:"required,ne="` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewDeleteAPIKeyOptions : Instantiate DeleteAPIKeyOptions +func (*IamIdentityV1) NewDeleteAPIKeyOptions(id string) *DeleteAPIKeyOptions { + return &DeleteAPIKeyOptions{ + ID: core.StringPtr(id), + } +} + +// SetID : Allow user to set ID +func (_options *DeleteAPIKeyOptions) SetID(id string) *DeleteAPIKeyOptions { + _options.ID = core.StringPtr(id) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *DeleteAPIKeyOptions) SetHeaders(param map[string]string) *DeleteAPIKeyOptions { + options.Headers = param + return options +} + +// DeleteClaimRuleOptions : The DeleteClaimRule options. +type DeleteClaimRuleOptions struct { + // ID of the trusted profile. + ProfileID *string `json:"profile-id" validate:"required,ne="` + + // ID of the claim rule to delete. + RuleID *string `json:"rule-id" validate:"required,ne="` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewDeleteClaimRuleOptions : Instantiate DeleteClaimRuleOptions +func (*IamIdentityV1) NewDeleteClaimRuleOptions(profileID string, ruleID string) *DeleteClaimRuleOptions { + return &DeleteClaimRuleOptions{ + ProfileID: core.StringPtr(profileID), + RuleID: core.StringPtr(ruleID), + } +} + +// SetProfileID : Allow user to set ProfileID +func (_options *DeleteClaimRuleOptions) SetProfileID(profileID string) *DeleteClaimRuleOptions { + _options.ProfileID = core.StringPtr(profileID) + return _options +} + +// SetRuleID : Allow user to set RuleID +func (_options *DeleteClaimRuleOptions) SetRuleID(ruleID string) *DeleteClaimRuleOptions { + _options.RuleID = core.StringPtr(ruleID) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *DeleteClaimRuleOptions) SetHeaders(param map[string]string) *DeleteClaimRuleOptions { + options.Headers = param + return options +} + +// DeleteLinkOptions : The DeleteLink options. +type DeleteLinkOptions struct { + // ID of the trusted profile. + ProfileID *string `json:"profile-id" validate:"required,ne="` + + // ID of the link. + LinkID *string `json:"link-id" validate:"required,ne="` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewDeleteLinkOptions : Instantiate DeleteLinkOptions +func (*IamIdentityV1) NewDeleteLinkOptions(profileID string, linkID string) *DeleteLinkOptions { + return &DeleteLinkOptions{ + ProfileID: core.StringPtr(profileID), + LinkID: core.StringPtr(linkID), + } +} + +// SetProfileID : Allow user to set ProfileID +func (_options *DeleteLinkOptions) SetProfileID(profileID string) *DeleteLinkOptions { + _options.ProfileID = core.StringPtr(profileID) + return _options +} + +// SetLinkID : Allow user to set LinkID +func (_options *DeleteLinkOptions) SetLinkID(linkID string) *DeleteLinkOptions { + _options.LinkID = core.StringPtr(linkID) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *DeleteLinkOptions) SetHeaders(param map[string]string) *DeleteLinkOptions { + options.Headers = param + return options +} + +// DeleteProfileIdentityOptions : The DeleteProfileIdentity options. +type DeleteProfileIdentityOptions struct { + // ID of the trusted profile. + ProfileID *string `json:"profile-id" validate:"required,ne="` + + // Type of the identity. + IdentityType *string `json:"identity-type" validate:"required,ne="` + + // Identifier of the identity that can assume the trusted profiles. + IdentifierID *string `json:"identifier-id" validate:"required,ne="` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// Constants associated with the DeleteProfileIdentityOptions.IdentityType property. +// Type of the identity. +const ( + DeleteProfileIdentityOptionsIdentityTypeCRNConst = "crn" + DeleteProfileIdentityOptionsIdentityTypeServiceidConst = "serviceid" + DeleteProfileIdentityOptionsIdentityTypeUserConst = "user" +) + +// NewDeleteProfileIdentityOptions : Instantiate DeleteProfileIdentityOptions +func (*IamIdentityV1) NewDeleteProfileIdentityOptions(profileID string, identityType string, identifierID string) *DeleteProfileIdentityOptions { + return &DeleteProfileIdentityOptions{ + ProfileID: core.StringPtr(profileID), + IdentityType: core.StringPtr(identityType), + IdentifierID: core.StringPtr(identifierID), + } +} + +// SetProfileID : Allow user to set ProfileID +func (_options *DeleteProfileIdentityOptions) SetProfileID(profileID string) *DeleteProfileIdentityOptions { + _options.ProfileID = core.StringPtr(profileID) + return _options +} + +// SetIdentityType : Allow user to set IdentityType +func (_options *DeleteProfileIdentityOptions) SetIdentityType(identityType string) *DeleteProfileIdentityOptions { + _options.IdentityType = core.StringPtr(identityType) + return _options +} + +// SetIdentifierID : Allow user to set IdentifierID +func (_options *DeleteProfileIdentityOptions) SetIdentifierID(identifierID string) *DeleteProfileIdentityOptions { + _options.IdentifierID = core.StringPtr(identifierID) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *DeleteProfileIdentityOptions) SetHeaders(param map[string]string) *DeleteProfileIdentityOptions { + options.Headers = param + return options +} + +// DeleteProfileOptions : The DeleteProfile options. +type DeleteProfileOptions struct { + // ID of the trusted profile. + ProfileID *string `json:"profile-id" validate:"required,ne="` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewDeleteProfileOptions : Instantiate DeleteProfileOptions +func (*IamIdentityV1) NewDeleteProfileOptions(profileID string) *DeleteProfileOptions { + return &DeleteProfileOptions{ + ProfileID: core.StringPtr(profileID), + } +} + +// SetProfileID : Allow user to set ProfileID +func (_options *DeleteProfileOptions) SetProfileID(profileID string) *DeleteProfileOptions { + _options.ProfileID = core.StringPtr(profileID) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *DeleteProfileOptions) SetHeaders(param map[string]string) *DeleteProfileOptions { + options.Headers = param + return options +} + +// DeleteProfileTemplateVersionOptions : The DeleteProfileTemplateVersion options. +type DeleteProfileTemplateVersionOptions struct { + // ID of the Profile Template. + TemplateID *string `json:"template_id" validate:"required,ne="` + + // Version of the Profile Template. + Version *string `json:"version" validate:"required,ne="` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewDeleteProfileTemplateVersionOptions : Instantiate DeleteProfileTemplateVersionOptions +func (*IamIdentityV1) NewDeleteProfileTemplateVersionOptions(templateID string, version string) *DeleteProfileTemplateVersionOptions { + return &DeleteProfileTemplateVersionOptions{ + TemplateID: core.StringPtr(templateID), + Version: core.StringPtr(version), + } +} + +// SetTemplateID : Allow user to set TemplateID +func (_options *DeleteProfileTemplateVersionOptions) SetTemplateID(templateID string) *DeleteProfileTemplateVersionOptions { + _options.TemplateID = core.StringPtr(templateID) + return _options +} + +// SetVersion : Allow user to set Version +func (_options *DeleteProfileTemplateVersionOptions) SetVersion(version string) *DeleteProfileTemplateVersionOptions { + _options.Version = core.StringPtr(version) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *DeleteProfileTemplateVersionOptions) SetHeaders(param map[string]string) *DeleteProfileTemplateVersionOptions { + options.Headers = param + return options +} + +// DeleteServiceIDOptions : The DeleteServiceID options. +type DeleteServiceIDOptions struct { + // Unique ID of the service ID. + ID *string `json:"id" validate:"required,ne="` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewDeleteServiceIDOptions : Instantiate DeleteServiceIDOptions +func (*IamIdentityV1) NewDeleteServiceIDOptions(id string) *DeleteServiceIDOptions { + return &DeleteServiceIDOptions{ + ID: core.StringPtr(id), + } +} + +// SetID : Allow user to set ID +func (_options *DeleteServiceIDOptions) SetID(id string) *DeleteServiceIDOptions { + _options.ID = core.StringPtr(id) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *DeleteServiceIDOptions) SetHeaders(param map[string]string) *DeleteServiceIDOptions { + options.Headers = param + return options +} + +// DeleteTrustedProfileAssignmentOptions : The DeleteTrustedProfileAssignment options. +type DeleteTrustedProfileAssignmentOptions struct { + // ID of the Assignment Record. + AssignmentID *string `json:"assignment_id" validate:"required,ne="` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewDeleteTrustedProfileAssignmentOptions : Instantiate DeleteTrustedProfileAssignmentOptions +func (*IamIdentityV1) NewDeleteTrustedProfileAssignmentOptions(assignmentID string) *DeleteTrustedProfileAssignmentOptions { + return &DeleteTrustedProfileAssignmentOptions{ + AssignmentID: core.StringPtr(assignmentID), + } +} + +// SetAssignmentID : Allow user to set AssignmentID +func (_options *DeleteTrustedProfileAssignmentOptions) SetAssignmentID(assignmentID string) *DeleteTrustedProfileAssignmentOptions { + _options.AssignmentID = core.StringPtr(assignmentID) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *DeleteTrustedProfileAssignmentOptions) SetHeaders(param map[string]string) *DeleteTrustedProfileAssignmentOptions { + options.Headers = param + return options +} + +// EnityHistoryRecord : Response body format for an entity history record. +type EnityHistoryRecord struct { + // Timestamp when the action was triggered. + Timestamp *string `json:"timestamp" validate:"required"` + + // IAM ID of the identity which triggered the action. + IamID *string `json:"iam_id" validate:"required"` + + // Account of the identity which triggered the action. + IamIDAccount *string `json:"iam_id_account" validate:"required"` + + // Action of the history entry. + Action *string `json:"action" validate:"required"` + + // Params of the history entry. + Params []string `json:"params" validate:"required"` + + // Message which summarizes the executed action. + Message *string `json:"message" validate:"required"` +} + +// UnmarshalEnityHistoryRecord unmarshals an instance of EnityHistoryRecord from the specified map of raw messages. +func UnmarshalEnityHistoryRecord(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(EnityHistoryRecord) + err = core.UnmarshalPrimitive(m, "timestamp", &obj.Timestamp) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "iam_id", &obj.IamID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "iam_id_account", &obj.IamIDAccount) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "action", &obj.Action) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "params", &obj.Params) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "message", &obj.Message) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// EntityActivity : EntityActivity struct +type EntityActivity struct { + // Unique id of the entity. + ID *string `json:"id" validate:"required"` + + // Name provided during creation of the entity. + Name *string `json:"name,omitempty"` + + // Time when the entity was last authenticated. + LastAuthn *string `json:"last_authn,omitempty"` +} + +// UnmarshalEntityActivity unmarshals an instance of EntityActivity from the specified map of raw messages. +func UnmarshalEntityActivity(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(EntityActivity) + err = core.UnmarshalPrimitive(m, "id", &obj.ID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "name", &obj.Name) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "last_authn", &obj.LastAuthn) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// Error : Error information. +type Error struct { + // Error code of the REST Exception. + Code *string `json:"code" validate:"required"` + + // Error message code of the REST Exception. + MessageCode *string `json:"message_code" validate:"required"` + + // Error message of the REST Exception. Error messages are derived base on the input locale of the REST request and the + // available Message catalogs. Dynamic fallback to 'us-english' is happening if no message catalog is available for the + // provided input locale. + Message *string `json:"message" validate:"required"` + + // Error details of the REST Exception. + Details *string `json:"details,omitempty"` +} + +// UnmarshalError unmarshals an instance of Error from the specified map of raw messages. +func UnmarshalError(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(Error) + err = core.UnmarshalPrimitive(m, "code", &obj.Code) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "message_code", &obj.MessageCode) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "message", &obj.Message) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "details", &obj.Details) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// ExceptionResponse : Response body parameters in case of error situations. +type ExceptionResponse struct { + // Context with key properties for problem determination. + Context *ResponseContext `json:"context,omitempty"` + + // Error message code of the REST Exception. + StatusCode *string `json:"status_code" validate:"required"` + + // List of errors that occured. + Errors []Error `json:"errors" validate:"required"` + + // Unique ID of the requst. + Trace *string `json:"trace,omitempty"` +} + +// UnmarshalExceptionResponse unmarshals an instance of ExceptionResponse from the specified map of raw messages. +func UnmarshalExceptionResponse(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(ExceptionResponse) + err = core.UnmarshalModel(m, "context", &obj.Context, UnmarshalResponseContext) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "status_code", &obj.StatusCode) + if err != nil { + return + } + err = core.UnmarshalModel(m, "errors", &obj.Errors, UnmarshalError) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "trace", &obj.Trace) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// GetAccountSettingsAssignmentOptions : The GetAccountSettingsAssignment options. +type GetAccountSettingsAssignmentOptions struct { + // ID of the Assignment Record. + AssignmentID *string `json:"assignment_id" validate:"required,ne="` + + // Defines if the entity history is included in the response. + IncludeHistory *bool `json:"include_history,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewGetAccountSettingsAssignmentOptions : Instantiate GetAccountSettingsAssignmentOptions +func (*IamIdentityV1) NewGetAccountSettingsAssignmentOptions(assignmentID string) *GetAccountSettingsAssignmentOptions { + return &GetAccountSettingsAssignmentOptions{ + AssignmentID: core.StringPtr(assignmentID), + } +} + +// SetAssignmentID : Allow user to set AssignmentID +func (_options *GetAccountSettingsAssignmentOptions) SetAssignmentID(assignmentID string) *GetAccountSettingsAssignmentOptions { + _options.AssignmentID = core.StringPtr(assignmentID) + return _options +} + +// SetIncludeHistory : Allow user to set IncludeHistory +func (_options *GetAccountSettingsAssignmentOptions) SetIncludeHistory(includeHistory bool) *GetAccountSettingsAssignmentOptions { + _options.IncludeHistory = core.BoolPtr(includeHistory) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *GetAccountSettingsAssignmentOptions) SetHeaders(param map[string]string) *GetAccountSettingsAssignmentOptions { + options.Headers = param + return options +} + +// GetAccountSettingsOptions : The GetAccountSettings options. +type GetAccountSettingsOptions struct { + // Unique ID of the account. + AccountID *string `json:"account_id" validate:"required,ne="` + + // Defines if the entity history is included in the response. + IncludeHistory *bool `json:"include_history,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewGetAccountSettingsOptions : Instantiate GetAccountSettingsOptions +func (*IamIdentityV1) NewGetAccountSettingsOptions(accountID string) *GetAccountSettingsOptions { + return &GetAccountSettingsOptions{ + AccountID: core.StringPtr(accountID), + } +} + +// SetAccountID : Allow user to set AccountID +func (_options *GetAccountSettingsOptions) SetAccountID(accountID string) *GetAccountSettingsOptions { + _options.AccountID = core.StringPtr(accountID) + return _options +} + +// SetIncludeHistory : Allow user to set IncludeHistory +func (_options *GetAccountSettingsOptions) SetIncludeHistory(includeHistory bool) *GetAccountSettingsOptions { + _options.IncludeHistory = core.BoolPtr(includeHistory) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *GetAccountSettingsOptions) SetHeaders(param map[string]string) *GetAccountSettingsOptions { + options.Headers = param + return options +} + +// GetAccountSettingsTemplateVersionOptions : The GetAccountSettingsTemplateVersion options. +type GetAccountSettingsTemplateVersionOptions struct { + // ID of the Account Settings Template. + TemplateID *string `json:"template_id" validate:"required,ne="` + + // Version of the Account Settings Template. + Version *string `json:"version" validate:"required,ne="` + + // Defines if the entity history is included in the response. + IncludeHistory *bool `json:"include_history,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewGetAccountSettingsTemplateVersionOptions : Instantiate GetAccountSettingsTemplateVersionOptions +func (*IamIdentityV1) NewGetAccountSettingsTemplateVersionOptions(templateID string, version string) *GetAccountSettingsTemplateVersionOptions { + return &GetAccountSettingsTemplateVersionOptions{ + TemplateID: core.StringPtr(templateID), + Version: core.StringPtr(version), + } +} + +// SetTemplateID : Allow user to set TemplateID +func (_options *GetAccountSettingsTemplateVersionOptions) SetTemplateID(templateID string) *GetAccountSettingsTemplateVersionOptions { + _options.TemplateID = core.StringPtr(templateID) + return _options +} + +// SetVersion : Allow user to set Version +func (_options *GetAccountSettingsTemplateVersionOptions) SetVersion(version string) *GetAccountSettingsTemplateVersionOptions { + _options.Version = core.StringPtr(version) + return _options +} + +// SetIncludeHistory : Allow user to set IncludeHistory +func (_options *GetAccountSettingsTemplateVersionOptions) SetIncludeHistory(includeHistory bool) *GetAccountSettingsTemplateVersionOptions { + _options.IncludeHistory = core.BoolPtr(includeHistory) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *GetAccountSettingsTemplateVersionOptions) SetHeaders(param map[string]string) *GetAccountSettingsTemplateVersionOptions { + options.Headers = param + return options +} + +// GetAPIKeyOptions : The GetAPIKey options. +type GetAPIKeyOptions struct { + // Unique ID of the API key. + ID *string `json:"id" validate:"required,ne="` + + // Defines if the entity history is included in the response. + IncludeHistory *bool `json:"include_history,omitempty"` + + // Defines if the entity's activity is included in the response. Retrieving activity data is an expensive operation, so + // please only request this when needed. + IncludeActivity *bool `json:"include_activity,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewGetAPIKeyOptions : Instantiate GetAPIKeyOptions +func (*IamIdentityV1) NewGetAPIKeyOptions(id string) *GetAPIKeyOptions { + return &GetAPIKeyOptions{ + ID: core.StringPtr(id), + } +} + +// SetID : Allow user to set ID +func (_options *GetAPIKeyOptions) SetID(id string) *GetAPIKeyOptions { + _options.ID = core.StringPtr(id) + return _options +} + +// SetIncludeHistory : Allow user to set IncludeHistory +func (_options *GetAPIKeyOptions) SetIncludeHistory(includeHistory bool) *GetAPIKeyOptions { + _options.IncludeHistory = core.BoolPtr(includeHistory) + return _options +} + +// SetIncludeActivity : Allow user to set IncludeActivity +func (_options *GetAPIKeyOptions) SetIncludeActivity(includeActivity bool) *GetAPIKeyOptions { + _options.IncludeActivity = core.BoolPtr(includeActivity) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *GetAPIKeyOptions) SetHeaders(param map[string]string) *GetAPIKeyOptions { + options.Headers = param + return options +} + +// GetAPIKeysDetailsOptions : The GetAPIKeysDetails options. +type GetAPIKeysDetailsOptions struct { + // API key value. + IamAPIKey *string `json:"IAM-ApiKey,omitempty"` + + // Defines if the entity history is included in the response. + IncludeHistory *bool `json:"include_history,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewGetAPIKeysDetailsOptions : Instantiate GetAPIKeysDetailsOptions +func (*IamIdentityV1) NewGetAPIKeysDetailsOptions() *GetAPIKeysDetailsOptions { + return &GetAPIKeysDetailsOptions{} +} + +// SetIamAPIKey : Allow user to set IamAPIKey +func (_options *GetAPIKeysDetailsOptions) SetIamAPIKey(iamAPIKey string) *GetAPIKeysDetailsOptions { + _options.IamAPIKey = core.StringPtr(iamAPIKey) + return _options +} + +// SetIncludeHistory : Allow user to set IncludeHistory +func (_options *GetAPIKeysDetailsOptions) SetIncludeHistory(includeHistory bool) *GetAPIKeysDetailsOptions { + _options.IncludeHistory = core.BoolPtr(includeHistory) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *GetAPIKeysDetailsOptions) SetHeaders(param map[string]string) *GetAPIKeysDetailsOptions { + options.Headers = param + return options +} + +// GetClaimRuleOptions : The GetClaimRule options. +type GetClaimRuleOptions struct { + // ID of the trusted profile. + ProfileID *string `json:"profile-id" validate:"required,ne="` + + // ID of the claim rule to get. + RuleID *string `json:"rule-id" validate:"required,ne="` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewGetClaimRuleOptions : Instantiate GetClaimRuleOptions +func (*IamIdentityV1) NewGetClaimRuleOptions(profileID string, ruleID string) *GetClaimRuleOptions { + return &GetClaimRuleOptions{ + ProfileID: core.StringPtr(profileID), + RuleID: core.StringPtr(ruleID), + } +} + +// SetProfileID : Allow user to set ProfileID +func (_options *GetClaimRuleOptions) SetProfileID(profileID string) *GetClaimRuleOptions { + _options.ProfileID = core.StringPtr(profileID) + return _options +} + +// SetRuleID : Allow user to set RuleID +func (_options *GetClaimRuleOptions) SetRuleID(ruleID string) *GetClaimRuleOptions { + _options.RuleID = core.StringPtr(ruleID) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *GetClaimRuleOptions) SetHeaders(param map[string]string) *GetClaimRuleOptions { + options.Headers = param + return options +} + +// GetLatestAccountSettingsTemplateVersionOptions : The GetLatestAccountSettingsTemplateVersion options. +type GetLatestAccountSettingsTemplateVersionOptions struct { + // ID of the Account Settings Template. + TemplateID *string `json:"template_id" validate:"required,ne="` + + // Defines if the entity history is included in the response. + IncludeHistory *bool `json:"include_history,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewGetLatestAccountSettingsTemplateVersionOptions : Instantiate GetLatestAccountSettingsTemplateVersionOptions +func (*IamIdentityV1) NewGetLatestAccountSettingsTemplateVersionOptions(templateID string) *GetLatestAccountSettingsTemplateVersionOptions { + return &GetLatestAccountSettingsTemplateVersionOptions{ + TemplateID: core.StringPtr(templateID), + } +} + +// SetTemplateID : Allow user to set TemplateID +func (_options *GetLatestAccountSettingsTemplateVersionOptions) SetTemplateID(templateID string) *GetLatestAccountSettingsTemplateVersionOptions { + _options.TemplateID = core.StringPtr(templateID) + return _options +} + +// SetIncludeHistory : Allow user to set IncludeHistory +func (_options *GetLatestAccountSettingsTemplateVersionOptions) SetIncludeHistory(includeHistory bool) *GetLatestAccountSettingsTemplateVersionOptions { + _options.IncludeHistory = core.BoolPtr(includeHistory) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *GetLatestAccountSettingsTemplateVersionOptions) SetHeaders(param map[string]string) *GetLatestAccountSettingsTemplateVersionOptions { + options.Headers = param + return options +} + +// GetLatestProfileTemplateVersionOptions : The GetLatestProfileTemplateVersion options. +type GetLatestProfileTemplateVersionOptions struct { + // ID of the Profile Template. + TemplateID *string `json:"template_id" validate:"required,ne="` + + // Defines if the entity history is included in the response. + IncludeHistory *bool `json:"include_history,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewGetLatestProfileTemplateVersionOptions : Instantiate GetLatestProfileTemplateVersionOptions +func (*IamIdentityV1) NewGetLatestProfileTemplateVersionOptions(templateID string) *GetLatestProfileTemplateVersionOptions { + return &GetLatestProfileTemplateVersionOptions{ + TemplateID: core.StringPtr(templateID), + } +} + +// SetTemplateID : Allow user to set TemplateID +func (_options *GetLatestProfileTemplateVersionOptions) SetTemplateID(templateID string) *GetLatestProfileTemplateVersionOptions { + _options.TemplateID = core.StringPtr(templateID) + return _options +} + +// SetIncludeHistory : Allow user to set IncludeHistory +func (_options *GetLatestProfileTemplateVersionOptions) SetIncludeHistory(includeHistory bool) *GetLatestProfileTemplateVersionOptions { + _options.IncludeHistory = core.BoolPtr(includeHistory) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *GetLatestProfileTemplateVersionOptions) SetHeaders(param map[string]string) *GetLatestProfileTemplateVersionOptions { + options.Headers = param + return options +} + +// GetLinkOptions : The GetLink options. +type GetLinkOptions struct { + // ID of the trusted profile. + ProfileID *string `json:"profile-id" validate:"required,ne="` + + // ID of the link. + LinkID *string `json:"link-id" validate:"required,ne="` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewGetLinkOptions : Instantiate GetLinkOptions +func (*IamIdentityV1) NewGetLinkOptions(profileID string, linkID string) *GetLinkOptions { + return &GetLinkOptions{ + ProfileID: core.StringPtr(profileID), + LinkID: core.StringPtr(linkID), + } +} + +// SetProfileID : Allow user to set ProfileID +func (_options *GetLinkOptions) SetProfileID(profileID string) *GetLinkOptions { + _options.ProfileID = core.StringPtr(profileID) + return _options +} + +// SetLinkID : Allow user to set LinkID +func (_options *GetLinkOptions) SetLinkID(linkID string) *GetLinkOptions { + _options.LinkID = core.StringPtr(linkID) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *GetLinkOptions) SetHeaders(param map[string]string) *GetLinkOptions { + options.Headers = param + return options +} + +// GetMfaReportOptions : The GetMfaReport options. +type GetMfaReportOptions struct { + // ID of the account. + AccountID *string `json:"account_id" validate:"required,ne="` + + // Reference for the report to be generated, You can use 'latest' to get the latest report for the given account. + Reference *string `json:"reference" validate:"required,ne="` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewGetMfaReportOptions : Instantiate GetMfaReportOptions +func (*IamIdentityV1) NewGetMfaReportOptions(accountID string, reference string) *GetMfaReportOptions { + return &GetMfaReportOptions{ + AccountID: core.StringPtr(accountID), + Reference: core.StringPtr(reference), + } +} + +// SetAccountID : Allow user to set AccountID +func (_options *GetMfaReportOptions) SetAccountID(accountID string) *GetMfaReportOptions { + _options.AccountID = core.StringPtr(accountID) + return _options +} + +// SetReference : Allow user to set Reference +func (_options *GetMfaReportOptions) SetReference(reference string) *GetMfaReportOptions { + _options.Reference = core.StringPtr(reference) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *GetMfaReportOptions) SetHeaders(param map[string]string) *GetMfaReportOptions { + options.Headers = param + return options +} + +// GetMfaStatusOptions : The GetMfaStatus options. +type GetMfaStatusOptions struct { + // ID of the account. + AccountID *string `json:"account_id" validate:"required,ne="` + + // iam_id of the user. This user must be the member of the account. + IamID *string `json:"iam_id" validate:"required"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewGetMfaStatusOptions : Instantiate GetMfaStatusOptions +func (*IamIdentityV1) NewGetMfaStatusOptions(accountID string, iamID string) *GetMfaStatusOptions { + return &GetMfaStatusOptions{ + AccountID: core.StringPtr(accountID), + IamID: core.StringPtr(iamID), + } +} + +// SetAccountID : Allow user to set AccountID +func (_options *GetMfaStatusOptions) SetAccountID(accountID string) *GetMfaStatusOptions { + _options.AccountID = core.StringPtr(accountID) + return _options +} + +// SetIamID : Allow user to set IamID +func (_options *GetMfaStatusOptions) SetIamID(iamID string) *GetMfaStatusOptions { + _options.IamID = core.StringPtr(iamID) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *GetMfaStatusOptions) SetHeaders(param map[string]string) *GetMfaStatusOptions { + options.Headers = param + return options +} + +// GetProfileIdentitiesOptions : The GetProfileIdentities options. +type GetProfileIdentitiesOptions struct { + // ID of the trusted profile. + ProfileID *string `json:"profile-id" validate:"required,ne="` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewGetProfileIdentitiesOptions : Instantiate GetProfileIdentitiesOptions +func (*IamIdentityV1) NewGetProfileIdentitiesOptions(profileID string) *GetProfileIdentitiesOptions { + return &GetProfileIdentitiesOptions{ + ProfileID: core.StringPtr(profileID), + } +} + +// SetProfileID : Allow user to set ProfileID +func (_options *GetProfileIdentitiesOptions) SetProfileID(profileID string) *GetProfileIdentitiesOptions { + _options.ProfileID = core.StringPtr(profileID) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *GetProfileIdentitiesOptions) SetHeaders(param map[string]string) *GetProfileIdentitiesOptions { + options.Headers = param + return options +} + +// GetProfileIdentityOptions : The GetProfileIdentity options. +type GetProfileIdentityOptions struct { + // ID of the trusted profile. + ProfileID *string `json:"profile-id" validate:"required,ne="` + + // Type of the identity. + IdentityType *string `json:"identity-type" validate:"required,ne="` + + // Identifier of the identity that can assume the trusted profiles. + IdentifierID *string `json:"identifier-id" validate:"required,ne="` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// Constants associated with the GetProfileIdentityOptions.IdentityType property. +// Type of the identity. +const ( + GetProfileIdentityOptionsIdentityTypeCRNConst = "crn" + GetProfileIdentityOptionsIdentityTypeServiceidConst = "serviceid" + GetProfileIdentityOptionsIdentityTypeUserConst = "user" +) + +// NewGetProfileIdentityOptions : Instantiate GetProfileIdentityOptions +func (*IamIdentityV1) NewGetProfileIdentityOptions(profileID string, identityType string, identifierID string) *GetProfileIdentityOptions { + return &GetProfileIdentityOptions{ + ProfileID: core.StringPtr(profileID), + IdentityType: core.StringPtr(identityType), + IdentifierID: core.StringPtr(identifierID), + } +} + +// SetProfileID : Allow user to set ProfileID +func (_options *GetProfileIdentityOptions) SetProfileID(profileID string) *GetProfileIdentityOptions { + _options.ProfileID = core.StringPtr(profileID) + return _options +} + +// SetIdentityType : Allow user to set IdentityType +func (_options *GetProfileIdentityOptions) SetIdentityType(identityType string) *GetProfileIdentityOptions { + _options.IdentityType = core.StringPtr(identityType) + return _options +} + +// SetIdentifierID : Allow user to set IdentifierID +func (_options *GetProfileIdentityOptions) SetIdentifierID(identifierID string) *GetProfileIdentityOptions { + _options.IdentifierID = core.StringPtr(identifierID) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *GetProfileIdentityOptions) SetHeaders(param map[string]string) *GetProfileIdentityOptions { + options.Headers = param + return options +} + +// GetProfileOptions : The GetProfile options. +type GetProfileOptions struct { + // ID of the trusted profile to get. + ProfileID *string `json:"profile-id" validate:"required,ne="` + + // Defines if the entity's activity is included in the response. Retrieving activity data is an expensive operation, so + // please only request this when needed. + IncludeActivity *bool `json:"include_activity,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewGetProfileOptions : Instantiate GetProfileOptions +func (*IamIdentityV1) NewGetProfileOptions(profileID string) *GetProfileOptions { + return &GetProfileOptions{ + ProfileID: core.StringPtr(profileID), + } +} + +// SetProfileID : Allow user to set ProfileID +func (_options *GetProfileOptions) SetProfileID(profileID string) *GetProfileOptions { + _options.ProfileID = core.StringPtr(profileID) + return _options +} + +// SetIncludeActivity : Allow user to set IncludeActivity +func (_options *GetProfileOptions) SetIncludeActivity(includeActivity bool) *GetProfileOptions { + _options.IncludeActivity = core.BoolPtr(includeActivity) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *GetProfileOptions) SetHeaders(param map[string]string) *GetProfileOptions { + options.Headers = param + return options +} + +// GetProfileTemplateVersionOptions : The GetProfileTemplateVersion options. +type GetProfileTemplateVersionOptions struct { + // ID of the Profile Template. + TemplateID *string `json:"template_id" validate:"required,ne="` + + // Version of the Profile Template. + Version *string `json:"version" validate:"required,ne="` + + // Defines if the entity history is included in the response. + IncludeHistory *bool `json:"include_history,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewGetProfileTemplateVersionOptions : Instantiate GetProfileTemplateVersionOptions +func (*IamIdentityV1) NewGetProfileTemplateVersionOptions(templateID string, version string) *GetProfileTemplateVersionOptions { + return &GetProfileTemplateVersionOptions{ + TemplateID: core.StringPtr(templateID), + Version: core.StringPtr(version), + } +} + +// SetTemplateID : Allow user to set TemplateID +func (_options *GetProfileTemplateVersionOptions) SetTemplateID(templateID string) *GetProfileTemplateVersionOptions { + _options.TemplateID = core.StringPtr(templateID) + return _options +} + +// SetVersion : Allow user to set Version +func (_options *GetProfileTemplateVersionOptions) SetVersion(version string) *GetProfileTemplateVersionOptions { + _options.Version = core.StringPtr(version) + return _options +} + +// SetIncludeHistory : Allow user to set IncludeHistory +func (_options *GetProfileTemplateVersionOptions) SetIncludeHistory(includeHistory bool) *GetProfileTemplateVersionOptions { + _options.IncludeHistory = core.BoolPtr(includeHistory) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *GetProfileTemplateVersionOptions) SetHeaders(param map[string]string) *GetProfileTemplateVersionOptions { + options.Headers = param + return options +} + +// GetReportOptions : The GetReport options. +type GetReportOptions struct { + // ID of the account. + AccountID *string `json:"account_id" validate:"required,ne="` + + // Reference for the report to be generated, You can use 'latest' to get the latest report for the given account. + Reference *string `json:"reference" validate:"required,ne="` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewGetReportOptions : Instantiate GetReportOptions +func (*IamIdentityV1) NewGetReportOptions(accountID string, reference string) *GetReportOptions { + return &GetReportOptions{ + AccountID: core.StringPtr(accountID), + Reference: core.StringPtr(reference), + } +} + +// SetAccountID : Allow user to set AccountID +func (_options *GetReportOptions) SetAccountID(accountID string) *GetReportOptions { + _options.AccountID = core.StringPtr(accountID) + return _options +} + +// SetReference : Allow user to set Reference +func (_options *GetReportOptions) SetReference(reference string) *GetReportOptions { + _options.Reference = core.StringPtr(reference) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *GetReportOptions) SetHeaders(param map[string]string) *GetReportOptions { + options.Headers = param + return options +} + +// GetServiceIDOptions : The GetServiceID options. +type GetServiceIDOptions struct { + // Unique ID of the service ID. + ID *string `json:"id" validate:"required,ne="` + + // Defines if the entity history is included in the response. + IncludeHistory *bool `json:"include_history,omitempty"` + + // Defines if the entity's activity is included in the response. Retrieving activity data is an expensive operation, so + // please only request this when needed. + IncludeActivity *bool `json:"include_activity,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewGetServiceIDOptions : Instantiate GetServiceIDOptions +func (*IamIdentityV1) NewGetServiceIDOptions(id string) *GetServiceIDOptions { + return &GetServiceIDOptions{ + ID: core.StringPtr(id), + } +} + +// SetID : Allow user to set ID +func (_options *GetServiceIDOptions) SetID(id string) *GetServiceIDOptions { + _options.ID = core.StringPtr(id) + return _options +} + +// SetIncludeHistory : Allow user to set IncludeHistory +func (_options *GetServiceIDOptions) SetIncludeHistory(includeHistory bool) *GetServiceIDOptions { + _options.IncludeHistory = core.BoolPtr(includeHistory) + return _options +} + +// SetIncludeActivity : Allow user to set IncludeActivity +func (_options *GetServiceIDOptions) SetIncludeActivity(includeActivity bool) *GetServiceIDOptions { + _options.IncludeActivity = core.BoolPtr(includeActivity) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *GetServiceIDOptions) SetHeaders(param map[string]string) *GetServiceIDOptions { + options.Headers = param + return options +} + +// GetTrustedProfileAssignmentOptions : The GetTrustedProfileAssignment options. +type GetTrustedProfileAssignmentOptions struct { + // ID of the Assignment Record. + AssignmentID *string `json:"assignment_id" validate:"required,ne="` + + // Defines if the entity history is included in the response. + IncludeHistory *bool `json:"include_history,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewGetTrustedProfileAssignmentOptions : Instantiate GetTrustedProfileAssignmentOptions +func (*IamIdentityV1) NewGetTrustedProfileAssignmentOptions(assignmentID string) *GetTrustedProfileAssignmentOptions { + return &GetTrustedProfileAssignmentOptions{ + AssignmentID: core.StringPtr(assignmentID), + } +} + +// SetAssignmentID : Allow user to set AssignmentID +func (_options *GetTrustedProfileAssignmentOptions) SetAssignmentID(assignmentID string) *GetTrustedProfileAssignmentOptions { + _options.AssignmentID = core.StringPtr(assignmentID) + return _options +} + +// SetIncludeHistory : Allow user to set IncludeHistory +func (_options *GetTrustedProfileAssignmentOptions) SetIncludeHistory(includeHistory bool) *GetTrustedProfileAssignmentOptions { + _options.IncludeHistory = core.BoolPtr(includeHistory) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *GetTrustedProfileAssignmentOptions) SetHeaders(param map[string]string) *GetTrustedProfileAssignmentOptions { + options.Headers = param + return options +} + +// IDBasedMfaEnrollment : IDBasedMfaEnrollment struct +type IDBasedMfaEnrollment struct { + // Defines the MFA trait for the account. Valid values: + // * NONE - No MFA trait set + // * NONE_NO_ROPC- No MFA, disable CLI logins with only a password + // * TOTP - For all non-federated IBMId users + // * TOTP4ALL - For all users + // * LEVEL1 - Email-based MFA for all users + // * LEVEL2 - TOTP-based MFA for all users + // * LEVEL3 - U2F MFA for all users. + TraitAccountDefault *string `json:"trait_account_default" validate:"required"` + + // Defines the MFA trait for the account. Valid values: + // * NONE - No MFA trait set + // * NONE_NO_ROPC- No MFA, disable CLI logins with only a password + // * TOTP - For all non-federated IBMId users + // * TOTP4ALL - For all users + // * LEVEL1 - Email-based MFA for all users + // * LEVEL2 - TOTP-based MFA for all users + // * LEVEL3 - U2F MFA for all users. + TraitUserSpecific *string `json:"trait_user_specific,omitempty"` + + // Defines the MFA trait for the account. Valid values: + // * NONE - No MFA trait set + // * NONE_NO_ROPC- No MFA, disable CLI logins with only a password + // * TOTP - For all non-federated IBMId users + // * TOTP4ALL - For all users + // * LEVEL1 - Email-based MFA for all users + // * LEVEL2 - TOTP-based MFA for all users + // * LEVEL3 - U2F MFA for all users. + TraitEffective *string `json:"trait_effective" validate:"required"` + + // The enrollment complies to the effective requirement. + Complies *bool `json:"complies" validate:"required"` +} + +// Constants associated with the IDBasedMfaEnrollment.TraitAccountDefault property. +// Defines the MFA trait for the account. Valid values: +// * NONE - No MFA trait set +// * NONE_NO_ROPC- No MFA, disable CLI logins with only a password +// * TOTP - For all non-federated IBMId users +// * TOTP4ALL - For all users +// * LEVEL1 - Email-based MFA for all users +// * LEVEL2 - TOTP-based MFA for all users +// * LEVEL3 - U2F MFA for all users. +const ( + IDBasedMfaEnrollmentTraitAccountDefaultLevel1Const = "LEVEL1" + IDBasedMfaEnrollmentTraitAccountDefaultLevel2Const = "LEVEL2" + IDBasedMfaEnrollmentTraitAccountDefaultLevel3Const = "LEVEL3" + IDBasedMfaEnrollmentTraitAccountDefaultNoneConst = "NONE" + IDBasedMfaEnrollmentTraitAccountDefaultNoneNoRopcConst = "NONE_NO_ROPC" + IDBasedMfaEnrollmentTraitAccountDefaultTotpConst = "TOTP" + IDBasedMfaEnrollmentTraitAccountDefaultTotp4allConst = "TOTP4ALL" +) + +// Constants associated with the IDBasedMfaEnrollment.TraitUserSpecific property. +// Defines the MFA trait for the account. Valid values: +// * NONE - No MFA trait set +// * NONE_NO_ROPC- No MFA, disable CLI logins with only a password +// * TOTP - For all non-federated IBMId users +// * TOTP4ALL - For all users +// * LEVEL1 - Email-based MFA for all users +// * LEVEL2 - TOTP-based MFA for all users +// * LEVEL3 - U2F MFA for all users. +const ( + IDBasedMfaEnrollmentTraitUserSpecificLevel1Const = "LEVEL1" + IDBasedMfaEnrollmentTraitUserSpecificLevel2Const = "LEVEL2" + IDBasedMfaEnrollmentTraitUserSpecificLevel3Const = "LEVEL3" + IDBasedMfaEnrollmentTraitUserSpecificNoneConst = "NONE" + IDBasedMfaEnrollmentTraitUserSpecificNoneNoRopcConst = "NONE_NO_ROPC" + IDBasedMfaEnrollmentTraitUserSpecificTotpConst = "TOTP" + IDBasedMfaEnrollmentTraitUserSpecificTotp4allConst = "TOTP4ALL" +) + +// Constants associated with the IDBasedMfaEnrollment.TraitEffective property. +// Defines the MFA trait for the account. Valid values: +// * NONE - No MFA trait set +// * NONE_NO_ROPC- No MFA, disable CLI logins with only a password +// * TOTP - For all non-federated IBMId users +// * TOTP4ALL - For all users +// * LEVEL1 - Email-based MFA for all users +// * LEVEL2 - TOTP-based MFA for all users +// * LEVEL3 - U2F MFA for all users. +const ( + IDBasedMfaEnrollmentTraitEffectiveLevel1Const = "LEVEL1" + IDBasedMfaEnrollmentTraitEffectiveLevel2Const = "LEVEL2" + IDBasedMfaEnrollmentTraitEffectiveLevel3Const = "LEVEL3" + IDBasedMfaEnrollmentTraitEffectiveNoneConst = "NONE" + IDBasedMfaEnrollmentTraitEffectiveNoneNoRopcConst = "NONE_NO_ROPC" + IDBasedMfaEnrollmentTraitEffectiveTotpConst = "TOTP" + IDBasedMfaEnrollmentTraitEffectiveTotp4allConst = "TOTP4ALL" +) + +// UnmarshalIDBasedMfaEnrollment unmarshals an instance of IDBasedMfaEnrollment from the specified map of raw messages. +func UnmarshalIDBasedMfaEnrollment(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(IDBasedMfaEnrollment) + err = core.UnmarshalPrimitive(m, "trait_account_default", &obj.TraitAccountDefault) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "trait_user_specific", &obj.TraitUserSpecific) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "trait_effective", &obj.TraitEffective) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "complies", &obj.Complies) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// ListAccountSettingsAssignmentsOptions : The ListAccountSettingsAssignments options. +type ListAccountSettingsAssignmentsOptions struct { + // Account ID of the Assignments to query. This parameter is required unless using a pagetoken. + AccountID *string `json:"account_id,omitempty"` + + // Filter results by Template Id. + TemplateID *string `json:"template_id,omitempty"` + + // Filter results Template Version. + TemplateVersion *string `json:"template_version,omitempty"` + + // Filter results by the assignment target. + Target *string `json:"target,omitempty"` + + // Filter results by the assignment's target type. + TargetType *string `json:"target_type,omitempty"` + + // Optional size of a single page. Default is 20 items per page. Valid range is 1 to 100. + Limit *int64 `json:"limit,omitempty"` + + // Optional Prev or Next page token returned from a previous query execution. Default is start with first page. + Pagetoken *string `json:"pagetoken,omitempty"` + + // If specified, the items are sorted by the value of this property. + Sort *string `json:"sort,omitempty"` + + // Sort order. + Order *string `json:"order,omitempty"` + + // Defines if the entity history is included in the response. + IncludeHistory *bool `json:"include_history,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// Constants associated with the ListAccountSettingsAssignmentsOptions.TargetType property. +// Filter results by the assignment's target type. +const ( + ListAccountSettingsAssignmentsOptionsTargetTypeAccountConst = "Account" + ListAccountSettingsAssignmentsOptionsTargetTypeAccountgroupConst = "AccountGroup" +) + +// Constants associated with the ListAccountSettingsAssignmentsOptions.Sort property. +// If specified, the items are sorted by the value of this property. +const ( + ListAccountSettingsAssignmentsOptionsSortCreatedAtConst = "created_at" + ListAccountSettingsAssignmentsOptionsSortLastModifiedAtConst = "last_modified_at" + ListAccountSettingsAssignmentsOptionsSortTemplateIDConst = "template_id" +) + +// Constants associated with the ListAccountSettingsAssignmentsOptions.Order property. +// Sort order. +const ( + ListAccountSettingsAssignmentsOptionsOrderAscConst = "asc" + ListAccountSettingsAssignmentsOptionsOrderDescConst = "desc" +) + +// NewListAccountSettingsAssignmentsOptions : Instantiate ListAccountSettingsAssignmentsOptions +func (*IamIdentityV1) NewListAccountSettingsAssignmentsOptions() *ListAccountSettingsAssignmentsOptions { + return &ListAccountSettingsAssignmentsOptions{} +} + +// SetAccountID : Allow user to set AccountID +func (_options *ListAccountSettingsAssignmentsOptions) SetAccountID(accountID string) *ListAccountSettingsAssignmentsOptions { + _options.AccountID = core.StringPtr(accountID) + return _options +} + +// SetTemplateID : Allow user to set TemplateID +func (_options *ListAccountSettingsAssignmentsOptions) SetTemplateID(templateID string) *ListAccountSettingsAssignmentsOptions { + _options.TemplateID = core.StringPtr(templateID) + return _options +} + +// SetTemplateVersion : Allow user to set TemplateVersion +func (_options *ListAccountSettingsAssignmentsOptions) SetTemplateVersion(templateVersion string) *ListAccountSettingsAssignmentsOptions { + _options.TemplateVersion = core.StringPtr(templateVersion) + return _options +} + +// SetTarget : Allow user to set Target +func (_options *ListAccountSettingsAssignmentsOptions) SetTarget(target string) *ListAccountSettingsAssignmentsOptions { + _options.Target = core.StringPtr(target) + return _options +} + +// SetTargetType : Allow user to set TargetType +func (_options *ListAccountSettingsAssignmentsOptions) SetTargetType(targetType string) *ListAccountSettingsAssignmentsOptions { + _options.TargetType = core.StringPtr(targetType) + return _options +} + +// SetLimit : Allow user to set Limit +func (_options *ListAccountSettingsAssignmentsOptions) SetLimit(limit int64) *ListAccountSettingsAssignmentsOptions { + _options.Limit = core.Int64Ptr(limit) + return _options +} + +// SetPagetoken : Allow user to set Pagetoken +func (_options *ListAccountSettingsAssignmentsOptions) SetPagetoken(pagetoken string) *ListAccountSettingsAssignmentsOptions { + _options.Pagetoken = core.StringPtr(pagetoken) + return _options +} + +// SetSort : Allow user to set Sort +func (_options *ListAccountSettingsAssignmentsOptions) SetSort(sort string) *ListAccountSettingsAssignmentsOptions { + _options.Sort = core.StringPtr(sort) + return _options +} + +// SetOrder : Allow user to set Order +func (_options *ListAccountSettingsAssignmentsOptions) SetOrder(order string) *ListAccountSettingsAssignmentsOptions { + _options.Order = core.StringPtr(order) + return _options +} + +// SetIncludeHistory : Allow user to set IncludeHistory +func (_options *ListAccountSettingsAssignmentsOptions) SetIncludeHistory(includeHistory bool) *ListAccountSettingsAssignmentsOptions { + _options.IncludeHistory = core.BoolPtr(includeHistory) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *ListAccountSettingsAssignmentsOptions) SetHeaders(param map[string]string) *ListAccountSettingsAssignmentsOptions { + options.Headers = param + return options +} + +// ListAccountSettingsTemplatesOptions : The ListAccountSettingsTemplates options. +type ListAccountSettingsTemplatesOptions struct { + // Account ID of the Account Settings Templates to query. This parameter is required unless using a pagetoken. + AccountID *string `json:"account_id,omitempty"` + + // Optional size of a single page. + Limit *string `json:"limit,omitempty"` + + // Optional Prev or Next page token returned from a previous query execution. Default is start with first page. + Pagetoken *string `json:"pagetoken,omitempty"` + + // Optional sort property. If specified, the returned templated are sorted according to this property. + Sort *string `json:"sort,omitempty"` + + // Optional sort order. + Order *string `json:"order,omitempty"` + + // Defines if the entity history is included in the response. + IncludeHistory *string `json:"include_history,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// Constants associated with the ListAccountSettingsTemplatesOptions.Sort property. +// Optional sort property. If specified, the returned templated are sorted according to this property. +const ( + ListAccountSettingsTemplatesOptionsSortCreatedAtConst = "created_at" + ListAccountSettingsTemplatesOptionsSortLastModifiedAtConst = "last_modified_at" + ListAccountSettingsTemplatesOptionsSortNameConst = "name" +) + +// Constants associated with the ListAccountSettingsTemplatesOptions.Order property. +// Optional sort order. +const ( + ListAccountSettingsTemplatesOptionsOrderAscConst = "asc" + ListAccountSettingsTemplatesOptionsOrderDescConst = "desc" +) + +// NewListAccountSettingsTemplatesOptions : Instantiate ListAccountSettingsTemplatesOptions +func (*IamIdentityV1) NewListAccountSettingsTemplatesOptions() *ListAccountSettingsTemplatesOptions { + return &ListAccountSettingsTemplatesOptions{} +} + +// SetAccountID : Allow user to set AccountID +func (_options *ListAccountSettingsTemplatesOptions) SetAccountID(accountID string) *ListAccountSettingsTemplatesOptions { + _options.AccountID = core.StringPtr(accountID) + return _options +} + +// SetLimit : Allow user to set Limit +func (_options *ListAccountSettingsTemplatesOptions) SetLimit(limit string) *ListAccountSettingsTemplatesOptions { + _options.Limit = core.StringPtr(limit) + return _options +} + +// SetPagetoken : Allow user to set Pagetoken +func (_options *ListAccountSettingsTemplatesOptions) SetPagetoken(pagetoken string) *ListAccountSettingsTemplatesOptions { + _options.Pagetoken = core.StringPtr(pagetoken) + return _options +} + +// SetSort : Allow user to set Sort +func (_options *ListAccountSettingsTemplatesOptions) SetSort(sort string) *ListAccountSettingsTemplatesOptions { + _options.Sort = core.StringPtr(sort) + return _options +} + +// SetOrder : Allow user to set Order +func (_options *ListAccountSettingsTemplatesOptions) SetOrder(order string) *ListAccountSettingsTemplatesOptions { + _options.Order = core.StringPtr(order) + return _options +} + +// SetIncludeHistory : Allow user to set IncludeHistory +func (_options *ListAccountSettingsTemplatesOptions) SetIncludeHistory(includeHistory string) *ListAccountSettingsTemplatesOptions { + _options.IncludeHistory = core.StringPtr(includeHistory) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *ListAccountSettingsTemplatesOptions) SetHeaders(param map[string]string) *ListAccountSettingsTemplatesOptions { + options.Headers = param + return options +} + +// ListAPIKeysOptions : The ListAPIKeys options. +type ListAPIKeysOptions struct { + // Account ID of the API keys(s) to query. If a service IAM ID is specified in iam_id then account_id must match the + // account of the IAM ID. If a user IAM ID is specified in iam_id then then account_id must match the account of the + // Authorization token. + AccountID *string `json:"account_id,omitempty"` + + // IAM ID of the API key(s) to be queried. The IAM ID may be that of a user or a service. For a user IAM ID iam_id must + // match the Authorization token. + IamID *string `json:"iam_id,omitempty"` + + // Optional size of a single page. Default is 20 items per page. Valid range is 1 to 100. + Pagesize *int64 `json:"pagesize,omitempty"` + + // Optional Prev or Next page token returned from a previous query execution. Default is start with first page. + Pagetoken *string `json:"pagetoken,omitempty"` + + // Optional parameter to define the scope of the queried API Keys. Can be 'entity' (default) or 'account'. + Scope *string `json:"scope,omitempty"` + + // Optional parameter to filter the type of the queried API Keys. Can be 'user' or 'serviceid'. + Type *string `json:"type,omitempty"` + + // Optional sort property, valid values are name, description, created_at and created_by. If specified, the items are + // sorted by the value of this property. + Sort *string `json:"sort,omitempty"` + + // Optional sort order, valid values are asc and desc. Default: asc. + Order *string `json:"order,omitempty"` + + // Defines if the entity history is included in the response. + IncludeHistory *bool `json:"include_history,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// Constants associated with the ListAPIKeysOptions.Scope property. +// Optional parameter to define the scope of the queried API Keys. Can be 'entity' (default) or 'account'. +const ( + ListAPIKeysOptionsScopeAccountConst = "account" + ListAPIKeysOptionsScopeEntityConst = "entity" +) + +// Constants associated with the ListAPIKeysOptions.Type property. +// Optional parameter to filter the type of the queried API Keys. Can be 'user' or 'serviceid'. +const ( + ListAPIKeysOptionsTypeServiceidConst = "serviceid" + ListAPIKeysOptionsTypeUserConst = "user" +) + +// Constants associated with the ListAPIKeysOptions.Order property. +// Optional sort order, valid values are asc and desc. Default: asc. +const ( + ListAPIKeysOptionsOrderAscConst = "asc" + ListAPIKeysOptionsOrderDescConst = "desc" +) + +// NewListAPIKeysOptions : Instantiate ListAPIKeysOptions +func (*IamIdentityV1) NewListAPIKeysOptions() *ListAPIKeysOptions { + return &ListAPIKeysOptions{} +} + +// SetAccountID : Allow user to set AccountID +func (_options *ListAPIKeysOptions) SetAccountID(accountID string) *ListAPIKeysOptions { + _options.AccountID = core.StringPtr(accountID) + return _options +} + +// SetIamID : Allow user to set IamID +func (_options *ListAPIKeysOptions) SetIamID(iamID string) *ListAPIKeysOptions { + _options.IamID = core.StringPtr(iamID) + return _options +} + +// SetPagesize : Allow user to set Pagesize +func (_options *ListAPIKeysOptions) SetPagesize(pagesize int64) *ListAPIKeysOptions { + _options.Pagesize = core.Int64Ptr(pagesize) + return _options +} + +// SetPagetoken : Allow user to set Pagetoken +func (_options *ListAPIKeysOptions) SetPagetoken(pagetoken string) *ListAPIKeysOptions { + _options.Pagetoken = core.StringPtr(pagetoken) + return _options +} + +// SetScope : Allow user to set Scope +func (_options *ListAPIKeysOptions) SetScope(scope string) *ListAPIKeysOptions { + _options.Scope = core.StringPtr(scope) + return _options +} + +// SetType : Allow user to set Type +func (_options *ListAPIKeysOptions) SetType(typeVar string) *ListAPIKeysOptions { + _options.Type = core.StringPtr(typeVar) + return _options +} + +// SetSort : Allow user to set Sort +func (_options *ListAPIKeysOptions) SetSort(sort string) *ListAPIKeysOptions { + _options.Sort = core.StringPtr(sort) + return _options +} + +// SetOrder : Allow user to set Order +func (_options *ListAPIKeysOptions) SetOrder(order string) *ListAPIKeysOptions { + _options.Order = core.StringPtr(order) + return _options +} + +// SetIncludeHistory : Allow user to set IncludeHistory +func (_options *ListAPIKeysOptions) SetIncludeHistory(includeHistory bool) *ListAPIKeysOptions { + _options.IncludeHistory = core.BoolPtr(includeHistory) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *ListAPIKeysOptions) SetHeaders(param map[string]string) *ListAPIKeysOptions { + options.Headers = param + return options +} + +// ListClaimRulesOptions : The ListClaimRules options. +type ListClaimRulesOptions struct { + // ID of the trusted profile. + ProfileID *string `json:"profile-id" validate:"required,ne="` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewListClaimRulesOptions : Instantiate ListClaimRulesOptions +func (*IamIdentityV1) NewListClaimRulesOptions(profileID string) *ListClaimRulesOptions { + return &ListClaimRulesOptions{ + ProfileID: core.StringPtr(profileID), + } +} + +// SetProfileID : Allow user to set ProfileID +func (_options *ListClaimRulesOptions) SetProfileID(profileID string) *ListClaimRulesOptions { + _options.ProfileID = core.StringPtr(profileID) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *ListClaimRulesOptions) SetHeaders(param map[string]string) *ListClaimRulesOptions { + options.Headers = param + return options +} + +// ListLinksOptions : The ListLinks options. +type ListLinksOptions struct { + // ID of the trusted profile. + ProfileID *string `json:"profile-id" validate:"required,ne="` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewListLinksOptions : Instantiate ListLinksOptions +func (*IamIdentityV1) NewListLinksOptions(profileID string) *ListLinksOptions { + return &ListLinksOptions{ + ProfileID: core.StringPtr(profileID), + } +} + +// SetProfileID : Allow user to set ProfileID +func (_options *ListLinksOptions) SetProfileID(profileID string) *ListLinksOptions { + _options.ProfileID = core.StringPtr(profileID) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *ListLinksOptions) SetHeaders(param map[string]string) *ListLinksOptions { + options.Headers = param + return options +} + +// ListProfileTemplatesOptions : The ListProfileTemplates options. +type ListProfileTemplatesOptions struct { + // Account ID of the Profile Templates to query. This parameter is required unless using a pagetoken. + AccountID *string `json:"account_id,omitempty"` + + // Optional size of a single page. + Limit *string `json:"limit,omitempty"` + + // Optional Prev or Next page token returned from a previous query execution. Default is start with first page. + Pagetoken *string `json:"pagetoken,omitempty"` + + // Optional sort property. If specified, the returned templated are sorted according to this property. + Sort *string `json:"sort,omitempty"` + + // Optional sort order. + Order *string `json:"order,omitempty"` + + // Defines if the entity history is included in the response. + IncludeHistory *string `json:"include_history,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// Constants associated with the ListProfileTemplatesOptions.Sort property. +// Optional sort property. If specified, the returned templated are sorted according to this property. +const ( + ListProfileTemplatesOptionsSortCreatedAtConst = "created_at" + ListProfileTemplatesOptionsSortLastModifiedAtConst = "last_modified_at" + ListProfileTemplatesOptionsSortNameConst = "name" +) + +// Constants associated with the ListProfileTemplatesOptions.Order property. +// Optional sort order. +const ( + ListProfileTemplatesOptionsOrderAscConst = "asc" + ListProfileTemplatesOptionsOrderDescConst = "desc" +) + +// NewListProfileTemplatesOptions : Instantiate ListProfileTemplatesOptions +func (*IamIdentityV1) NewListProfileTemplatesOptions() *ListProfileTemplatesOptions { + return &ListProfileTemplatesOptions{} +} + +// SetAccountID : Allow user to set AccountID +func (_options *ListProfileTemplatesOptions) SetAccountID(accountID string) *ListProfileTemplatesOptions { + _options.AccountID = core.StringPtr(accountID) + return _options +} + +// SetLimit : Allow user to set Limit +func (_options *ListProfileTemplatesOptions) SetLimit(limit string) *ListProfileTemplatesOptions { + _options.Limit = core.StringPtr(limit) + return _options +} + +// SetPagetoken : Allow user to set Pagetoken +func (_options *ListProfileTemplatesOptions) SetPagetoken(pagetoken string) *ListProfileTemplatesOptions { + _options.Pagetoken = core.StringPtr(pagetoken) + return _options +} + +// SetSort : Allow user to set Sort +func (_options *ListProfileTemplatesOptions) SetSort(sort string) *ListProfileTemplatesOptions { + _options.Sort = core.StringPtr(sort) + return _options +} + +// SetOrder : Allow user to set Order +func (_options *ListProfileTemplatesOptions) SetOrder(order string) *ListProfileTemplatesOptions { + _options.Order = core.StringPtr(order) + return _options +} + +// SetIncludeHistory : Allow user to set IncludeHistory +func (_options *ListProfileTemplatesOptions) SetIncludeHistory(includeHistory string) *ListProfileTemplatesOptions { + _options.IncludeHistory = core.StringPtr(includeHistory) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *ListProfileTemplatesOptions) SetHeaders(param map[string]string) *ListProfileTemplatesOptions { + options.Headers = param + return options +} + +// ListProfilesOptions : The ListProfiles options. +type ListProfilesOptions struct { + // Account ID to query for trusted profiles. + AccountID *string `json:"account_id" validate:"required"` + + // Name of the trusted profile to query. + Name *string `json:"name,omitempty"` + + // Optional size of a single page. Default is 20 items per page. Valid range is 1 to 100. + Pagesize *int64 `json:"pagesize,omitempty"` + + // Optional sort property, valid values are name, description, created_at and modified_at. If specified, the items are + // sorted by the value of this property. + Sort *string `json:"sort,omitempty"` + + // Optional sort order, valid values are asc and desc. Default: asc. + Order *string `json:"order,omitempty"` + + // Defines if the entity history is included in the response. + IncludeHistory *bool `json:"include_history,omitempty"` + + // Optional Prev or Next page token returned from a previous query execution. Default is start with first page. + Pagetoken *string `json:"pagetoken,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// Constants associated with the ListProfilesOptions.Order property. +// Optional sort order, valid values are asc and desc. Default: asc. +const ( + ListProfilesOptionsOrderAscConst = "asc" + ListProfilesOptionsOrderDescConst = "desc" +) + +// NewListProfilesOptions : Instantiate ListProfilesOptions +func (*IamIdentityV1) NewListProfilesOptions(accountID string) *ListProfilesOptions { + return &ListProfilesOptions{ + AccountID: core.StringPtr(accountID), + } +} + +// SetAccountID : Allow user to set AccountID +func (_options *ListProfilesOptions) SetAccountID(accountID string) *ListProfilesOptions { + _options.AccountID = core.StringPtr(accountID) + return _options +} + +// SetName : Allow user to set Name +func (_options *ListProfilesOptions) SetName(name string) *ListProfilesOptions { + _options.Name = core.StringPtr(name) + return _options +} + +// SetPagesize : Allow user to set Pagesize +func (_options *ListProfilesOptions) SetPagesize(pagesize int64) *ListProfilesOptions { + _options.Pagesize = core.Int64Ptr(pagesize) + return _options +} + +// SetSort : Allow user to set Sort +func (_options *ListProfilesOptions) SetSort(sort string) *ListProfilesOptions { + _options.Sort = core.StringPtr(sort) + return _options +} + +// SetOrder : Allow user to set Order +func (_options *ListProfilesOptions) SetOrder(order string) *ListProfilesOptions { + _options.Order = core.StringPtr(order) + return _options +} + +// SetIncludeHistory : Allow user to set IncludeHistory +func (_options *ListProfilesOptions) SetIncludeHistory(includeHistory bool) *ListProfilesOptions { + _options.IncludeHistory = core.BoolPtr(includeHistory) + return _options +} + +// SetPagetoken : Allow user to set Pagetoken +func (_options *ListProfilesOptions) SetPagetoken(pagetoken string) *ListProfilesOptions { + _options.Pagetoken = core.StringPtr(pagetoken) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *ListProfilesOptions) SetHeaders(param map[string]string) *ListProfilesOptions { + options.Headers = param + return options +} + +// ListServiceIdsOptions : The ListServiceIds options. +type ListServiceIdsOptions struct { + // Account ID of the service ID(s) to query. This parameter is required (unless using a pagetoken). + AccountID *string `json:"account_id,omitempty"` + + // Name of the service ID(s) to query. Optional.20 items per page. Valid range is 1 to 100. + Name *string `json:"name,omitempty"` + + // Optional size of a single page. Default is 20 items per page. Valid range is 1 to 100. + Pagesize *int64 `json:"pagesize,omitempty"` + + // Optional Prev or Next page token returned from a previous query execution. Default is start with first page. + Pagetoken *string `json:"pagetoken,omitempty"` + + // Optional sort property, valid values are name, description, created_at and modified_at. If specified, the items are + // sorted by the value of this property. + Sort *string `json:"sort,omitempty"` + + // Optional sort order, valid values are asc and desc. Default: asc. + Order *string `json:"order,omitempty"` + + // Defines if the entity history is included in the response. + IncludeHistory *bool `json:"include_history,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// Constants associated with the ListServiceIdsOptions.Order property. +// Optional sort order, valid values are asc and desc. Default: asc. +const ( + ListServiceIdsOptionsOrderAscConst = "asc" + ListServiceIdsOptionsOrderDescConst = "desc" +) + +// NewListServiceIdsOptions : Instantiate ListServiceIdsOptions +func (*IamIdentityV1) NewListServiceIdsOptions() *ListServiceIdsOptions { + return &ListServiceIdsOptions{} +} + +// SetAccountID : Allow user to set AccountID +func (_options *ListServiceIdsOptions) SetAccountID(accountID string) *ListServiceIdsOptions { + _options.AccountID = core.StringPtr(accountID) + return _options +} + +// SetName : Allow user to set Name +func (_options *ListServiceIdsOptions) SetName(name string) *ListServiceIdsOptions { + _options.Name = core.StringPtr(name) + return _options +} + +// SetPagesize : Allow user to set Pagesize +func (_options *ListServiceIdsOptions) SetPagesize(pagesize int64) *ListServiceIdsOptions { + _options.Pagesize = core.Int64Ptr(pagesize) + return _options +} + +// SetPagetoken : Allow user to set Pagetoken +func (_options *ListServiceIdsOptions) SetPagetoken(pagetoken string) *ListServiceIdsOptions { + _options.Pagetoken = core.StringPtr(pagetoken) + return _options +} + +// SetSort : Allow user to set Sort +func (_options *ListServiceIdsOptions) SetSort(sort string) *ListServiceIdsOptions { + _options.Sort = core.StringPtr(sort) + return _options +} + +// SetOrder : Allow user to set Order +func (_options *ListServiceIdsOptions) SetOrder(order string) *ListServiceIdsOptions { + _options.Order = core.StringPtr(order) + return _options +} + +// SetIncludeHistory : Allow user to set IncludeHistory +func (_options *ListServiceIdsOptions) SetIncludeHistory(includeHistory bool) *ListServiceIdsOptions { + _options.IncludeHistory = core.BoolPtr(includeHistory) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *ListServiceIdsOptions) SetHeaders(param map[string]string) *ListServiceIdsOptions { + options.Headers = param + return options +} + +// ListTrustedProfileAssignmentsOptions : The ListTrustedProfileAssignments options. +type ListTrustedProfileAssignmentsOptions struct { + // Account ID of the Assignments to query. This parameter is required unless using a pagetoken. + AccountID *string `json:"account_id,omitempty"` + + // Filter results by Template Id. + TemplateID *string `json:"template_id,omitempty"` + + // Filter results Template Version. + TemplateVersion *string `json:"template_version,omitempty"` + + // Filter results by the assignment target. + Target *string `json:"target,omitempty"` + + // Filter results by the assignment's target type. + TargetType *string `json:"target_type,omitempty"` + + // Optional size of a single page. Default is 20 items per page. Valid range is 1 to 100. + Limit *int64 `json:"limit,omitempty"` + + // Optional Prev or Next page token returned from a previous query execution. Default is start with first page. + Pagetoken *string `json:"pagetoken,omitempty"` + + // If specified, the items are sorted by the value of this property. + Sort *string `json:"sort,omitempty"` + + // Sort order. + Order *string `json:"order,omitempty"` + + // Defines if the entity history is included in the response. + IncludeHistory *bool `json:"include_history,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// Constants associated with the ListTrustedProfileAssignmentsOptions.TargetType property. +// Filter results by the assignment's target type. +const ( + ListTrustedProfileAssignmentsOptionsTargetTypeAccountConst = "Account" + ListTrustedProfileAssignmentsOptionsTargetTypeAccountgroupConst = "AccountGroup" +) + +// Constants associated with the ListTrustedProfileAssignmentsOptions.Sort property. +// If specified, the items are sorted by the value of this property. +const ( + ListTrustedProfileAssignmentsOptionsSortCreatedAtConst = "created_at" + ListTrustedProfileAssignmentsOptionsSortLastModifiedAtConst = "last_modified_at" + ListTrustedProfileAssignmentsOptionsSortTemplateIDConst = "template_id" +) + +// Constants associated with the ListTrustedProfileAssignmentsOptions.Order property. +// Sort order. +const ( + ListTrustedProfileAssignmentsOptionsOrderAscConst = "asc" + ListTrustedProfileAssignmentsOptionsOrderDescConst = "desc" +) + +// NewListTrustedProfileAssignmentsOptions : Instantiate ListTrustedProfileAssignmentsOptions +func (*IamIdentityV1) NewListTrustedProfileAssignmentsOptions() *ListTrustedProfileAssignmentsOptions { + return &ListTrustedProfileAssignmentsOptions{} +} // SetAccountID : Allow user to set AccountID -func (_options *GetMfaStatusOptions) SetAccountID(accountID string) *GetMfaStatusOptions { +func (_options *ListTrustedProfileAssignmentsOptions) SetAccountID(accountID string) *ListTrustedProfileAssignmentsOptions { _options.AccountID = core.StringPtr(accountID) return _options } -// SetIamID : Allow user to set IamID -func (_options *GetMfaStatusOptions) SetIamID(iamID string) *GetMfaStatusOptions { - _options.IamID = core.StringPtr(iamID) +// SetTemplateID : Allow user to set TemplateID +func (_options *ListTrustedProfileAssignmentsOptions) SetTemplateID(templateID string) *ListTrustedProfileAssignmentsOptions { + _options.TemplateID = core.StringPtr(templateID) return _options } -// SetHeaders : Allow user to set Headers -func (options *GetMfaStatusOptions) SetHeaders(param map[string]string) *GetMfaStatusOptions { - options.Headers = param - return options +// SetTemplateVersion : Allow user to set TemplateVersion +func (_options *ListTrustedProfileAssignmentsOptions) SetTemplateVersion(templateVersion string) *ListTrustedProfileAssignmentsOptions { + _options.TemplateVersion = core.StringPtr(templateVersion) + return _options } -// GetProfileIdentitiesOptions : The GetProfileIdentities options. -type GetProfileIdentitiesOptions struct { - // ID of the trusted profile. - ProfileID *string `json:"profile-id" validate:"required,ne="` +// SetTarget : Allow user to set Target +func (_options *ListTrustedProfileAssignmentsOptions) SetTarget(target string) *ListTrustedProfileAssignmentsOptions { + _options.Target = core.StringPtr(target) + return _options +} - // Allows users to set headers on API requests - Headers map[string]string +// SetTargetType : Allow user to set TargetType +func (_options *ListTrustedProfileAssignmentsOptions) SetTargetType(targetType string) *ListTrustedProfileAssignmentsOptions { + _options.TargetType = core.StringPtr(targetType) + return _options } -// NewGetProfileIdentitiesOptions : Instantiate GetProfileIdentitiesOptions -func (*IamIdentityV1) NewGetProfileIdentitiesOptions(profileID string) *GetProfileIdentitiesOptions { - return &GetProfileIdentitiesOptions{ - ProfileID: core.StringPtr(profileID), - } +// SetLimit : Allow user to set Limit +func (_options *ListTrustedProfileAssignmentsOptions) SetLimit(limit int64) *ListTrustedProfileAssignmentsOptions { + _options.Limit = core.Int64Ptr(limit) + return _options } -// SetProfileID : Allow user to set ProfileID -func (_options *GetProfileIdentitiesOptions) SetProfileID(profileID string) *GetProfileIdentitiesOptions { - _options.ProfileID = core.StringPtr(profileID) +// SetPagetoken : Allow user to set Pagetoken +func (_options *ListTrustedProfileAssignmentsOptions) SetPagetoken(pagetoken string) *ListTrustedProfileAssignmentsOptions { + _options.Pagetoken = core.StringPtr(pagetoken) + return _options +} + +// SetSort : Allow user to set Sort +func (_options *ListTrustedProfileAssignmentsOptions) SetSort(sort string) *ListTrustedProfileAssignmentsOptions { + _options.Sort = core.StringPtr(sort) + return _options +} + +// SetOrder : Allow user to set Order +func (_options *ListTrustedProfileAssignmentsOptions) SetOrder(order string) *ListTrustedProfileAssignmentsOptions { + _options.Order = core.StringPtr(order) + return _options +} + +// SetIncludeHistory : Allow user to set IncludeHistory +func (_options *ListTrustedProfileAssignmentsOptions) SetIncludeHistory(includeHistory bool) *ListTrustedProfileAssignmentsOptions { + _options.IncludeHistory = core.BoolPtr(includeHistory) return _options } // SetHeaders : Allow user to set Headers -func (options *GetProfileIdentitiesOptions) SetHeaders(param map[string]string) *GetProfileIdentitiesOptions { +func (options *ListTrustedProfileAssignmentsOptions) SetHeaders(param map[string]string) *ListTrustedProfileAssignmentsOptions { options.Headers = param return options } -// GetProfileIdentityOptions : The GetProfileIdentity options. -type GetProfileIdentityOptions struct { - // ID of the trusted profile. - ProfileID *string `json:"profile-id" validate:"required,ne="` +// ListVersionsOfAccountSettingsTemplateOptions : The ListVersionsOfAccountSettingsTemplate options. +type ListVersionsOfAccountSettingsTemplateOptions struct { + // ID of the Account Settings Template. + TemplateID *string `json:"template_id" validate:"required,ne="` - // Type of the identity. - IdentityType *string `json:"identity-type" validate:"required,ne="` + // Optional size of a single page. + Limit *string `json:"limit,omitempty"` - // Identifier of the identity that can assume the trusted profiles. - IdentifierID *string `json:"identifier-id" validate:"required,ne="` + // Optional Prev or Next page token returned from a previous query execution. Default is start with first page. + Pagetoken *string `json:"pagetoken,omitempty"` + + // Optional sort property. If specified, the returned templated are sorted according to this property. + Sort *string `json:"sort,omitempty"` + + // Optional sort order. + Order *string `json:"order,omitempty"` + + // Defines if the entity history is included in the response. + IncludeHistory *string `json:"include_history,omitempty"` // Allows users to set headers on API requests Headers map[string]string } -// Constants associated with the GetProfileIdentityOptions.IdentityType property. -// Type of the identity. +// Constants associated with the ListVersionsOfAccountSettingsTemplateOptions.Sort property. +// Optional sort property. If specified, the returned templated are sorted according to this property. const ( - GetProfileIdentityOptionsIdentityTypeCRNConst = "crn" - GetProfileIdentityOptionsIdentityTypeServiceidConst = "serviceid" - GetProfileIdentityOptionsIdentityTypeUserConst = "user" + ListVersionsOfAccountSettingsTemplateOptionsSortCreatedAtConst = "created_at" + ListVersionsOfAccountSettingsTemplateOptionsSortLastModifiedAtConst = "last_modified_at" + ListVersionsOfAccountSettingsTemplateOptionsSortNameConst = "name" ) -// NewGetProfileIdentityOptions : Instantiate GetProfileIdentityOptions -func (*IamIdentityV1) NewGetProfileIdentityOptions(profileID string, identityType string, identifierID string) *GetProfileIdentityOptions { - return &GetProfileIdentityOptions{ - ProfileID: core.StringPtr(profileID), - IdentityType: core.StringPtr(identityType), - IdentifierID: core.StringPtr(identifierID), +// Constants associated with the ListVersionsOfAccountSettingsTemplateOptions.Order property. +// Optional sort order. +const ( + ListVersionsOfAccountSettingsTemplateOptionsOrderAscConst = "asc" + ListVersionsOfAccountSettingsTemplateOptionsOrderDescConst = "desc" +) + +// NewListVersionsOfAccountSettingsTemplateOptions : Instantiate ListVersionsOfAccountSettingsTemplateOptions +func (*IamIdentityV1) NewListVersionsOfAccountSettingsTemplateOptions(templateID string) *ListVersionsOfAccountSettingsTemplateOptions { + return &ListVersionsOfAccountSettingsTemplateOptions{ + TemplateID: core.StringPtr(templateID), } } -// SetProfileID : Allow user to set ProfileID -func (_options *GetProfileIdentityOptions) SetProfileID(profileID string) *GetProfileIdentityOptions { - _options.ProfileID = core.StringPtr(profileID) +// SetTemplateID : Allow user to set TemplateID +func (_options *ListVersionsOfAccountSettingsTemplateOptions) SetTemplateID(templateID string) *ListVersionsOfAccountSettingsTemplateOptions { + _options.TemplateID = core.StringPtr(templateID) return _options } -// SetIdentityType : Allow user to set IdentityType -func (_options *GetProfileIdentityOptions) SetIdentityType(identityType string) *GetProfileIdentityOptions { - _options.IdentityType = core.StringPtr(identityType) +// SetLimit : Allow user to set Limit +func (_options *ListVersionsOfAccountSettingsTemplateOptions) SetLimit(limit string) *ListVersionsOfAccountSettingsTemplateOptions { + _options.Limit = core.StringPtr(limit) return _options } -// SetIdentifierID : Allow user to set IdentifierID -func (_options *GetProfileIdentityOptions) SetIdentifierID(identifierID string) *GetProfileIdentityOptions { - _options.IdentifierID = core.StringPtr(identifierID) +// SetPagetoken : Allow user to set Pagetoken +func (_options *ListVersionsOfAccountSettingsTemplateOptions) SetPagetoken(pagetoken string) *ListVersionsOfAccountSettingsTemplateOptions { + _options.Pagetoken = core.StringPtr(pagetoken) + return _options +} + +// SetSort : Allow user to set Sort +func (_options *ListVersionsOfAccountSettingsTemplateOptions) SetSort(sort string) *ListVersionsOfAccountSettingsTemplateOptions { + _options.Sort = core.StringPtr(sort) + return _options +} + +// SetOrder : Allow user to set Order +func (_options *ListVersionsOfAccountSettingsTemplateOptions) SetOrder(order string) *ListVersionsOfAccountSettingsTemplateOptions { + _options.Order = core.StringPtr(order) + return _options +} + +// SetIncludeHistory : Allow user to set IncludeHistory +func (_options *ListVersionsOfAccountSettingsTemplateOptions) SetIncludeHistory(includeHistory string) *ListVersionsOfAccountSettingsTemplateOptions { + _options.IncludeHistory = core.StringPtr(includeHistory) return _options } // SetHeaders : Allow user to set Headers -func (options *GetProfileIdentityOptions) SetHeaders(param map[string]string) *GetProfileIdentityOptions { +func (options *ListVersionsOfAccountSettingsTemplateOptions) SetHeaders(param map[string]string) *ListVersionsOfAccountSettingsTemplateOptions { options.Headers = param return options } -// GetProfileOptions : The GetProfile options. -type GetProfileOptions struct { - // ID of the trusted profile to get. - ProfileID *string `json:"profile-id" validate:"required,ne="` +// ListVersionsOfProfileTemplateOptions : The ListVersionsOfProfileTemplate options. +type ListVersionsOfProfileTemplateOptions struct { + // ID of the Profile Template. + TemplateID *string `json:"template_id" validate:"required,ne="` - // Defines if the entity's activity is included in the response. Retrieving activity data is an expensive operation, so - // please only request this when needed. - IncludeActivity *bool `json:"include_activity,omitempty"` + // Optional size of a single page. + Limit *string `json:"limit,omitempty"` + + // Optional Prev or Next page token returned from a previous query execution. Default is start with first page. + Pagetoken *string `json:"pagetoken,omitempty"` + + // Optional sort property. If specified, the returned templated are sorted according to this property. + Sort *string `json:"sort,omitempty"` + + // Optional sort order. + Order *string `json:"order,omitempty"` + + // Defines if the entity history is included in the response. + IncludeHistory *string `json:"include_history,omitempty"` // Allows users to set headers on API requests Headers map[string]string } -// NewGetProfileOptions : Instantiate GetProfileOptions -func (*IamIdentityV1) NewGetProfileOptions(profileID string) *GetProfileOptions { - return &GetProfileOptions{ - ProfileID: core.StringPtr(profileID), +// Constants associated with the ListVersionsOfProfileTemplateOptions.Sort property. +// Optional sort property. If specified, the returned templated are sorted according to this property. +const ( + ListVersionsOfProfileTemplateOptionsSortCreatedAtConst = "created_at" + ListVersionsOfProfileTemplateOptionsSortLastModifiedAtConst = "last_modified_at" + ListVersionsOfProfileTemplateOptionsSortNameConst = "name" +) + +// Constants associated with the ListVersionsOfProfileTemplateOptions.Order property. +// Optional sort order. +const ( + ListVersionsOfProfileTemplateOptionsOrderAscConst = "asc" + ListVersionsOfProfileTemplateOptionsOrderDescConst = "desc" +) + +// NewListVersionsOfProfileTemplateOptions : Instantiate ListVersionsOfProfileTemplateOptions +func (*IamIdentityV1) NewListVersionsOfProfileTemplateOptions(templateID string) *ListVersionsOfProfileTemplateOptions { + return &ListVersionsOfProfileTemplateOptions{ + TemplateID: core.StringPtr(templateID), } } -// SetProfileID : Allow user to set ProfileID -func (_options *GetProfileOptions) SetProfileID(profileID string) *GetProfileOptions { - _options.ProfileID = core.StringPtr(profileID) +// SetTemplateID : Allow user to set TemplateID +func (_options *ListVersionsOfProfileTemplateOptions) SetTemplateID(templateID string) *ListVersionsOfProfileTemplateOptions { + _options.TemplateID = core.StringPtr(templateID) return _options } -// SetIncludeActivity : Allow user to set IncludeActivity -func (_options *GetProfileOptions) SetIncludeActivity(includeActivity bool) *GetProfileOptions { - _options.IncludeActivity = core.BoolPtr(includeActivity) +// SetLimit : Allow user to set Limit +func (_options *ListVersionsOfProfileTemplateOptions) SetLimit(limit string) *ListVersionsOfProfileTemplateOptions { + _options.Limit = core.StringPtr(limit) return _options } -// SetHeaders : Allow user to set Headers -func (options *GetProfileOptions) SetHeaders(param map[string]string) *GetProfileOptions { - options.Headers = param - return options -} - -// GetReportOptions : The GetReport options. -type GetReportOptions struct { - // ID of the account. - AccountID *string `json:"account_id" validate:"required,ne="` - - // Reference for the report to be generated, You can use 'latest' to get the latest report for the given account. - Reference *string `json:"reference" validate:"required,ne="` - - // Allows users to set headers on API requests - Headers map[string]string +// SetPagetoken : Allow user to set Pagetoken +func (_options *ListVersionsOfProfileTemplateOptions) SetPagetoken(pagetoken string) *ListVersionsOfProfileTemplateOptions { + _options.Pagetoken = core.StringPtr(pagetoken) + return _options } -// NewGetReportOptions : Instantiate GetReportOptions -func (*IamIdentityV1) NewGetReportOptions(accountID string, reference string) *GetReportOptions { - return &GetReportOptions{ - AccountID: core.StringPtr(accountID), - Reference: core.StringPtr(reference), - } +// SetSort : Allow user to set Sort +func (_options *ListVersionsOfProfileTemplateOptions) SetSort(sort string) *ListVersionsOfProfileTemplateOptions { + _options.Sort = core.StringPtr(sort) + return _options } -// SetAccountID : Allow user to set AccountID -func (_options *GetReportOptions) SetAccountID(accountID string) *GetReportOptions { - _options.AccountID = core.StringPtr(accountID) +// SetOrder : Allow user to set Order +func (_options *ListVersionsOfProfileTemplateOptions) SetOrder(order string) *ListVersionsOfProfileTemplateOptions { + _options.Order = core.StringPtr(order) return _options } -// SetReference : Allow user to set Reference -func (_options *GetReportOptions) SetReference(reference string) *GetReportOptions { - _options.Reference = core.StringPtr(reference) +// SetIncludeHistory : Allow user to set IncludeHistory +func (_options *ListVersionsOfProfileTemplateOptions) SetIncludeHistory(includeHistory string) *ListVersionsOfProfileTemplateOptions { + _options.IncludeHistory = core.StringPtr(includeHistory) return _options } // SetHeaders : Allow user to set Headers -func (options *GetReportOptions) SetHeaders(param map[string]string) *GetReportOptions { +func (options *ListVersionsOfProfileTemplateOptions) SetHeaders(param map[string]string) *ListVersionsOfProfileTemplateOptions { options.Headers = param return options } -// GetServiceIDOptions : The GetServiceID options. -type GetServiceIDOptions struct { - // Unique ID of the service ID. +// LockAPIKeyOptions : The LockAPIKey options. +type LockAPIKeyOptions struct { + // Unique ID of the API key. ID *string `json:"id" validate:"required,ne="` - // Defines if the entity history is included in the response. - IncludeHistory *bool `json:"include_history,omitempty"` - - // Defines if the entity's activity is included in the response. Retrieving activity data is an expensive operation, so - // please only request this when needed. - IncludeActivity *bool `json:"include_activity,omitempty"` - // Allows users to set headers on API requests Headers map[string]string } -// NewGetServiceIDOptions : Instantiate GetServiceIDOptions -func (*IamIdentityV1) NewGetServiceIDOptions(id string) *GetServiceIDOptions { - return &GetServiceIDOptions{ +// NewLockAPIKeyOptions : Instantiate LockAPIKeyOptions +func (*IamIdentityV1) NewLockAPIKeyOptions(id string) *LockAPIKeyOptions { + return &LockAPIKeyOptions{ ID: core.StringPtr(id), } } // SetID : Allow user to set ID -func (_options *GetServiceIDOptions) SetID(id string) *GetServiceIDOptions { +func (_options *LockAPIKeyOptions) SetID(id string) *LockAPIKeyOptions { _options.ID = core.StringPtr(id) return _options } -// SetIncludeHistory : Allow user to set IncludeHistory -func (_options *GetServiceIDOptions) SetIncludeHistory(includeHistory bool) *GetServiceIDOptions { - _options.IncludeHistory = core.BoolPtr(includeHistory) - return _options -} - -// SetIncludeActivity : Allow user to set IncludeActivity -func (_options *GetServiceIDOptions) SetIncludeActivity(includeActivity bool) *GetServiceIDOptions { - _options.IncludeActivity = core.BoolPtr(includeActivity) - return _options -} - // SetHeaders : Allow user to set Headers -func (options *GetServiceIDOptions) SetHeaders(param map[string]string) *GetServiceIDOptions { +func (options *LockAPIKeyOptions) SetHeaders(param map[string]string) *LockAPIKeyOptions { options.Headers = param return options } -// IDBasedMfaEnrollment : IDBasedMfaEnrollment struct -type IDBasedMfaEnrollment struct { - // Defines the MFA trait for the account. Valid values: - // * NONE - No MFA trait set - // * NONE_NO_ROPC- No MFA, disable CLI logins with only a password - // * TOTP - For all non-federated IBMId users - // * TOTP4ALL - For all users - // * LEVEL1 - Email-based MFA for all users - // * LEVEL2 - TOTP-based MFA for all users - // * LEVEL3 - U2F MFA for all users. - TraitAccountDefault *string `json:"trait_account_default" validate:"required"` +// LockServiceIDOptions : The LockServiceID options. +type LockServiceIDOptions struct { + // Unique ID of the service ID. + ID *string `json:"id" validate:"required,ne="` - // Defines the MFA trait for the account. Valid values: - // * NONE - No MFA trait set - // * NONE_NO_ROPC- No MFA, disable CLI logins with only a password - // * TOTP - For all non-federated IBMId users - // * TOTP4ALL - For all users - // * LEVEL1 - Email-based MFA for all users - // * LEVEL2 - TOTP-based MFA for all users - // * LEVEL3 - U2F MFA for all users. - TraitUserSpecific *string `json:"trait_user_specific,omitempty"` + // Allows users to set headers on API requests + Headers map[string]string +} - // Defines the MFA trait for the account. Valid values: - // * NONE - No MFA trait set - // * NONE_NO_ROPC- No MFA, disable CLI logins with only a password - // * TOTP - For all non-federated IBMId users - // * TOTP4ALL - For all users - // * LEVEL1 - Email-based MFA for all users - // * LEVEL2 - TOTP-based MFA for all users - // * LEVEL3 - U2F MFA for all users. - TraitEffective *string `json:"trait_effective" validate:"required"` +// NewLockServiceIDOptions : Instantiate LockServiceIDOptions +func (*IamIdentityV1) NewLockServiceIDOptions(id string) *LockServiceIDOptions { + return &LockServiceIDOptions{ + ID: core.StringPtr(id), + } +} - // The enrollment complies to the effective requirement. - Complies *bool `json:"complies" validate:"required"` +// SetID : Allow user to set ID +func (_options *LockServiceIDOptions) SetID(id string) *LockServiceIDOptions { + _options.ID = core.StringPtr(id) + return _options } -// Constants associated with the IDBasedMfaEnrollment.TraitAccountDefault property. -// Defines the MFA trait for the account. Valid values: -// - NONE - No MFA trait set -// - NONE_NO_ROPC- No MFA, disable CLI logins with only a password -// - TOTP - For all non-federated IBMId users -// - TOTP4ALL - For all users -// - LEVEL1 - Email-based MFA for all users -// - LEVEL2 - TOTP-based MFA for all users -// - LEVEL3 - U2F MFA for all users. -const ( - IDBasedMfaEnrollmentTraitAccountDefaultLevel1Const = "LEVEL1" - IDBasedMfaEnrollmentTraitAccountDefaultLevel2Const = "LEVEL2" - IDBasedMfaEnrollmentTraitAccountDefaultLevel3Const = "LEVEL3" - IDBasedMfaEnrollmentTraitAccountDefaultNoneConst = "NONE" - IDBasedMfaEnrollmentTraitAccountDefaultNoneNoRopcConst = "NONE_NO_ROPC" - IDBasedMfaEnrollmentTraitAccountDefaultTotpConst = "TOTP" - IDBasedMfaEnrollmentTraitAccountDefaultTotp4allConst = "TOTP4ALL" -) +// SetHeaders : Allow user to set Headers +func (options *LockServiceIDOptions) SetHeaders(param map[string]string) *LockServiceIDOptions { + options.Headers = param + return options +} -// Constants associated with the IDBasedMfaEnrollment.TraitUserSpecific property. -// Defines the MFA trait for the account. Valid values: -// - NONE - No MFA trait set -// - NONE_NO_ROPC- No MFA, disable CLI logins with only a password -// - TOTP - For all non-federated IBMId users -// - TOTP4ALL - For all users -// - LEVEL1 - Email-based MFA for all users -// - LEVEL2 - TOTP-based MFA for all users -// - LEVEL3 - U2F MFA for all users. -const ( - IDBasedMfaEnrollmentTraitUserSpecificLevel1Const = "LEVEL1" - IDBasedMfaEnrollmentTraitUserSpecificLevel2Const = "LEVEL2" - IDBasedMfaEnrollmentTraitUserSpecificLevel3Const = "LEVEL3" - IDBasedMfaEnrollmentTraitUserSpecificNoneConst = "NONE" - IDBasedMfaEnrollmentTraitUserSpecificNoneNoRopcConst = "NONE_NO_ROPC" - IDBasedMfaEnrollmentTraitUserSpecificTotpConst = "TOTP" - IDBasedMfaEnrollmentTraitUserSpecificTotp4allConst = "TOTP4ALL" -) +// MfaEnrollmentTypeStatus : MfaEnrollmentTypeStatus struct +type MfaEnrollmentTypeStatus struct { + // Describes whether the enrollment type is required. + Required *bool `json:"required" validate:"required"` -// Constants associated with the IDBasedMfaEnrollment.TraitEffective property. -// Defines the MFA trait for the account. Valid values: -// - NONE - No MFA trait set -// - NONE_NO_ROPC- No MFA, disable CLI logins with only a password -// - TOTP - For all non-federated IBMId users -// - TOTP4ALL - For all users -// - LEVEL1 - Email-based MFA for all users -// - LEVEL2 - TOTP-based MFA for all users -// - LEVEL3 - U2F MFA for all users. -const ( - IDBasedMfaEnrollmentTraitEffectiveLevel1Const = "LEVEL1" - IDBasedMfaEnrollmentTraitEffectiveLevel2Const = "LEVEL2" - IDBasedMfaEnrollmentTraitEffectiveLevel3Const = "LEVEL3" - IDBasedMfaEnrollmentTraitEffectiveNoneConst = "NONE" - IDBasedMfaEnrollmentTraitEffectiveNoneNoRopcConst = "NONE_NO_ROPC" - IDBasedMfaEnrollmentTraitEffectiveTotpConst = "TOTP" - IDBasedMfaEnrollmentTraitEffectiveTotp4allConst = "TOTP4ALL" -) + // Describes whether the enrollment type is enrolled. + Enrolled *bool `json:"enrolled" validate:"required"` +} -// UnmarshalIDBasedMfaEnrollment unmarshals an instance of IDBasedMfaEnrollment from the specified map of raw messages. -func UnmarshalIDBasedMfaEnrollment(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(IDBasedMfaEnrollment) - err = core.UnmarshalPrimitive(m, "trait_account_default", &obj.TraitAccountDefault) +// UnmarshalMfaEnrollmentTypeStatus unmarshals an instance of MfaEnrollmentTypeStatus from the specified map of raw messages. +func UnmarshalMfaEnrollmentTypeStatus(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(MfaEnrollmentTypeStatus) + err = core.UnmarshalPrimitive(m, "required", &obj.Required) if err != nil { return } - err = core.UnmarshalPrimitive(m, "trait_user_specific", &obj.TraitUserSpecific) + err = core.UnmarshalPrimitive(m, "enrolled", &obj.Enrolled) if err != nil { return } - err = core.UnmarshalPrimitive(m, "trait_effective", &obj.TraitEffective) + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// MfaEnrollments : MfaEnrollments struct +type MfaEnrollments struct { + // currently effective mfa type i.e. id_based_mfa or account_based_mfa. + EffectiveMfaType *string `json:"effective_mfa_type" validate:"required"` + + IDBasedMfa *IDBasedMfaEnrollment `json:"id_based_mfa,omitempty"` + + AccountBasedMfa *AccountBasedMfaEnrollment `json:"account_based_mfa,omitempty"` +} + +// UnmarshalMfaEnrollments unmarshals an instance of MfaEnrollments from the specified map of raw messages. +func UnmarshalMfaEnrollments(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(MfaEnrollments) + err = core.UnmarshalPrimitive(m, "effective_mfa_type", &obj.EffectiveMfaType) if err != nil { return } - err = core.UnmarshalPrimitive(m, "complies", &obj.Complies) + err = core.UnmarshalModel(m, "id_based_mfa", &obj.IDBasedMfa, UnmarshalIDBasedMfaEnrollment) + if err != nil { + return + } + err = core.UnmarshalModel(m, "account_based_mfa", &obj.AccountBasedMfa, UnmarshalAccountBasedMfaEnrollment) if err != nil { return } @@ -4923,465 +9304,656 @@ func UnmarshalIDBasedMfaEnrollment(m map[string]json.RawMessage, result interfac return } -// ListAPIKeysOptions : The ListAPIKeys options. -type ListAPIKeysOptions struct { - // Account ID of the API keys to query. If a service IAM ID is specified in iam_id then account_id must match the - // account of the IAM ID. If a user IAM ID is specified in iam_id then then account_id must match the account of the - // Authorization token. - AccountID *string `json:"account_id,omitempty"` - - // IAM ID of the API keys to be queried. The IAM ID may be that of a user or a service. For a user IAM ID iam_id must - // match the Authorization token. - IamID *string `json:"iam_id,omitempty"` - - // Optional size of a single page. Default is 20 items per page. Valid range is 1 to 100. - Pagesize *int64 `json:"pagesize,omitempty"` +// PolicyTemplateReference : Metadata for external access policy. +type PolicyTemplateReference struct { + // ID of Access Policy Template. + ID *string `json:"id" validate:"required"` - // Optional Prev or Next page token returned from a previous query execution. Default is start with first page. - Pagetoken *string `json:"pagetoken,omitempty"` + // Version of Access Policy Template. + Version *string `json:"version" validate:"required"` +} - // Optional parameter to define the scope of the queried API keys. Can be 'entity' (default) or 'account'. - Scope *string `json:"scope,omitempty"` +// NewPolicyTemplateReference : Instantiate PolicyTemplateReference (Generic Model Constructor) +func (*IamIdentityV1) NewPolicyTemplateReference(id string, version string) (_model *PolicyTemplateReference, err error) { + _model = &PolicyTemplateReference{ + ID: core.StringPtr(id), + Version: core.StringPtr(version), + } + err = core.ValidateStruct(_model, "required parameters") + return +} - // Optional parameter to filter the type of the queried API keys. Can be 'user' or 'serviceid'. - Type *string `json:"type,omitempty"` +// UnmarshalPolicyTemplateReference unmarshals an instance of PolicyTemplateReference from the specified map of raw messages. +func UnmarshalPolicyTemplateReference(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(PolicyTemplateReference) + err = core.UnmarshalPrimitive(m, "id", &obj.ID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "version", &obj.Version) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} - // Optional sort property, valid values are name, description, created_at and created_by. If specified, the items are - // sorted by the value of this property. - Sort *string `json:"sort,omitempty"` +// ProfileClaimRule : ProfileClaimRule struct +type ProfileClaimRule struct { + // the unique identifier of the claim rule. + ID *string `json:"id" validate:"required"` - // Optional sort order, valid values are asc and desc. Default: asc. - Order *string `json:"order,omitempty"` + // version of the claim rule. + EntityTag *string `json:"entity_tag" validate:"required"` - // Defines if the entity history is included in the response. - IncludeHistory *bool `json:"include_history,omitempty"` + // If set contains a date time string of the creation date in ISO format. + CreatedAt *strfmt.DateTime `json:"created_at" validate:"required"` - // Allows users to set headers on API requests - Headers map[string]string -} + // If set contains a date time string of the last modification date in ISO format. + ModifiedAt *strfmt.DateTime `json:"modified_at,omitempty"` -// Constants associated with the ListAPIKeysOptions.Scope property. -// Optional parameter to define the scope of the queried API keys. Can be 'entity' (default) or 'account'. -const ( - ListAPIKeysOptionsScopeAccountConst = "account" - ListAPIKeysOptionsScopeEntityConst = "entity" -) + // The optional claim rule name. + Name *string `json:"name,omitempty"` -// Constants associated with the ListAPIKeysOptions.Type property. -// Optional parameter to filter the type of the queried API keys. Can be 'user' or 'serviceid'. -const ( - ListAPIKeysOptionsTypeServiceidConst = "serviceid" - ListAPIKeysOptionsTypeUserConst = "user" -) + // Type of the claim rule, either 'Profile-SAML' or 'Profile-CR'. + Type *string `json:"type" validate:"required"` -// Constants associated with the ListAPIKeysOptions.Order property. -// Optional sort order, valid values are asc and desc. Default: asc. -const ( - ListAPIKeysOptionsOrderAscConst = "asc" - ListAPIKeysOptionsOrderDescConst = "desc" -) + // The realm name of the Idp this claim rule applies to. + RealmName *string `json:"realm_name,omitempty"` -// NewListAPIKeysOptions : Instantiate ListAPIKeysOptions -func (*IamIdentityV1) NewListAPIKeysOptions() *ListAPIKeysOptions { - return &ListAPIKeysOptions{} -} + // Session expiration in seconds. + Expiration *int64 `json:"expiration" validate:"required"` -// SetAccountID : Allow user to set AccountID -func (_options *ListAPIKeysOptions) SetAccountID(accountID string) *ListAPIKeysOptions { - _options.AccountID = core.StringPtr(accountID) - return _options -} + // The compute resource type. Not required if type is Profile-SAML. Valid values are VSI, IKS_SA, ROKS_SA. + CrType *string `json:"cr_type,omitempty"` -// SetIamID : Allow user to set IamID -func (_options *ListAPIKeysOptions) SetIamID(iamID string) *ListAPIKeysOptions { - _options.IamID = core.StringPtr(iamID) - return _options + // Conditions of this claim rule. + Conditions []ProfileClaimRuleConditions `json:"conditions" validate:"required"` } -// SetPagesize : Allow user to set Pagesize -func (_options *ListAPIKeysOptions) SetPagesize(pagesize int64) *ListAPIKeysOptions { - _options.Pagesize = core.Int64Ptr(pagesize) - return _options +// UnmarshalProfileClaimRule unmarshals an instance of ProfileClaimRule from the specified map of raw messages. +func UnmarshalProfileClaimRule(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(ProfileClaimRule) + err = core.UnmarshalPrimitive(m, "id", &obj.ID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "entity_tag", &obj.EntityTag) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "created_at", &obj.CreatedAt) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "modified_at", &obj.ModifiedAt) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "name", &obj.Name) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "type", &obj.Type) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "realm_name", &obj.RealmName) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "expiration", &obj.Expiration) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "cr_type", &obj.CrType) + if err != nil { + return + } + err = core.UnmarshalModel(m, "conditions", &obj.Conditions, UnmarshalProfileClaimRuleConditions) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return } -// SetPagetoken : Allow user to set Pagetoken -func (_options *ListAPIKeysOptions) SetPagetoken(pagetoken string) *ListAPIKeysOptions { - _options.Pagetoken = core.StringPtr(pagetoken) - return _options -} +// ProfileClaimRuleConditions : ProfileClaimRuleConditions struct +type ProfileClaimRuleConditions struct { + // The claim to evaluate against. + Claim *string `json:"claim" validate:"required"` -// SetScope : Allow user to set Scope -func (_options *ListAPIKeysOptions) SetScope(scope string) *ListAPIKeysOptions { - _options.Scope = core.StringPtr(scope) - return _options -} + // The operation to perform on the claim. valid values are EQUALS, NOT_EQUALS, EQUALS_IGNORE_CASE, + // NOT_EQUALS_IGNORE_CASE, CONTAINS, IN. + Operator *string `json:"operator" validate:"required"` -// SetType : Allow user to set Type -func (_options *ListAPIKeysOptions) SetType(typeVar string) *ListAPIKeysOptions { - _options.Type = core.StringPtr(typeVar) - return _options + // The stringified JSON value that the claim is compared to using the operator. + Value *string `json:"value" validate:"required"` } -// SetSort : Allow user to set Sort -func (_options *ListAPIKeysOptions) SetSort(sort string) *ListAPIKeysOptions { - _options.Sort = core.StringPtr(sort) - return _options +// NewProfileClaimRuleConditions : Instantiate ProfileClaimRuleConditions (Generic Model Constructor) +func (*IamIdentityV1) NewProfileClaimRuleConditions(claim string, operator string, value string) (_model *ProfileClaimRuleConditions, err error) { + _model = &ProfileClaimRuleConditions{ + Claim: core.StringPtr(claim), + Operator: core.StringPtr(operator), + Value: core.StringPtr(value), + } + err = core.ValidateStruct(_model, "required parameters") + return } -// SetOrder : Allow user to set Order -func (_options *ListAPIKeysOptions) SetOrder(order string) *ListAPIKeysOptions { - _options.Order = core.StringPtr(order) - return _options +// UnmarshalProfileClaimRuleConditions unmarshals an instance of ProfileClaimRuleConditions from the specified map of raw messages. +func UnmarshalProfileClaimRuleConditions(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(ProfileClaimRuleConditions) + err = core.UnmarshalPrimitive(m, "claim", &obj.Claim) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "operator", &obj.Operator) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "value", &obj.Value) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return } -// SetIncludeHistory : Allow user to set IncludeHistory -func (_options *ListAPIKeysOptions) SetIncludeHistory(includeHistory bool) *ListAPIKeysOptions { - _options.IncludeHistory = core.BoolPtr(includeHistory) - return _options +// ProfileClaimRuleList : ProfileClaimRuleList struct +type ProfileClaimRuleList struct { + // Context with key properties for problem determination. + Context *ResponseContext `json:"context,omitempty"` + + // List of claim rules. + Rules []ProfileClaimRule `json:"rules" validate:"required"` } -// SetHeaders : Allow user to set Headers -func (options *ListAPIKeysOptions) SetHeaders(param map[string]string) *ListAPIKeysOptions { - options.Headers = param - return options +// UnmarshalProfileClaimRuleList unmarshals an instance of ProfileClaimRuleList from the specified map of raw messages. +func UnmarshalProfileClaimRuleList(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(ProfileClaimRuleList) + err = core.UnmarshalModel(m, "context", &obj.Context, UnmarshalResponseContext) + if err != nil { + return + } + err = core.UnmarshalModel(m, "rules", &obj.Rules, UnmarshalProfileClaimRule) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return } -// ListClaimRulesOptions : The ListClaimRules options. -type ListClaimRulesOptions struct { - // ID of the trusted profile. - ProfileID *string `json:"profile-id" validate:"required,ne="` +// ProfileIdentitiesResponse : ProfileIdentitiesResponse struct +type ProfileIdentitiesResponse struct { + // Entity tag of the profile identities response. + EntityTag *string `json:"entity_tag,omitempty"` - // Allows users to set headers on API requests - Headers map[string]string + // List of identities. + Identities []ProfileIdentityResponse `json:"identities,omitempty"` } -// NewListClaimRulesOptions : Instantiate ListClaimRulesOptions -func (*IamIdentityV1) NewListClaimRulesOptions(profileID string) *ListClaimRulesOptions { - return &ListClaimRulesOptions{ - ProfileID: core.StringPtr(profileID), +// UnmarshalProfileIdentitiesResponse unmarshals an instance of ProfileIdentitiesResponse from the specified map of raw messages. +func UnmarshalProfileIdentitiesResponse(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(ProfileIdentitiesResponse) + err = core.UnmarshalPrimitive(m, "entity_tag", &obj.EntityTag) + if err != nil { + return + } + err = core.UnmarshalModel(m, "identities", &obj.Identities, UnmarshalProfileIdentityResponse) + if err != nil { + return } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return } -// SetProfileID : Allow user to set ProfileID -func (_options *ListClaimRulesOptions) SetProfileID(profileID string) *ListClaimRulesOptions { - _options.ProfileID = core.StringPtr(profileID) - return _options -} +// ProfileIdentityRequest : ProfileIdentityRequest struct +type ProfileIdentityRequest struct { + // Identifier of the identity that can assume the trusted profiles. This can be a user identifier (IAM id), serviceid + // or crn. Internally it uses account id of the service id for the identifier 'serviceid' and for the identifier 'crn' + // it uses account id contained in the CRN. + Identifier *string `json:"identifier" validate:"required"` -// SetHeaders : Allow user to set Headers -func (options *ListClaimRulesOptions) SetHeaders(param map[string]string) *ListClaimRulesOptions { - options.Headers = param - return options -} + // Type of the identity. + Type *string `json:"type" validate:"required"` -// ListLinksOptions : The ListLinks options. -type ListLinksOptions struct { - // ID of the trusted profile. - ProfileID *string `json:"profile-id" validate:"required,ne="` + // Only valid for the type user. Accounts from which a user can assume the trusted profile. + Accounts []string `json:"accounts,omitempty"` - // Allows users to set headers on API requests - Headers map[string]string + // Description of the identity that can assume the trusted profile. This is optional field for all the types of + // identities. When this field is not set for the identity type 'serviceid' then the description of the service id is + // used. Description is recommended for the identity type 'crn' E.g. 'Instance 1234 of IBM Cloud Service project'. + Description *string `json:"description,omitempty"` } -// NewListLinksOptions : Instantiate ListLinksOptions -func (*IamIdentityV1) NewListLinksOptions(profileID string) *ListLinksOptions { - return &ListLinksOptions{ - ProfileID: core.StringPtr(profileID), - } -} +// Constants associated with the ProfileIdentityRequest.Type property. +// Type of the identity. +const ( + ProfileIdentityRequestTypeCRNConst = "crn" + ProfileIdentityRequestTypeServiceidConst = "serviceid" + ProfileIdentityRequestTypeUserConst = "user" +) -// SetProfileID : Allow user to set ProfileID -func (_options *ListLinksOptions) SetProfileID(profileID string) *ListLinksOptions { - _options.ProfileID = core.StringPtr(profileID) - return _options +// NewProfileIdentityRequest : Instantiate ProfileIdentityRequest (Generic Model Constructor) +func (*IamIdentityV1) NewProfileIdentityRequest(identifier string, typeVar string) (_model *ProfileIdentityRequest, err error) { + _model = &ProfileIdentityRequest{ + Identifier: core.StringPtr(identifier), + Type: core.StringPtr(typeVar), + } + err = core.ValidateStruct(_model, "required parameters") + return } -// SetHeaders : Allow user to set Headers -func (options *ListLinksOptions) SetHeaders(param map[string]string) *ListLinksOptions { - options.Headers = param - return options +// UnmarshalProfileIdentityRequest unmarshals an instance of ProfileIdentityRequest from the specified map of raw messages. +func UnmarshalProfileIdentityRequest(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(ProfileIdentityRequest) + err = core.UnmarshalPrimitive(m, "identifier", &obj.Identifier) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "type", &obj.Type) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "accounts", &obj.Accounts) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "description", &obj.Description) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return } -// ListProfilesOptions : The ListProfiles options. -type ListProfilesOptions struct { - // Account ID to query for trusted profiles. - AccountID *string `json:"account_id" validate:"required"` - - // Name of the trusted profile to query. - Name *string `json:"name,omitempty"` - - // Optional size of a single page. Default is 20 items per page. Valid range is 1 to 100. - Pagesize *int64 `json:"pagesize,omitempty"` - - // Optional sort property, valid values are name, description, created_at and modified_at. If specified, the items are - // sorted by the value of this property. - Sort *string `json:"sort,omitempty"` +// ProfileIdentityResponse : ProfileIdentityResponse struct +type ProfileIdentityResponse struct { + // IAM ID of the identity. + IamID *string `json:"iam_id" validate:"required"` - // Optional sort order, valid values are asc and desc. Default: asc. - Order *string `json:"order,omitempty"` + // Identifier of the identity that can assume the trusted profiles. This can be a user identifier (IAM id), serviceid + // or crn. Internally it uses account id of the service id for the identifier 'serviceid' and for the identifier 'crn' + // it uses account id contained in the CRN. + Identifier *string `json:"identifier" validate:"required"` - // Defines if the entity history is included in the response. - IncludeHistory *bool `json:"include_history,omitempty"` + // Type of the identity. + Type *string `json:"type" validate:"required"` - // Optional Prev or Next page token returned from a previous query execution. Default is start with first page. - Pagetoken *string `json:"pagetoken,omitempty"` + // Only valid for the type user. Accounts from which a user can assume the trusted profile. + Accounts []string `json:"accounts,omitempty"` - // Allows users to set headers on API requests - Headers map[string]string + // Description of the identity that can assume the trusted profile. This is optional field for all the types of + // identities. When this field is not set for the identity type 'serviceid' then the description of the service id is + // used. Description is recommended for the identity type 'crn' E.g. 'Instance 1234 of IBM Cloud Service project'. + Description *string `json:"description,omitempty"` } -// Constants associated with the ListProfilesOptions.Order property. -// Optional sort order, valid values are asc and desc. Default: asc. +// Constants associated with the ProfileIdentityResponse.Type property. +// Type of the identity. const ( - ListProfilesOptionsOrderAscConst = "asc" - ListProfilesOptionsOrderDescConst = "desc" + ProfileIdentityResponseTypeCRNConst = "crn" + ProfileIdentityResponseTypeServiceidConst = "serviceid" + ProfileIdentityResponseTypeUserConst = "user" ) -// NewListProfilesOptions : Instantiate ListProfilesOptions -func (*IamIdentityV1) NewListProfilesOptions(accountID string) *ListProfilesOptions { - return &ListProfilesOptions{ - AccountID: core.StringPtr(accountID), +// UnmarshalProfileIdentityResponse unmarshals an instance of ProfileIdentityResponse from the specified map of raw messages. +func UnmarshalProfileIdentityResponse(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(ProfileIdentityResponse) + err = core.UnmarshalPrimitive(m, "iam_id", &obj.IamID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "identifier", &obj.Identifier) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "type", &obj.Type) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "accounts", &obj.Accounts) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "description", &obj.Description) + if err != nil { + return } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return } -// SetAccountID : Allow user to set AccountID -func (_options *ListProfilesOptions) SetAccountID(accountID string) *ListProfilesOptions { - _options.AccountID = core.StringPtr(accountID) - return _options -} +// ProfileLink : Link details. +type ProfileLink struct { + // the unique identifier of the link. + ID *string `json:"id" validate:"required"` -// SetName : Allow user to set Name -func (_options *ListProfilesOptions) SetName(name string) *ListProfilesOptions { - _options.Name = core.StringPtr(name) - return _options -} + // version of the link. + EntityTag *string `json:"entity_tag" validate:"required"` -// SetPagesize : Allow user to set Pagesize -func (_options *ListProfilesOptions) SetPagesize(pagesize int64) *ListProfilesOptions { - _options.Pagesize = core.Int64Ptr(pagesize) - return _options + // If set contains a date time string of the creation date in ISO format. + CreatedAt *strfmt.DateTime `json:"created_at" validate:"required"` + + // If set contains a date time string of the last modification date in ISO format. + ModifiedAt *strfmt.DateTime `json:"modified_at" validate:"required"` + + // Optional name of the Link. + Name *string `json:"name,omitempty"` + + // The compute resource type. Valid values are VSI, IKS_SA, ROKS_SA. + CrType *string `json:"cr_type" validate:"required"` + + Link *ProfileLinkLink `json:"link" validate:"required"` } -// SetSort : Allow user to set Sort -func (_options *ListProfilesOptions) SetSort(sort string) *ListProfilesOptions { - _options.Sort = core.StringPtr(sort) - return _options +// UnmarshalProfileLink unmarshals an instance of ProfileLink from the specified map of raw messages. +func UnmarshalProfileLink(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(ProfileLink) + err = core.UnmarshalPrimitive(m, "id", &obj.ID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "entity_tag", &obj.EntityTag) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "created_at", &obj.CreatedAt) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "modified_at", &obj.ModifiedAt) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "name", &obj.Name) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "cr_type", &obj.CrType) + if err != nil { + return + } + err = core.UnmarshalModel(m, "link", &obj.Link, UnmarshalProfileLinkLink) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return } -// SetOrder : Allow user to set Order -func (_options *ListProfilesOptions) SetOrder(order string) *ListProfilesOptions { - _options.Order = core.StringPtr(order) - return _options -} +// ProfileLinkLink : ProfileLinkLink struct +type ProfileLinkLink struct { + // The CRN of the compute resource. + CRN *string `json:"crn,omitempty"` -// SetIncludeHistory : Allow user to set IncludeHistory -func (_options *ListProfilesOptions) SetIncludeHistory(includeHistory bool) *ListProfilesOptions { - _options.IncludeHistory = core.BoolPtr(includeHistory) - return _options + // The compute resource namespace, only required if cr_type is IKS_SA or ROKS_SA. + Namespace *string `json:"namespace,omitempty"` + + // Name of the compute resource, only required if cr_type is IKS_SA or ROKS_SA. + Name *string `json:"name,omitempty"` } -// SetPagetoken : Allow user to set Pagetoken -func (_options *ListProfilesOptions) SetPagetoken(pagetoken string) *ListProfilesOptions { - _options.Pagetoken = core.StringPtr(pagetoken) - return _options +// UnmarshalProfileLinkLink unmarshals an instance of ProfileLinkLink from the specified map of raw messages. +func UnmarshalProfileLinkLink(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(ProfileLinkLink) + err = core.UnmarshalPrimitive(m, "crn", &obj.CRN) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "namespace", &obj.Namespace) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "name", &obj.Name) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return } -// SetHeaders : Allow user to set Headers -func (options *ListProfilesOptions) SetHeaders(param map[string]string) *ListProfilesOptions { - options.Headers = param - return options +// ProfileLinkList : ProfileLinkList struct +type ProfileLinkList struct { + // List of links to a trusted profile. + Links []ProfileLink `json:"links" validate:"required"` } -// ListServiceIdsOptions : The ListServiceIds options. -type ListServiceIdsOptions struct { - // Account ID of the service ID(s) to query. This parameter is required (unless using a pagetoken). - AccountID *string `json:"account_id,omitempty"` +// UnmarshalProfileLinkList unmarshals an instance of ProfileLinkList from the specified map of raw messages. +func UnmarshalProfileLinkList(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(ProfileLinkList) + err = core.UnmarshalModel(m, "links", &obj.Links, UnmarshalProfileLink) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} - // Name of the service ID(s) to query. Optional.20 items per page. Valid range is 1 to 100. - Name *string `json:"name,omitempty"` +// Report : Report struct +type Report struct { + // IAMid of the user who triggered the report. + CreatedBy *string `json:"created_by" validate:"required"` - // Optional size of a single page. Default is 20 items per page. Valid range is 1 to 100. - Pagesize *int64 `json:"pagesize,omitempty"` + // Unique reference used to generate the report. + Reference *string `json:"reference" validate:"required"` - // Optional Prev or Next page token returned from a previous query execution. Default is start with first page. - Pagetoken *string `json:"pagetoken,omitempty"` + // Duration in hours for which the report is generated. + ReportDuration *string `json:"report_duration" validate:"required"` - // Optional sort property, valid values are name, description, created_at and modified_at. If specified, the items are - // sorted by the value of this property. - Sort *string `json:"sort,omitempty"` + // Start time of the report. + ReportStartTime *string `json:"report_start_time" validate:"required"` - // Optional sort order, valid values are asc and desc. Default: asc. - Order *string `json:"order,omitempty"` + // End time of the report. + ReportEndTime *string `json:"report_end_time" validate:"required"` - // Defines if the entity history is included in the response. - IncludeHistory *bool `json:"include_history,omitempty"` + // List of users. + Users []UserActivity `json:"users,omitempty"` - // Allows users to set headers on API requests - Headers map[string]string -} + // List of apikeys. + Apikeys []ApikeyActivity `json:"apikeys,omitempty"` -// Constants associated with the ListServiceIdsOptions.Order property. -// Optional sort order, valid values are asc and desc. Default: asc. -const ( - ListServiceIdsOptionsOrderAscConst = "asc" - ListServiceIdsOptionsOrderDescConst = "desc" -) + // List of serviceids. + Serviceids []EntityActivity `json:"serviceids,omitempty"` -// NewListServiceIdsOptions : Instantiate ListServiceIdsOptions -func (*IamIdentityV1) NewListServiceIdsOptions() *ListServiceIdsOptions { - return &ListServiceIdsOptions{} + // List of profiles. + Profiles []EntityActivity `json:"profiles,omitempty"` } -// SetAccountID : Allow user to set AccountID -func (_options *ListServiceIdsOptions) SetAccountID(accountID string) *ListServiceIdsOptions { - _options.AccountID = core.StringPtr(accountID) - return _options +// UnmarshalReport unmarshals an instance of Report from the specified map of raw messages. +func UnmarshalReport(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(Report) + err = core.UnmarshalPrimitive(m, "created_by", &obj.CreatedBy) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "reference", &obj.Reference) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "report_duration", &obj.ReportDuration) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "report_start_time", &obj.ReportStartTime) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "report_end_time", &obj.ReportEndTime) + if err != nil { + return + } + err = core.UnmarshalModel(m, "users", &obj.Users, UnmarshalUserActivity) + if err != nil { + return + } + err = core.UnmarshalModel(m, "apikeys", &obj.Apikeys, UnmarshalApikeyActivity) + if err != nil { + return + } + err = core.UnmarshalModel(m, "serviceids", &obj.Serviceids, UnmarshalEntityActivity) + if err != nil { + return + } + err = core.UnmarshalModel(m, "profiles", &obj.Profiles, UnmarshalEntityActivity) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return } -// SetName : Allow user to set Name -func (_options *ListServiceIdsOptions) SetName(name string) *ListServiceIdsOptions { - _options.Name = core.StringPtr(name) - return _options -} +// ReportMfaEnrollmentStatus : ReportMfaEnrollmentStatus struct +type ReportMfaEnrollmentStatus struct { + // IAMid of the user who triggered the report. + CreatedBy *string `json:"created_by" validate:"required"` -// SetPagesize : Allow user to set Pagesize -func (_options *ListServiceIdsOptions) SetPagesize(pagesize int64) *ListServiceIdsOptions { - _options.Pagesize = core.Int64Ptr(pagesize) - return _options -} + // Unique reference used to generate the report. + Reference *string `json:"reference" validate:"required"` -// SetPagetoken : Allow user to set Pagetoken -func (_options *ListServiceIdsOptions) SetPagetoken(pagetoken string) *ListServiceIdsOptions { - _options.Pagetoken = core.StringPtr(pagetoken) - return _options -} + // Date time at which report is generated. Date is in ISO format. + ReportTime *string `json:"report_time" validate:"required"` -// SetSort : Allow user to set Sort -func (_options *ListServiceIdsOptions) SetSort(sort string) *ListServiceIdsOptions { - _options.Sort = core.StringPtr(sort) - return _options -} + // BSS account id of the user who triggered the report. + AccountID *string `json:"account_id" validate:"required"` -// SetOrder : Allow user to set Order -func (_options *ListServiceIdsOptions) SetOrder(order string) *ListServiceIdsOptions { - _options.Order = core.StringPtr(order) - return _options -} + // IMS account id of the user who triggered the report. + ImsAccountID *string `json:"ims_account_id,omitempty"` -// SetIncludeHistory : Allow user to set IncludeHistory -func (_options *ListServiceIdsOptions) SetIncludeHistory(includeHistory bool) *ListServiceIdsOptions { - _options.IncludeHistory = core.BoolPtr(includeHistory) - return _options + // List of users. + Users []UserReportMfaEnrollmentStatus `json:"users,omitempty"` } -// SetHeaders : Allow user to set Headers -func (options *ListServiceIdsOptions) SetHeaders(param map[string]string) *ListServiceIdsOptions { - options.Headers = param - return options +// UnmarshalReportMfaEnrollmentStatus unmarshals an instance of ReportMfaEnrollmentStatus from the specified map of raw messages. +func UnmarshalReportMfaEnrollmentStatus(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(ReportMfaEnrollmentStatus) + err = core.UnmarshalPrimitive(m, "created_by", &obj.CreatedBy) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "reference", &obj.Reference) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "report_time", &obj.ReportTime) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "account_id", &obj.AccountID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "ims_account_id", &obj.ImsAccountID) + if err != nil { + return + } + err = core.UnmarshalModel(m, "users", &obj.Users, UnmarshalUserReportMfaEnrollmentStatus) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return } -// LockAPIKeyOptions : The LockAPIKey options. -type LockAPIKeyOptions struct { - // Unique ID of the API key. - ID *string `json:"id" validate:"required,ne="` - - // Allows users to set headers on API requests - Headers map[string]string +// ReportReference : ReportReference struct +type ReportReference struct { + // Reference for the report to be generated. + Reference *string `json:"reference" validate:"required"` } -// NewLockAPIKeyOptions : Instantiate LockAPIKeyOptions -func (*IamIdentityV1) NewLockAPIKeyOptions(id string) *LockAPIKeyOptions { - return &LockAPIKeyOptions{ - ID: core.StringPtr(id), +// UnmarshalReportReference unmarshals an instance of ReportReference from the specified map of raw messages. +func UnmarshalReportReference(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(ReportReference) + err = core.UnmarshalPrimitive(m, "reference", &obj.Reference) + if err != nil { + return } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return } -// SetID : Allow user to set ID -func (_options *LockAPIKeyOptions) SetID(id string) *LockAPIKeyOptions { - _options.ID = core.StringPtr(id) - return _options -} +// ResponseContext : Context with key properties for problem determination. +type ResponseContext struct { + // The transaction ID of the inbound REST request. + TransactionID *string `json:"transaction_id,omitempty"` + + // The operation of the inbound REST request. + Operation *string `json:"operation,omitempty"` + + // The user agent of the inbound REST request. + UserAgent *string `json:"user_agent,omitempty"` -// SetHeaders : Allow user to set Headers -func (options *LockAPIKeyOptions) SetHeaders(param map[string]string) *LockAPIKeyOptions { - options.Headers = param - return options -} + // The URL of that cluster. + URL *string `json:"url,omitempty"` -// LockServiceIDOptions : The LockServiceID options. -type LockServiceIDOptions struct { - // Unique ID of the service ID. - ID *string `json:"id" validate:"required,ne="` + // The instance ID of the server instance processing the request. + InstanceID *string `json:"instance_id,omitempty"` - // Allows users to set headers on API requests - Headers map[string]string -} + // The thread ID of the server instance processing the request. + ThreadID *string `json:"thread_id,omitempty"` -// NewLockServiceIDOptions : Instantiate LockServiceIDOptions -func (*IamIdentityV1) NewLockServiceIDOptions(id string) *LockServiceIDOptions { - return &LockServiceIDOptions{ - ID: core.StringPtr(id), - } -} + // The host of the server instance processing the request. + Host *string `json:"host,omitempty"` -// SetID : Allow user to set ID -func (_options *LockServiceIDOptions) SetID(id string) *LockServiceIDOptions { - _options.ID = core.StringPtr(id) - return _options -} + // The start time of the request. + StartTime *string `json:"start_time,omitempty"` -// SetHeaders : Allow user to set Headers -func (options *LockServiceIDOptions) SetHeaders(param map[string]string) *LockServiceIDOptions { - options.Headers = param - return options -} + // The finish time of the request. + EndTime *string `json:"end_time,omitempty"` -// MfaEnrollmentTypeStatus : MfaEnrollmentTypeStatus struct -type MfaEnrollmentTypeStatus struct { - // Describes whether the enrollment type is required. - Required *bool `json:"required" validate:"required"` + // The elapsed time in msec. + ElapsedTime *string `json:"elapsed_time,omitempty"` - // Describes whether the enrollment type is enrolled. - Enrolled *bool `json:"enrolled" validate:"required"` + // The cluster name. + ClusterName *string `json:"cluster_name,omitempty"` } -// UnmarshalMfaEnrollmentTypeStatus unmarshals an instance of MfaEnrollmentTypeStatus from the specified map of raw messages. -func UnmarshalMfaEnrollmentTypeStatus(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(MfaEnrollmentTypeStatus) - err = core.UnmarshalPrimitive(m, "required", &obj.Required) +// UnmarshalResponseContext unmarshals an instance of ResponseContext from the specified map of raw messages. +func UnmarshalResponseContext(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(ResponseContext) + err = core.UnmarshalPrimitive(m, "transaction_id", &obj.TransactionID) if err != nil { return } - err = core.UnmarshalPrimitive(m, "enrolled", &obj.Enrolled) + err = core.UnmarshalPrimitive(m, "operation", &obj.Operation) if err != nil { return } - reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) - return -} - -// MfaEnrollments : MfaEnrollments struct -type MfaEnrollments struct { - // currently effective mfa type i.e. id_based_mfa or account_based_mfa. - EffectiveMfaType *string `json:"effective_mfa_type" validate:"required"` - - IDBasedMfa *IDBasedMfaEnrollment `json:"id_based_mfa,omitempty"` - - AccountBasedMfa *AccountBasedMfaEnrollment `json:"account_based_mfa,omitempty"` -} - -// UnmarshalMfaEnrollments unmarshals an instance of MfaEnrollments from the specified map of raw messages. -func UnmarshalMfaEnrollments(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(MfaEnrollments) - err = core.UnmarshalPrimitive(m, "effective_mfa_type", &obj.EffectiveMfaType) + err = core.UnmarshalPrimitive(m, "user_agent", &obj.UserAgent) if err != nil { return } - err = core.UnmarshalModel(m, "id_based_mfa", &obj.IDBasedMfa, UnmarshalIDBasedMfaEnrollment) + err = core.UnmarshalPrimitive(m, "url", &obj.URL) if err != nil { return } - err = core.UnmarshalModel(m, "account_based_mfa", &obj.AccountBasedMfa, UnmarshalAccountBasedMfaEnrollment) + err = core.UnmarshalPrimitive(m, "instance_id", &obj.InstanceID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "thread_id", &obj.ThreadID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "host", &obj.Host) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "start_time", &obj.StartTime) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "end_time", &obj.EndTime) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "elapsed_time", &obj.ElapsedTime) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "cluster_name", &obj.ClusterName) if err != nil { return } @@ -5389,50 +9961,84 @@ func UnmarshalMfaEnrollments(m map[string]json.RawMessage, result interface{}) ( return } -// ProfileClaimRule : ProfileClaimRule struct -type ProfileClaimRule struct { - // the unique identifier of the claim rule. +// ServiceID : Response body format for service ID V1 REST requests. +type ServiceID struct { + // Context with key properties for problem determination. + Context *ResponseContext `json:"context,omitempty"` + + // Unique identifier of this Service Id. ID *string `json:"id" validate:"required"` - // version of the claim rule. + // Cloud wide identifier for identities of this service ID. + IamID *string `json:"iam_id" validate:"required"` + + // Version of the service ID details object. You need to specify this value when updating the service ID to avoid stale + // updates. EntityTag *string `json:"entity_tag" validate:"required"` + // Cloud Resource Name of the item. Example Cloud Resource Name: + // 'crn:v1:bluemix:public:iam-identity:us-south:a/myaccount::serviceid:1234-5678-9012'. + CRN *string `json:"crn" validate:"required"` + + // The service ID cannot be changed if set to true. + Locked *bool `json:"locked" validate:"required"` + // If set contains a date time string of the creation date in ISO format. CreatedAt *strfmt.DateTime `json:"created_at" validate:"required"` // If set contains a date time string of the last modification date in ISO format. - ModifiedAt *strfmt.DateTime `json:"modified_at,omitempty"` + ModifiedAt *strfmt.DateTime `json:"modified_at" validate:"required"` - // The optional claim rule name. - Name *string `json:"name,omitempty"` + // ID of the account the service ID belongs to. + AccountID *string `json:"account_id" validate:"required"` - // Type of the claim rule, either 'Profile-SAML' or 'Profile-CR'. - Type *string `json:"type" validate:"required"` + // Name of the Service Id. The name is not checked for uniqueness. Therefore multiple names with the same value can + // exist. Access is done via the UUID of the Service Id. + Name *string `json:"name" validate:"required"` - // The realm name of the Idp this claim rule applies to. - RealmName *string `json:"realm_name,omitempty"` + // The optional description of the Service Id. The 'description' property is only available if a description was + // provided during a create of a Service Id. + Description *string `json:"description,omitempty"` - // Session expiration in seconds. - Expiration *int64 `json:"expiration" validate:"required"` + // Optional list of CRNs (string array) which point to the services connected to the service ID. + UniqueInstanceCrns []string `json:"unique_instance_crns,omitempty"` - // The compute resource type. Not required if type is Profile-SAML. Valid values are VSI, IKS_SA, ROKS_SA. - CrType *string `json:"cr_type,omitempty"` + // History of the Service ID. + History []EnityHistoryRecord `json:"history,omitempty"` - // Conditions of this claim rule. - Conditions []ProfileClaimRuleConditions `json:"conditions" validate:"required"` + // Response body format for API key V1 REST requests. + Apikey *APIKey `json:"apikey,omitempty"` + + Activity *Activity `json:"activity,omitempty"` } -// UnmarshalProfileClaimRule unmarshals an instance of ProfileClaimRule from the specified map of raw messages. -func UnmarshalProfileClaimRule(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(ProfileClaimRule) +// UnmarshalServiceID unmarshals an instance of ServiceID from the specified map of raw messages. +func UnmarshalServiceID(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(ServiceID) + err = core.UnmarshalModel(m, "context", &obj.Context, UnmarshalResponseContext) + if err != nil { + return + } err = core.UnmarshalPrimitive(m, "id", &obj.ID) if err != nil { return } + err = core.UnmarshalPrimitive(m, "iam_id", &obj.IamID) + if err != nil { + return + } err = core.UnmarshalPrimitive(m, "entity_tag", &obj.EntityTag) if err != nil { return } + err = core.UnmarshalPrimitive(m, "crn", &obj.CRN) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "locked", &obj.Locked) + if err != nil { + return + } err = core.UnmarshalPrimitive(m, "created_at", &obj.CreatedAt) if err != nil { return @@ -5441,27 +10047,92 @@ func UnmarshalProfileClaimRule(m map[string]json.RawMessage, result interface{}) if err != nil { return } + err = core.UnmarshalPrimitive(m, "account_id", &obj.AccountID) + if err != nil { + return + } err = core.UnmarshalPrimitive(m, "name", &obj.Name) if err != nil { return } - err = core.UnmarshalPrimitive(m, "type", &obj.Type) + err = core.UnmarshalPrimitive(m, "description", &obj.Description) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "unique_instance_crns", &obj.UniqueInstanceCrns) + if err != nil { + return + } + err = core.UnmarshalModel(m, "history", &obj.History, UnmarshalEnityHistoryRecord) + if err != nil { + return + } + err = core.UnmarshalModel(m, "apikey", &obj.Apikey, UnmarshalAPIKey) + if err != nil { + return + } + err = core.UnmarshalModel(m, "activity", &obj.Activity, UnmarshalActivity) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// ServiceIDList : Response body format for the list service ID V1 REST request. +type ServiceIDList struct { + // Context with key properties for problem determination. + Context *ResponseContext `json:"context,omitempty"` + + // The offset of the current page. + Offset *int64 `json:"offset,omitempty"` + + // Optional size of a single page. Default is 20 items per page. Valid range is 1 to 100. + Limit *int64 `json:"limit,omitempty"` + + // Link to the first page. + First *string `json:"first,omitempty"` + + // Link to the previous available page. If 'previous' property is not part of the response no previous page is + // available. + Previous *string `json:"previous,omitempty"` + + // Link to the next available page. If 'next' property is not part of the response no next page is available. + Next *string `json:"next,omitempty"` + + // List of service IDs based on the query paramters and the page size. The service IDs array is always part of the + // response but might be empty depending on the query parameter values provided. + Serviceids []ServiceID `json:"serviceids" validate:"required"` +} + +// UnmarshalServiceIDList unmarshals an instance of ServiceIDList from the specified map of raw messages. +func UnmarshalServiceIDList(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(ServiceIDList) + err = core.UnmarshalModel(m, "context", &obj.Context, UnmarshalResponseContext) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "offset", &obj.Offset) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "limit", &obj.Limit) if err != nil { return } - err = core.UnmarshalPrimitive(m, "realm_name", &obj.RealmName) + err = core.UnmarshalPrimitive(m, "first", &obj.First) if err != nil { return } - err = core.UnmarshalPrimitive(m, "expiration", &obj.Expiration) + err = core.UnmarshalPrimitive(m, "previous", &obj.Previous) if err != nil { return } - err = core.UnmarshalPrimitive(m, "cr_type", &obj.CrType) + err = core.UnmarshalPrimitive(m, "next", &obj.Next) if err != nil { return } - err = core.UnmarshalModel(m, "conditions", &obj.Conditions, UnmarshalProfileClaimRuleConditions) + err = core.UnmarshalModel(m, "serviceids", &obj.Serviceids, UnmarshalServiceID) if err != nil { return } @@ -5469,102 +10140,62 @@ func UnmarshalProfileClaimRule(m map[string]json.RawMessage, result interface{}) return } -// ProfileClaimRuleConditions : ProfileClaimRuleConditions struct -type ProfileClaimRuleConditions struct { - // The claim to evaluate against. [Learn - // more](/docs/account?topic=account-iam-condition-properties&interface=ui#cr-attribute-names). - Claim *string `json:"claim" validate:"required"` +// SetProfileIdentitiesOptions : The SetProfileIdentities options. +type SetProfileIdentitiesOptions struct { + // ID of the trusted profile. + ProfileID *string `json:"profile-id" validate:"required,ne="` - // The operation to perform on the claim. valid values are EQUALS, NOT_EQUALS, EQUALS_IGNORE_CASE, - // NOT_EQUALS_IGNORE_CASE, CONTAINS, IN. - Operator *string `json:"operator" validate:"required"` + // Entity tag of the Identities to be updated. Specify the tag that you retrieved when reading the Profile Identities. + // This value helps identify parallel usage of this API. Pass * to indicate updating any available version, which may + // result in stale updates. + IfMatch *string `json:"If-Match" validate:"required"` - // The stringified JSON value that the claim is compared to using the operator. - Value *string `json:"value" validate:"required"` -} + // List of identities that can assume the trusted profile. + Identities []ProfileIdentityRequest `json:"identities,omitempty"` -// NewProfileClaimRuleConditions : Instantiate ProfileClaimRuleConditions (Generic Model Constructor) -func (*IamIdentityV1) NewProfileClaimRuleConditions(claim string, operator string, value string) (_model *ProfileClaimRuleConditions, err error) { - _model = &ProfileClaimRuleConditions{ - Claim: core.StringPtr(claim), - Operator: core.StringPtr(operator), - Value: core.StringPtr(value), - } - err = core.ValidateStruct(_model, "required parameters") - return + // Allows users to set headers on API requests + Headers map[string]string } -// UnmarshalProfileClaimRuleConditions unmarshals an instance of ProfileClaimRuleConditions from the specified map of raw messages. -func UnmarshalProfileClaimRuleConditions(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(ProfileClaimRuleConditions) - err = core.UnmarshalPrimitive(m, "claim", &obj.Claim) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "operator", &obj.Operator) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "value", &obj.Value) - if err != nil { - return +// NewSetProfileIdentitiesOptions : Instantiate SetProfileIdentitiesOptions +func (*IamIdentityV1) NewSetProfileIdentitiesOptions(profileID string, ifMatch string) *SetProfileIdentitiesOptions { + return &SetProfileIdentitiesOptions{ + ProfileID: core.StringPtr(profileID), + IfMatch: core.StringPtr(ifMatch), } - reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) - return } -// ProfileClaimRuleList : ProfileClaimRuleList struct -type ProfileClaimRuleList struct { - // Context with key properties for problem determination. - Context *ResponseContext `json:"context,omitempty"` - - // List of claim rules. - Rules []ProfileClaimRule `json:"rules" validate:"required"` +// SetProfileID : Allow user to set ProfileID +func (_options *SetProfileIdentitiesOptions) SetProfileID(profileID string) *SetProfileIdentitiesOptions { + _options.ProfileID = core.StringPtr(profileID) + return _options } -// UnmarshalProfileClaimRuleList unmarshals an instance of ProfileClaimRuleList from the specified map of raw messages. -func UnmarshalProfileClaimRuleList(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(ProfileClaimRuleList) - err = core.UnmarshalModel(m, "context", &obj.Context, UnmarshalResponseContext) - if err != nil { - return - } - err = core.UnmarshalModel(m, "rules", &obj.Rules, UnmarshalProfileClaimRule) - if err != nil { - return - } - reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) - return +// SetIfMatch : Allow user to set IfMatch +func (_options *SetProfileIdentitiesOptions) SetIfMatch(ifMatch string) *SetProfileIdentitiesOptions { + _options.IfMatch = core.StringPtr(ifMatch) + return _options } -// ProfileIdentitiesResponse : ProfileIdentitiesResponse struct -type ProfileIdentitiesResponse struct { - // Entity tag of the profile identities response. - EntityTag *string `json:"entity_tag,omitempty"` - - // List of identities. - Identities []ProfileIdentity `json:"identities,omitempty"` +// SetIdentities : Allow user to set Identities +func (_options *SetProfileIdentitiesOptions) SetIdentities(identities []ProfileIdentityRequest) *SetProfileIdentitiesOptions { + _options.Identities = identities + return _options } -// UnmarshalProfileIdentitiesResponse unmarshals an instance of ProfileIdentitiesResponse from the specified map of raw messages. -func UnmarshalProfileIdentitiesResponse(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(ProfileIdentitiesResponse) - err = core.UnmarshalPrimitive(m, "entity_tag", &obj.EntityTag) - if err != nil { - return - } - err = core.UnmarshalModel(m, "identities", &obj.Identities, UnmarshalProfileIdentity) - if err != nil { - return - } - reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) - return +// SetHeaders : Allow user to set Headers +func (options *SetProfileIdentitiesOptions) SetHeaders(param map[string]string) *SetProfileIdentitiesOptions { + options.Headers = param + return options } -// ProfileIdentity : ProfileIdentity struct -type ProfileIdentity struct { - // IAM ID of the identity. - IamID *string `json:"iam_id,omitempty"` +// SetProfileIdentityOptions : The SetProfileIdentity options. +type SetProfileIdentityOptions struct { + // ID of the trusted profile. + ProfileID *string `json:"profile-id" validate:"required,ne="` + + // Type of the identity. + IdentityType *string `json:"identity-type" validate:"required,ne="` // Identifier of the identity that can assume the trusted profiles. This can be a user identifier (IAM id), serviceid // or crn. Internally it uses account id of the service id for the identifier 'serviceid' and for the identifier 'crn' @@ -5581,104 +10212,150 @@ type ProfileIdentity struct { // identities. When this field is not set for the identity type 'serviceid' then the description of the service id is // used. Description is recommended for the identity type 'crn' E.g. 'Instance 1234 of IBM Cloud Service project'. Description *string `json:"description,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string } -// Constants associated with the ProfileIdentity.Type property. +// Constants associated with the SetProfileIdentityOptions.IdentityType property. +// Type of the identity. +const ( + SetProfileIdentityOptionsIdentityTypeCRNConst = "crn" + SetProfileIdentityOptionsIdentityTypeServiceidConst = "serviceid" + SetProfileIdentityOptionsIdentityTypeUserConst = "user" +) + +// Constants associated with the SetProfileIdentityOptions.Type property. // Type of the identity. const ( - ProfileIdentityTypeCRNConst = "crn" - ProfileIdentityTypeServiceidConst = "serviceid" - ProfileIdentityTypeUserConst = "user" + SetProfileIdentityOptionsTypeCRNConst = "crn" + SetProfileIdentityOptionsTypeServiceidConst = "serviceid" + SetProfileIdentityOptionsTypeUserConst = "user" ) -// NewProfileIdentity : Instantiate ProfileIdentity (Generic Model Constructor) -func (*IamIdentityV1) NewProfileIdentity(identifier string, typeVar string) (_model *ProfileIdentity, err error) { - _model = &ProfileIdentity{ +// NewSetProfileIdentityOptions : Instantiate SetProfileIdentityOptions +func (*IamIdentityV1) NewSetProfileIdentityOptions(profileID string, identityType string, identifier string, typeVar string) *SetProfileIdentityOptions { + return &SetProfileIdentityOptions{ + ProfileID: core.StringPtr(profileID), + IdentityType: core.StringPtr(identityType), Identifier: core.StringPtr(identifier), - Type: core.StringPtr(typeVar), + Type: core.StringPtr(typeVar), } - err = core.ValidateStruct(_model, "required parameters") - return } -// UnmarshalProfileIdentity unmarshals an instance of ProfileIdentity from the specified map of raw messages. -func UnmarshalProfileIdentity(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(ProfileIdentity) - err = core.UnmarshalPrimitive(m, "iam_id", &obj.IamID) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "identifier", &obj.Identifier) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "type", &obj.Type) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "accounts", &obj.Accounts) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "description", &obj.Description) - if err != nil { - return - } - reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) - return +// SetProfileID : Allow user to set ProfileID +func (_options *SetProfileIdentityOptions) SetProfileID(profileID string) *SetProfileIdentityOptions { + _options.ProfileID = core.StringPtr(profileID) + return _options } -// ProfileLink : Link details. -type ProfileLink struct { - // the unique identifier of the link. - ID *string `json:"id" validate:"required"` +// SetIdentityType : Allow user to set IdentityType +func (_options *SetProfileIdentityOptions) SetIdentityType(identityType string) *SetProfileIdentityOptions { + _options.IdentityType = core.StringPtr(identityType) + return _options +} - // version of the link. - EntityTag *string `json:"entity_tag" validate:"required"` +// SetIdentifier : Allow user to set Identifier +func (_options *SetProfileIdentityOptions) SetIdentifier(identifier string) *SetProfileIdentityOptions { + _options.Identifier = core.StringPtr(identifier) + return _options +} - // If set contains a date time string of the creation date in ISO format. - CreatedAt *strfmt.DateTime `json:"created_at" validate:"required"` +// SetType : Allow user to set Type +func (_options *SetProfileIdentityOptions) SetType(typeVar string) *SetProfileIdentityOptions { + _options.Type = core.StringPtr(typeVar) + return _options +} - // If set contains a date time string of the last modification date in ISO format. - ModifiedAt *strfmt.DateTime `json:"modified_at" validate:"required"` +// SetAccounts : Allow user to set Accounts +func (_options *SetProfileIdentityOptions) SetAccounts(accounts []string) *SetProfileIdentityOptions { + _options.Accounts = accounts + return _options +} - // Optional name of the Link. - Name *string `json:"name,omitempty"` +// SetDescription : Allow user to set Description +func (_options *SetProfileIdentityOptions) SetDescription(description string) *SetProfileIdentityOptions { + _options.Description = core.StringPtr(description) + return _options +} - // The compute resource type. Valid values are VSI, IKS_SA, ROKS_SA. - CrType *string `json:"cr_type" validate:"required"` +// SetHeaders : Allow user to set Headers +func (options *SetProfileIdentityOptions) SetHeaders(param map[string]string) *SetProfileIdentityOptions { + options.Headers = param + return options +} - Link *ProfileLinkLink `json:"link" validate:"required"` +// TemplateAssignmentListResponse : List Response body format for Template Assignments Records. +type TemplateAssignmentListResponse struct { + // Context with key properties for problem determination. + Context *ResponseContext `json:"context,omitempty"` + + // The offset of the current page. + Offset *int64 `json:"offset,omitempty"` + + // Optional size of a single page. Default is 20 items per page. Valid range is 1 to 100. + Limit *int64 `json:"limit,omitempty"` + + // Link to the first page. + First *string `json:"first,omitempty"` + + // Link to the previous available page. If 'previous' property is not part of the response no previous page is + // available. + Previous *string `json:"previous,omitempty"` + + // Link to the next available page. If 'next' property is not part of the response no next page is available. + Next *string `json:"next,omitempty"` + + // List of Assignments based on the query paramters and the page size. The assignments array is always part of the + // response but might be empty depending on the query parameter values provided. + Assignments []TemplateAssignmentResponse `json:"assignments" validate:"required"` } -// UnmarshalProfileLink unmarshals an instance of ProfileLink from the specified map of raw messages. -func UnmarshalProfileLink(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(ProfileLink) - err = core.UnmarshalPrimitive(m, "id", &obj.ID) +// UnmarshalTemplateAssignmentListResponse unmarshals an instance of TemplateAssignmentListResponse from the specified map of raw messages. +func UnmarshalTemplateAssignmentListResponse(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(TemplateAssignmentListResponse) + err = core.UnmarshalModel(m, "context", &obj.Context, UnmarshalResponseContext) if err != nil { return } - err = core.UnmarshalPrimitive(m, "entity_tag", &obj.EntityTag) + err = core.UnmarshalPrimitive(m, "offset", &obj.Offset) if err != nil { return } - err = core.UnmarshalPrimitive(m, "created_at", &obj.CreatedAt) + err = core.UnmarshalPrimitive(m, "limit", &obj.Limit) if err != nil { return } - err = core.UnmarshalPrimitive(m, "modified_at", &obj.ModifiedAt) + err = core.UnmarshalPrimitive(m, "first", &obj.First) if err != nil { return } - err = core.UnmarshalPrimitive(m, "name", &obj.Name) + err = core.UnmarshalPrimitive(m, "previous", &obj.Previous) if err != nil { return } - err = core.UnmarshalPrimitive(m, "cr_type", &obj.CrType) + err = core.UnmarshalPrimitive(m, "next", &obj.Next) if err != nil { return } - err = core.UnmarshalModel(m, "link", &obj.Link, UnmarshalProfileLinkLink) + err = core.UnmarshalModel(m, "assignments", &obj.Assignments, UnmarshalTemplateAssignmentResponse) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// TemplateAssignmentResource : Body parameters for created resource. +type TemplateAssignmentResource struct { + // Id of the created resource. + ID *string `json:"id,omitempty"` +} + +// UnmarshalTemplateAssignmentResource unmarshals an instance of TemplateAssignmentResource from the specified map of raw messages. +func UnmarshalTemplateAssignmentResource(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(TemplateAssignmentResource) + err = core.UnmarshalPrimitive(m, "id", &obj.ID) if err != nil { return } @@ -5686,47 +10363,37 @@ func UnmarshalProfileLink(m map[string]json.RawMessage, result interface{}) (err return } -// ProfileLinkLink : ProfileLinkLink struct -type ProfileLinkLink struct { - // The CRN of the compute resource. - CRN *string `json:"crn,omitempty"` +// TemplateAssignmentResourceError : Body parameters for assignment error. +type TemplateAssignmentResourceError struct { + // Name of the error. + Name *string `json:"name,omitempty"` + + // Internal error code. + ErrorCode *string `json:"errorCode,omitempty"` - // The compute resource namespace, only required if cr_type is IKS_SA or ROKS_SA. - Namespace *string `json:"namespace,omitempty"` + // Error message detailing the nature of the error. + Message *string `json:"message,omitempty"` - // Name of the compute resource, only required if cr_type is IKS_SA or ROKS_SA. - Name *string `json:"name,omitempty"` + // Internal status code for the error. + StatusCode *string `json:"statusCode,omitempty"` } -// UnmarshalProfileLinkLink unmarshals an instance of ProfileLinkLink from the specified map of raw messages. -func UnmarshalProfileLinkLink(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(ProfileLinkLink) - err = core.UnmarshalPrimitive(m, "crn", &obj.CRN) +// UnmarshalTemplateAssignmentResourceError unmarshals an instance of TemplateAssignmentResourceError from the specified map of raw messages. +func UnmarshalTemplateAssignmentResourceError(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(TemplateAssignmentResourceError) + err = core.UnmarshalPrimitive(m, "name", &obj.Name) if err != nil { return } - err = core.UnmarshalPrimitive(m, "namespace", &obj.Namespace) + err = core.UnmarshalPrimitive(m, "errorCode", &obj.ErrorCode) if err != nil { return } - err = core.UnmarshalPrimitive(m, "name", &obj.Name) + err = core.UnmarshalPrimitive(m, "message", &obj.Message) if err != nil { return } - reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) - return -} - -// ProfileLinkList : ProfileLinkList struct -type ProfileLinkList struct { - // List of links to a trusted profile. - Links []ProfileLink `json:"links" validate:"required"` -} - -// UnmarshalProfileLinkList unmarshals an instance of ProfileLinkList from the specified map of raw messages. -func UnmarshalProfileLinkList(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(ProfileLinkList) - err = core.UnmarshalModel(m, "links", &obj.Links, UnmarshalProfileLink) + err = core.UnmarshalPrimitive(m, "statusCode", &obj.StatusCode) if err != nil { return } @@ -5734,124 +10401,123 @@ func UnmarshalProfileLinkList(m map[string]json.RawMessage, result interface{}) return } -// Report : Report struct -type Report struct { - // IAMid of the user who triggered the report. - CreatedBy *string `json:"created_by" validate:"required"` +// TemplateAssignmentResponse : Response body format for Template Assignment Record. +type TemplateAssignmentResponse struct { + // Context with key properties for problem determination. + Context *ResponseContext `json:"context,omitempty"` - // Unique reference used to generate the report. - Reference *string `json:"reference" validate:"required"` + // Assignment record Id. + ID *string `json:"id" validate:"required"` - // Duration in hours for which the report is generated. - ReportDuration *string `json:"report_duration" validate:"required"` + // Enterprise Account Id. + AccountID *string `json:"account_id" validate:"required"` - // Start time of the report. - ReportStartTime *string `json:"report_start_time" validate:"required"` + // Template Id. + TemplateID *string `json:"template_id" validate:"required"` - // End time of the report. - ReportEndTime *string `json:"report_end_time" validate:"required"` + // Template Version. + TemplateVersion *int64 `json:"template_version" validate:"required"` - // List of users. - Users []UserActivity `json:"users,omitempty"` + // Assignment Target Type. + TargetType *string `json:"target_type" validate:"required"` - // List of apikeys. - Apikeys []ApikeyActivity `json:"apikeys,omitempty"` + // Assignment Target. + Target *string `json:"target" validate:"required"` - // List of serviceids. - Serviceids []EntityActivity `json:"serviceids,omitempty"` + // Assignment Status. + Status *string `json:"status" validate:"required"` - // List of profiles. - Profiles []EntityActivity `json:"profiles,omitempty"` + // Status breakdown per target account of resources created or errors encountered in attempting to create those + // resources. Resources are only included in the response providing the assignment is not in progress. Resources are + // also only included when getting a single assignment, and excluded by list apis. + Resources []TemplateAssignmentResponseResource `json:"resources,omitempty"` + + // Assignment history. + History []EnityHistoryRecord `json:"history,omitempty"` + + // Href. + Href *string `json:"href,omitempty"` + + // Assignment created at. + CreatedAt *string `json:"created_at" validate:"required"` + + // IAMid of the identity that created the assignment. + CreatedByID *string `json:"created_by_id" validate:"required"` + + // Assignment modified at. + LastModifiedAt *string `json:"last_modified_at" validate:"required"` + + // IAMid of the identity that last modified the assignment. + LastModifiedByID *string `json:"last_modified_by_id" validate:"required"` + + // Entity tag for this assignment record. + EntityTag *string `json:"entity_tag" validate:"required"` } -// UnmarshalReport unmarshals an instance of Report from the specified map of raw messages. -func UnmarshalReport(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(Report) - err = core.UnmarshalPrimitive(m, "created_by", &obj.CreatedBy) +// UnmarshalTemplateAssignmentResponse unmarshals an instance of TemplateAssignmentResponse from the specified map of raw messages. +func UnmarshalTemplateAssignmentResponse(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(TemplateAssignmentResponse) + err = core.UnmarshalModel(m, "context", &obj.Context, UnmarshalResponseContext) if err != nil { return } - err = core.UnmarshalPrimitive(m, "reference", &obj.Reference) + err = core.UnmarshalPrimitive(m, "id", &obj.ID) if err != nil { return } - err = core.UnmarshalPrimitive(m, "report_duration", &obj.ReportDuration) + err = core.UnmarshalPrimitive(m, "account_id", &obj.AccountID) if err != nil { return } - err = core.UnmarshalPrimitive(m, "report_start_time", &obj.ReportStartTime) + err = core.UnmarshalPrimitive(m, "template_id", &obj.TemplateID) if err != nil { return } - err = core.UnmarshalPrimitive(m, "report_end_time", &obj.ReportEndTime) + err = core.UnmarshalPrimitive(m, "template_version", &obj.TemplateVersion) if err != nil { return } - err = core.UnmarshalModel(m, "users", &obj.Users, UnmarshalUserActivity) + err = core.UnmarshalPrimitive(m, "target_type", &obj.TargetType) if err != nil { return } - err = core.UnmarshalModel(m, "apikeys", &obj.Apikeys, UnmarshalApikeyActivity) + err = core.UnmarshalPrimitive(m, "target", &obj.Target) if err != nil { return } - err = core.UnmarshalModel(m, "serviceids", &obj.Serviceids, UnmarshalEntityActivity) + err = core.UnmarshalPrimitive(m, "status", &obj.Status) if err != nil { return } - err = core.UnmarshalModel(m, "profiles", &obj.Profiles, UnmarshalEntityActivity) + err = core.UnmarshalModel(m, "resources", &obj.Resources, UnmarshalTemplateAssignmentResponseResource) if err != nil { return } - reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) - return -} - -// ReportMfaEnrollmentStatus : ReportMfaEnrollmentStatus struct -type ReportMfaEnrollmentStatus struct { - // IAMid of the user who triggered the report. - CreatedBy *string `json:"created_by" validate:"required"` - - // Unique reference used to generate the report. - Reference *string `json:"reference" validate:"required"` - - // Date time at which report is generated. Date is in ISO format. - ReportTime *string `json:"report_time" validate:"required"` - - // BSS account id of the user who triggered the report. - AccountID *string `json:"account_id" validate:"required"` - - // IMS account id of the user who triggered the report. - ImsAccountID *string `json:"ims_account_id,omitempty"` - - // List of users. - Users []UserReportMfaEnrollmentStatus `json:"users,omitempty"` -} - -// UnmarshalReportMfaEnrollmentStatus unmarshals an instance of ReportMfaEnrollmentStatus from the specified map of raw messages. -func UnmarshalReportMfaEnrollmentStatus(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(ReportMfaEnrollmentStatus) - err = core.UnmarshalPrimitive(m, "created_by", &obj.CreatedBy) + err = core.UnmarshalModel(m, "history", &obj.History, UnmarshalEnityHistoryRecord) if err != nil { return } - err = core.UnmarshalPrimitive(m, "reference", &obj.Reference) + err = core.UnmarshalPrimitive(m, "href", &obj.Href) if err != nil { return } - err = core.UnmarshalPrimitive(m, "report_time", &obj.ReportTime) + err = core.UnmarshalPrimitive(m, "created_at", &obj.CreatedAt) if err != nil { return } - err = core.UnmarshalPrimitive(m, "account_id", &obj.AccountID) + err = core.UnmarshalPrimitive(m, "created_by_id", &obj.CreatedByID) if err != nil { return } - err = core.UnmarshalPrimitive(m, "ims_account_id", &obj.ImsAccountID) + err = core.UnmarshalPrimitive(m, "last_modified_at", &obj.LastModifiedAt) if err != nil { return } - err = core.UnmarshalModel(m, "users", &obj.Users, UnmarshalUserReportMfaEnrollmentStatus) + err = core.UnmarshalPrimitive(m, "last_modified_by_id", &obj.LastModifiedByID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "entity_tag", &obj.EntityTag) if err != nil { return } @@ -5859,16 +10525,35 @@ func UnmarshalReportMfaEnrollmentStatus(m map[string]json.RawMessage, result int return } -// ReportReference : ReportReference struct -type ReportReference struct { - // Reference for the report to be generated. - Reference *string `json:"reference" validate:"required"` +// TemplateAssignmentResponseResource : Overview of resources assignment per target account. +type TemplateAssignmentResponseResource struct { + // Target account the resource is created in. + Target *string `json:"target" validate:"required"` + + Profile *TemplateAssignmentResponseResourceDetail `json:"profile,omitempty"` + + AccountSettings *TemplateAssignmentResponseResourceDetail `json:"account_settings,omitempty"` + + // Policy resource(s) included only for Trusted Profile Assignments with Policy references. + PolicyTemplateRefs []TemplateAssignmentResponseResourceDetail `json:"policy_template_refs,omitempty"` } -// UnmarshalReportReference unmarshals an instance of ReportReference from the specified map of raw messages. -func UnmarshalReportReference(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(ReportReference) - err = core.UnmarshalPrimitive(m, "reference", &obj.Reference) +// UnmarshalTemplateAssignmentResponseResource unmarshals an instance of TemplateAssignmentResponseResource from the specified map of raw messages. +func UnmarshalTemplateAssignmentResponseResource(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(TemplateAssignmentResponseResource) + err = core.UnmarshalPrimitive(m, "target", &obj.Target) + if err != nil { + return + } + err = core.UnmarshalModel(m, "profile", &obj.Profile, UnmarshalTemplateAssignmentResponseResourceDetail) + if err != nil { + return + } + err = core.UnmarshalModel(m, "account_settings", &obj.AccountSettings, UnmarshalTemplateAssignmentResponseResourceDetail) + if err != nil { + return + } + err = core.UnmarshalModel(m, "policy_template_refs", &obj.PolicyTemplateRefs, UnmarshalTemplateAssignmentResponseResourceDetail) if err != nil { return } @@ -5876,86 +10561,129 @@ func UnmarshalReportReference(m map[string]json.RawMessage, result interface{}) return } -// ResponseContext : Context with key properties for problem determination. -type ResponseContext struct { - // The transaction ID of the inbound REST request. - TransactionID *string `json:"transaction_id,omitempty"` - - // The operation of the inbound REST request. - Operation *string `json:"operation,omitempty"` - - // The user agent of the inbound REST request. - UserAgent *string `json:"user_agent,omitempty"` - - // The URL of that cluster. - URL *string `json:"url,omitempty"` - - // The instance ID of the server instance processing the request. - InstanceID *string `json:"instance_id,omitempty"` - - // The thread ID of the server instance processing the request. - ThreadID *string `json:"thread_id,omitempty"` - - // The host of the server instance processing the request. - Host *string `json:"host,omitempty"` +// TemplateAssignmentResponseResourceDetail : TemplateAssignmentResponseResourceDetail struct +type TemplateAssignmentResponseResourceDetail struct { + // Policy Template Id, only returned for a profile assignment with policy references. + ID *string `json:"id,omitempty"` - // The start time of the request. - StartTime *string `json:"start_time,omitempty"` + // Policy verser, only returned for a profile assignment with policy references. + Version *string `json:"version,omitempty"` - // The finish time of the request. - EndTime *string `json:"end_time,omitempty"` + // Body parameters for created resource. + ResourceCreated *TemplateAssignmentResource `json:"resource_created,omitempty"` - // The elapsed time in msec. - ElapsedTime *string `json:"elapsed_time,omitempty"` + // Body parameters for assignment error. + ErrorMessage *TemplateAssignmentResourceError `json:"error_message,omitempty"` - // The cluster name. - ClusterName *string `json:"cluster_name,omitempty"` + // Status for the target account's assignment. + Status *string `json:"status" validate:"required"` } -// UnmarshalResponseContext unmarshals an instance of ResponseContext from the specified map of raw messages. -func UnmarshalResponseContext(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(ResponseContext) - err = core.UnmarshalPrimitive(m, "transaction_id", &obj.TransactionID) +// UnmarshalTemplateAssignmentResponseResourceDetail unmarshals an instance of TemplateAssignmentResponseResourceDetail from the specified map of raw messages. +func UnmarshalTemplateAssignmentResponseResourceDetail(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(TemplateAssignmentResponseResourceDetail) + err = core.UnmarshalPrimitive(m, "id", &obj.ID) if err != nil { return } - err = core.UnmarshalPrimitive(m, "operation", &obj.Operation) + err = core.UnmarshalPrimitive(m, "version", &obj.Version) if err != nil { return } - err = core.UnmarshalPrimitive(m, "user_agent", &obj.UserAgent) + err = core.UnmarshalModel(m, "resource_created", &obj.ResourceCreated, UnmarshalTemplateAssignmentResource) if err != nil { return } - err = core.UnmarshalPrimitive(m, "url", &obj.URL) + err = core.UnmarshalModel(m, "error_message", &obj.ErrorMessage, UnmarshalTemplateAssignmentResourceError) if err != nil { return } - err = core.UnmarshalPrimitive(m, "instance_id", &obj.InstanceID) + err = core.UnmarshalPrimitive(m, "status", &obj.Status) if err != nil { return } - err = core.UnmarshalPrimitive(m, "thread_id", &obj.ThreadID) + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// TemplateProfileComponentRequest : Input body parameters for the TemplateProfileComponent. +type TemplateProfileComponentRequest struct { + // Name of the Profile. + Name *string `json:"name" validate:"required"` + + // Description of the Profile. + Description *string `json:"description,omitempty"` + + // Rules for the Profile. + Rules []TrustedProfileTemplateClaimRule `json:"rules,omitempty"` + + // Identities for the Profile. + Identities []ProfileIdentityRequest `json:"identities,omitempty"` +} + +// NewTemplateProfileComponentRequest : Instantiate TemplateProfileComponentRequest (Generic Model Constructor) +func (*IamIdentityV1) NewTemplateProfileComponentRequest(name string) (_model *TemplateProfileComponentRequest, err error) { + _model = &TemplateProfileComponentRequest{ + Name: core.StringPtr(name), + } + err = core.ValidateStruct(_model, "required parameters") + return +} + +// UnmarshalTemplateProfileComponentRequest unmarshals an instance of TemplateProfileComponentRequest from the specified map of raw messages. +func UnmarshalTemplateProfileComponentRequest(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(TemplateProfileComponentRequest) + err = core.UnmarshalPrimitive(m, "name", &obj.Name) if err != nil { return } - err = core.UnmarshalPrimitive(m, "host", &obj.Host) + err = core.UnmarshalPrimitive(m, "description", &obj.Description) if err != nil { return } - err = core.UnmarshalPrimitive(m, "start_time", &obj.StartTime) + err = core.UnmarshalModel(m, "rules", &obj.Rules, UnmarshalTrustedProfileTemplateClaimRule) if err != nil { return } - err = core.UnmarshalPrimitive(m, "end_time", &obj.EndTime) + err = core.UnmarshalModel(m, "identities", &obj.Identities, UnmarshalProfileIdentityRequest) if err != nil { return } - err = core.UnmarshalPrimitive(m, "elapsed_time", &obj.ElapsedTime) + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// TemplateProfileComponentResponse : Input body parameters for the TemplateProfileComponent. +type TemplateProfileComponentResponse struct { + // Name of the Profile. + Name *string `json:"name" validate:"required"` + + // Description of the Profile. + Description *string `json:"description,omitempty"` + + // Rules for the Profile. + Rules []TrustedProfileTemplateClaimRule `json:"rules,omitempty"` + + // Identities for the Profile. + Identities []ProfileIdentityResponse `json:"identities,omitempty"` +} + +// UnmarshalTemplateProfileComponentResponse unmarshals an instance of TemplateProfileComponentResponse from the specified map of raw messages. +func UnmarshalTemplateProfileComponentResponse(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(TemplateProfileComponentResponse) + err = core.UnmarshalPrimitive(m, "name", &obj.Name) if err != nil { return } - err = core.UnmarshalPrimitive(m, "cluster_name", &obj.ClusterName) + err = core.UnmarshalPrimitive(m, "description", &obj.Description) + if err != nil { + return + } + err = core.UnmarshalModel(m, "rules", &obj.Rules, UnmarshalTrustedProfileTemplateClaimRule) + if err != nil { + return + } + err = core.UnmarshalModel(m, "identities", &obj.Identities, UnmarshalProfileIdentityResponse) if err != nil { return } @@ -5963,60 +10691,57 @@ func UnmarshalResponseContext(m map[string]json.RawMessage, result interface{}) return } -// ServiceID : Response body format for service ID V1 REST requests. -type ServiceID struct { +// TrustedProfile : Response body format for trusted profile V1 REST requests. +type TrustedProfile struct { // Context with key properties for problem determination. Context *ResponseContext `json:"context,omitempty"` - // Unique identifier of this Service Id. + // the unique identifier of the trusted profile. Example:'Profile-94497d0d-2ac3-41bf-a993-a49d1b14627c'. ID *string `json:"id" validate:"required"` - // Cloud wide identifier for identities of this service ID. - IamID *string `json:"iam_id" validate:"required"` - - // Version of the service ID details object. You need to specify this value when updating the service ID to avoid stale - // updates. + // Version of the trusted profile details object. You need to specify this value when updating the trusted profile to + // avoid stale updates. EntityTag *string `json:"entity_tag" validate:"required"` // Cloud Resource Name of the item. Example Cloud Resource Name: - // 'crn:v1:bluemix:public:iam-identity:us-south:a/myaccount::serviceid:1234-5678-9012'. + // 'crn:v1:bluemix:public:iam-identity:us-south:a/myaccount::profile:Profile-94497d0d-2ac3-41bf-a993-a49d1b14627c'. CRN *string `json:"crn" validate:"required"` - // The service ID cannot be changed if set to true. - Locked *bool `json:"locked" validate:"required"` + // Name of the trusted profile. The name is checked for uniqueness. Therefore trusted profiles with the same names can + // not exist in the same account. + Name *string `json:"name" validate:"required"` + + // The optional description of the trusted profile. The 'description' property is only available if a description was + // provided during a create of a trusted profile. + Description *string `json:"description,omitempty"` // If set contains a date time string of the creation date in ISO format. - CreatedAt *strfmt.DateTime `json:"created_at" validate:"required"` + CreatedAt *strfmt.DateTime `json:"created_at,omitempty"` // If set contains a date time string of the last modification date in ISO format. - ModifiedAt *strfmt.DateTime `json:"modified_at" validate:"required"` + ModifiedAt *strfmt.DateTime `json:"modified_at,omitempty"` - // ID of the account the service ID belongs to. + // The iam_id of this trusted profile. + IamID *string `json:"iam_id" validate:"required"` + + // ID of the account that this trusted profile belong to. AccountID *string `json:"account_id" validate:"required"` - // Name of the Service Id. The name is not checked for uniqueness. Therefore multiple names with the same value can - // exist. Access is done via the UUID of the Service Id. - Name *string `json:"name" validate:"required"` - - // The optional description of the Service Id. The 'description' property is only available if a description was - // provided during a create of a Service Id. - Description *string `json:"description,omitempty"` + // IMS acount ID of the trusted profile. + ImsAccountID *int64 `json:"ims_account_id,omitempty"` - // Optional list of CRNs (string array) which point to the services connected to the service ID. - UniqueInstanceCrns []string `json:"unique_instance_crns,omitempty"` + // IMS user ID of the trusted profile. + ImsUserID *int64 `json:"ims_user_id,omitempty"` - // History of the Service ID. + // History of the trusted profile. History []EnityHistoryRecord `json:"history,omitempty"` - // Response body format for API key V1 REST requests. - Apikey *APIKey `json:"apikey,omitempty"` - Activity *Activity `json:"activity,omitempty"` } -// UnmarshalServiceID unmarshals an instance of ServiceID from the specified map of raw messages. -func UnmarshalServiceID(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(ServiceID) +// UnmarshalTrustedProfile unmarshals an instance of TrustedProfile from the specified map of raw messages. +func UnmarshalTrustedProfile(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(TrustedProfile) err = core.UnmarshalModel(m, "context", &obj.Context, UnmarshalResponseContext) if err != nil { return @@ -6025,19 +10750,19 @@ func UnmarshalServiceID(m map[string]json.RawMessage, result interface{}) (err e if err != nil { return } - err = core.UnmarshalPrimitive(m, "iam_id", &obj.IamID) + err = core.UnmarshalPrimitive(m, "entity_tag", &obj.EntityTag) if err != nil { return } - err = core.UnmarshalPrimitive(m, "entity_tag", &obj.EntityTag) + err = core.UnmarshalPrimitive(m, "crn", &obj.CRN) if err != nil { return } - err = core.UnmarshalPrimitive(m, "crn", &obj.CRN) + err = core.UnmarshalPrimitive(m, "name", &obj.Name) if err != nil { return } - err = core.UnmarshalPrimitive(m, "locked", &obj.Locked) + err = core.UnmarshalPrimitive(m, "description", &obj.Description) if err != nil { return } @@ -6049,19 +10774,19 @@ func UnmarshalServiceID(m map[string]json.RawMessage, result interface{}) (err e if err != nil { return } - err = core.UnmarshalPrimitive(m, "account_id", &obj.AccountID) + err = core.UnmarshalPrimitive(m, "iam_id", &obj.IamID) if err != nil { return } - err = core.UnmarshalPrimitive(m, "name", &obj.Name) + err = core.UnmarshalPrimitive(m, "account_id", &obj.AccountID) if err != nil { return } - err = core.UnmarshalPrimitive(m, "description", &obj.Description) + err = core.UnmarshalPrimitive(m, "ims_account_id", &obj.ImsAccountID) if err != nil { return } - err = core.UnmarshalPrimitive(m, "unique_instance_crns", &obj.UniqueInstanceCrns) + err = core.UnmarshalPrimitive(m, "ims_user_id", &obj.ImsUserID) if err != nil { return } @@ -6069,10 +10794,6 @@ func UnmarshalServiceID(m map[string]json.RawMessage, result interface{}) (err e if err != nil { return } - err = core.UnmarshalModel(m, "apikey", &obj.Apikey, UnmarshalAPIKey) - if err != nil { - return - } err = core.UnmarshalModel(m, "activity", &obj.Activity, UnmarshalActivity) if err != nil { return @@ -6081,60 +10802,61 @@ func UnmarshalServiceID(m map[string]json.RawMessage, result interface{}) (err e return } -// ServiceIDList : Response body format for the list service ID V1 REST request. -type ServiceIDList struct { - // Context with key properties for problem determination. - Context *ResponseContext `json:"context,omitempty"` +// TrustedProfileTemplateClaimRule : TrustedProfileTemplateClaimRule struct +type TrustedProfileTemplateClaimRule struct { + // Name of the claim rule to be created or updated. + Name *string `json:"name,omitempty"` - // The offset of the current page. - Offset *int64 `json:"offset,omitempty"` + // Type of the claim rule. + Type *string `json:"type" validate:"required"` - // Optional size of a single page. Default is 20 items per page. Valid range is 1 to 100. - Limit *int64 `json:"limit,omitempty"` + // The realm name of the Idp this claim rule applies to. This field is required only if the type is specified as + // 'Profile-SAML'. + RealmName *string `json:"realm_name,omitempty"` - // Link to the first page. - First *string `json:"first,omitempty"` + // Session expiration in seconds, only required if type is 'Profile-SAML'. + Expiration *int64 `json:"expiration,omitempty"` - // Link to the previous available page. If 'previous' property is not part of the response no previous page is - // available. - Previous *string `json:"previous,omitempty"` + // Conditions of this claim rule. + Conditions []ProfileClaimRuleConditions `json:"conditions" validate:"required"` +} - // Link to the next available page. If 'next' property is not part of the response no next page is available. - Next *string `json:"next,omitempty"` +// Constants associated with the TrustedProfileTemplateClaimRule.Type property. +// Type of the claim rule. +const ( + TrustedProfileTemplateClaimRuleTypeProfileSamlConst = "Profile-SAML" +) - // List of service IDs based on the query paramters and the page size. The service IDs array is always part of the - // response but might be empty depending on the query parameter values provided. - Serviceids []ServiceID `json:"serviceids" validate:"required"` +// NewTrustedProfileTemplateClaimRule : Instantiate TrustedProfileTemplateClaimRule (Generic Model Constructor) +func (*IamIdentityV1) NewTrustedProfileTemplateClaimRule(typeVar string, conditions []ProfileClaimRuleConditions) (_model *TrustedProfileTemplateClaimRule, err error) { + _model = &TrustedProfileTemplateClaimRule{ + Type: core.StringPtr(typeVar), + Conditions: conditions, + } + err = core.ValidateStruct(_model, "required parameters") + return } -// UnmarshalServiceIDList unmarshals an instance of ServiceIDList from the specified map of raw messages. -func UnmarshalServiceIDList(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(ServiceIDList) - err = core.UnmarshalModel(m, "context", &obj.Context, UnmarshalResponseContext) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "offset", &obj.Offset) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "limit", &obj.Limit) +// UnmarshalTrustedProfileTemplateClaimRule unmarshals an instance of TrustedProfileTemplateClaimRule from the specified map of raw messages. +func UnmarshalTrustedProfileTemplateClaimRule(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(TrustedProfileTemplateClaimRule) + err = core.UnmarshalPrimitive(m, "name", &obj.Name) if err != nil { return } - err = core.UnmarshalPrimitive(m, "first", &obj.First) + err = core.UnmarshalPrimitive(m, "type", &obj.Type) if err != nil { return } - err = core.UnmarshalPrimitive(m, "previous", &obj.Previous) + err = core.UnmarshalPrimitive(m, "realm_name", &obj.RealmName) if err != nil { return } - err = core.UnmarshalPrimitive(m, "next", &obj.Next) + err = core.UnmarshalPrimitive(m, "expiration", &obj.Expiration) if err != nil { return } - err = core.UnmarshalModel(m, "serviceids", &obj.Serviceids, UnmarshalServiceID) + err = core.UnmarshalModel(m, "conditions", &obj.Conditions, UnmarshalProfileClaimRuleConditions) if err != nil { return } @@ -6142,224 +10864,127 @@ func UnmarshalServiceIDList(m map[string]json.RawMessage, result interface{}) (e return } -// SetProfileIdentitiesOptions : The SetProfileIdentities options. -type SetProfileIdentitiesOptions struct { - // ID of the trusted profile. - ProfileID *string `json:"profile-id" validate:"required,ne="` - - // Entity tag of the Identities to be updated. Specify the tag that you retrieved when reading the Profile Identities. - // This value helps identify parallel usage of this API. Pass * to indicate updating any available version, which may - // result in stale updates. - IfMatch *string `json:"If-Match" validate:"required"` - - // List of identities that can assume the trusted profile. - Identities []ProfileIdentity `json:"identities,omitempty"` - - // Allows users to set headers on API requests - Headers map[string]string -} - -// NewSetProfileIdentitiesOptions : Instantiate SetProfileIdentitiesOptions -func (*IamIdentityV1) NewSetProfileIdentitiesOptions(profileID string, ifMatch string) *SetProfileIdentitiesOptions { - return &SetProfileIdentitiesOptions{ - ProfileID: core.StringPtr(profileID), - IfMatch: core.StringPtr(ifMatch), - } -} - -// SetProfileID : Allow user to set ProfileID -func (_options *SetProfileIdentitiesOptions) SetProfileID(profileID string) *SetProfileIdentitiesOptions { - _options.ProfileID = core.StringPtr(profileID) - return _options -} - -// SetIfMatch : Allow user to set IfMatch -func (_options *SetProfileIdentitiesOptions) SetIfMatch(ifMatch string) *SetProfileIdentitiesOptions { - _options.IfMatch = core.StringPtr(ifMatch) - return _options -} - -// SetIdentities : Allow user to set Identities -func (_options *SetProfileIdentitiesOptions) SetIdentities(identities []ProfileIdentity) *SetProfileIdentitiesOptions { - _options.Identities = identities - return _options -} - -// SetHeaders : Allow user to set Headers -func (options *SetProfileIdentitiesOptions) SetHeaders(param map[string]string) *SetProfileIdentitiesOptions { - options.Headers = param - return options -} - -// SetProfileIdentityOptions : The SetProfileIdentity options. -type SetProfileIdentityOptions struct { - // ID of the trusted profile. - ProfileID *string `json:"profile-id" validate:"required,ne="` - - // Type of the identity. - IdentityType *string `json:"identity-type" validate:"required,ne="` +// TrustedProfileTemplateList : TrustedProfileTemplateList struct +type TrustedProfileTemplateList struct { + // Context with key properties for problem determination. + Context *ResponseContext `json:"context,omitempty"` - // Identifier of the identity that can assume the trusted profiles. This can be a user identifier (IAM id), serviceid - // or crn. Internally it uses account id of the service id for the identifier 'serviceid' and for the identifier 'crn' - // it uses account id contained in the CRN. - Identifier *string `json:"identifier" validate:"required"` + // The offset of the current page. + Offset *int64 `json:"offset,omitempty"` - // Type of the identity. - Type *string `json:"type" validate:"required"` + // Optional size of a single page. + Limit *int64 `json:"limit,omitempty"` - // IAM ID of the identity. - IamID *string `json:"iam_id,omitempty"` + // Link to the first page. + First *string `json:"first,omitempty"` - // Only valid for the type user. Accounts from which a user can assume the trusted profile. - Accounts []string `json:"accounts,omitempty"` + // Link to the previous available page. If 'previous' property is not part of the response no previous page is + // available. + Previous *string `json:"previous,omitempty"` - // Description of the identity that can assume the trusted profile. This is optional field for all the types of - // identities. When this field is not set for the identity type 'serviceid' then the description of the service id is - // used. Description is recommended for the identity type 'crn' E.g. 'Instance 1234 of IBM Cloud Service project'. - Description *string `json:"description,omitempty"` + // Link to the next available page. If 'next' property is not part of the response no next page is available. + Next *string `json:"next,omitempty"` - // Allows users to set headers on API requests - Headers map[string]string + // List of Profile Templates based on the query paramters and the page size. The profile_templates array is always part + // of the response but might be empty depending on the query parameter values provided. + ProfileTemplates []TrustedProfileTemplateResponse `json:"profile_templates" validate:"required"` } -// Constants associated with the SetProfileIdentityOptions.IdentityType property. -// Type of the identity. -const ( - SetProfileIdentityOptionsIdentityTypeCRNConst = "crn" - SetProfileIdentityOptionsIdentityTypeServiceidConst = "serviceid" - SetProfileIdentityOptionsIdentityTypeUserConst = "user" -) - -// Constants associated with the SetProfileIdentityOptions.Type property. -// Type of the identity. -const ( - SetProfileIdentityOptionsTypeCRNConst = "crn" - SetProfileIdentityOptionsTypeServiceidConst = "serviceid" - SetProfileIdentityOptionsTypeUserConst = "user" -) - -// NewSetProfileIdentityOptions : Instantiate SetProfileIdentityOptions -func (*IamIdentityV1) NewSetProfileIdentityOptions(profileID string, identityType string, identifier string, typeVar string) *SetProfileIdentityOptions { - return &SetProfileIdentityOptions{ - ProfileID: core.StringPtr(profileID), - IdentityType: core.StringPtr(identityType), - Identifier: core.StringPtr(identifier), - Type: core.StringPtr(typeVar), +// UnmarshalTrustedProfileTemplateList unmarshals an instance of TrustedProfileTemplateList from the specified map of raw messages. +func UnmarshalTrustedProfileTemplateList(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(TrustedProfileTemplateList) + err = core.UnmarshalModel(m, "context", &obj.Context, UnmarshalResponseContext) + if err != nil { + return } + err = core.UnmarshalPrimitive(m, "offset", &obj.Offset) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "limit", &obj.Limit) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "first", &obj.First) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "previous", &obj.Previous) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "next", &obj.Next) + if err != nil { + return + } + err = core.UnmarshalModel(m, "profile_templates", &obj.ProfileTemplates, UnmarshalTrustedProfileTemplateResponse) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return } -// SetProfileID : Allow user to set ProfileID -func (_options *SetProfileIdentityOptions) SetProfileID(profileID string) *SetProfileIdentityOptions { - _options.ProfileID = core.StringPtr(profileID) - return _options -} - -// SetIdentityType : Allow user to set IdentityType -func (_options *SetProfileIdentityOptions) SetIdentityType(identityType string) *SetProfileIdentityOptions { - _options.IdentityType = core.StringPtr(identityType) - return _options -} - -// SetIdentifier : Allow user to set Identifier -func (_options *SetProfileIdentityOptions) SetIdentifier(identifier string) *SetProfileIdentityOptions { - _options.Identifier = core.StringPtr(identifier) - return _options -} - -// SetType : Allow user to set Type -func (_options *SetProfileIdentityOptions) SetType(typeVar string) *SetProfileIdentityOptions { - _options.Type = core.StringPtr(typeVar) - return _options -} - -// SetIamID : Allow user to set IamID -func (_options *SetProfileIdentityOptions) SetIamID(iamID string) *SetProfileIdentityOptions { - _options.IamID = core.StringPtr(iamID) - return _options -} - -// SetAccounts : Allow user to set Accounts -func (_options *SetProfileIdentityOptions) SetAccounts(accounts []string) *SetProfileIdentityOptions { - _options.Accounts = accounts - return _options -} - -// SetDescription : Allow user to set Description -func (_options *SetProfileIdentityOptions) SetDescription(description string) *SetProfileIdentityOptions { - _options.Description = core.StringPtr(description) - return _options -} - -// SetHeaders : Allow user to set Headers -func (options *SetProfileIdentityOptions) SetHeaders(param map[string]string) *SetProfileIdentityOptions { - options.Headers = param - return options -} - -// TrustedProfile : Response body format for trusted profile V1 REST requests. -type TrustedProfile struct { - // Context with key properties for problem determination. - Context *ResponseContext `json:"context,omitempty"` - - // the unique identifier of the trusted profile. Example:'Profile-94497d0d-2ac3-41bf-a993-a49d1b14627c'. +// TrustedProfileTemplateResponse : Response body format for Trusted Profile Template REST requests. +type TrustedProfileTemplateResponse struct { + // ID of the the template. ID *string `json:"id" validate:"required"` - // Version of the trusted profile details object. You need to specify this value when updating the trusted profile to - // avoid stale updates. - EntityTag *string `json:"entity_tag" validate:"required"` + // Version of the the template. + Version *int64 `json:"version" validate:"required"` - // Cloud Resource Name of the item. Example Cloud Resource Name: - // 'crn:v1:bluemix:public:iam-identity:us-south:a/myaccount::profile:Profile-94497d0d-2ac3-41bf-a993-a49d1b14627c'. - CRN *string `json:"crn" validate:"required"` + // ID of the account where the template resides. + AccountID *string `json:"account_id" validate:"required"` - // Name of the trusted profile. The name is checked for uniqueness. Therefore trusted profiles with the same names can - // not exist in the same account. + // Name of the Template. Name *string `json:"name" validate:"required"` - // The optional description of the trusted profile. The 'description' property is only available if a description was - // provided during a create of a trusted profile. + // Description of the Template. Description *string `json:"description,omitempty"` - // If set contains a date time string of the creation date in ISO format. - CreatedAt *strfmt.DateTime `json:"created_at,omitempty"` + // Committed flag determines if the template is ready for assignment. + Committed *bool `json:"committed,omitempty"` - // If set contains a date time string of the last modification date in ISO format. - ModifiedAt *strfmt.DateTime `json:"modified_at,omitempty"` + // Input body parameters for the TemplateProfileComponent. + Profile *TemplateProfileComponentResponse `json:"profile,omitempty"` - // The iam_id of this trusted profile. - IamID *string `json:"iam_id" validate:"required"` + // Policy templates to be deployed for the Profile component. + PolicyTemplateReferences []PolicyTemplateReference `json:"policy_template_references,omitempty"` - // ID of the account that this trusted profile belong to. - AccountID *string `json:"account_id" validate:"required"` + // History of the Profile Template. + History []EnityHistoryRecord `json:"history,omitempty"` - // IMS acount ID of the trusted profile. - ImsAccountID *int64 `json:"ims_account_id,omitempty"` + // Entity tag for this templateId-version combination. + EntityTag *string `json:"entity_tag,omitempty"` - // IMS user ID of the trusted profile. - ImsUserID *int64 `json:"ims_user_id,omitempty"` + // Cloud resource name. + CRN *string `json:"crn,omitempty"` - // History of the trusted profile. - History []EnityHistoryRecord `json:"history,omitempty"` + // Template Created At. + CreatedAt *string `json:"created_at,omitempty"` - Activity *Activity `json:"activity,omitempty"` + // IAMid of the creator. + CreatedByID *string `json:"created_by_id,omitempty"` + + // Template last modified at. + LastModifiedAt *string `json:"last_modified_at,omitempty"` + + // IAMid of the identity that made the latest modification. + LastModifiedByID *string `json:"last_modified_by_id,omitempty"` } -// UnmarshalTrustedProfile unmarshals an instance of TrustedProfile from the specified map of raw messages. -func UnmarshalTrustedProfile(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(TrustedProfile) - err = core.UnmarshalModel(m, "context", &obj.Context, UnmarshalResponseContext) - if err != nil { - return - } +// UnmarshalTrustedProfileTemplateResponse unmarshals an instance of TrustedProfileTemplateResponse from the specified map of raw messages. +func UnmarshalTrustedProfileTemplateResponse(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(TrustedProfileTemplateResponse) err = core.UnmarshalPrimitive(m, "id", &obj.ID) if err != nil { return } - err = core.UnmarshalPrimitive(m, "entity_tag", &obj.EntityTag) + err = core.UnmarshalPrimitive(m, "version", &obj.Version) if err != nil { return } - err = core.UnmarshalPrimitive(m, "crn", &obj.CRN) + err = core.UnmarshalPrimitive(m, "account_id", &obj.AccountID) if err != nil { return } @@ -6371,35 +10996,43 @@ func UnmarshalTrustedProfile(m map[string]json.RawMessage, result interface{}) ( if err != nil { return } - err = core.UnmarshalPrimitive(m, "created_at", &obj.CreatedAt) + err = core.UnmarshalPrimitive(m, "committed", &obj.Committed) if err != nil { return } - err = core.UnmarshalPrimitive(m, "modified_at", &obj.ModifiedAt) + err = core.UnmarshalModel(m, "profile", &obj.Profile, UnmarshalTemplateProfileComponentResponse) if err != nil { return } - err = core.UnmarshalPrimitive(m, "iam_id", &obj.IamID) + err = core.UnmarshalModel(m, "policy_template_references", &obj.PolicyTemplateReferences, UnmarshalPolicyTemplateReference) if err != nil { return } - err = core.UnmarshalPrimitive(m, "account_id", &obj.AccountID) + err = core.UnmarshalModel(m, "history", &obj.History, UnmarshalEnityHistoryRecord) if err != nil { return } - err = core.UnmarshalPrimitive(m, "ims_account_id", &obj.ImsAccountID) + err = core.UnmarshalPrimitive(m, "entity_tag", &obj.EntityTag) if err != nil { return } - err = core.UnmarshalPrimitive(m, "ims_user_id", &obj.ImsUserID) + err = core.UnmarshalPrimitive(m, "crn", &obj.CRN) if err != nil { return } - err = core.UnmarshalModel(m, "history", &obj.History, UnmarshalEnityHistoryRecord) + err = core.UnmarshalPrimitive(m, "created_at", &obj.CreatedAt) if err != nil { return } - err = core.UnmarshalModel(m, "activity", &obj.Activity, UnmarshalActivity) + err = core.UnmarshalPrimitive(m, "created_by_id", &obj.CreatedByID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "last_modified_at", &obj.LastModifiedAt) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "last_modified_by_id", &obj.LastModifiedByID) if err != nil { return } @@ -6523,6 +11156,58 @@ func (options *UnlockServiceIDOptions) SetHeaders(param map[string]string) *Unlo return options } +// UpdateAccountSettingsAssignmentOptions : The UpdateAccountSettingsAssignment options. +type UpdateAccountSettingsAssignmentOptions struct { + // ID of the Assignment Record. + AssignmentID *string `json:"assignment_id" validate:"required,ne="` + + // Version of the Assignment to be updated. Specify the version that you retrieved when reading the Assignment. This + // value helps identifying parallel usage of this API. Pass * to indicate to update any version available. This might + // result in stale updates. + IfMatch *string `json:"If-Match" validate:"required"` + + // Template version which shall be applied to the assignment. Providing the existing version indicates to retry all + // failed assignments. Providing a new version start the assignment process from the beginning, migrating previously + // assignment resources to the new Version. + TemplateVersion *int64 `json:"template_version" validate:"required"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewUpdateAccountSettingsAssignmentOptions : Instantiate UpdateAccountSettingsAssignmentOptions +func (*IamIdentityV1) NewUpdateAccountSettingsAssignmentOptions(assignmentID string, ifMatch string, templateVersion int64) *UpdateAccountSettingsAssignmentOptions { + return &UpdateAccountSettingsAssignmentOptions{ + AssignmentID: core.StringPtr(assignmentID), + IfMatch: core.StringPtr(ifMatch), + TemplateVersion: core.Int64Ptr(templateVersion), + } +} + +// SetAssignmentID : Allow user to set AssignmentID +func (_options *UpdateAccountSettingsAssignmentOptions) SetAssignmentID(assignmentID string) *UpdateAccountSettingsAssignmentOptions { + _options.AssignmentID = core.StringPtr(assignmentID) + return _options +} + +// SetIfMatch : Allow user to set IfMatch +func (_options *UpdateAccountSettingsAssignmentOptions) SetIfMatch(ifMatch string) *UpdateAccountSettingsAssignmentOptions { + _options.IfMatch = core.StringPtr(ifMatch) + return _options +} + +// SetTemplateVersion : Allow user to set TemplateVersion +func (_options *UpdateAccountSettingsAssignmentOptions) SetTemplateVersion(templateVersion int64) *UpdateAccountSettingsAssignmentOptions { + _options.TemplateVersion = core.Int64Ptr(templateVersion) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *UpdateAccountSettingsAssignmentOptions) SetHeaders(param map[string]string) *UpdateAccountSettingsAssignmentOptions { + options.Headers = param + return options +} + // UpdateAccountSettingsOptions : The UpdateAccountSettings options. type UpdateAccountSettingsOptions struct { // Version of the account settings to be updated. Specify the version that you retrieved as entity_tag (ETag header) @@ -6592,49 +11277,49 @@ type UpdateAccountSettingsOptions struct { // Constants associated with the UpdateAccountSettingsOptions.RestrictCreateServiceID property. // Defines whether or not creating a Service Id is access controlled. Valid values: -// - RESTRICTED - to apply access control -// - NOT_RESTRICTED - to remove access control -// - NOT_SET - to unset a previously set value. +// * RESTRICTED - to apply access control +// * NOT_RESTRICTED - to remove access control +// * NOT_SET - to unset a previously set value. const ( UpdateAccountSettingsOptionsRestrictCreateServiceIDNotRestrictedConst = "NOT_RESTRICTED" - UpdateAccountSettingsOptionsRestrictCreateServiceIDNotSetConst = "NOT_SET" - UpdateAccountSettingsOptionsRestrictCreateServiceIDRestrictedConst = "RESTRICTED" + UpdateAccountSettingsOptionsRestrictCreateServiceIDNotSetConst = "NOT_SET" + UpdateAccountSettingsOptionsRestrictCreateServiceIDRestrictedConst = "RESTRICTED" ) // Constants associated with the UpdateAccountSettingsOptions.RestrictCreatePlatformApikey property. // Defines whether or not creating platform API keys is access controlled. Valid values: -// - RESTRICTED - to apply access control -// - NOT_RESTRICTED - to remove access control -// - NOT_SET - to 'unset' a previous set value. +// * RESTRICTED - to apply access control +// * NOT_RESTRICTED - to remove access control +// * NOT_SET - to 'unset' a previous set value. const ( UpdateAccountSettingsOptionsRestrictCreatePlatformApikeyNotRestrictedConst = "NOT_RESTRICTED" - UpdateAccountSettingsOptionsRestrictCreatePlatformApikeyNotSetConst = "NOT_SET" - UpdateAccountSettingsOptionsRestrictCreatePlatformApikeyRestrictedConst = "RESTRICTED" + UpdateAccountSettingsOptionsRestrictCreatePlatformApikeyNotSetConst = "NOT_SET" + UpdateAccountSettingsOptionsRestrictCreatePlatformApikeyRestrictedConst = "RESTRICTED" ) // Constants associated with the UpdateAccountSettingsOptions.Mfa property. // Defines the MFA trait for the account. Valid values: -// - NONE - No MFA trait set -// - NONE_NO_ROPC- No MFA, disable CLI logins with only a password -// - TOTP - For all non-federated IBMId users -// - TOTP4ALL - For all users -// - LEVEL1 - Email-based MFA for all users -// - LEVEL2 - TOTP-based MFA for all users -// - LEVEL3 - U2F MFA for all users. +// * NONE - No MFA trait set +// * NONE_NO_ROPC- No MFA, disable CLI logins with only a password +// * TOTP - For all non-federated IBMId users +// * TOTP4ALL - For all users +// * LEVEL1 - Email-based MFA for all users +// * LEVEL2 - TOTP-based MFA for all users +// * LEVEL3 - U2F MFA for all users. const ( - UpdateAccountSettingsOptionsMfaLevel1Const = "LEVEL1" - UpdateAccountSettingsOptionsMfaLevel2Const = "LEVEL2" - UpdateAccountSettingsOptionsMfaLevel3Const = "LEVEL3" - UpdateAccountSettingsOptionsMfaNoneConst = "NONE" + UpdateAccountSettingsOptionsMfaLevel1Const = "LEVEL1" + UpdateAccountSettingsOptionsMfaLevel2Const = "LEVEL2" + UpdateAccountSettingsOptionsMfaLevel3Const = "LEVEL3" + UpdateAccountSettingsOptionsMfaNoneConst = "NONE" UpdateAccountSettingsOptionsMfaNoneNoRopcConst = "NONE_NO_ROPC" - UpdateAccountSettingsOptionsMfaTotpConst = "TOTP" - UpdateAccountSettingsOptionsMfaTotp4allConst = "TOTP4ALL" + UpdateAccountSettingsOptionsMfaTotpConst = "TOTP" + UpdateAccountSettingsOptionsMfaTotp4allConst = "TOTP4ALL" ) // NewUpdateAccountSettingsOptions : Instantiate UpdateAccountSettingsOptions func (*IamIdentityV1) NewUpdateAccountSettingsOptions(ifMatch string, accountID string) *UpdateAccountSettingsOptions { return &UpdateAccountSettingsOptions{ - IfMatch: core.StringPtr(ifMatch), + IfMatch: core.StringPtr(ifMatch), AccountID: core.StringPtr(accountID), } } @@ -6717,6 +11402,91 @@ func (options *UpdateAccountSettingsOptions) SetHeaders(param map[string]string) return options } +// UpdateAccountSettingsTemplateVersionOptions : The UpdateAccountSettingsTemplateVersion options. +type UpdateAccountSettingsTemplateVersionOptions struct { + // Entity tag of the Template to be updated. Specify the tag that you retrieved when reading the Account Settings + // Template. This value helps identifying parallel usage of this API. Pass * to indicate to update any version + // available. This might result in stale updates. + IfMatch *string `json:"If-Match" validate:"required"` + + // ID of the Account Settings Template. + TemplateID *string `json:"template_id" validate:"required,ne="` + + // Version of the Account Settings Template. + Version *string `json:"version" validate:"required,ne="` + + // ID of the account where the template resides. + AccountID *string `json:"account_id,omitempty"` + + // Name of the Template. + Name *string `json:"name,omitempty"` + + // Description of the Template. + Description *string `json:"description,omitempty"` + + AccountSettings *AccountSettingsComponent `json:"account_settings,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewUpdateAccountSettingsTemplateVersionOptions : Instantiate UpdateAccountSettingsTemplateVersionOptions +func (*IamIdentityV1) NewUpdateAccountSettingsTemplateVersionOptions(ifMatch string, templateID string, version string) *UpdateAccountSettingsTemplateVersionOptions { + return &UpdateAccountSettingsTemplateVersionOptions{ + IfMatch: core.StringPtr(ifMatch), + TemplateID: core.StringPtr(templateID), + Version: core.StringPtr(version), + } +} + +// SetIfMatch : Allow user to set IfMatch +func (_options *UpdateAccountSettingsTemplateVersionOptions) SetIfMatch(ifMatch string) *UpdateAccountSettingsTemplateVersionOptions { + _options.IfMatch = core.StringPtr(ifMatch) + return _options +} + +// SetTemplateID : Allow user to set TemplateID +func (_options *UpdateAccountSettingsTemplateVersionOptions) SetTemplateID(templateID string) *UpdateAccountSettingsTemplateVersionOptions { + _options.TemplateID = core.StringPtr(templateID) + return _options +} + +// SetVersion : Allow user to set Version +func (_options *UpdateAccountSettingsTemplateVersionOptions) SetVersion(version string) *UpdateAccountSettingsTemplateVersionOptions { + _options.Version = core.StringPtr(version) + return _options +} + +// SetAccountID : Allow user to set AccountID +func (_options *UpdateAccountSettingsTemplateVersionOptions) SetAccountID(accountID string) *UpdateAccountSettingsTemplateVersionOptions { + _options.AccountID = core.StringPtr(accountID) + return _options +} + +// SetName : Allow user to set Name +func (_options *UpdateAccountSettingsTemplateVersionOptions) SetName(name string) *UpdateAccountSettingsTemplateVersionOptions { + _options.Name = core.StringPtr(name) + return _options +} + +// SetDescription : Allow user to set Description +func (_options *UpdateAccountSettingsTemplateVersionOptions) SetDescription(description string) *UpdateAccountSettingsTemplateVersionOptions { + _options.Description = core.StringPtr(description) + return _options +} + +// SetAccountSettings : Allow user to set AccountSettings +func (_options *UpdateAccountSettingsTemplateVersionOptions) SetAccountSettings(accountSettings *AccountSettingsComponent) *UpdateAccountSettingsTemplateVersionOptions { + _options.AccountSettings = accountSettings + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *UpdateAccountSettingsTemplateVersionOptions) SetHeaders(param map[string]string) *UpdateAccountSettingsTemplateVersionOptions { + options.Headers = param + return options +} + // UpdateAPIKeyOptions : The UpdateAPIKey options. type UpdateAPIKeyOptions struct { // Unique ID of the API key to be updated. @@ -6742,7 +11512,7 @@ type UpdateAPIKeyOptions struct { // NewUpdateAPIKeyOptions : Instantiate UpdateAPIKeyOptions func (*IamIdentityV1) NewUpdateAPIKeyOptions(id string, ifMatch string) *UpdateAPIKeyOptions { return &UpdateAPIKeyOptions{ - ID: core.StringPtr(id), + ID: core.StringPtr(id), IfMatch: core.StringPtr(ifMatch), } } @@ -6820,10 +11590,10 @@ type UpdateClaimRuleOptions struct { // NewUpdateClaimRuleOptions : Instantiate UpdateClaimRuleOptions func (*IamIdentityV1) NewUpdateClaimRuleOptions(profileID string, ruleID string, ifMatch string, typeVar string, conditions []ProfileClaimRuleConditions) *UpdateClaimRuleOptions { return &UpdateClaimRuleOptions{ - ProfileID: core.StringPtr(profileID), - RuleID: core.StringPtr(ruleID), - IfMatch: core.StringPtr(ifMatch), - Type: core.StringPtr(typeVar), + ProfileID: core.StringPtr(profileID), + RuleID: core.StringPtr(ruleID), + IfMatch: core.StringPtr(ifMatch), + Type: core.StringPtr(typeVar), Conditions: conditions, } } @@ -6920,7 +11690,7 @@ type UpdateProfileOptions struct { func (*IamIdentityV1) NewUpdateProfileOptions(profileID string, ifMatch string) *UpdateProfileOptions { return &UpdateProfileOptions{ ProfileID: core.StringPtr(profileID), - IfMatch: core.StringPtr(ifMatch), + IfMatch: core.StringPtr(ifMatch), } } @@ -6954,6 +11724,101 @@ func (options *UpdateProfileOptions) SetHeaders(param map[string]string) *Update return options } +// UpdateProfileTemplateVersionOptions : The UpdateProfileTemplateVersion options. +type UpdateProfileTemplateVersionOptions struct { + // Entity tag of the Template to be updated. Specify the tag that you retrieved when reading the Profile Template. This + // value helps identifying parallel usage of this API. Pass * to indicate to update any version available. This might + // result in stale updates. + IfMatch *string `json:"If-Match" validate:"required"` + + // ID of the Profile Template. + TemplateID *string `json:"template_id" validate:"required,ne="` + + // Version of the Profile Template. + Version *string `json:"version" validate:"required,ne="` + + // ID of the account where the template resides. + AccountID *string `json:"account_id,omitempty"` + + // Name of the Template. + Name *string `json:"name,omitempty"` + + // Description of the Template. + Description *string `json:"description,omitempty"` + + // Input body parameters for the TemplateProfileComponent. + Profile *TemplateProfileComponentRequest `json:"profile,omitempty"` + + // Policy templates to be deployed for the Profile component. + PolicyTemplateReferences []PolicyTemplateReference `json:"policy_template_references,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewUpdateProfileTemplateVersionOptions : Instantiate UpdateProfileTemplateVersionOptions +func (*IamIdentityV1) NewUpdateProfileTemplateVersionOptions(ifMatch string, templateID string, version string) *UpdateProfileTemplateVersionOptions { + return &UpdateProfileTemplateVersionOptions{ + IfMatch: core.StringPtr(ifMatch), + TemplateID: core.StringPtr(templateID), + Version: core.StringPtr(version), + } +} + +// SetIfMatch : Allow user to set IfMatch +func (_options *UpdateProfileTemplateVersionOptions) SetIfMatch(ifMatch string) *UpdateProfileTemplateVersionOptions { + _options.IfMatch = core.StringPtr(ifMatch) + return _options +} + +// SetTemplateID : Allow user to set TemplateID +func (_options *UpdateProfileTemplateVersionOptions) SetTemplateID(templateID string) *UpdateProfileTemplateVersionOptions { + _options.TemplateID = core.StringPtr(templateID) + return _options +} + +// SetVersion : Allow user to set Version +func (_options *UpdateProfileTemplateVersionOptions) SetVersion(version string) *UpdateProfileTemplateVersionOptions { + _options.Version = core.StringPtr(version) + return _options +} + +// SetAccountID : Allow user to set AccountID +func (_options *UpdateProfileTemplateVersionOptions) SetAccountID(accountID string) *UpdateProfileTemplateVersionOptions { + _options.AccountID = core.StringPtr(accountID) + return _options +} + +// SetName : Allow user to set Name +func (_options *UpdateProfileTemplateVersionOptions) SetName(name string) *UpdateProfileTemplateVersionOptions { + _options.Name = core.StringPtr(name) + return _options +} + +// SetDescription : Allow user to set Description +func (_options *UpdateProfileTemplateVersionOptions) SetDescription(description string) *UpdateProfileTemplateVersionOptions { + _options.Description = core.StringPtr(description) + return _options +} + +// SetProfile : Allow user to set Profile +func (_options *UpdateProfileTemplateVersionOptions) SetProfile(profile *TemplateProfileComponentRequest) *UpdateProfileTemplateVersionOptions { + _options.Profile = profile + return _options +} + +// SetPolicyTemplateReferences : Allow user to set PolicyTemplateReferences +func (_options *UpdateProfileTemplateVersionOptions) SetPolicyTemplateReferences(policyTemplateReferences []PolicyTemplateReference) *UpdateProfileTemplateVersionOptions { + _options.PolicyTemplateReferences = policyTemplateReferences + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *UpdateProfileTemplateVersionOptions) SetHeaders(param map[string]string) *UpdateProfileTemplateVersionOptions { + options.Headers = param + return options +} + // UpdateServiceIDOptions : The UpdateServiceID options. type UpdateServiceIDOptions struct { // Unique ID of the service ID to be updated. @@ -6983,7 +11848,7 @@ type UpdateServiceIDOptions struct { // NewUpdateServiceIDOptions : Instantiate UpdateServiceIDOptions func (*IamIdentityV1) NewUpdateServiceIDOptions(id string, ifMatch string) *UpdateServiceIDOptions { return &UpdateServiceIDOptions{ - ID: core.StringPtr(id), + ID: core.StringPtr(id), IfMatch: core.StringPtr(ifMatch), } } @@ -7024,6 +11889,58 @@ func (options *UpdateServiceIDOptions) SetHeaders(param map[string]string) *Upda return options } +// UpdateTrustedProfileAssignmentOptions : The UpdateTrustedProfileAssignment options. +type UpdateTrustedProfileAssignmentOptions struct { + // ID of the Assignment Record. + AssignmentID *string `json:"assignment_id" validate:"required,ne="` + + // Version of the Assignment to be updated. Specify the version that you retrieved when reading the Assignment. This + // value helps identifying parallel usage of this API. Pass * to indicate to update any version available. This might + // result in stale updates. + IfMatch *string `json:"If-Match" validate:"required"` + + // Template version which shall be applied to the assignment. Providing the existing version indicates to retry all + // failed assignments. Providing a new version start the assignment process from the beginning, migrating previously + // assignment resources to the new Version. + TemplateVersion *int64 `json:"template_version" validate:"required"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewUpdateTrustedProfileAssignmentOptions : Instantiate UpdateTrustedProfileAssignmentOptions +func (*IamIdentityV1) NewUpdateTrustedProfileAssignmentOptions(assignmentID string, ifMatch string, templateVersion int64) *UpdateTrustedProfileAssignmentOptions { + return &UpdateTrustedProfileAssignmentOptions{ + AssignmentID: core.StringPtr(assignmentID), + IfMatch: core.StringPtr(ifMatch), + TemplateVersion: core.Int64Ptr(templateVersion), + } +} + +// SetAssignmentID : Allow user to set AssignmentID +func (_options *UpdateTrustedProfileAssignmentOptions) SetAssignmentID(assignmentID string) *UpdateTrustedProfileAssignmentOptions { + _options.AssignmentID = core.StringPtr(assignmentID) + return _options +} + +// SetIfMatch : Allow user to set IfMatch +func (_options *UpdateTrustedProfileAssignmentOptions) SetIfMatch(ifMatch string) *UpdateTrustedProfileAssignmentOptions { + _options.IfMatch = core.StringPtr(ifMatch) + return _options +} + +// SetTemplateVersion : Allow user to set TemplateVersion +func (_options *UpdateTrustedProfileAssignmentOptions) SetTemplateVersion(templateVersion int64) *UpdateTrustedProfileAssignmentOptions { + _options.TemplateVersion = core.Int64Ptr(templateVersion) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *UpdateTrustedProfileAssignmentOptions) SetHeaders(param map[string]string) *UpdateTrustedProfileAssignmentOptions { + options.Headers = param + return options +} + // UserActivity : UserActivity struct type UserActivity struct { // IAMid of the user. diff --git a/iamidentityv1/iam_identity_v1_examples_test.go b/iamidentityv1/iam_identity_v1_examples_test.go index cc4b0766..faab553f 100644 --- a/iamidentityv1/iam_identity_v1_examples_test.go +++ b/iamidentityv1/iam_identity_v1_examples_test.go @@ -23,6 +23,9 @@ import ( "encoding/json" "fmt" "os" + "strconv" + "strings" + "time" "github.com/IBM/go-sdk-core/v5/core" "github.com/IBM/platform-services-go-sdk/iamidentityv1" @@ -76,10 +79,26 @@ var _ = Describe(`IamIdentityV1 Examples Tests`, func() { claimRuleId string claimRuleEtag string claimRuleType string = "Profile-SAML" - realmName string = "https://w3id.sso.ibm.com/auth/sps/samlidp2/saml20" + realmName string = "https://sdk.test.realm/1234" linkId string accountSettingEtag string + + enterpriseAccountID string + enterpriseSubAccountID string + profileTemplateName string = "Example-Profile-Template" + profileTemplateProfileName string = "Example-Profile-From-Template" + profileTemplateId string + profileTemplateVersion int64 + profileTemplateEtag string + profileTemplateAssignmentId string + profileTemplateAssignmentEtag string + accountSettingsTemplateName string = "Example-AccountSettings-Template" + accountSettingsTemplateId string + accountSettingsTemplateVersion int64 + accountSettingsTemplateEtag string + accountSettingsTemplateAssignmentId string + accountSettingsTemplateAssignmentEtag string ) var shouldSkipTest = func() { @@ -120,6 +139,12 @@ var _ = Describe(`IamIdentityV1 Examples Tests`, func() { iamAPIKey = config["APIKEY"] Expect(iamAPIKey).ToNot(BeEmpty()) + enterpriseAccountID = config["ENTERPRISE_ACCOUNT_ID"] + Expect(enterpriseAccountID).ToNot(BeEmpty()) + + enterpriseSubAccountID = config["ENTERPRISE_SUBACCOUNT_ID"] + Expect(enterpriseSubAccountID).ToNot(BeEmpty()) + fmt.Printf("Service URL: %s\n", serviceURL) }) }) @@ -749,13 +774,13 @@ var _ = Describe(`IamIdentityV1 Examples Tests`, func() { // begin-set_profile_identities accounts := []string{accountID} - identity := &iamidentityv1.ProfileIdentity{ + identity := &iamidentityv1.ProfileIdentityRequest{ Identifier: &iamID, Accounts: accounts, Type: core.StringPtr("user"), Description: core.StringPtr("Identity description"), } - listProfileIdentity := []iamidentityv1.ProfileIdentity{*identity} + listProfileIdentity := []iamidentityv1.ProfileIdentityRequest{*identity} setProfileIdentitiesOptions := iamidentityv1.SetProfileIdentitiesOptions{ ProfileID: &profileId, Identities: listProfileIdentity, @@ -1023,5 +1048,788 @@ var _ = Describe(`IamIdentityV1 Examples Tests`, func() { Expect(response.StatusCode).To(Equal(200)) Expect(mfaStatusResponse).ToNot(BeNil()) }) + It(`CreateProfileTemplate request example`, func() { + fmt.Println("\nCreateProfileTemplate() result:") + // begin-create_profile_template + profileClaimRuleConditions := new(iamidentityv1.ProfileClaimRuleConditions) + profileClaimRuleConditions.Claim = core.StringPtr("blueGroups") + profileClaimRuleConditions.Operator = core.StringPtr("EQUALS") + profileClaimRuleConditions.Value = core.StringPtr("\"cloud-docs-dev\"") + + profileTemplateClaimRule := new(iamidentityv1.TrustedProfileTemplateClaimRule) + profileTemplateClaimRule.Name = core.StringPtr("My Rule") + profileTemplateClaimRule.RealmName = &realmName + profileTemplateClaimRule.Type = &claimRuleType + profileTemplateClaimRule.Expiration = core.Int64Ptr(int64(43200)) + profileTemplateClaimRule.Conditions = []iamidentityv1.ProfileClaimRuleConditions{*profileClaimRuleConditions} + + profile := new(iamidentityv1.TemplateProfileComponentRequest) + profile.Name = &profileTemplateProfileName + profile.Description = core.StringPtr("Example Profile created from Profile Template") + profile.Rules = []iamidentityv1.TrustedProfileTemplateClaimRule{*profileTemplateClaimRule} + + createOptions := &iamidentityv1.CreateProfileTemplateOptions{ + Name: &profileTemplateName, + Description: core.StringPtr("Example Profile Template"), + AccountID: &enterpriseAccountID, + Profile: profile, + } + + createResponse, response, err := iamIdentityService.CreateProfileTemplate(createOptions) + + b, _ := json.MarshalIndent(createResponse, "", " ") + fmt.Println(string(b)) + + // Grab the ID and Etag value from the response for use in the update operation + profileTemplateId = *createResponse.ID + profileTemplateVersion = *createResponse.Version + profileTemplateEtag = response.GetHeaders().Get("Etag") + + // end-create_profile_template + Expect(response.StatusCode).To(Equal(201)) + Expect(err).To(BeNil()) + Expect(createResponse).ToNot(BeNil()) + Expect(profileTemplateId).ToNot(BeNil()) + Expect(profileTemplateEtag).ToNot(BeEmpty()) + }) + It(`GetProfileTemplateVersion request example`, func() { + fmt.Println("\nGetProfileTemplateVersion() result:") + // begin-get_profile_template_version + + getOptions := &iamidentityv1.GetProfileTemplateVersionOptions{ + TemplateID: &profileTemplateId, + Version: core.StringPtr(strconv.FormatInt(profileTemplateVersion, 10)), + } + getResponse, response, err := iamIdentityService.GetProfileTemplateVersion(getOptions) + + b, _ := json.MarshalIndent(getResponse, "", " ") + fmt.Println(string(b)) + + // Grab the Etag value from the response for use in the update operation + profileTemplateEtag = response.GetHeaders().Get("Etag") + + // end-get_profile_template_version + Expect(response.StatusCode).To(Equal(200)) + Expect(err).To(BeNil()) + Expect(getResponse).ToNot(BeNil()) + Expect(profileTemplateEtag).ToNot(BeEmpty()) + }) + It(`ListProfileTemplates request example`, func() { + fmt.Println("\nListProfileTemplates() result:") + // begin-list_profile_templates + listOptions := &iamidentityv1.ListProfileTemplatesOptions{ + AccountID: &enterpriseAccountID, + } + listResponse, response, err := iamIdentityService.ListProfileTemplates(listOptions) + + b, _ := json.MarshalIndent(listResponse, "", " ") + fmt.Println(string(b)) + + // end-list_profile_templates + Expect(response.StatusCode).To(Equal(200)) + Expect(err).To(BeNil()) + Expect(listResponse).ToNot(BeNil()) + }) + It(`UpdateProfileTemplateVersion request example`, func() { + fmt.Println("\nUpdateProfileTemplateVersion() result:") + // begin-update_profile_template_version + + updateOptions := &iamidentityv1.UpdateProfileTemplateVersionOptions{ + AccountID: &enterpriseAccountID, + TemplateID: &profileTemplateId, + Version: core.StringPtr(strconv.FormatInt(profileTemplateVersion, 10)), + IfMatch: &profileTemplateEtag, + Name: &profileTemplateName, + Description: core.StringPtr("Example Profile Template - updated"), + } + updateResponse, response, err := iamIdentityService.UpdateProfileTemplateVersion(updateOptions) + + b, _ := json.MarshalIndent(updateResponse, "", " ") + fmt.Println(string(b)) + + // Grab the Etag value from the response for use in the update operation. + profileTemplateEtag = response.GetHeaders().Get("Etag") + + // end-update_profile_template_version + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(updateResponse).ToNot(BeNil()) + Expect(profileTemplateEtag).ToNot(BeEmpty()) + }) + It(`CommitProfileTemplate request example`, func() { + fmt.Println("\nCommitProfileTemplate() result:") + // begin-commit_profile_template + + commitOptions := &iamidentityv1.CommitProfileTemplateOptions{ + TemplateID: &profileTemplateId, + Version: core.StringPtr(strconv.FormatInt(profileTemplateVersion, 10)), + } + + response, err := iamIdentityService.CommitProfileTemplate(commitOptions) + + // end-commit_profile_template + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(204)) + }) + It(`CreateProfileTemplateAssignment request example`, func() { + fmt.Println("\nCreateProfileTemplateAssignment() result:") + // begin-create_trusted_profile_assignment + + assignOptions := &iamidentityv1.CreateTrustedProfileAssignmentOptions{ + TemplateID: &profileTemplateId, + TemplateVersion: &profileTemplateVersion, + TargetType: core.StringPtr("Account"), + Target: &enterpriseSubAccountID, + } + + assignResponse, response, err := iamIdentityService.CreateTrustedProfileAssignment(assignOptions) + + b, _ := json.MarshalIndent(assignResponse, "", " ") + fmt.Println(string(b)) + + // Grab the Etag and id for use by other test methods. + profileTemplateAssignmentEtag = response.GetHeaders().Get("Etag") + profileTemplateAssignmentId = *assignResponse.ID + + // end-create_trusted_profile_assignment + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(202)) + Expect(assignResponse).ToNot(BeNil()) + Expect(profileTemplateAssignmentId).ToNot(BeNil()) + Expect(profileTemplateAssignmentEtag).ToNot(BeEmpty()) + }) + It(`GetProfileTemplateAssignment request example`, func() { + fmt.Println("\nGetProfileTemplateAssignment() result:") + // begin-get_trusted_profile_assignment + + getAssignmentOptions := &iamidentityv1.GetTrustedProfileAssignmentOptions{ + AssignmentID: &profileTemplateAssignmentId, + } + + assignment, response, err := iamIdentityService.GetTrustedProfileAssignment(getAssignmentOptions) + + b, _ := json.MarshalIndent(assignment, "", " ") + fmt.Println(string(b)) + + // end-get_trusted_profile_assignment + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(assignment).ToNot(BeNil()) + }) + It(`ListTrustedProfileAssignments request example`, func() { + fmt.Println("\nListTrustedProfileAssignments() result:") + // begin-list_trusted_profile_assignments + + listOptions := &iamidentityv1.ListTrustedProfileAssignmentsOptions{ + AccountID: &enterpriseAccountID, + TemplateID: &profileTemplateId, + } + + listResponse, response, err := iamIdentityService.ListTrustedProfileAssignments(listOptions) + + b, _ := json.MarshalIndent(listResponse, "", " ") + fmt.Println(string(b)) + + // end-list_trusted_profile_assignments + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(listResponse).ToNot(BeNil()) + }) + It(`CreateProfileTemplateVersion request example`, func() { + fmt.Println("\nCreateProfileTemplateVersion() result:") + // begin-create_profile_template_version + + profileClaimRuleConditions := new(iamidentityv1.ProfileClaimRuleConditions) + profileClaimRuleConditions.Claim = core.StringPtr("blueGroups") + profileClaimRuleConditions.Operator = core.StringPtr("EQUALS") + profileClaimRuleConditions.Value = core.StringPtr("\"cloud-docs-dev\"") + + profileTemplateClaimRule := new(iamidentityv1.TrustedProfileTemplateClaimRule) + profileTemplateClaimRule.Name = core.StringPtr("My Rule") + profileTemplateClaimRule.RealmName = &realmName + profileTemplateClaimRule.Type = &claimRuleType + profileTemplateClaimRule.Expiration = core.Int64Ptr(int64(43200)) + profileTemplateClaimRule.Conditions = []iamidentityv1.ProfileClaimRuleConditions{*profileClaimRuleConditions} + + profile := new(iamidentityv1.TemplateProfileComponentRequest) + profile.Name = &profileTemplateProfileName + profile.Description = core.StringPtr("Example Profile created from Profile Template - new version") + profile.Rules = []iamidentityv1.TrustedProfileTemplateClaimRule{*profileTemplateClaimRule} + + createOptions := &iamidentityv1.CreateProfileTemplateVersionOptions{ + Name: &profileTemplateName, + Description: core.StringPtr("Example Profile Template - new version"), + AccountID: &enterpriseAccountID, + TemplateID: &profileTemplateId, + Profile: profile, + } + + createResponse, response, err := iamIdentityService.CreateProfileTemplateVersion(createOptions) + + b, _ := json.MarshalIndent(createResponse, "", " ") + fmt.Println(string(b)) + + // save the new version to be used in subsequent calls + profileTemplateVersion = *createResponse.Version + + // end-create_profile_template_version + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(201)) + Expect(createResponse).ToNot(BeNil()) + }) + It(`GetLatestProfileTemplateVersion request example`, func() { + fmt.Println("\nGetLatestProfileTemplateVersion() result:") + // begin-get_latest_profile_template_version + + getOptions := &iamidentityv1.GetLatestProfileTemplateVersionOptions{ + TemplateID: &profileTemplateId, + } + + getResponse, response, err := iamIdentityService.GetLatestProfileTemplateVersion(getOptions) + + b, _ := json.MarshalIndent(getResponse, "", " ") + fmt.Println(string(b)) + + // end-get_latest_profile_template_version + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(getResponse).ToNot(BeNil()) + }) + It(`ListVersionsOfProfileTemplate request example`, func() { + fmt.Println("\nListVersionsOfProfileTemplate() result:") + // begin-list_versions_of_profile_template + + listOptions := &iamidentityv1.ListVersionsOfProfileTemplateOptions{ + TemplateID: &profileTemplateId, + } + listResponse, response, err := iamIdentityService.ListVersionsOfProfileTemplate(listOptions) + + b, _ := json.MarshalIndent(listResponse, "", " ") + fmt.Println(string(b)) + + // end-list_versions_of_profile_template + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(listResponse).ToNot(BeNil()) + }) + It(`UpdateTrustedProfileAssignment request example`, func() { + + commitOptions := &iamidentityv1.CommitProfileTemplateOptions{ + TemplateID: &profileTemplateId, + Version: core.StringPtr(strconv.FormatInt(profileTemplateVersion, 10)), + } + cResponse, cErr := iamIdentityService.CommitProfileTemplate(commitOptions) + Expect(cResponse.StatusCode).To(Equal(204)) + Expect(cErr).To(BeNil()) + + waitUntilTrustedProfileAssignmentFinished(iamIdentityService, &profileTemplateAssignmentId, &profileTemplateAssignmentEtag) + + fmt.Println("\nUpdateTrustedProfileAssignment() result:") + // begin-update_trusted_profile_assignment + + updateOptions := &iamidentityv1.UpdateTrustedProfileAssignmentOptions{ + AssignmentID: &profileTemplateAssignmentId, + TemplateVersion: &profileTemplateVersion, + IfMatch: &profileTemplateAssignmentEtag, + } + + updateResponse, response, err := iamIdentityService.UpdateTrustedProfileAssignment(updateOptions) + + b, _ := json.MarshalIndent(updateResponse, "", " ") + fmt.Println(string(b)) + + // Grab the Etag and id for use by other test methods. + profileTemplateAssignmentEtag = response.GetHeaders().Get("Etag") + + // end-update_trusted_profile_assignment + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(202)) + Expect(updateResponse).ToNot(BeNil()) + Expect(profileTemplateAssignmentEtag).ToNot(BeEmpty()) + }) + It(`DeleteTrustedProfileAssignment request example`, func() { + waitUntilTrustedProfileAssignmentFinished(iamIdentityService, &profileTemplateAssignmentId, &profileTemplateAssignmentEtag) + + fmt.Println("\nDeleteTrustedProfileAssignmentx() result:") + // begin-delete_trusted_profile_assignment + + deleteOptions := &iamidentityv1.DeleteTrustedProfileAssignmentOptions{ + AssignmentID: &profileTemplateAssignmentId, + } + excResponse, response, err := iamIdentityService.DeleteTrustedProfileAssignment(deleteOptions) + + // end-delete_trusted_profile_assignment + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(202)) + Expect(excResponse).To(BeNil()) + }) + It(`DeleteProfileTemplateVersion request example`, func() { + fmt.Println("\nDeleteProfileTemplateVersion() result:") + // begin-delete_profile_template_version + + deleteOptions := &iamidentityv1.DeleteProfileTemplateVersionOptions{ + TemplateID: &profileTemplateId, + Version: core.StringPtr("1"), + } + + response, err := iamIdentityService.DeleteProfileTemplateVersion(deleteOptions) + + // end-delete_profile_template_version + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(204)) + }) + It(`DeleteProfileTemplateAllVersions request example`, func() { + waitUntilTrustedProfileAssignmentFinished(iamIdentityService, &profileTemplateAssignmentId, &profileTemplateAssignmentEtag) + + fmt.Println("\nDeleteProfileTemplateAllVersions() result:") + // begin-delete_all_versions_of_profile_template + + deleteOptions := &iamidentityv1.DeleteAllVersionsOfProfileTemplateOptions{ + TemplateID: &profileTemplateId, + } + + response, err := iamIdentityService.DeleteAllVersionsOfProfileTemplate(deleteOptions) + + // end-delete_all_versions_of_profile_template + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(204)) + }) + It(`createAccountSettingsTemplate request example`, func() { + + fmt.Println("\ncreateAccountSettingsTemplate() result:") + // begin-create_account_settings_template + + settings := &iamidentityv1.AccountSettingsComponent{ + Mfa: core.StringPtr("LEVEL1"), + SystemAccessTokenExpirationInSeconds: core.StringPtr("3000"), + } + + createOptions := &iamidentityv1.CreateAccountSettingsTemplateOptions{ + Name: &accountSettingsTemplateName, + Description: core.StringPtr("GoSDK test Account Settings Template"), + AccountID: &enterpriseAccountID, + AccountSettings: settings, + } + + createResponse, response, err := iamIdentityService.CreateAccountSettingsTemplate(createOptions) + + b, _ := json.MarshalIndent(createResponse, "", " ") + fmt.Println(string(b)) + + // Grab the ID and Etag value from the response for use in the update operation. + accountSettingsTemplateId = *createResponse.ID + accountSettingsTemplateVersion = *createResponse.Version + accountSettingsTemplateEtag = response.GetHeaders().Get("Etag") + + // end-create_account_settings_template + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(201)) + Expect(createResponse).ToNot(BeNil()) + Expect(accountSettingsTemplateId).ToNot(BeNil()) + Expect(accountSettingsTemplateEtag).ToNot(BeEmpty()) + }) + It(`getAccountSettingsTemplateVersion request example`, func() { + + fmt.Println("\ngetAccountSettingsTemplateVersion() result:") + // begin-get_account_settings_template_version + + getOptions := &iamidentityv1.GetAccountSettingsTemplateVersionOptions{ + TemplateID: &accountSettingsTemplateId, + Version: core.StringPtr(strconv.FormatInt(accountSettingsTemplateVersion, 10)), + } + + getResponse, response, err := iamIdentityService.GetAccountSettingsTemplateVersion(getOptions) + + b, _ := json.MarshalIndent(getResponse, "", " ") + fmt.Println(string(b)) + + // Grab the Etag value from the response for use in the update operation. + accountSettingsTemplateEtag = response.GetHeaders().Get("Etag") + + // end-get_account_settings_template_version + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(getResponse).ToNot(BeNil()) + Expect(accountSettingsTemplateEtag).ToNot(BeEmpty()) + }) + It(`listAccountSettingsTemplates request example`, func() { + + fmt.Println("\nlistAccountSettingsTemplates() result:") + // begin-list_account_settings_templates + + listOptions := &iamidentityv1.ListAccountSettingsTemplatesOptions{ + AccountID: &enterpriseAccountID, + } + + listResponse, response, err := iamIdentityService.ListAccountSettingsTemplates(listOptions) + + b, _ := json.MarshalIndent(listResponse, "", " ") + fmt.Println(string(b)) + + // end-list_account_settings_templates + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(listResponse).ToNot(BeNil()) + }) + It(`updateAccountSettingsTemplateVersion request example`, func() { + + fmt.Println("\nupdateAccountSettingsTemplateVersion() result:") + // begin-update_account_settings_template_version + + settings := &iamidentityv1.AccountSettingsComponent{ + Mfa: core.StringPtr("LEVEL1"), + SystemAccessTokenExpirationInSeconds: core.StringPtr("3000"), + } + + updateOptions := &iamidentityv1.UpdateAccountSettingsTemplateVersionOptions{ + AccountID: &enterpriseAccountID, + TemplateID: &accountSettingsTemplateId, + Version: core.StringPtr(strconv.FormatInt(accountSettingsTemplateVersion, 10)), + IfMatch: &accountSettingsTemplateEtag, + Name: &accountSettingsTemplateName, + Description: core.StringPtr("GoSDK test Account Settings Template - updated"), + AccountSettings: settings, + } + + updateResponse, response, err := iamIdentityService.UpdateAccountSettingsTemplateVersion(updateOptions) + + b, _ := json.MarshalIndent(updateResponse, "", " ") + fmt.Println(string(b)) + + // Grab the Etag value from the response for use in the update operation. + accountSettingsTemplateEtag = response.GetHeaders().Get("Etag") + + // end-update_account_settings_template_version + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(updateResponse).ToNot(BeNil()) + Expect(accountSettingsTemplateEtag).ToNot(BeEmpty()) + }) + It(`commitAccountSettingsTemplate request example`, func() { + + fmt.Println("\ncommitAccountSettingsTemplate() result:") + // begin-commit_account_settings_template + + commitOptions := &iamidentityv1.CommitAccountSettingsTemplateOptions{ + TemplateID: &accountSettingsTemplateId, + Version: core.StringPtr(strconv.FormatInt(accountSettingsTemplateVersion, 10)), + } + + response, err := iamIdentityService.CommitAccountSettingsTemplate(commitOptions) + + // end-commit_account_settings_template + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(204)) + }) + It(`createAccountSettingsAssignment request example`, func() { + + fmt.Println("\ncreateAccountSettingsAssignment() result:") + // begin-create_account_settings_assignment + + assignOptions := &iamidentityv1.CreateAccountSettingsAssignmentOptions{ + TemplateID: &accountSettingsTemplateId, + TemplateVersion: &accountSettingsTemplateVersion, + TargetType: core.StringPtr("Account"), + Target: &enterpriseSubAccountID, + } + + assignResponse, response, err := iamIdentityService.CreateAccountSettingsAssignment(assignOptions) + + b, _ := json.MarshalIndent(assignResponse, "", " ") + fmt.Println(string(b)) + + // Grab the Etag and id for use by other test methods. + accountSettingsTemplateAssignmentEtag = response.GetHeaders().Get("Etag") + accountSettingsTemplateAssignmentId = *assignResponse.ID + + // end-create_account_settings_assignment + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(202)) + Expect(assignResponse).ToNot(BeNil()) + Expect(accountSettingsTemplateAssignmentId).ToNot(BeNil()) + Expect(accountSettingsTemplateAssignmentEtag).ToNot(BeEmpty()) + }) + It(`listAccountSettingsAssignments request example`, func() { + + fmt.Println("\nlistAccountSettingsAssignments() result:") + // begin-list_account_settings_assignments + + listOptions := &iamidentityv1.ListAccountSettingsAssignmentsOptions{ + AccountID: &enterpriseAccountID, + TemplateID: &accountSettingsTemplateId, + } + + listResponse, response, err := iamIdentityService.ListAccountSettingsAssignments(listOptions) + + b, _ := json.MarshalIndent(listResponse, "", " ") + fmt.Println(string(b)) + + // end-list_account_settings_assignments + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(listResponse).ToNot(BeNil()) + }) + It(`getAccountSettingsAssignment request example`, func() { + + fmt.Println("\ngetAccountSettingsAssignment() result:") + // begin-get_account_settings_assignment + + getAssignmentOptions := &iamidentityv1.GetAccountSettingsAssignmentOptions{ + AssignmentID: &accountSettingsTemplateAssignmentId, + } + + assignment, response, err := iamIdentityService.GetAccountSettingsAssignment(getAssignmentOptions) + + b, _ := json.MarshalIndent(assignment, "", " ") + fmt.Println(string(b)) + + // end-get_account_settings_assignment + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(assignment).ToNot(BeNil()) + }) + It(`createAccountSettingsTemplateVersion request example`, func() { + + fmt.Println("\ncreateAccountSettingsTemplateVersion() result:") + // begin-create_account_settings_template_version + + settings := &iamidentityv1.AccountSettingsComponent{ + Mfa: core.StringPtr("LEVEL1"), + SystemAccessTokenExpirationInSeconds: core.StringPtr("2600"), + RestrictCreatePlatformApikey: core.StringPtr("RESTRICTED"), + RestrictCreateServiceID: core.StringPtr("RESTRICTED"), + } + + createOptions := &iamidentityv1.CreateAccountSettingsTemplateVersionOptions{ + Name: &accountSettingsTemplateName, + Description: core.StringPtr("GoSDK test Account Settings Template - new version"), + AccountID: &enterpriseAccountID, + TemplateID: &accountSettingsTemplateId, + AccountSettings: settings, + } + + createResponse, response, err := iamIdentityService.CreateAccountSettingsTemplateVersion(createOptions) + + b, _ := json.MarshalIndent(createResponse, "", " ") + fmt.Println(string(b)) + + // save the new version to be used in subsequent calls + accountSettingsTemplateVersion = *createResponse.Version + + // end-create_account_settings_template_version + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(201)) + Expect(createResponse).ToNot(BeNil()) + Expect(accountSettingsTemplateVersion).ToNot(BeNil()) + }) + It(`getLatestAccountSettingsTemplateVersion request example`, func() { + + fmt.Println("\ngetLatestAccountSettingsTemplateVersion() result:") + // begin-get_latest_account_settings_template_version + + getOptions := &iamidentityv1.GetLatestAccountSettingsTemplateVersionOptions{ + TemplateID: &accountSettingsTemplateId, + } + + getResponse, response, err := iamIdentityService.GetLatestAccountSettingsTemplateVersion(getOptions) + + b, _ := json.MarshalIndent(getResponse, "", " ") + fmt.Println(string(b)) + + // end-get_latest_account_settings_template_version + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(getResponse).ToNot(BeNil()) + }) + It(`listVersionsOfAccountSettingsTemplate request example`, func() { + + fmt.Println("\nlistVersionsOfAccountSettingsTemplate() result:") + // begin-list_versions_of_account_settings_template + + listOptions := &iamidentityv1.ListVersionsOfAccountSettingsTemplateOptions{ + TemplateID: &accountSettingsTemplateId, + } + + listResponse, response, err := iamIdentityService.ListVersionsOfAccountSettingsTemplate(listOptions) + + b, _ := json.MarshalIndent(listResponse, "", " ") + fmt.Println(string(b)) + + // end-list_versions_of_account_settings_template + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(listResponse).ToNot(BeNil()) + }) + It(`updateAccountSettingsAssignment request example`, func() { + + commitOptions := &iamidentityv1.CommitAccountSettingsTemplateOptions{ + TemplateID: &accountSettingsTemplateId, + Version: core.StringPtr(strconv.FormatInt(accountSettingsTemplateVersion, 10)), + } + cResponse, cErr := iamIdentityService.CommitAccountSettingsTemplate(commitOptions) + Expect(cResponse.StatusCode).To(Equal(204)) + Expect(cErr).To(BeNil()) + + waitUntilAccountSettingsAssignmentFinished(iamIdentityService, &accountSettingsTemplateAssignmentId, &accountSettingsTemplateAssignmentEtag) + + fmt.Println("\nupdateAccountSettingsAssignment() result:") + // begin-update_account_settings_assignment + + updateOptions := &iamidentityv1.UpdateAccountSettingsAssignmentOptions{ + AssignmentID: &accountSettingsTemplateAssignmentId, + TemplateVersion: &accountSettingsTemplateVersion, + IfMatch: &accountSettingsTemplateAssignmentEtag, + } + + updateResponse, response, err := iamIdentityService.UpdateAccountSettingsAssignment(updateOptions) + + b, _ := json.MarshalIndent(updateResponse, "", " ") + fmt.Println(string(b)) + + // end-update_account_settings_assignment + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(202)) + Expect(updateResponse).ToNot(BeNil()) + }) + It(`deleteAccountSettingsAssignment request example`, func() { + + waitUntilAccountSettingsAssignmentFinished(iamIdentityService, &accountSettingsTemplateAssignmentId, &accountSettingsTemplateAssignmentEtag) + + fmt.Println("\ndeleteAccountSettingsAssignment() result:") + // begin-delete_account_settings_assignment + + deleteOptions := &iamidentityv1.DeleteAccountSettingsAssignmentOptions{ + AssignmentID: &accountSettingsTemplateAssignmentId, + } + + excResponse, response, err := iamIdentityService.DeleteAccountSettingsAssignment(deleteOptions) + + // end-delete_account_settings_assignment + + Expect(response.StatusCode).To(Equal(202)) + Expect(err).To(BeNil()) + Expect(excResponse).To(BeNil()) + }) + It(`deleteAccountSettingsTemplateVersion request example`, func() { + + fmt.Println("\ndeleteAccountSettingsTemplateVersion() result:") + // begin-delete_account_settings_template_version + + deleteOptions := &iamidentityv1.DeleteAccountSettingsTemplateVersionOptions{ + TemplateID: &accountSettingsTemplateId, + Version: core.StringPtr("1"), + } + + response, err := iamIdentityService.DeleteAccountSettingsTemplateVersion(deleteOptions) + + // end-delete_account_settings_template_version + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(204)) + }) + It(`deleteAllVersionsOfAccountSettingsTemplate request example`, func() { + + waitUntilAccountSettingsAssignmentFinished(iamIdentityService, &accountSettingsTemplateAssignmentId, &accountSettingsTemplateAssignmentEtag) + + fmt.Println("\ndeleteAllVersionsOfAccountSettingsTemplate() result:") + // begin-delete_all_versions_of_account_settings_template + + deleteOptions := &iamidentityv1.DeleteAllVersionsOfAccountSettingsTemplateOptions{ + TemplateID: &accountSettingsTemplateId, + } + + response, err := iamIdentityService.DeleteAllVersionsOfAccountSettingsTemplate(deleteOptions) + + // end-delete_all_versions_of_account_settings_template + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(204)) + }) }) }) + +func isFinished(status *string) bool { + var finished = false + if strings.EqualFold(*status, "succeeded") || strings.EqualFold(*status, "failed") { + finished = true + } + return finished +} + +func waitUntilTrustedProfileAssignmentFinished(service *iamidentityv1.IamIdentityV1, assignmentId *string, profileTemplateAssignmentEtag *string) { + getAssignmentOptions := &iamidentityv1.GetTrustedProfileAssignmentOptions{ + AssignmentID: assignmentId, + } + + var finished = true + for i := 0; i < 30; i++ { + assignment, response, err := service.GetTrustedProfileAssignment(getAssignmentOptions) + if response.StatusCode == 404 { + Expect(err).ToNot(BeNil()) + finished = true // assignment removed + break + } else { + finished = isFinished(assignment.Status) + if finished { + // Grab the Etag value from the response for use in the update operation. + Expect(response.GetHeaders()).ToNot(BeNil()) + *profileTemplateAssignmentEtag = response.GetHeaders().Get("Etag") + Expect(*profileTemplateAssignmentEtag).ToNot(BeEmpty()) + break + } + } + time.Sleep(10 * time.Second) + } + Expect(finished).To(BeTrue()) +} + +func waitUntilAccountSettingsAssignmentFinished(service *iamidentityv1.IamIdentityV1, assignmentId *string, accountSettingsTemplateAssignmentEtag *string) { + getAssignmentOptions := &iamidentityv1.GetAccountSettingsAssignmentOptions{ + AssignmentID: assignmentId, + } + + var finished = true + for i := 0; i < 30; i++ { + assignment, response, err := service.GetAccountSettingsAssignment(getAssignmentOptions) + if response.StatusCode == 404 { + Expect(err).ToNot(BeNil()) + finished = true // assignment removed + break + } else { + finished = isFinished(assignment.Status) + if finished { + // Grab the Etag value from the response for use in the update operation. + Expect(response.GetHeaders()).ToNot(BeNil()) + *accountSettingsTemplateAssignmentEtag = response.GetHeaders().Get("Etag") + Expect(*accountSettingsTemplateAssignmentEtag).ToNot(BeEmpty()) + break + } + } + time.Sleep(10 * time.Second) + } + Expect(finished).To(BeTrue()) +} diff --git a/iamidentityv1/iam_identity_v1_integration_test.go b/iamidentityv1/iam_identity_v1_integration_test.go index 6440a571..66124f89 100644 --- a/iamidentityv1/iam_identity_v1_integration_test.go +++ b/iamidentityv1/iam_identity_v1_integration_test.go @@ -24,6 +24,8 @@ import ( "log" "net/url" "os" + "strconv" + "strings" "time" "github.com/IBM/go-sdk-core/v5/core" @@ -55,7 +57,7 @@ var _ = Describe(`IamIdentityV1 Integration Tests`, func() { iamIDMember string iamAPIKey string claimRuleType string = "Profile-SAML" - realmName string = "https://w3id.sso.ibm.com/auth/sps/samlidp2/saml20" + realmName string = "https://sdk.test.realm/1234" iamIdentityService *iamidentityv1.IamIdentityV1 err error @@ -85,6 +87,22 @@ var _ = Describe(`IamIdentityV1 Integration Tests`, func() { reportId string reportReferenceMfa string + + enterpriseAccountID string + enterpriseSubAccountID string + profileTemplateName string = "Go-SDK-IT-Profile-Template" + profileTemplateProfileName string = "Go-SDK-IT-Profile-From-Template" + profileTemplateId string + profileTemplateVersion int64 + profileTemplateEtag string + profileTemplateAssignmentId string + profileTemplateAssignmentEtag string + accountSettingsTemplateName string = "Go-SDK-IT-AccountSettings-Template" + accountSettingsTemplateId string + accountSettingsTemplateVersion int64 + accountSettingsTemplateEtag string + accountSettingsTemplateAssignmentId string + accountSettingsTemplateAssignmentEtag string ) var shouldSkipTest = func() { @@ -122,6 +140,12 @@ var _ = Describe(`IamIdentityV1 Integration Tests`, func() { fmt.Fprintf(GinkgoWriter, "Service URL: %s\n", serviceURL) shouldSkipTest = func() {} + + enterpriseAccountID = config["ENTERPRISE_ACCOUNT_ID"] + Expect(enterpriseAccountID).ToNot(BeEmpty()) + + enterpriseSubAccountID = config["ENTERPRISE_SUBACCOUNT_ID"] + Expect(enterpriseSubAccountID).ToNot(BeEmpty()) }) }) @@ -144,7 +168,7 @@ var _ = Describe(`IamIdentityV1 Integration Tests`, func() { }) It("Successfully setup the environment for tests", func() { fmt.Fprintln(GinkgoWriter, "Setup...") - cleanupResources(iamIdentityService, accountID, iamID, apikeyName, serviceIDName, profileName1, profileName2) + cleanupResources(iamIdentityService, accountID, iamID, apikeyName, serviceIDName, profileName1, profileName2, enterpriseAccountID, profileTemplateName, &profileTemplateAssignmentEtag, accountSettingsTemplateName, &accountSettingsTemplateAssignmentEtag) fmt.Fprintln(GinkgoWriter, "Finished setup.") }) }) @@ -1041,26 +1065,26 @@ var _ = Describe(`IamIdentityV1 Integration Tests`, func() { It(`SetProfileIdentities(setProfileIdentitiesOptions *SetProfileIdentitiesOptions)`, func() { accounts := []string{accountID} - identity := &iamidentityv1.ProfileIdentity{ + identity := &iamidentityv1.ProfileIdentityRequest{ Identifier: &iamID, Accounts: accounts, Type: core.StringPtr("user"), Description: core.StringPtr("Identity description"), } - listProfileIdentity := []iamidentityv1.ProfileIdentity{*identity} + listProfileIdentity := []iamidentityv1.ProfileIdentityRequest{*identity} setProfileIdentitiesOptions := iamidentityv1.SetProfileIdentitiesOptions{ ProfileID: &profileId2, Identities: listProfileIdentity, IfMatch: core.StringPtr("*"), } - profileIdnetities, response, err := iamIdentityService.SetProfileIdentities(&setProfileIdentitiesOptions) + profileIdentities, response, err := iamIdentityService.SetProfileIdentities(&setProfileIdentitiesOptions) Expect(err).To(BeNil()) Expect(response.StatusCode).To(Equal(200)) - Expect(profileIdnetities.Identities).ToNot(BeNil()) - fmt.Fprintf(GinkgoWriter, "SetProfileIdentities #1 response:\n%s\n", common.ToJSON(profileIdnetities)) + Expect(profileIdentities.Identities).ToNot(BeNil()) + fmt.Fprintf(GinkgoWriter, "SetProfileIdentities #1 response:\n%s\n", common.ToJSON(profileIdentities)) }) }) @@ -1074,14 +1098,14 @@ var _ = Describe(`IamIdentityV1 Integration Tests`, func() { ProfileID: &profileId2, } - profileIdnetities, response, err := iamIdentityService.GetProfileIdentities(&getProfileIdentitiesOptions) + profileIdentities, response, err := iamIdentityService.GetProfileIdentities(&getProfileIdentitiesOptions) Expect(err).To(BeNil()) Expect(response.StatusCode).To(Equal(200)) - Expect(profileIdnetities.Identities).ToNot(BeNil()) - Expect(profileIdnetities.Identities[0].Identifier).ToNot(BeNil()) - fmt.Fprintf(GinkgoWriter, "SetProfileIdentities #1 response:\n%s\n", common.ToJSON(profileIdnetities)) + Expect(profileIdentities.Identities).ToNot(BeNil()) + Expect(profileIdentities.Identities[0].Identifier).ToNot(BeNil()) + fmt.Fprintf(GinkgoWriter, "SetProfileIdentities #1 response:\n%s\n", common.ToJSON(profileIdentities)) }) }) @@ -1668,9 +1692,603 @@ var _ = Describe(`IamIdentityV1 Integration Tests`, func() { }) }) + Describe(`CreateProfileTemplateIT`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`CreateProfileTemplateIT`, func() { + profileClaimRuleConditions := new(iamidentityv1.ProfileClaimRuleConditions) + profileClaimRuleConditions.Claim = core.StringPtr("blueGroups") + profileClaimRuleConditions.Operator = core.StringPtr("EQUALS") + profileClaimRuleConditions.Value = core.StringPtr("\"cloud-docs-dev\"") + + profileTemplateClaimRule := new(iamidentityv1.TrustedProfileTemplateClaimRule) + profileTemplateClaimRule.Name = core.StringPtr("My Rule") + profileTemplateClaimRule.RealmName = &realmName + profileTemplateClaimRule.Type = &claimRuleType + profileTemplateClaimRule.Expiration = core.Int64Ptr(int64(43200)) + profileTemplateClaimRule.Conditions = []iamidentityv1.ProfileClaimRuleConditions{*profileClaimRuleConditions} + + profile := new(iamidentityv1.TemplateProfileComponentRequest) + profile.Name = &profileTemplateProfileName + profile.Description = core.StringPtr("GoSDK test Profile cretaed from Profile Template") + profile.Rules = []iamidentityv1.TrustedProfileTemplateClaimRule{*profileTemplateClaimRule} + + createOptions := &iamidentityv1.CreateProfileTemplateOptions{ + Name: &profileTemplateName, + Description: core.StringPtr("GoSDK test Profile Template"), + AccountID: &enterpriseAccountID, + Profile: profile, + } + + createResponse, response, err := iamIdentityService.CreateProfileTemplate(createOptions) + Expect(response.StatusCode).To(Equal(201)) + Expect(err).To(BeNil()) + Expect(createResponse).ToNot(BeNil()) + + // Grab the ID and Etag value from the response for use in the update operation. + profileTemplateId = *createResponse.ID + Expect(profileTemplateId).ToNot(BeNil()) + profileTemplateVersion = *createResponse.Version + Expect(response.GetHeaders()).ToNot(BeNil()) + profileTemplateEtag = response.GetHeaders().Get("Etag") + Expect(profileTemplateEtag).ToNot(BeEmpty()) + }) + }) + + Describe(`GetProfileTemplateIT`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`GetProfileTemplateIT`, func() { + getOptions := &iamidentityv1.GetProfileTemplateVersionOptions{ + TemplateID: &profileTemplateId, + Version: core.StringPtr(strconv.FormatInt(profileTemplateVersion, 10)), + } + getResponse, response, err := iamIdentityService.GetProfileTemplateVersion(getOptions) + Expect(response.StatusCode).To(Equal(200)) + Expect(err).To(BeNil()) + Expect(getResponse).ToNot(BeNil()) + // Grab the Etag value from the response for use in the update operation. + Expect(response.GetHeaders()).ToNot(BeNil()) + profileTemplateEtag = response.GetHeaders().Get("Etag") + Expect(profileTemplateEtag).ToNot(BeEmpty()) + }) + }) + + Describe(`ListProfileTemplatesIT`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`ListProfileTemplatesIT`, func() { + listOptions := &iamidentityv1.ListProfileTemplatesOptions{ + AccountID: &enterpriseAccountID, + } + listResponse, response, err := iamIdentityService.ListProfileTemplates(listOptions) + Expect(response.StatusCode).To(Equal(200)) + Expect(err).To(BeNil()) + Expect(listResponse).ToNot(BeNil()) + }) + }) + + Describe(`UpdateProfileTemplateIT`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`UpdateProfileTemplateIT`, func() { + updateOptions := &iamidentityv1.UpdateProfileTemplateVersionOptions{ + AccountID: &enterpriseAccountID, + TemplateID: &profileTemplateId, + Version: core.StringPtr(strconv.FormatInt(profileTemplateVersion, 10)), + IfMatch: &profileTemplateEtag, + Name: &profileTemplateName, + Description: core.StringPtr("GoSDK test Profile Template - updated"), + } + updateResponse, response, err := iamIdentityService.UpdateProfileTemplateVersion(updateOptions) + Expect(response.StatusCode).To(Equal(200)) + Expect(err).To(BeNil()) + Expect(updateResponse).ToNot(BeNil()) + // Grab the Etag value from the response for use in the update operation. + Expect(response.GetHeaders()).ToNot(BeNil()) + profileTemplateEtag = response.GetHeaders().Get("Etag") + Expect(profileTemplateEtag).ToNot(BeEmpty()) + }) + }) + + Describe(`AssignProfileTemplateIT`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`AssignProfileTemplateIT`, func() { + commitOptions := &iamidentityv1.CommitProfileTemplateOptions{ + TemplateID: &profileTemplateId, + Version: core.StringPtr(strconv.FormatInt(profileTemplateVersion, 10)), + } + cResponse, cErr := iamIdentityService.CommitProfileTemplate(commitOptions) + Expect(cResponse.StatusCode).To(Equal(204)) + Expect(cErr).To(BeNil()) + + assignOptions := &iamidentityv1.CreateTrustedProfileAssignmentOptions{ + TemplateID: &profileTemplateId, + TemplateVersion: &profileTemplateVersion, + TargetType: core.StringPtr("Account"), + Target: &enterpriseSubAccountID, + } + assignResponse, aResponse, aErr := iamIdentityService.CreateTrustedProfileAssignment(assignOptions) + Expect(aResponse.StatusCode).To(Equal(202)) + Expect(aErr).To(BeNil()) + Expect(assignResponse).ToNot(BeNil()) + // Grab the Etag and id for use by other test methods. + Expect(aResponse.GetHeaders()).ToNot(BeNil()) + profileTemplateAssignmentEtag = aResponse.GetHeaders().Get("Etag") + Expect(profileTemplateAssignmentEtag).ToNot(BeEmpty()) + profileTemplateAssignmentId = *assignResponse.ID + Expect(profileTemplateAssignmentId).ToNot(BeNil()) + }) + }) + + Describe(`ListProfileTemplateAssignmentsIT`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`ListProfileTemplateAssignmentsIT`, func() { + listOptions := &iamidentityv1.ListTrustedProfileAssignmentsOptions{ + AccountID: &enterpriseAccountID, + TemplateID: &profileTemplateId, + } + listResponse, response, err := iamIdentityService.ListTrustedProfileAssignments(listOptions) + Expect(response.StatusCode).To(Equal(200)) + Expect(err).To(BeNil()) + Expect(listResponse).ToNot(BeNil()) + Expect(listResponse.Assignments).ToNot(BeNil()) + numAssignments := len(listResponse.Assignments) + Expect(numAssignments).ToNot(BeZero()) + }) + }) + + Describe(`CreateNewProfileTemplateVersionIT`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`CreateNewProfileTemplateVersionIT`, func() { + profileClaimRuleConditions := new(iamidentityv1.ProfileClaimRuleConditions) + profileClaimRuleConditions.Claim = core.StringPtr("blueGroups") + profileClaimRuleConditions.Operator = core.StringPtr("EQUALS") + profileClaimRuleConditions.Value = core.StringPtr("\"cloud-docs-dev\"") + + profileTemplateClaimRule := new(iamidentityv1.TrustedProfileTemplateClaimRule) + profileTemplateClaimRule.Name = core.StringPtr("My Rule") + profileTemplateClaimRule.RealmName = &realmName + profileTemplateClaimRule.Type = &claimRuleType + profileTemplateClaimRule.Expiration = core.Int64Ptr(int64(43200)) + profileTemplateClaimRule.Conditions = []iamidentityv1.ProfileClaimRuleConditions{*profileClaimRuleConditions} + + profile := new(iamidentityv1.TemplateProfileComponentRequest) + profile.Name = &profileTemplateProfileName + profile.Description = core.StringPtr("GoSDK test Profile cretaed from Profile Template - new version") + profile.Rules = []iamidentityv1.TrustedProfileTemplateClaimRule{*profileTemplateClaimRule} + + createOptions := &iamidentityv1.CreateProfileTemplateVersionOptions{ + Name: &profileTemplateName, + Description: core.StringPtr("GoSDK test Profile Template - new version"), + AccountID: &enterpriseAccountID, + TemplateID: &profileTemplateId, + Profile: profile, + } + + createResponse, response, err := iamIdentityService.CreateProfileTemplateVersion(createOptions) + Expect(response.StatusCode).To(Equal(201)) + Expect(err).To(BeNil()) + Expect(createResponse).ToNot(BeNil()) + // save the new version to be used in subsequent calls + profileTemplateVersion = *createResponse.Version + Expect(response.GetHeaders()).ToNot(BeNil()) + }) + }) + + Describe(`GetLatestProfileTemplateVersionIT`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`GetLatestProfileTemplateVersionIT`, func() { + getOptions := &iamidentityv1.GetLatestProfileTemplateVersionOptions{ + TemplateID: &profileTemplateId, + } + getResponse, response, err := iamIdentityService.GetLatestProfileTemplateVersion(getOptions) + Expect(response.StatusCode).To(Equal(200)) + Expect(err).To(BeNil()) + Expect(getResponse).ToNot(BeNil()) + }) + }) + + Describe(`ListProfileTemplateVersionsIT`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`ListProfileTemplateVersionsIT`, func() { + listOptions := &iamidentityv1.ListVersionsOfProfileTemplateOptions{ + TemplateID: &profileTemplateId, + } + listResponse, response, err := iamIdentityService.ListVersionsOfProfileTemplate(listOptions) + Expect(response.StatusCode).To(Equal(200)) + Expect(err).To(BeNil()) + Expect(listResponse).ToNot(BeNil()) + Expect(listResponse.ProfileTemplates).ToNot(BeNil()) + numTemplates := len(listResponse.ProfileTemplates) + Expect(numTemplates).ToNot(BeZero()) + }) + }) + + Describe(`UpdateProfileTemplateAssignmentIT`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`UpdateProfileTemplateAssignmentIT`, func() { + commitOptions := &iamidentityv1.CommitProfileTemplateOptions{ + TemplateID: &profileTemplateId, + Version: core.StringPtr(strconv.FormatInt(profileTemplateVersion, 10)), + } + cResponse, cErr := iamIdentityService.CommitProfileTemplate(commitOptions) + Expect(cResponse.StatusCode).To(Equal(204)) + Expect(cErr).To(BeNil()) + + waitUntilTrustedProfileAssignmentFinishedIT(iamIdentityService, &profileTemplateAssignmentId, &profileTemplateAssignmentEtag) + + updateOptions := &iamidentityv1.UpdateTrustedProfileAssignmentOptions{ + AssignmentID: &profileTemplateAssignmentId, + TemplateVersion: &profileTemplateVersion, + IfMatch: &profileTemplateAssignmentEtag, + } + updateResponse, uResponse, uErr := iamIdentityService.UpdateTrustedProfileAssignment(updateOptions) + Expect(uResponse.StatusCode).To(Equal(202)) + Expect(uErr).To(BeNil()) + Expect(updateResponse).ToNot(BeNil()) + // Grab the Etag and id for use by other test methods. + Expect(uResponse.GetHeaders()).ToNot(BeNil()) + profileTemplateAssignmentEtag = uResponse.GetHeaders().Get("Etag") + Expect(profileTemplateAssignmentEtag).ToNot(BeEmpty()) + }) + }) + + Describe(`DeleteProfileTemplateAssignmentIT`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`DeleteProfileTemplateAssignmentIT`, func() { + waitUntilTrustedProfileAssignmentFinishedIT(iamIdentityService, &profileTemplateAssignmentId, &profileTemplateAssignmentEtag) + + deleteOptions := &iamidentityv1.DeleteTrustedProfileAssignmentOptions{ + AssignmentID: &profileTemplateAssignmentId, + } + excResponse, response, err := iamIdentityService.DeleteTrustedProfileAssignment(deleteOptions) + Expect(response.StatusCode).To(Equal(202)) + Expect(err).To(BeNil()) + Expect(excResponse).To(BeNil()) + }) + }) + + Describe(`DeleteProfileTemplateVersionIT`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`DeleteProfileTemplateVersionIT`, func() { + deleteOptions := &iamidentityv1.DeleteProfileTemplateVersionOptions{ + TemplateID: &profileTemplateId, + Version: core.StringPtr("1"), + } + response, err := iamIdentityService.DeleteProfileTemplateVersion(deleteOptions) + Expect(response.StatusCode).To(Equal(204)) + Expect(err).To(BeNil()) + }) + }) + + Describe(`DeleteProfileTemplateIT`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`DeleteProfileTemplateIT`, func() { + waitUntilTrustedProfileAssignmentFinishedIT(iamIdentityService, &profileTemplateAssignmentId, &profileTemplateAssignmentEtag) + + deleteOptions := &iamidentityv1.DeleteAllVersionsOfProfileTemplateOptions{ + TemplateID: &profileTemplateId, + } + response, err := iamIdentityService.DeleteAllVersionsOfProfileTemplate(deleteOptions) + Expect(response.StatusCode).To(Equal(204)) + Expect(err).To(BeNil()) + }) + }) + + Describe(`CreateAccountSettingsTemplateIT`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`CreateAccountSettingsTemplateIT`, func() { + + settings := &iamidentityv1.AccountSettingsComponent{ + Mfa: core.StringPtr("LEVEL1"), + SystemAccessTokenExpirationInSeconds: core.StringPtr("3000"), + } + createOptions := &iamidentityv1.CreateAccountSettingsTemplateOptions{ + Name: &accountSettingsTemplateName, + Description: core.StringPtr("GoSDK test Account Settings Template"), + AccountID: &enterpriseAccountID, + AccountSettings: settings, + } + + createResponse, response, err := iamIdentityService.CreateAccountSettingsTemplate(createOptions) + Expect(response.StatusCode).To(Equal(201)) + Expect(err).To(BeNil()) + Expect(createResponse).ToNot(BeNil()) + + // Grab the ID and Etag value from the response for use in the update operation. + accountSettingsTemplateId = *createResponse.ID + Expect(accountSettingsTemplateId).ToNot(BeNil()) + accountSettingsTemplateVersion = *createResponse.Version + Expect(response.GetHeaders()).ToNot(BeNil()) + accountSettingsTemplateEtag = response.GetHeaders().Get("Etag") + Expect(accountSettingsTemplateEtag).ToNot(BeEmpty()) + }) + }) + + Describe(`GetAccountSettingsTemplateIT`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`GetAccountSettingsTemplateIT`, func() { + getOptions := &iamidentityv1.GetAccountSettingsTemplateVersionOptions{ + TemplateID: &accountSettingsTemplateId, + Version: core.StringPtr(strconv.FormatInt(accountSettingsTemplateVersion, 10)), + } + getResponse, response, err := iamIdentityService.GetAccountSettingsTemplateVersion(getOptions) + Expect(response.StatusCode).To(Equal(200)) + Expect(err).To(BeNil()) + Expect(getResponse).ToNot(BeNil()) + // Grab the Etag value from the response for use in the update operation. + Expect(response.GetHeaders()).ToNot(BeNil()) + accountSettingsTemplateEtag = response.GetHeaders().Get("Etag") + Expect(accountSettingsTemplateEtag).ToNot(BeEmpty()) + }) + }) + + Describe(`ListAccountSettingsTemplatesIT`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`ListAccountSettingsTemplatesIT`, func() { + listOptions := &iamidentityv1.ListAccountSettingsTemplatesOptions{ + AccountID: &enterpriseAccountID, + } + listResponse, response, err := iamIdentityService.ListAccountSettingsTemplates(listOptions) + Expect(response.StatusCode).To(Equal(200)) + Expect(err).To(BeNil()) + Expect(listResponse).ToNot(BeNil()) + }) + }) + + Describe(`UpdateAccountSettingsTemplateIT`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`UpdateAccountSettingsTemplateIT`, func() { + settings := &iamidentityv1.AccountSettingsComponent{ + Mfa: core.StringPtr("LEVEL1"), + SystemAccessTokenExpirationInSeconds: core.StringPtr("3000"), + } + updateOptions := &iamidentityv1.UpdateAccountSettingsTemplateVersionOptions{ + AccountID: &enterpriseAccountID, + TemplateID: &accountSettingsTemplateId, + Version: core.StringPtr(strconv.FormatInt(accountSettingsTemplateVersion, 10)), + IfMatch: &accountSettingsTemplateEtag, + Name: &accountSettingsTemplateName, + Description: core.StringPtr("GoSDK test Account Settings Template - updated"), + AccountSettings: settings, + } + updateResponse, response, err := iamIdentityService.UpdateAccountSettingsTemplateVersion(updateOptions) + Expect(response.StatusCode).To(Equal(200)) + Expect(err).To(BeNil()) + Expect(updateResponse).ToNot(BeNil()) + // Grab the Etag value from the response for use in the update operation. + Expect(response.GetHeaders()).ToNot(BeNil()) + accountSettingsTemplateEtag = response.GetHeaders().Get("Etag") + Expect(accountSettingsTemplateEtag).ToNot(BeEmpty()) + }) + }) + + Describe(`AssignAccountSettingsTemplateIT`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`AssignAccountSettingsTemplateIT`, func() { + commitOptions := &iamidentityv1.CommitAccountSettingsTemplateOptions{ + TemplateID: &accountSettingsTemplateId, + Version: core.StringPtr(strconv.FormatInt(accountSettingsTemplateVersion, 10)), + } + cResponse, cErr := iamIdentityService.CommitAccountSettingsTemplate(commitOptions) + Expect(cResponse.StatusCode).To(Equal(204)) + Expect(cErr).To(BeNil()) + + assignOptions := &iamidentityv1.CreateAccountSettingsAssignmentOptions{ + TemplateID: &accountSettingsTemplateId, + TemplateVersion: &accountSettingsTemplateVersion, + TargetType: core.StringPtr("Account"), + Target: &enterpriseSubAccountID, + } + assignResponse, aResponse, aErr := iamIdentityService.CreateAccountSettingsAssignment(assignOptions) + Expect(aResponse.StatusCode).To(Equal(202)) + Expect(aErr).To(BeNil()) + Expect(assignResponse).ToNot(BeNil()) + // Grab the Etag and id for use by other test methods. + Expect(aResponse.GetHeaders()).ToNot(BeNil()) + accountSettingsTemplateAssignmentEtag = aResponse.GetHeaders().Get("Etag") + Expect(accountSettingsTemplateAssignmentEtag).ToNot(BeEmpty()) + accountSettingsTemplateAssignmentId = *assignResponse.ID + Expect(accountSettingsTemplateAssignmentId).ToNot(BeNil()) + }) + }) + + Describe(`ListAccountSettingsTemplateAssignmentsIT`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`ListAccountSettingsTemplateAssignmentsIT`, func() { + listOptions := &iamidentityv1.ListAccountSettingsAssignmentsOptions{ + AccountID: &enterpriseAccountID, + TemplateID: &accountSettingsTemplateId, + } + listResponse, response, err := iamIdentityService.ListAccountSettingsAssignments(listOptions) + Expect(response.StatusCode).To(Equal(200)) + Expect(err).To(BeNil()) + Expect(listResponse).ToNot(BeNil()) + Expect(listResponse.Assignments).ToNot(BeNil()) + numAssignments := len(listResponse.Assignments) + Expect(numAssignments).ToNot(BeZero()) + }) + }) + + Describe(`CreateNewAccountSettingsTemplateVersionIT`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`CreateNewAccountSettingsTemplateVersionIT`, func() { + settings := &iamidentityv1.AccountSettingsComponent{ + Mfa: core.StringPtr("LEVEL1"), + SystemAccessTokenExpirationInSeconds: core.StringPtr("2600"), + RestrictCreatePlatformApikey: core.StringPtr("RESTRICTED"), + RestrictCreateServiceID: core.StringPtr("RESTRICTED"), + } + createOptions := &iamidentityv1.CreateAccountSettingsTemplateVersionOptions{ + Name: &accountSettingsTemplateName, + Description: core.StringPtr("GoSDK test Account Settings Template - new version"), + AccountID: &enterpriseAccountID, + TemplateID: &accountSettingsTemplateId, + AccountSettings: settings, + } + + createResponse, response, err := iamIdentityService.CreateAccountSettingsTemplateVersion(createOptions) + Expect(response.StatusCode).To(Equal(201)) + Expect(err).To(BeNil()) + Expect(createResponse).ToNot(BeNil()) + // save the new version to be used in subsequent calls + accountSettingsTemplateVersion = *createResponse.Version + Expect(response.GetHeaders()).ToNot(BeNil()) + }) + }) + + Describe(`GetLatestAccountSettingsTemplateVersionIT`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`GetLatestAccountSettingsTemplateVersionIT`, func() { + getOptions := &iamidentityv1.GetLatestAccountSettingsTemplateVersionOptions{ + TemplateID: &accountSettingsTemplateId, + } + getResponse, response, err := iamIdentityService.GetLatestAccountSettingsTemplateVersion(getOptions) + Expect(response.StatusCode).To(Equal(200)) + Expect(err).To(BeNil()) + Expect(getResponse).ToNot(BeNil()) + }) + }) + + Describe(`ListAccountSettingsTemplateVersionsIT`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`ListAccountSettingsTemplateVersionsIT`, func() { + listOptions := &iamidentityv1.ListVersionsOfAccountSettingsTemplateOptions{ + TemplateID: &accountSettingsTemplateId, + } + listResponse, response, err := iamIdentityService.ListVersionsOfAccountSettingsTemplate(listOptions) + Expect(response.StatusCode).To(Equal(200)) + Expect(err).To(BeNil()) + Expect(listResponse).ToNot(BeNil()) + Expect(listResponse.AccountSettingsTemplates).ToNot(BeNil()) + numTemplates := len(listResponse.AccountSettingsTemplates) + Expect(numTemplates).ToNot(BeZero()) + }) + }) + + Describe(`UpdateAccountSettingsTemplateAssignmentIT`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`UpdateAccountSettingsTemplateAssignmentIT`, func() { + commitOptions := &iamidentityv1.CommitAccountSettingsTemplateOptions{ + TemplateID: &accountSettingsTemplateId, + Version: core.StringPtr(strconv.FormatInt(accountSettingsTemplateVersion, 10)), + } + cResponse, cErr := iamIdentityService.CommitAccountSettingsTemplate(commitOptions) + Expect(cResponse.StatusCode).To(Equal(204)) + Expect(cErr).To(BeNil()) + + waitUntilAccountSettingsAssignmentFinishedIT(iamIdentityService, &accountSettingsTemplateAssignmentId, &accountSettingsTemplateAssignmentEtag) + + updateOptions := &iamidentityv1.UpdateAccountSettingsAssignmentOptions{ + AssignmentID: &accountSettingsTemplateAssignmentId, + TemplateVersion: &accountSettingsTemplateVersion, + IfMatch: &accountSettingsTemplateAssignmentEtag, + } + updateResponse, uResponse, uErr := iamIdentityService.UpdateAccountSettingsAssignment(updateOptions) + Expect(uResponse.StatusCode).To(Equal(202)) + Expect(uErr).To(BeNil()) + Expect(updateResponse).ToNot(BeNil()) + // Grab the Etag and id for use by other test methods. + Expect(uResponse.GetHeaders()).ToNot(BeNil()) + accountSettingsTemplateAssignmentEtag = uResponse.GetHeaders().Get("Etag") + Expect(accountSettingsTemplateAssignmentEtag).ToNot(BeEmpty()) + }) + }) + + Describe(`DeleteAccountSettingsTemplateAssignmentIT`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`DeleteAccountSettingsTemplateAssignmentIT`, func() { + waitUntilAccountSettingsAssignmentFinishedIT(iamIdentityService, &accountSettingsTemplateAssignmentId, &accountSettingsTemplateAssignmentEtag) + + deleteOptions := &iamidentityv1.DeleteAccountSettingsAssignmentOptions{ + AssignmentID: &accountSettingsTemplateAssignmentId, + } + excResponse, response, err := iamIdentityService.DeleteAccountSettingsAssignment(deleteOptions) + Expect(response.StatusCode).To(Equal(202)) + Expect(err).To(BeNil()) + Expect(excResponse).To(BeNil()) + }) + }) + + Describe(`DeleteAccountSettingsTemplateVersionIT`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`DeleteAccountSettingsTemplateVersionIT`, func() { + deleteOptions := &iamidentityv1.DeleteAccountSettingsTemplateVersionOptions{ + TemplateID: &accountSettingsTemplateId, + Version: core.StringPtr("1"), + } + response, err := iamIdentityService.DeleteAccountSettingsTemplateVersion(deleteOptions) + Expect(response.StatusCode).To(Equal(204)) + Expect(err).To(BeNil()) + }) + }) + + Describe(`DeleteAccountSettingsTemplateIT`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`DeleteAccountSettingsTemplateIT`, func() { + waitUntilAccountSettingsAssignmentFinishedIT(iamIdentityService, &accountSettingsTemplateAssignmentId, &accountSettingsTemplateAssignmentEtag) + + deleteOptions := &iamidentityv1.DeleteAllVersionsOfAccountSettingsTemplateOptions{ + TemplateID: &accountSettingsTemplateId, + } + response, err := iamIdentityService.DeleteAllVersionsOfAccountSettingsTemplate(deleteOptions) + Expect(response.StatusCode).To(Equal(204)) + Expect(err).To(BeNil()) + }) + }) + AfterSuite(func() { fmt.Println("\nBeginning teardown.") - cleanupResources(iamIdentityService, accountID, iamID, apikeyName, serviceIDName, profileName1, profileName2) + cleanupResources(iamIdentityService, accountID, iamID, apikeyName, serviceIDName, profileName1, profileName2, enterpriseAccountID, profileTemplateName, &profileTemplateAssignmentEtag, accountSettingsTemplateName, &accountSettingsTemplateAssignmentEtag) fmt.Println("Finished teardown.") }) }) @@ -1717,6 +2335,68 @@ func getLink(service *iamidentityv1.IamIdentityV1, profileID string, linkID stri return link } +func isFinishedIT(status *string) bool { + var finished = false + if strings.EqualFold(*status, "succeeded") || strings.EqualFold(*status, "failed") { + finished = true + } + return finished +} + +func waitUntilTrustedProfileAssignmentFinishedIT(service *iamidentityv1.IamIdentityV1, assignmentId *string, profileTemplateAssignmentEtag *string) { + getAssignmentOptions := &iamidentityv1.GetTrustedProfileAssignmentOptions{ + AssignmentID: assignmentId, + } + + var finished = true + for i := 0; i < 30; i++ { + assignment, response, err := service.GetTrustedProfileAssignment(getAssignmentOptions) + if response.StatusCode == 404 { + Expect(err).ToNot(BeNil()) + finished = true // assignment removed + break + } else { + finished = isFinishedIT(assignment.Status) + if finished { + // Grab the Etag value from the response for use in the update operation. + Expect(response.GetHeaders()).ToNot(BeNil()) + *profileTemplateAssignmentEtag = response.GetHeaders().Get("Etag") + Expect(*profileTemplateAssignmentEtag).ToNot(BeEmpty()) + break + } + } + time.Sleep(10 * time.Second) + } + Expect(finished).To(BeTrue()) +} + +func waitUntilAccountSettingsAssignmentFinishedIT(service *iamidentityv1.IamIdentityV1, assignmentId *string, accountSettingsTemplateAssignmentEtag *string) { + getAssignmentOptions := &iamidentityv1.GetAccountSettingsAssignmentOptions{ + AssignmentID: assignmentId, + } + + var finished = true + for i := 0; i < 30; i++ { + assignment, response, err := service.GetAccountSettingsAssignment(getAssignmentOptions) + if response.StatusCode == 404 { + Expect(err).ToNot(BeNil()) + finished = true // assignment removed + break + } else { + finished = isFinishedIT(assignment.Status) + if finished { + // Grab the Etag value from the response for use in the update operation. + Expect(response.GetHeaders()).ToNot(BeNil()) + *accountSettingsTemplateAssignmentEtag = response.GetHeaders().Get("Etag") + Expect(*accountSettingsTemplateAssignmentEtag).ToNot(BeEmpty()) + break + } + } + time.Sleep(10 * time.Second) + } + Expect(finished).To(BeTrue()) +} + func getPageTokenFromURL(sptr *string) *string { if sptr == nil { return nil @@ -1748,7 +2428,7 @@ func getPageTokenFromURL(sptr *string) *string { return &token } -func cleanupResources(service *iamidentityv1.IamIdentityV1, accountID string, iamID string, apikeyName string, serviceIDName string, profileName1 string, profileName2 string) { +func cleanupResources(service *iamidentityv1.IamIdentityV1, accountID string, iamID string, apikeyName string, serviceIDName string, profileName1 string, profileName2 string, enterpriseAccountID string, profileTemplateName string, profileTemplateAssignmentEtag *string, accountSettingsTemplateName string, accountSettingsTemplateAssignmentEtag *string) { if service == nil { panic("'service' cannot be nil!") } @@ -1812,7 +2492,7 @@ func cleanupResources(service *iamidentityv1.IamIdentityV1, accountID string, ia Expect(response.StatusCode).To(Equal(200)) numProfiles := len(profileList.Profiles) - fmt.Fprintf(GinkgoWriter, ">>> Cleanup found %d apikeys.\n", numProfiles) + fmt.Fprintf(GinkgoWriter, ">>> Cleanup found %d profiles.\n", numProfiles) if numProfiles > 0 { for _, element := range profileList.Profiles { @@ -1828,4 +2508,103 @@ func cleanupResources(service *iamidentityv1.IamIdentityV1, accountID string, ia } } + listProfileTemplateOptions := &iamidentityv1.ListProfileTemplatesOptions{ + AccountID: &enterpriseAccountID, + } + profileTemplateList, response, err := service.ListProfileTemplates(listProfileTemplateOptions) + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + + numProfileTemplates := len(profileTemplateList.ProfileTemplates) + fmt.Fprintf(GinkgoWriter, ">>> Cleanup found %d profile templates.\n", numProfileTemplates) + + if numProfileTemplates > 0 { + for _, element := range profileTemplateList.ProfileTemplates { + if *element.Name == profileTemplateName { + fmt.Fprintf(GinkgoWriter, ">>> Deleting profile template: %s\n", *element.ID) + + listAssignmentsOptions := &iamidentityv1.ListTrustedProfileAssignmentsOptions{ + AccountID: &enterpriseAccountID, + TemplateID: element.ID, + } + assignmentsList, alResponse, alErr := service.ListTrustedProfileAssignments(listAssignmentsOptions) + Expect(alErr).To(BeNil()) + Expect(alResponse.StatusCode).To(Equal(200)) + Expect(assignmentsList).ToNot(BeNil()) + numAssignments := len(assignmentsList.Assignments) + if numAssignments > 0 { + for _, assignment := range assignmentsList.Assignments { + if !isFinishedIT(assignment.Status) { + waitUntilTrustedProfileAssignmentFinishedIT(service, assignment.ID, profileTemplateAssignmentEtag) + } + deleteAssignmentOptions := &iamidentityv1.DeleteTrustedProfileAssignmentOptions{ + AssignmentID: assignment.ID, + } + exceptionRsp, daResponse, daErr := service.DeleteTrustedProfileAssignment(deleteAssignmentOptions) + Expect(exceptionRsp).To(BeNil()) + Expect(daResponse).ToNot(BeNil()) + Expect(daErr).To(BeNil()) + waitUntilTrustedProfileAssignmentFinishedIT(service, assignment.ID, profileTemplateAssignmentEtag) + } + } + + deleteProfileTemplateOptions := &iamidentityv1.DeleteAllVersionsOfProfileTemplateOptions{ + TemplateID: element.ID, + } + response, err := service.DeleteAllVersionsOfProfileTemplate(deleteProfileTemplateOptions) + Expect(response).ToNot(BeNil()) + Expect(err).To(BeNil()) + } + } + } + + listAccountSettingsTemplateOptions := &iamidentityv1.ListAccountSettingsTemplatesOptions{ + AccountID: &enterpriseAccountID, + } + AccountSettingsTemplateList, response, err := service.ListAccountSettingsTemplates(listAccountSettingsTemplateOptions) + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + + numAccountSettingsTemplates := len(AccountSettingsTemplateList.AccountSettingsTemplates) + fmt.Fprintf(GinkgoWriter, ">>> Cleanup found %d account settings templates.\n", numAccountSettingsTemplates) + + if numAccountSettingsTemplates > 0 { + for _, element := range AccountSettingsTemplateList.AccountSettingsTemplates { + if *element.Name == accountSettingsTemplateName { + fmt.Fprintf(GinkgoWriter, ">>> Deleting account settings template: %s\n", *element.ID) + + listAssignmentsOptions := &iamidentityv1.ListAccountSettingsAssignmentsOptions{ + AccountID: &enterpriseAccountID, + TemplateID: element.ID, + } + assignmentsList, alResponse, alErr := service.ListAccountSettingsAssignments(listAssignmentsOptions) + Expect(alErr).To(BeNil()) + Expect(alResponse.StatusCode).To(Equal(200)) + Expect(assignmentsList).ToNot(BeNil()) + numAssignments := len(assignmentsList.Assignments) + if numAssignments > 0 { + for _, assignment := range assignmentsList.Assignments { + if !isFinishedIT(assignment.Status) { + waitUntilAccountSettingsAssignmentFinishedIT(service, assignment.ID, accountSettingsTemplateAssignmentEtag) + } + deleteAssignmentOptions := &iamidentityv1.DeleteAccountSettingsAssignmentOptions{ + AssignmentID: assignment.ID, + } + exceptionRsp, daResponse, daErr := service.DeleteAccountSettingsAssignment(deleteAssignmentOptions) + Expect(exceptionRsp).To(BeNil()) + Expect(daResponse).ToNot(BeNil()) + Expect(daErr).To(BeNil()) + waitUntilAccountSettingsAssignmentFinishedIT(service, assignment.ID, accountSettingsTemplateAssignmentEtag) + } + } + + deleteAccountSettingsTemplateOptions := &iamidentityv1.DeleteAllVersionsOfAccountSettingsTemplateOptions{ + TemplateID: element.ID, + } + response, err := service.DeleteAllVersionsOfAccountSettingsTemplate(deleteAccountSettingsTemplateOptions) + Expect(response).ToNot(BeNil()) + Expect(err).To(BeNil()) + } + } + } } diff --git a/iamidentityv1/iam_identity_v1_test.go b/iamidentityv1/iam_identity_v1_test.go index 01abf269..0c661d70 100644 --- a/iamidentityv1/iam_identity_v1_test.go +++ b/iamidentityv1/iam_identity_v1_test.go @@ -6267,19 +6267,18 @@ var _ = Describe(`IamIdentityV1`, func() { Expect(serviceErr).To(BeNil()) Expect(iamIdentityService).ToNot(BeNil()) - // Construct an instance of the ProfileIdentity model - profileIdentityModel := new(iamidentityv1.ProfileIdentity) - profileIdentityModel.IamID = core.StringPtr("testString") - profileIdentityModel.Identifier = core.StringPtr("testString") - profileIdentityModel.Type = core.StringPtr("user") - profileIdentityModel.Accounts = []string{"testString"} - profileIdentityModel.Description = core.StringPtr("testString") + // Construct an instance of the ProfileIdentityRequest model + profileIdentityRequestModel := new(iamidentityv1.ProfileIdentityRequest) + profileIdentityRequestModel.Identifier = core.StringPtr("testString") + profileIdentityRequestModel.Type = core.StringPtr("user") + profileIdentityRequestModel.Accounts = []string{"testString"} + profileIdentityRequestModel.Description = core.StringPtr("testString") // Construct an instance of the SetProfileIdentitiesOptions model setProfileIdentitiesOptionsModel := new(iamidentityv1.SetProfileIdentitiesOptions) setProfileIdentitiesOptionsModel.ProfileID = core.StringPtr("testString") setProfileIdentitiesOptionsModel.IfMatch = core.StringPtr("testString") - setProfileIdentitiesOptionsModel.Identities = []iamidentityv1.ProfileIdentity{*profileIdentityModel} + setProfileIdentitiesOptionsModel.Identities = []iamidentityv1.ProfileIdentityRequest{*profileIdentityRequestModel} setProfileIdentitiesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response result, response, operationErr := iamIdentityService.SetProfileIdentities(setProfileIdentitiesOptionsModel) @@ -6346,19 +6345,18 @@ var _ = Describe(`IamIdentityV1`, func() { Expect(iamIdentityService).ToNot(BeNil()) iamIdentityService.EnableRetries(0, 0) - // Construct an instance of the ProfileIdentity model - profileIdentityModel := new(iamidentityv1.ProfileIdentity) - profileIdentityModel.IamID = core.StringPtr("testString") - profileIdentityModel.Identifier = core.StringPtr("testString") - profileIdentityModel.Type = core.StringPtr("user") - profileIdentityModel.Accounts = []string{"testString"} - profileIdentityModel.Description = core.StringPtr("testString") + // Construct an instance of the ProfileIdentityRequest model + profileIdentityRequestModel := new(iamidentityv1.ProfileIdentityRequest) + profileIdentityRequestModel.Identifier = core.StringPtr("testString") + profileIdentityRequestModel.Type = core.StringPtr("user") + profileIdentityRequestModel.Accounts = []string{"testString"} + profileIdentityRequestModel.Description = core.StringPtr("testString") // Construct an instance of the SetProfileIdentitiesOptions model setProfileIdentitiesOptionsModel := new(iamidentityv1.SetProfileIdentitiesOptions) setProfileIdentitiesOptionsModel.ProfileID = core.StringPtr("testString") setProfileIdentitiesOptionsModel.IfMatch = core.StringPtr("testString") - setProfileIdentitiesOptionsModel.Identities = []iamidentityv1.ProfileIdentity{*profileIdentityModel} + setProfileIdentitiesOptionsModel.Identities = []iamidentityv1.ProfileIdentityRequest{*profileIdentityRequestModel} setProfileIdentitiesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error @@ -6433,19 +6431,18 @@ var _ = Describe(`IamIdentityV1`, func() { Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the ProfileIdentity model - profileIdentityModel := new(iamidentityv1.ProfileIdentity) - profileIdentityModel.IamID = core.StringPtr("testString") - profileIdentityModel.Identifier = core.StringPtr("testString") - profileIdentityModel.Type = core.StringPtr("user") - profileIdentityModel.Accounts = []string{"testString"} - profileIdentityModel.Description = core.StringPtr("testString") + // Construct an instance of the ProfileIdentityRequest model + profileIdentityRequestModel := new(iamidentityv1.ProfileIdentityRequest) + profileIdentityRequestModel.Identifier = core.StringPtr("testString") + profileIdentityRequestModel.Type = core.StringPtr("user") + profileIdentityRequestModel.Accounts = []string{"testString"} + profileIdentityRequestModel.Description = core.StringPtr("testString") // Construct an instance of the SetProfileIdentitiesOptions model setProfileIdentitiesOptionsModel := new(iamidentityv1.SetProfileIdentitiesOptions) setProfileIdentitiesOptionsModel.ProfileID = core.StringPtr("testString") setProfileIdentitiesOptionsModel.IfMatch = core.StringPtr("testString") - setProfileIdentitiesOptionsModel.Identities = []iamidentityv1.ProfileIdentity{*profileIdentityModel} + setProfileIdentitiesOptionsModel.Identities = []iamidentityv1.ProfileIdentityRequest{*profileIdentityRequestModel} setProfileIdentitiesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) @@ -6463,19 +6460,18 @@ var _ = Describe(`IamIdentityV1`, func() { Expect(serviceErr).To(BeNil()) Expect(iamIdentityService).ToNot(BeNil()) - // Construct an instance of the ProfileIdentity model - profileIdentityModel := new(iamidentityv1.ProfileIdentity) - profileIdentityModel.IamID = core.StringPtr("testString") - profileIdentityModel.Identifier = core.StringPtr("testString") - profileIdentityModel.Type = core.StringPtr("user") - profileIdentityModel.Accounts = []string{"testString"} - profileIdentityModel.Description = core.StringPtr("testString") + // Construct an instance of the ProfileIdentityRequest model + profileIdentityRequestModel := new(iamidentityv1.ProfileIdentityRequest) + profileIdentityRequestModel.Identifier = core.StringPtr("testString") + profileIdentityRequestModel.Type = core.StringPtr("user") + profileIdentityRequestModel.Accounts = []string{"testString"} + profileIdentityRequestModel.Description = core.StringPtr("testString") // Construct an instance of the SetProfileIdentitiesOptions model setProfileIdentitiesOptionsModel := new(iamidentityv1.SetProfileIdentitiesOptions) setProfileIdentitiesOptionsModel.ProfileID = core.StringPtr("testString") setProfileIdentitiesOptionsModel.IfMatch = core.StringPtr("testString") - setProfileIdentitiesOptionsModel.Identities = []iamidentityv1.ProfileIdentity{*profileIdentityModel} + setProfileIdentitiesOptionsModel.Identities = []iamidentityv1.ProfileIdentityRequest{*profileIdentityRequestModel} setProfileIdentitiesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := iamIdentityService.SetServiceURL("") @@ -6514,19 +6510,18 @@ var _ = Describe(`IamIdentityV1`, func() { Expect(serviceErr).To(BeNil()) Expect(iamIdentityService).ToNot(BeNil()) - // Construct an instance of the ProfileIdentity model - profileIdentityModel := new(iamidentityv1.ProfileIdentity) - profileIdentityModel.IamID = core.StringPtr("testString") - profileIdentityModel.Identifier = core.StringPtr("testString") - profileIdentityModel.Type = core.StringPtr("user") - profileIdentityModel.Accounts = []string{"testString"} - profileIdentityModel.Description = core.StringPtr("testString") + // Construct an instance of the ProfileIdentityRequest model + profileIdentityRequestModel := new(iamidentityv1.ProfileIdentityRequest) + profileIdentityRequestModel.Identifier = core.StringPtr("testString") + profileIdentityRequestModel.Type = core.StringPtr("user") + profileIdentityRequestModel.Accounts = []string{"testString"} + profileIdentityRequestModel.Description = core.StringPtr("testString") // Construct an instance of the SetProfileIdentitiesOptions model setProfileIdentitiesOptionsModel := new(iamidentityv1.SetProfileIdentitiesOptions) setProfileIdentitiesOptionsModel.ProfileID = core.StringPtr("testString") setProfileIdentitiesOptionsModel.IfMatch = core.StringPtr("testString") - setProfileIdentitiesOptionsModel.Identities = []iamidentityv1.ProfileIdentity{*profileIdentityModel} + setProfileIdentitiesOptionsModel.Identities = []iamidentityv1.ProfileIdentityRequest{*profileIdentityRequestModel} setProfileIdentitiesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation @@ -6571,7 +6566,6 @@ var _ = Describe(`IamIdentityV1`, func() { setProfileIdentityOptionsModel.IdentityType = core.StringPtr("user") setProfileIdentityOptionsModel.Identifier = core.StringPtr("testString") setProfileIdentityOptionsModel.Type = core.StringPtr("user") - setProfileIdentityOptionsModel.IamID = core.StringPtr("testString") setProfileIdentityOptionsModel.Accounts = []string{"testString"} setProfileIdentityOptionsModel.Description = core.StringPtr("testString") setProfileIdentityOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} @@ -6644,7 +6638,6 @@ var _ = Describe(`IamIdentityV1`, func() { setProfileIdentityOptionsModel.IdentityType = core.StringPtr("user") setProfileIdentityOptionsModel.Identifier = core.StringPtr("testString") setProfileIdentityOptionsModel.Type = core.StringPtr("user") - setProfileIdentityOptionsModel.IamID = core.StringPtr("testString") setProfileIdentityOptionsModel.Accounts = []string{"testString"} setProfileIdentityOptionsModel.Description = core.StringPtr("testString") setProfileIdentityOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} @@ -6725,7 +6718,6 @@ var _ = Describe(`IamIdentityV1`, func() { setProfileIdentityOptionsModel.IdentityType = core.StringPtr("user") setProfileIdentityOptionsModel.Identifier = core.StringPtr("testString") setProfileIdentityOptionsModel.Type = core.StringPtr("user") - setProfileIdentityOptionsModel.IamID = core.StringPtr("testString") setProfileIdentityOptionsModel.Accounts = []string{"testString"} setProfileIdentityOptionsModel.Description = core.StringPtr("testString") setProfileIdentityOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} @@ -6751,7 +6743,6 @@ var _ = Describe(`IamIdentityV1`, func() { setProfileIdentityOptionsModel.IdentityType = core.StringPtr("user") setProfileIdentityOptionsModel.Identifier = core.StringPtr("testString") setProfileIdentityOptionsModel.Type = core.StringPtr("user") - setProfileIdentityOptionsModel.IamID = core.StringPtr("testString") setProfileIdentityOptionsModel.Accounts = []string{"testString"} setProfileIdentityOptionsModel.Description = core.StringPtr("testString") setProfileIdentityOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} @@ -6798,7 +6789,6 @@ var _ = Describe(`IamIdentityV1`, func() { setProfileIdentityOptionsModel.IdentityType = core.StringPtr("user") setProfileIdentityOptionsModel.Identifier = core.StringPtr("testString") setProfileIdentityOptionsModel.Type = core.StringPtr("user") - setProfileIdentityOptionsModel.IamID = core.StringPtr("testString") setProfileIdentityOptionsModel.Accounts = []string{"testString"} setProfileIdentityOptionsModel.Description = core.StringPtr("testString") setProfileIdentityOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} @@ -8317,6 +8307,3456 @@ var _ = Describe(`IamIdentityV1`, func() { }) }) }) + Describe(`ListAccountSettingsAssignments(listAccountSettingsAssignmentsOptions *ListAccountSettingsAssignmentsOptions) - Operation response error`, func() { + listAccountSettingsAssignmentsPath := "/v1/account_settings_assignments/" + Context(`Using mock server endpoint with invalid JSON response`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listAccountSettingsAssignmentsPath)) + Expect(req.Method).To(Equal("GET")) + Expect(req.URL.Query()["account_id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["template_id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["template_version"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["target"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["target_type"]).To(Equal([]string{"Account"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(20))})) + Expect(req.URL.Query()["pagetoken"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["sort"]).To(Equal([]string{"created_at"})) + Expect(req.URL.Query()["order"]).To(Equal([]string{"asc"})) + // TODO: Add check for include_history query parameter + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke ListAccountSettingsAssignments with error: Operation response processing error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the ListAccountSettingsAssignmentsOptions model + listAccountSettingsAssignmentsOptionsModel := new(iamidentityv1.ListAccountSettingsAssignmentsOptions) + listAccountSettingsAssignmentsOptionsModel.AccountID = core.StringPtr("testString") + listAccountSettingsAssignmentsOptionsModel.TemplateID = core.StringPtr("testString") + listAccountSettingsAssignmentsOptionsModel.TemplateVersion = core.StringPtr("testString") + listAccountSettingsAssignmentsOptionsModel.Target = core.StringPtr("testString") + listAccountSettingsAssignmentsOptionsModel.TargetType = core.StringPtr("Account") + listAccountSettingsAssignmentsOptionsModel.Limit = core.Int64Ptr(int64(20)) + listAccountSettingsAssignmentsOptionsModel.Pagetoken = core.StringPtr("testString") + listAccountSettingsAssignmentsOptionsModel.Sort = core.StringPtr("created_at") + listAccountSettingsAssignmentsOptionsModel.Order = core.StringPtr("asc") + listAccountSettingsAssignmentsOptionsModel.IncludeHistory = core.BoolPtr(false) + listAccountSettingsAssignmentsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := iamIdentityService.ListAccountSettingsAssignments(listAccountSettingsAssignmentsOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + iamIdentityService.EnableRetries(0, 0) + result, response, operationErr = iamIdentityService.ListAccountSettingsAssignments(listAccountSettingsAssignmentsOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`ListAccountSettingsAssignments(listAccountSettingsAssignmentsOptions *ListAccountSettingsAssignmentsOptions)`, func() { + listAccountSettingsAssignmentsPath := "/v1/account_settings_assignments/" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listAccountSettingsAssignmentsPath)) + Expect(req.Method).To(Equal("GET")) + + Expect(req.URL.Query()["account_id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["template_id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["template_version"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["target"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["target_type"]).To(Equal([]string{"Account"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(20))})) + Expect(req.URL.Query()["pagetoken"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["sort"]).To(Equal([]string{"created_at"})) + Expect(req.URL.Query()["order"]).To(Equal([]string{"asc"})) + // TODO: Add check for include_history query parameter + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"context": {"transaction_id": "TransactionID", "operation": "Operation", "user_agent": "UserAgent", "url": "URL", "instance_id": "InstanceID", "thread_id": "ThreadID", "host": "Host", "start_time": "StartTime", "end_time": "EndTime", "elapsed_time": "ElapsedTime", "cluster_name": "ClusterName"}, "offset": 6, "limit": 5, "first": "First", "previous": "Previous", "next": "Next", "assignments": [{"context": {"transaction_id": "TransactionID", "operation": "Operation", "user_agent": "UserAgent", "url": "URL", "instance_id": "InstanceID", "thread_id": "ThreadID", "host": "Host", "start_time": "StartTime", "end_time": "EndTime", "elapsed_time": "ElapsedTime", "cluster_name": "ClusterName"}, "id": "ID", "account_id": "AccountID", "template_id": "TemplateID", "template_version": 15, "target_type": "TargetType", "target": "Target", "status": "Status", "resources": [{"target": "Target", "profile": {"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}, "account_settings": {"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}, "policy_template_refs": [{"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}]}], "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "href": "Href", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID", "entity_tag": "EntityTag"}]}`) + })) + }) + It(`Invoke ListAccountSettingsAssignments successfully with retries`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + iamIdentityService.EnableRetries(0, 0) + + // Construct an instance of the ListAccountSettingsAssignmentsOptions model + listAccountSettingsAssignmentsOptionsModel := new(iamidentityv1.ListAccountSettingsAssignmentsOptions) + listAccountSettingsAssignmentsOptionsModel.AccountID = core.StringPtr("testString") + listAccountSettingsAssignmentsOptionsModel.TemplateID = core.StringPtr("testString") + listAccountSettingsAssignmentsOptionsModel.TemplateVersion = core.StringPtr("testString") + listAccountSettingsAssignmentsOptionsModel.Target = core.StringPtr("testString") + listAccountSettingsAssignmentsOptionsModel.TargetType = core.StringPtr("Account") + listAccountSettingsAssignmentsOptionsModel.Limit = core.Int64Ptr(int64(20)) + listAccountSettingsAssignmentsOptionsModel.Pagetoken = core.StringPtr("testString") + listAccountSettingsAssignmentsOptionsModel.Sort = core.StringPtr("created_at") + listAccountSettingsAssignmentsOptionsModel.Order = core.StringPtr("asc") + listAccountSettingsAssignmentsOptionsModel.IncludeHistory = core.BoolPtr(false) + listAccountSettingsAssignmentsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := iamIdentityService.ListAccountSettingsAssignmentsWithContext(ctx, listAccountSettingsAssignmentsOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + iamIdentityService.DisableRetries() + result, response, operationErr := iamIdentityService.ListAccountSettingsAssignments(listAccountSettingsAssignmentsOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = iamIdentityService.ListAccountSettingsAssignmentsWithContext(ctx, listAccountSettingsAssignmentsOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listAccountSettingsAssignmentsPath)) + Expect(req.Method).To(Equal("GET")) + + Expect(req.URL.Query()["account_id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["template_id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["template_version"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["target"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["target_type"]).To(Equal([]string{"Account"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(20))})) + Expect(req.URL.Query()["pagetoken"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["sort"]).To(Equal([]string{"created_at"})) + Expect(req.URL.Query()["order"]).To(Equal([]string{"asc"})) + // TODO: Add check for include_history query parameter + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"context": {"transaction_id": "TransactionID", "operation": "Operation", "user_agent": "UserAgent", "url": "URL", "instance_id": "InstanceID", "thread_id": "ThreadID", "host": "Host", "start_time": "StartTime", "end_time": "EndTime", "elapsed_time": "ElapsedTime", "cluster_name": "ClusterName"}, "offset": 6, "limit": 5, "first": "First", "previous": "Previous", "next": "Next", "assignments": [{"context": {"transaction_id": "TransactionID", "operation": "Operation", "user_agent": "UserAgent", "url": "URL", "instance_id": "InstanceID", "thread_id": "ThreadID", "host": "Host", "start_time": "StartTime", "end_time": "EndTime", "elapsed_time": "ElapsedTime", "cluster_name": "ClusterName"}, "id": "ID", "account_id": "AccountID", "template_id": "TemplateID", "template_version": 15, "target_type": "TargetType", "target": "Target", "status": "Status", "resources": [{"target": "Target", "profile": {"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}, "account_settings": {"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}, "policy_template_refs": [{"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}]}], "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "href": "Href", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID", "entity_tag": "EntityTag"}]}`) + })) + }) + It(`Invoke ListAccountSettingsAssignments successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := iamIdentityService.ListAccountSettingsAssignments(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the ListAccountSettingsAssignmentsOptions model + listAccountSettingsAssignmentsOptionsModel := new(iamidentityv1.ListAccountSettingsAssignmentsOptions) + listAccountSettingsAssignmentsOptionsModel.AccountID = core.StringPtr("testString") + listAccountSettingsAssignmentsOptionsModel.TemplateID = core.StringPtr("testString") + listAccountSettingsAssignmentsOptionsModel.TemplateVersion = core.StringPtr("testString") + listAccountSettingsAssignmentsOptionsModel.Target = core.StringPtr("testString") + listAccountSettingsAssignmentsOptionsModel.TargetType = core.StringPtr("Account") + listAccountSettingsAssignmentsOptionsModel.Limit = core.Int64Ptr(int64(20)) + listAccountSettingsAssignmentsOptionsModel.Pagetoken = core.StringPtr("testString") + listAccountSettingsAssignmentsOptionsModel.Sort = core.StringPtr("created_at") + listAccountSettingsAssignmentsOptionsModel.Order = core.StringPtr("asc") + listAccountSettingsAssignmentsOptionsModel.IncludeHistory = core.BoolPtr(false) + listAccountSettingsAssignmentsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = iamIdentityService.ListAccountSettingsAssignments(listAccountSettingsAssignmentsOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke ListAccountSettingsAssignments with error: Operation request error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the ListAccountSettingsAssignmentsOptions model + listAccountSettingsAssignmentsOptionsModel := new(iamidentityv1.ListAccountSettingsAssignmentsOptions) + listAccountSettingsAssignmentsOptionsModel.AccountID = core.StringPtr("testString") + listAccountSettingsAssignmentsOptionsModel.TemplateID = core.StringPtr("testString") + listAccountSettingsAssignmentsOptionsModel.TemplateVersion = core.StringPtr("testString") + listAccountSettingsAssignmentsOptionsModel.Target = core.StringPtr("testString") + listAccountSettingsAssignmentsOptionsModel.TargetType = core.StringPtr("Account") + listAccountSettingsAssignmentsOptionsModel.Limit = core.Int64Ptr(int64(20)) + listAccountSettingsAssignmentsOptionsModel.Pagetoken = core.StringPtr("testString") + listAccountSettingsAssignmentsOptionsModel.Sort = core.StringPtr("created_at") + listAccountSettingsAssignmentsOptionsModel.Order = core.StringPtr("asc") + listAccountSettingsAssignmentsOptionsModel.IncludeHistory = core.BoolPtr(false) + listAccountSettingsAssignmentsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := iamIdentityService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := iamIdentityService.ListAccountSettingsAssignments(listAccountSettingsAssignmentsOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(200) + })) + }) + It(`Invoke ListAccountSettingsAssignments successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the ListAccountSettingsAssignmentsOptions model + listAccountSettingsAssignmentsOptionsModel := new(iamidentityv1.ListAccountSettingsAssignmentsOptions) + listAccountSettingsAssignmentsOptionsModel.AccountID = core.StringPtr("testString") + listAccountSettingsAssignmentsOptionsModel.TemplateID = core.StringPtr("testString") + listAccountSettingsAssignmentsOptionsModel.TemplateVersion = core.StringPtr("testString") + listAccountSettingsAssignmentsOptionsModel.Target = core.StringPtr("testString") + listAccountSettingsAssignmentsOptionsModel.TargetType = core.StringPtr("Account") + listAccountSettingsAssignmentsOptionsModel.Limit = core.Int64Ptr(int64(20)) + listAccountSettingsAssignmentsOptionsModel.Pagetoken = core.StringPtr("testString") + listAccountSettingsAssignmentsOptionsModel.Sort = core.StringPtr("created_at") + listAccountSettingsAssignmentsOptionsModel.Order = core.StringPtr("asc") + listAccountSettingsAssignmentsOptionsModel.IncludeHistory = core.BoolPtr(false) + listAccountSettingsAssignmentsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamIdentityService.ListAccountSettingsAssignments(listAccountSettingsAssignmentsOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`CreateAccountSettingsAssignment(createAccountSettingsAssignmentOptions *CreateAccountSettingsAssignmentOptions) - Operation response error`, func() { + createAccountSettingsAssignmentPath := "/v1/account_settings_assignments/" + Context(`Using mock server endpoint with invalid JSON response`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(createAccountSettingsAssignmentPath)) + Expect(req.Method).To(Equal("POST")) + res.Header().Set("Content-type", "application/json") + res.WriteHeader(202) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke CreateAccountSettingsAssignment with error: Operation response processing error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the CreateAccountSettingsAssignmentOptions model + createAccountSettingsAssignmentOptionsModel := new(iamidentityv1.CreateAccountSettingsAssignmentOptions) + createAccountSettingsAssignmentOptionsModel.TemplateID = core.StringPtr("testString") + createAccountSettingsAssignmentOptionsModel.TemplateVersion = core.Int64Ptr(int64(1)) + createAccountSettingsAssignmentOptionsModel.TargetType = core.StringPtr("Account") + createAccountSettingsAssignmentOptionsModel.Target = core.StringPtr("testString") + createAccountSettingsAssignmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := iamIdentityService.CreateAccountSettingsAssignment(createAccountSettingsAssignmentOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + iamIdentityService.EnableRetries(0, 0) + result, response, operationErr = iamIdentityService.CreateAccountSettingsAssignment(createAccountSettingsAssignmentOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`CreateAccountSettingsAssignment(createAccountSettingsAssignmentOptions *CreateAccountSettingsAssignmentOptions)`, func() { + createAccountSettingsAssignmentPath := "/v1/account_settings_assignments/" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(createAccountSettingsAssignmentPath)) + Expect(req.Method).To(Equal("POST")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(202) + fmt.Fprintf(res, "%s", `{"context": {"transaction_id": "TransactionID", "operation": "Operation", "user_agent": "UserAgent", "url": "URL", "instance_id": "InstanceID", "thread_id": "ThreadID", "host": "Host", "start_time": "StartTime", "end_time": "EndTime", "elapsed_time": "ElapsedTime", "cluster_name": "ClusterName"}, "id": "ID", "account_id": "AccountID", "template_id": "TemplateID", "template_version": 15, "target_type": "TargetType", "target": "Target", "status": "Status", "resources": [{"target": "Target", "profile": {"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}, "account_settings": {"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}, "policy_template_refs": [{"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}]}], "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "href": "Href", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID", "entity_tag": "EntityTag"}`) + })) + }) + It(`Invoke CreateAccountSettingsAssignment successfully with retries`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + iamIdentityService.EnableRetries(0, 0) + + // Construct an instance of the CreateAccountSettingsAssignmentOptions model + createAccountSettingsAssignmentOptionsModel := new(iamidentityv1.CreateAccountSettingsAssignmentOptions) + createAccountSettingsAssignmentOptionsModel.TemplateID = core.StringPtr("testString") + createAccountSettingsAssignmentOptionsModel.TemplateVersion = core.Int64Ptr(int64(1)) + createAccountSettingsAssignmentOptionsModel.TargetType = core.StringPtr("Account") + createAccountSettingsAssignmentOptionsModel.Target = core.StringPtr("testString") + createAccountSettingsAssignmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := iamIdentityService.CreateAccountSettingsAssignmentWithContext(ctx, createAccountSettingsAssignmentOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + iamIdentityService.DisableRetries() + result, response, operationErr := iamIdentityService.CreateAccountSettingsAssignment(createAccountSettingsAssignmentOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = iamIdentityService.CreateAccountSettingsAssignmentWithContext(ctx, createAccountSettingsAssignmentOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(createAccountSettingsAssignmentPath)) + Expect(req.Method).To(Equal("POST")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(202) + fmt.Fprintf(res, "%s", `{"context": {"transaction_id": "TransactionID", "operation": "Operation", "user_agent": "UserAgent", "url": "URL", "instance_id": "InstanceID", "thread_id": "ThreadID", "host": "Host", "start_time": "StartTime", "end_time": "EndTime", "elapsed_time": "ElapsedTime", "cluster_name": "ClusterName"}, "id": "ID", "account_id": "AccountID", "template_id": "TemplateID", "template_version": 15, "target_type": "TargetType", "target": "Target", "status": "Status", "resources": [{"target": "Target", "profile": {"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}, "account_settings": {"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}, "policy_template_refs": [{"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}]}], "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "href": "Href", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID", "entity_tag": "EntityTag"}`) + })) + }) + It(`Invoke CreateAccountSettingsAssignment successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := iamIdentityService.CreateAccountSettingsAssignment(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the CreateAccountSettingsAssignmentOptions model + createAccountSettingsAssignmentOptionsModel := new(iamidentityv1.CreateAccountSettingsAssignmentOptions) + createAccountSettingsAssignmentOptionsModel.TemplateID = core.StringPtr("testString") + createAccountSettingsAssignmentOptionsModel.TemplateVersion = core.Int64Ptr(int64(1)) + createAccountSettingsAssignmentOptionsModel.TargetType = core.StringPtr("Account") + createAccountSettingsAssignmentOptionsModel.Target = core.StringPtr("testString") + createAccountSettingsAssignmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = iamIdentityService.CreateAccountSettingsAssignment(createAccountSettingsAssignmentOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke CreateAccountSettingsAssignment with error: Operation validation and request error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the CreateAccountSettingsAssignmentOptions model + createAccountSettingsAssignmentOptionsModel := new(iamidentityv1.CreateAccountSettingsAssignmentOptions) + createAccountSettingsAssignmentOptionsModel.TemplateID = core.StringPtr("testString") + createAccountSettingsAssignmentOptionsModel.TemplateVersion = core.Int64Ptr(int64(1)) + createAccountSettingsAssignmentOptionsModel.TargetType = core.StringPtr("Account") + createAccountSettingsAssignmentOptionsModel.Target = core.StringPtr("testString") + createAccountSettingsAssignmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := iamIdentityService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := iamIdentityService.CreateAccountSettingsAssignment(createAccountSettingsAssignmentOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + // Construct a second instance of the CreateAccountSettingsAssignmentOptions model with no property values + createAccountSettingsAssignmentOptionsModelNew := new(iamidentityv1.CreateAccountSettingsAssignmentOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = iamIdentityService.CreateAccountSettingsAssignment(createAccountSettingsAssignmentOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(202) + })) + }) + It(`Invoke CreateAccountSettingsAssignment successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the CreateAccountSettingsAssignmentOptions model + createAccountSettingsAssignmentOptionsModel := new(iamidentityv1.CreateAccountSettingsAssignmentOptions) + createAccountSettingsAssignmentOptionsModel.TemplateID = core.StringPtr("testString") + createAccountSettingsAssignmentOptionsModel.TemplateVersion = core.Int64Ptr(int64(1)) + createAccountSettingsAssignmentOptionsModel.TargetType = core.StringPtr("Account") + createAccountSettingsAssignmentOptionsModel.Target = core.StringPtr("testString") + createAccountSettingsAssignmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamIdentityService.CreateAccountSettingsAssignment(createAccountSettingsAssignmentOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetAccountSettingsAssignment(getAccountSettingsAssignmentOptions *GetAccountSettingsAssignmentOptions) - Operation response error`, func() { + getAccountSettingsAssignmentPath := "/v1/account_settings_assignments/testString" + Context(`Using mock server endpoint with invalid JSON response`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getAccountSettingsAssignmentPath)) + Expect(req.Method).To(Equal("GET")) + // TODO: Add check for include_history query parameter + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke GetAccountSettingsAssignment with error: Operation response processing error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the GetAccountSettingsAssignmentOptions model + getAccountSettingsAssignmentOptionsModel := new(iamidentityv1.GetAccountSettingsAssignmentOptions) + getAccountSettingsAssignmentOptionsModel.AssignmentID = core.StringPtr("testString") + getAccountSettingsAssignmentOptionsModel.IncludeHistory = core.BoolPtr(false) + getAccountSettingsAssignmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := iamIdentityService.GetAccountSettingsAssignment(getAccountSettingsAssignmentOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + iamIdentityService.EnableRetries(0, 0) + result, response, operationErr = iamIdentityService.GetAccountSettingsAssignment(getAccountSettingsAssignmentOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetAccountSettingsAssignment(getAccountSettingsAssignmentOptions *GetAccountSettingsAssignmentOptions)`, func() { + getAccountSettingsAssignmentPath := "/v1/account_settings_assignments/testString" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getAccountSettingsAssignmentPath)) + Expect(req.Method).To(Equal("GET")) + + // TODO: Add check for include_history query parameter + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"context": {"transaction_id": "TransactionID", "operation": "Operation", "user_agent": "UserAgent", "url": "URL", "instance_id": "InstanceID", "thread_id": "ThreadID", "host": "Host", "start_time": "StartTime", "end_time": "EndTime", "elapsed_time": "ElapsedTime", "cluster_name": "ClusterName"}, "id": "ID", "account_id": "AccountID", "template_id": "TemplateID", "template_version": 15, "target_type": "TargetType", "target": "Target", "status": "Status", "resources": [{"target": "Target", "profile": {"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}, "account_settings": {"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}, "policy_template_refs": [{"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}]}], "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "href": "Href", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID", "entity_tag": "EntityTag"}`) + })) + }) + It(`Invoke GetAccountSettingsAssignment successfully with retries`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + iamIdentityService.EnableRetries(0, 0) + + // Construct an instance of the GetAccountSettingsAssignmentOptions model + getAccountSettingsAssignmentOptionsModel := new(iamidentityv1.GetAccountSettingsAssignmentOptions) + getAccountSettingsAssignmentOptionsModel.AssignmentID = core.StringPtr("testString") + getAccountSettingsAssignmentOptionsModel.IncludeHistory = core.BoolPtr(false) + getAccountSettingsAssignmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := iamIdentityService.GetAccountSettingsAssignmentWithContext(ctx, getAccountSettingsAssignmentOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + iamIdentityService.DisableRetries() + result, response, operationErr := iamIdentityService.GetAccountSettingsAssignment(getAccountSettingsAssignmentOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = iamIdentityService.GetAccountSettingsAssignmentWithContext(ctx, getAccountSettingsAssignmentOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getAccountSettingsAssignmentPath)) + Expect(req.Method).To(Equal("GET")) + + // TODO: Add check for include_history query parameter + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"context": {"transaction_id": "TransactionID", "operation": "Operation", "user_agent": "UserAgent", "url": "URL", "instance_id": "InstanceID", "thread_id": "ThreadID", "host": "Host", "start_time": "StartTime", "end_time": "EndTime", "elapsed_time": "ElapsedTime", "cluster_name": "ClusterName"}, "id": "ID", "account_id": "AccountID", "template_id": "TemplateID", "template_version": 15, "target_type": "TargetType", "target": "Target", "status": "Status", "resources": [{"target": "Target", "profile": {"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}, "account_settings": {"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}, "policy_template_refs": [{"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}]}], "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "href": "Href", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID", "entity_tag": "EntityTag"}`) + })) + }) + It(`Invoke GetAccountSettingsAssignment successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := iamIdentityService.GetAccountSettingsAssignment(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the GetAccountSettingsAssignmentOptions model + getAccountSettingsAssignmentOptionsModel := new(iamidentityv1.GetAccountSettingsAssignmentOptions) + getAccountSettingsAssignmentOptionsModel.AssignmentID = core.StringPtr("testString") + getAccountSettingsAssignmentOptionsModel.IncludeHistory = core.BoolPtr(false) + getAccountSettingsAssignmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = iamIdentityService.GetAccountSettingsAssignment(getAccountSettingsAssignmentOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke GetAccountSettingsAssignment with error: Operation validation and request error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the GetAccountSettingsAssignmentOptions model + getAccountSettingsAssignmentOptionsModel := new(iamidentityv1.GetAccountSettingsAssignmentOptions) + getAccountSettingsAssignmentOptionsModel.AssignmentID = core.StringPtr("testString") + getAccountSettingsAssignmentOptionsModel.IncludeHistory = core.BoolPtr(false) + getAccountSettingsAssignmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := iamIdentityService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := iamIdentityService.GetAccountSettingsAssignment(getAccountSettingsAssignmentOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + // Construct a second instance of the GetAccountSettingsAssignmentOptions model with no property values + getAccountSettingsAssignmentOptionsModelNew := new(iamidentityv1.GetAccountSettingsAssignmentOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = iamIdentityService.GetAccountSettingsAssignment(getAccountSettingsAssignmentOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(200) + })) + }) + It(`Invoke GetAccountSettingsAssignment successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the GetAccountSettingsAssignmentOptions model + getAccountSettingsAssignmentOptionsModel := new(iamidentityv1.GetAccountSettingsAssignmentOptions) + getAccountSettingsAssignmentOptionsModel.AssignmentID = core.StringPtr("testString") + getAccountSettingsAssignmentOptionsModel.IncludeHistory = core.BoolPtr(false) + getAccountSettingsAssignmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamIdentityService.GetAccountSettingsAssignment(getAccountSettingsAssignmentOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`DeleteAccountSettingsAssignment(deleteAccountSettingsAssignmentOptions *DeleteAccountSettingsAssignmentOptions) - Operation response error`, func() { + deleteAccountSettingsAssignmentPath := "/v1/account_settings_assignments/testString" + Context(`Using mock server endpoint with invalid JSON response`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(deleteAccountSettingsAssignmentPath)) + Expect(req.Method).To(Equal("DELETE")) + res.Header().Set("Content-type", "application/json") + res.WriteHeader(202) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke DeleteAccountSettingsAssignment with error: Operation response processing error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the DeleteAccountSettingsAssignmentOptions model + deleteAccountSettingsAssignmentOptionsModel := new(iamidentityv1.DeleteAccountSettingsAssignmentOptions) + deleteAccountSettingsAssignmentOptionsModel.AssignmentID = core.StringPtr("testString") + deleteAccountSettingsAssignmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := iamIdentityService.DeleteAccountSettingsAssignment(deleteAccountSettingsAssignmentOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + iamIdentityService.EnableRetries(0, 0) + result, response, operationErr = iamIdentityService.DeleteAccountSettingsAssignment(deleteAccountSettingsAssignmentOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`DeleteAccountSettingsAssignment(deleteAccountSettingsAssignmentOptions *DeleteAccountSettingsAssignmentOptions)`, func() { + deleteAccountSettingsAssignmentPath := "/v1/account_settings_assignments/testString" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(deleteAccountSettingsAssignmentPath)) + Expect(req.Method).To(Equal("DELETE")) + + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(202) + fmt.Fprintf(res, "%s", `{"context": {"transaction_id": "TransactionID", "operation": "Operation", "user_agent": "UserAgent", "url": "URL", "instance_id": "InstanceID", "thread_id": "ThreadID", "host": "Host", "start_time": "StartTime", "end_time": "EndTime", "elapsed_time": "ElapsedTime", "cluster_name": "ClusterName"}, "status_code": "StatusCode", "errors": [{"code": "Code", "message_code": "MessageCode", "message": "Message", "details": "Details"}], "trace": "Trace"}`) + })) + }) + It(`Invoke DeleteAccountSettingsAssignment successfully with retries`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + iamIdentityService.EnableRetries(0, 0) + + // Construct an instance of the DeleteAccountSettingsAssignmentOptions model + deleteAccountSettingsAssignmentOptionsModel := new(iamidentityv1.DeleteAccountSettingsAssignmentOptions) + deleteAccountSettingsAssignmentOptionsModel.AssignmentID = core.StringPtr("testString") + deleteAccountSettingsAssignmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := iamIdentityService.DeleteAccountSettingsAssignmentWithContext(ctx, deleteAccountSettingsAssignmentOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + iamIdentityService.DisableRetries() + result, response, operationErr := iamIdentityService.DeleteAccountSettingsAssignment(deleteAccountSettingsAssignmentOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = iamIdentityService.DeleteAccountSettingsAssignmentWithContext(ctx, deleteAccountSettingsAssignmentOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(deleteAccountSettingsAssignmentPath)) + Expect(req.Method).To(Equal("DELETE")) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(202) + fmt.Fprintf(res, "%s", `{"context": {"transaction_id": "TransactionID", "operation": "Operation", "user_agent": "UserAgent", "url": "URL", "instance_id": "InstanceID", "thread_id": "ThreadID", "host": "Host", "start_time": "StartTime", "end_time": "EndTime", "elapsed_time": "ElapsedTime", "cluster_name": "ClusterName"}, "status_code": "StatusCode", "errors": [{"code": "Code", "message_code": "MessageCode", "message": "Message", "details": "Details"}], "trace": "Trace"}`) + })) + }) + It(`Invoke DeleteAccountSettingsAssignment successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := iamIdentityService.DeleteAccountSettingsAssignment(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the DeleteAccountSettingsAssignmentOptions model + deleteAccountSettingsAssignmentOptionsModel := new(iamidentityv1.DeleteAccountSettingsAssignmentOptions) + deleteAccountSettingsAssignmentOptionsModel.AssignmentID = core.StringPtr("testString") + deleteAccountSettingsAssignmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = iamIdentityService.DeleteAccountSettingsAssignment(deleteAccountSettingsAssignmentOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke DeleteAccountSettingsAssignment with error: Operation validation and request error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the DeleteAccountSettingsAssignmentOptions model + deleteAccountSettingsAssignmentOptionsModel := new(iamidentityv1.DeleteAccountSettingsAssignmentOptions) + deleteAccountSettingsAssignmentOptionsModel.AssignmentID = core.StringPtr("testString") + deleteAccountSettingsAssignmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := iamIdentityService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := iamIdentityService.DeleteAccountSettingsAssignment(deleteAccountSettingsAssignmentOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + // Construct a second instance of the DeleteAccountSettingsAssignmentOptions model with no property values + deleteAccountSettingsAssignmentOptionsModelNew := new(iamidentityv1.DeleteAccountSettingsAssignmentOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = iamIdentityService.DeleteAccountSettingsAssignment(deleteAccountSettingsAssignmentOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(202) + })) + }) + It(`Invoke DeleteAccountSettingsAssignment successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the DeleteAccountSettingsAssignmentOptions model + deleteAccountSettingsAssignmentOptionsModel := new(iamidentityv1.DeleteAccountSettingsAssignmentOptions) + deleteAccountSettingsAssignmentOptionsModel.AssignmentID = core.StringPtr("testString") + deleteAccountSettingsAssignmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamIdentityService.DeleteAccountSettingsAssignment(deleteAccountSettingsAssignmentOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`UpdateAccountSettingsAssignment(updateAccountSettingsAssignmentOptions *UpdateAccountSettingsAssignmentOptions) - Operation response error`, func() { + updateAccountSettingsAssignmentPath := "/v1/account_settings_assignments/testString" + Context(`Using mock server endpoint with invalid JSON response`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(updateAccountSettingsAssignmentPath)) + Expect(req.Method).To(Equal("PATCH")) + Expect(req.Header["If-Match"]).ToNot(BeNil()) + Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke UpdateAccountSettingsAssignment with error: Operation response processing error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the UpdateAccountSettingsAssignmentOptions model + updateAccountSettingsAssignmentOptionsModel := new(iamidentityv1.UpdateAccountSettingsAssignmentOptions) + updateAccountSettingsAssignmentOptionsModel.AssignmentID = core.StringPtr("testString") + updateAccountSettingsAssignmentOptionsModel.IfMatch = core.StringPtr("testString") + updateAccountSettingsAssignmentOptionsModel.TemplateVersion = core.Int64Ptr(int64(1)) + updateAccountSettingsAssignmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := iamIdentityService.UpdateAccountSettingsAssignment(updateAccountSettingsAssignmentOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + iamIdentityService.EnableRetries(0, 0) + result, response, operationErr = iamIdentityService.UpdateAccountSettingsAssignment(updateAccountSettingsAssignmentOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`UpdateAccountSettingsAssignment(updateAccountSettingsAssignmentOptions *UpdateAccountSettingsAssignmentOptions)`, func() { + updateAccountSettingsAssignmentPath := "/v1/account_settings_assignments/testString" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(updateAccountSettingsAssignmentPath)) + Expect(req.Method).To(Equal("PATCH")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + + Expect(req.Header["If-Match"]).ToNot(BeNil()) + Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"context": {"transaction_id": "TransactionID", "operation": "Operation", "user_agent": "UserAgent", "url": "URL", "instance_id": "InstanceID", "thread_id": "ThreadID", "host": "Host", "start_time": "StartTime", "end_time": "EndTime", "elapsed_time": "ElapsedTime", "cluster_name": "ClusterName"}, "id": "ID", "account_id": "AccountID", "template_id": "TemplateID", "template_version": 15, "target_type": "TargetType", "target": "Target", "status": "Status", "resources": [{"target": "Target", "profile": {"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}, "account_settings": {"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}, "policy_template_refs": [{"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}]}], "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "href": "Href", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID", "entity_tag": "EntityTag"}`) + })) + }) + It(`Invoke UpdateAccountSettingsAssignment successfully with retries`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + iamIdentityService.EnableRetries(0, 0) + + // Construct an instance of the UpdateAccountSettingsAssignmentOptions model + updateAccountSettingsAssignmentOptionsModel := new(iamidentityv1.UpdateAccountSettingsAssignmentOptions) + updateAccountSettingsAssignmentOptionsModel.AssignmentID = core.StringPtr("testString") + updateAccountSettingsAssignmentOptionsModel.IfMatch = core.StringPtr("testString") + updateAccountSettingsAssignmentOptionsModel.TemplateVersion = core.Int64Ptr(int64(1)) + updateAccountSettingsAssignmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := iamIdentityService.UpdateAccountSettingsAssignmentWithContext(ctx, updateAccountSettingsAssignmentOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + iamIdentityService.DisableRetries() + result, response, operationErr := iamIdentityService.UpdateAccountSettingsAssignment(updateAccountSettingsAssignmentOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = iamIdentityService.UpdateAccountSettingsAssignmentWithContext(ctx, updateAccountSettingsAssignmentOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(updateAccountSettingsAssignmentPath)) + Expect(req.Method).To(Equal("PATCH")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + + Expect(req.Header["If-Match"]).ToNot(BeNil()) + Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"context": {"transaction_id": "TransactionID", "operation": "Operation", "user_agent": "UserAgent", "url": "URL", "instance_id": "InstanceID", "thread_id": "ThreadID", "host": "Host", "start_time": "StartTime", "end_time": "EndTime", "elapsed_time": "ElapsedTime", "cluster_name": "ClusterName"}, "id": "ID", "account_id": "AccountID", "template_id": "TemplateID", "template_version": 15, "target_type": "TargetType", "target": "Target", "status": "Status", "resources": [{"target": "Target", "profile": {"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}, "account_settings": {"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}, "policy_template_refs": [{"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}]}], "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "href": "Href", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID", "entity_tag": "EntityTag"}`) + })) + }) + It(`Invoke UpdateAccountSettingsAssignment successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := iamIdentityService.UpdateAccountSettingsAssignment(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the UpdateAccountSettingsAssignmentOptions model + updateAccountSettingsAssignmentOptionsModel := new(iamidentityv1.UpdateAccountSettingsAssignmentOptions) + updateAccountSettingsAssignmentOptionsModel.AssignmentID = core.StringPtr("testString") + updateAccountSettingsAssignmentOptionsModel.IfMatch = core.StringPtr("testString") + updateAccountSettingsAssignmentOptionsModel.TemplateVersion = core.Int64Ptr(int64(1)) + updateAccountSettingsAssignmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = iamIdentityService.UpdateAccountSettingsAssignment(updateAccountSettingsAssignmentOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke UpdateAccountSettingsAssignment with error: Operation validation and request error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the UpdateAccountSettingsAssignmentOptions model + updateAccountSettingsAssignmentOptionsModel := new(iamidentityv1.UpdateAccountSettingsAssignmentOptions) + updateAccountSettingsAssignmentOptionsModel.AssignmentID = core.StringPtr("testString") + updateAccountSettingsAssignmentOptionsModel.IfMatch = core.StringPtr("testString") + updateAccountSettingsAssignmentOptionsModel.TemplateVersion = core.Int64Ptr(int64(1)) + updateAccountSettingsAssignmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := iamIdentityService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := iamIdentityService.UpdateAccountSettingsAssignment(updateAccountSettingsAssignmentOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + // Construct a second instance of the UpdateAccountSettingsAssignmentOptions model with no property values + updateAccountSettingsAssignmentOptionsModelNew := new(iamidentityv1.UpdateAccountSettingsAssignmentOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = iamIdentityService.UpdateAccountSettingsAssignment(updateAccountSettingsAssignmentOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(200) + })) + }) + It(`Invoke UpdateAccountSettingsAssignment successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the UpdateAccountSettingsAssignmentOptions model + updateAccountSettingsAssignmentOptionsModel := new(iamidentityv1.UpdateAccountSettingsAssignmentOptions) + updateAccountSettingsAssignmentOptionsModel.AssignmentID = core.StringPtr("testString") + updateAccountSettingsAssignmentOptionsModel.IfMatch = core.StringPtr("testString") + updateAccountSettingsAssignmentOptionsModel.TemplateVersion = core.Int64Ptr(int64(1)) + updateAccountSettingsAssignmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamIdentityService.UpdateAccountSettingsAssignment(updateAccountSettingsAssignmentOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`ListAccountSettingsTemplates(listAccountSettingsTemplatesOptions *ListAccountSettingsTemplatesOptions) - Operation response error`, func() { + listAccountSettingsTemplatesPath := "/v1/account_settings_templates" + Context(`Using mock server endpoint with invalid JSON response`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listAccountSettingsTemplatesPath)) + Expect(req.Method).To(Equal("GET")) + Expect(req.URL.Query()["account_id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{"20"})) + Expect(req.URL.Query()["pagetoken"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["sort"]).To(Equal([]string{"created_at"})) + Expect(req.URL.Query()["order"]).To(Equal([]string{"asc"})) + Expect(req.URL.Query()["include_history"]).To(Equal([]string{"false"})) + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke ListAccountSettingsTemplates with error: Operation response processing error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the ListAccountSettingsTemplatesOptions model + listAccountSettingsTemplatesOptionsModel := new(iamidentityv1.ListAccountSettingsTemplatesOptions) + listAccountSettingsTemplatesOptionsModel.AccountID = core.StringPtr("testString") + listAccountSettingsTemplatesOptionsModel.Limit = core.StringPtr("20") + listAccountSettingsTemplatesOptionsModel.Pagetoken = core.StringPtr("testString") + listAccountSettingsTemplatesOptionsModel.Sort = core.StringPtr("created_at") + listAccountSettingsTemplatesOptionsModel.Order = core.StringPtr("asc") + listAccountSettingsTemplatesOptionsModel.IncludeHistory = core.StringPtr("false") + listAccountSettingsTemplatesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := iamIdentityService.ListAccountSettingsTemplates(listAccountSettingsTemplatesOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + iamIdentityService.EnableRetries(0, 0) + result, response, operationErr = iamIdentityService.ListAccountSettingsTemplates(listAccountSettingsTemplatesOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`ListAccountSettingsTemplates(listAccountSettingsTemplatesOptions *ListAccountSettingsTemplatesOptions)`, func() { + listAccountSettingsTemplatesPath := "/v1/account_settings_templates" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listAccountSettingsTemplatesPath)) + Expect(req.Method).To(Equal("GET")) + + Expect(req.URL.Query()["account_id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{"20"})) + Expect(req.URL.Query()["pagetoken"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["sort"]).To(Equal([]string{"created_at"})) + Expect(req.URL.Query()["order"]).To(Equal([]string{"asc"})) + Expect(req.URL.Query()["include_history"]).To(Equal([]string{"false"})) + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"context": {"transaction_id": "TransactionID", "operation": "Operation", "user_agent": "UserAgent", "url": "URL", "instance_id": "InstanceID", "thread_id": "ThreadID", "host": "Host", "start_time": "StartTime", "end_time": "EndTime", "elapsed_time": "ElapsedTime", "cluster_name": "ClusterName"}, "offset": 6, "limit": 20, "first": "First", "previous": "Previous", "next": "Next", "account_settings_templates": [{"id": "ID", "version": 7, "account_id": "AccountID", "name": "Name", "description": "Description", "committed": false, "account_settings": {"restrict_create_service_id": "NOT_SET", "restrict_create_platform_apikey": "NOT_SET", "allowed_ip_addresses": "AllowedIPAddresses", "mfa": "NONE", "user_mfa": [{"iam_id": "IamID", "mfa": "NONE"}], "session_expiration_in_seconds": "86400", "session_invalidation_in_seconds": "7200", "max_sessions_per_identity": "MaxSessionsPerIdentity", "system_access_token_expiration_in_seconds": "3600", "system_refresh_token_expiration_in_seconds": "259200"}, "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "entity_tag": "EntityTag", "crn": "CRN", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID"}]}`) + })) + }) + It(`Invoke ListAccountSettingsTemplates successfully with retries`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + iamIdentityService.EnableRetries(0, 0) + + // Construct an instance of the ListAccountSettingsTemplatesOptions model + listAccountSettingsTemplatesOptionsModel := new(iamidentityv1.ListAccountSettingsTemplatesOptions) + listAccountSettingsTemplatesOptionsModel.AccountID = core.StringPtr("testString") + listAccountSettingsTemplatesOptionsModel.Limit = core.StringPtr("20") + listAccountSettingsTemplatesOptionsModel.Pagetoken = core.StringPtr("testString") + listAccountSettingsTemplatesOptionsModel.Sort = core.StringPtr("created_at") + listAccountSettingsTemplatesOptionsModel.Order = core.StringPtr("asc") + listAccountSettingsTemplatesOptionsModel.IncludeHistory = core.StringPtr("false") + listAccountSettingsTemplatesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := iamIdentityService.ListAccountSettingsTemplatesWithContext(ctx, listAccountSettingsTemplatesOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + iamIdentityService.DisableRetries() + result, response, operationErr := iamIdentityService.ListAccountSettingsTemplates(listAccountSettingsTemplatesOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = iamIdentityService.ListAccountSettingsTemplatesWithContext(ctx, listAccountSettingsTemplatesOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listAccountSettingsTemplatesPath)) + Expect(req.Method).To(Equal("GET")) + + Expect(req.URL.Query()["account_id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{"20"})) + Expect(req.URL.Query()["pagetoken"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["sort"]).To(Equal([]string{"created_at"})) + Expect(req.URL.Query()["order"]).To(Equal([]string{"asc"})) + Expect(req.URL.Query()["include_history"]).To(Equal([]string{"false"})) + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"context": {"transaction_id": "TransactionID", "operation": "Operation", "user_agent": "UserAgent", "url": "URL", "instance_id": "InstanceID", "thread_id": "ThreadID", "host": "Host", "start_time": "StartTime", "end_time": "EndTime", "elapsed_time": "ElapsedTime", "cluster_name": "ClusterName"}, "offset": 6, "limit": 20, "first": "First", "previous": "Previous", "next": "Next", "account_settings_templates": [{"id": "ID", "version": 7, "account_id": "AccountID", "name": "Name", "description": "Description", "committed": false, "account_settings": {"restrict_create_service_id": "NOT_SET", "restrict_create_platform_apikey": "NOT_SET", "allowed_ip_addresses": "AllowedIPAddresses", "mfa": "NONE", "user_mfa": [{"iam_id": "IamID", "mfa": "NONE"}], "session_expiration_in_seconds": "86400", "session_invalidation_in_seconds": "7200", "max_sessions_per_identity": "MaxSessionsPerIdentity", "system_access_token_expiration_in_seconds": "3600", "system_refresh_token_expiration_in_seconds": "259200"}, "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "entity_tag": "EntityTag", "crn": "CRN", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID"}]}`) + })) + }) + It(`Invoke ListAccountSettingsTemplates successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := iamIdentityService.ListAccountSettingsTemplates(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the ListAccountSettingsTemplatesOptions model + listAccountSettingsTemplatesOptionsModel := new(iamidentityv1.ListAccountSettingsTemplatesOptions) + listAccountSettingsTemplatesOptionsModel.AccountID = core.StringPtr("testString") + listAccountSettingsTemplatesOptionsModel.Limit = core.StringPtr("20") + listAccountSettingsTemplatesOptionsModel.Pagetoken = core.StringPtr("testString") + listAccountSettingsTemplatesOptionsModel.Sort = core.StringPtr("created_at") + listAccountSettingsTemplatesOptionsModel.Order = core.StringPtr("asc") + listAccountSettingsTemplatesOptionsModel.IncludeHistory = core.StringPtr("false") + listAccountSettingsTemplatesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = iamIdentityService.ListAccountSettingsTemplates(listAccountSettingsTemplatesOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke ListAccountSettingsTemplates with error: Operation request error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the ListAccountSettingsTemplatesOptions model + listAccountSettingsTemplatesOptionsModel := new(iamidentityv1.ListAccountSettingsTemplatesOptions) + listAccountSettingsTemplatesOptionsModel.AccountID = core.StringPtr("testString") + listAccountSettingsTemplatesOptionsModel.Limit = core.StringPtr("20") + listAccountSettingsTemplatesOptionsModel.Pagetoken = core.StringPtr("testString") + listAccountSettingsTemplatesOptionsModel.Sort = core.StringPtr("created_at") + listAccountSettingsTemplatesOptionsModel.Order = core.StringPtr("asc") + listAccountSettingsTemplatesOptionsModel.IncludeHistory = core.StringPtr("false") + listAccountSettingsTemplatesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := iamIdentityService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := iamIdentityService.ListAccountSettingsTemplates(listAccountSettingsTemplatesOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(200) + })) + }) + It(`Invoke ListAccountSettingsTemplates successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the ListAccountSettingsTemplatesOptions model + listAccountSettingsTemplatesOptionsModel := new(iamidentityv1.ListAccountSettingsTemplatesOptions) + listAccountSettingsTemplatesOptionsModel.AccountID = core.StringPtr("testString") + listAccountSettingsTemplatesOptionsModel.Limit = core.StringPtr("20") + listAccountSettingsTemplatesOptionsModel.Pagetoken = core.StringPtr("testString") + listAccountSettingsTemplatesOptionsModel.Sort = core.StringPtr("created_at") + listAccountSettingsTemplatesOptionsModel.Order = core.StringPtr("asc") + listAccountSettingsTemplatesOptionsModel.IncludeHistory = core.StringPtr("false") + listAccountSettingsTemplatesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamIdentityService.ListAccountSettingsTemplates(listAccountSettingsTemplatesOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`CreateAccountSettingsTemplate(createAccountSettingsTemplateOptions *CreateAccountSettingsTemplateOptions) - Operation response error`, func() { + createAccountSettingsTemplatePath := "/v1/account_settings_templates" + Context(`Using mock server endpoint with invalid JSON response`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(createAccountSettingsTemplatePath)) + Expect(req.Method).To(Equal("POST")) + res.Header().Set("Content-type", "application/json") + res.WriteHeader(201) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke CreateAccountSettingsTemplate with error: Operation response processing error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the AccountSettingsUserMfa model + accountSettingsUserMfaModel := new(iamidentityv1.AccountSettingsUserMfa) + accountSettingsUserMfaModel.IamID = core.StringPtr("testString") + accountSettingsUserMfaModel.Mfa = core.StringPtr("NONE") + + // Construct an instance of the AccountSettingsComponent model + accountSettingsComponentModel := new(iamidentityv1.AccountSettingsComponent) + accountSettingsComponentModel.RestrictCreateServiceID = core.StringPtr("NOT_SET") + accountSettingsComponentModel.RestrictCreatePlatformApikey = core.StringPtr("NOT_SET") + accountSettingsComponentModel.AllowedIPAddresses = core.StringPtr("testString") + accountSettingsComponentModel.Mfa = core.StringPtr("NONE") + accountSettingsComponentModel.UserMfa = []iamidentityv1.AccountSettingsUserMfa{*accountSettingsUserMfaModel} + accountSettingsComponentModel.SessionExpirationInSeconds = core.StringPtr("86400") + accountSettingsComponentModel.SessionInvalidationInSeconds = core.StringPtr("7200") + accountSettingsComponentModel.MaxSessionsPerIdentity = core.StringPtr("testString") + accountSettingsComponentModel.SystemAccessTokenExpirationInSeconds = core.StringPtr("3600") + accountSettingsComponentModel.SystemRefreshTokenExpirationInSeconds = core.StringPtr("259200") + + // Construct an instance of the CreateAccountSettingsTemplateOptions model + createAccountSettingsTemplateOptionsModel := new(iamidentityv1.CreateAccountSettingsTemplateOptions) + createAccountSettingsTemplateOptionsModel.AccountID = core.StringPtr("testString") + createAccountSettingsTemplateOptionsModel.Name = core.StringPtr("testString") + createAccountSettingsTemplateOptionsModel.Description = core.StringPtr("testString") + createAccountSettingsTemplateOptionsModel.AccountSettings = accountSettingsComponentModel + createAccountSettingsTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := iamIdentityService.CreateAccountSettingsTemplate(createAccountSettingsTemplateOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + iamIdentityService.EnableRetries(0, 0) + result, response, operationErr = iamIdentityService.CreateAccountSettingsTemplate(createAccountSettingsTemplateOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`CreateAccountSettingsTemplate(createAccountSettingsTemplateOptions *CreateAccountSettingsTemplateOptions)`, func() { + createAccountSettingsTemplatePath := "/v1/account_settings_templates" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(createAccountSettingsTemplatePath)) + Expect(req.Method).To(Equal("POST")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(201) + fmt.Fprintf(res, "%s", `{"id": "ID", "version": 7, "account_id": "AccountID", "name": "Name", "description": "Description", "committed": false, "account_settings": {"restrict_create_service_id": "NOT_SET", "restrict_create_platform_apikey": "NOT_SET", "allowed_ip_addresses": "AllowedIPAddresses", "mfa": "NONE", "user_mfa": [{"iam_id": "IamID", "mfa": "NONE"}], "session_expiration_in_seconds": "86400", "session_invalidation_in_seconds": "7200", "max_sessions_per_identity": "MaxSessionsPerIdentity", "system_access_token_expiration_in_seconds": "3600", "system_refresh_token_expiration_in_seconds": "259200"}, "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "entity_tag": "EntityTag", "crn": "CRN", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID"}`) + })) + }) + It(`Invoke CreateAccountSettingsTemplate successfully with retries`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + iamIdentityService.EnableRetries(0, 0) + + // Construct an instance of the AccountSettingsUserMfa model + accountSettingsUserMfaModel := new(iamidentityv1.AccountSettingsUserMfa) + accountSettingsUserMfaModel.IamID = core.StringPtr("testString") + accountSettingsUserMfaModel.Mfa = core.StringPtr("NONE") + + // Construct an instance of the AccountSettingsComponent model + accountSettingsComponentModel := new(iamidentityv1.AccountSettingsComponent) + accountSettingsComponentModel.RestrictCreateServiceID = core.StringPtr("NOT_SET") + accountSettingsComponentModel.RestrictCreatePlatformApikey = core.StringPtr("NOT_SET") + accountSettingsComponentModel.AllowedIPAddresses = core.StringPtr("testString") + accountSettingsComponentModel.Mfa = core.StringPtr("NONE") + accountSettingsComponentModel.UserMfa = []iamidentityv1.AccountSettingsUserMfa{*accountSettingsUserMfaModel} + accountSettingsComponentModel.SessionExpirationInSeconds = core.StringPtr("86400") + accountSettingsComponentModel.SessionInvalidationInSeconds = core.StringPtr("7200") + accountSettingsComponentModel.MaxSessionsPerIdentity = core.StringPtr("testString") + accountSettingsComponentModel.SystemAccessTokenExpirationInSeconds = core.StringPtr("3600") + accountSettingsComponentModel.SystemRefreshTokenExpirationInSeconds = core.StringPtr("259200") + + // Construct an instance of the CreateAccountSettingsTemplateOptions model + createAccountSettingsTemplateOptionsModel := new(iamidentityv1.CreateAccountSettingsTemplateOptions) + createAccountSettingsTemplateOptionsModel.AccountID = core.StringPtr("testString") + createAccountSettingsTemplateOptionsModel.Name = core.StringPtr("testString") + createAccountSettingsTemplateOptionsModel.Description = core.StringPtr("testString") + createAccountSettingsTemplateOptionsModel.AccountSettings = accountSettingsComponentModel + createAccountSettingsTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := iamIdentityService.CreateAccountSettingsTemplateWithContext(ctx, createAccountSettingsTemplateOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + iamIdentityService.DisableRetries() + result, response, operationErr := iamIdentityService.CreateAccountSettingsTemplate(createAccountSettingsTemplateOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = iamIdentityService.CreateAccountSettingsTemplateWithContext(ctx, createAccountSettingsTemplateOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(createAccountSettingsTemplatePath)) + Expect(req.Method).To(Equal("POST")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(201) + fmt.Fprintf(res, "%s", `{"id": "ID", "version": 7, "account_id": "AccountID", "name": "Name", "description": "Description", "committed": false, "account_settings": {"restrict_create_service_id": "NOT_SET", "restrict_create_platform_apikey": "NOT_SET", "allowed_ip_addresses": "AllowedIPAddresses", "mfa": "NONE", "user_mfa": [{"iam_id": "IamID", "mfa": "NONE"}], "session_expiration_in_seconds": "86400", "session_invalidation_in_seconds": "7200", "max_sessions_per_identity": "MaxSessionsPerIdentity", "system_access_token_expiration_in_seconds": "3600", "system_refresh_token_expiration_in_seconds": "259200"}, "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "entity_tag": "EntityTag", "crn": "CRN", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID"}`) + })) + }) + It(`Invoke CreateAccountSettingsTemplate successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := iamIdentityService.CreateAccountSettingsTemplate(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the AccountSettingsUserMfa model + accountSettingsUserMfaModel := new(iamidentityv1.AccountSettingsUserMfa) + accountSettingsUserMfaModel.IamID = core.StringPtr("testString") + accountSettingsUserMfaModel.Mfa = core.StringPtr("NONE") + + // Construct an instance of the AccountSettingsComponent model + accountSettingsComponentModel := new(iamidentityv1.AccountSettingsComponent) + accountSettingsComponentModel.RestrictCreateServiceID = core.StringPtr("NOT_SET") + accountSettingsComponentModel.RestrictCreatePlatformApikey = core.StringPtr("NOT_SET") + accountSettingsComponentModel.AllowedIPAddresses = core.StringPtr("testString") + accountSettingsComponentModel.Mfa = core.StringPtr("NONE") + accountSettingsComponentModel.UserMfa = []iamidentityv1.AccountSettingsUserMfa{*accountSettingsUserMfaModel} + accountSettingsComponentModel.SessionExpirationInSeconds = core.StringPtr("86400") + accountSettingsComponentModel.SessionInvalidationInSeconds = core.StringPtr("7200") + accountSettingsComponentModel.MaxSessionsPerIdentity = core.StringPtr("testString") + accountSettingsComponentModel.SystemAccessTokenExpirationInSeconds = core.StringPtr("3600") + accountSettingsComponentModel.SystemRefreshTokenExpirationInSeconds = core.StringPtr("259200") + + // Construct an instance of the CreateAccountSettingsTemplateOptions model + createAccountSettingsTemplateOptionsModel := new(iamidentityv1.CreateAccountSettingsTemplateOptions) + createAccountSettingsTemplateOptionsModel.AccountID = core.StringPtr("testString") + createAccountSettingsTemplateOptionsModel.Name = core.StringPtr("testString") + createAccountSettingsTemplateOptionsModel.Description = core.StringPtr("testString") + createAccountSettingsTemplateOptionsModel.AccountSettings = accountSettingsComponentModel + createAccountSettingsTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = iamIdentityService.CreateAccountSettingsTemplate(createAccountSettingsTemplateOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke CreateAccountSettingsTemplate with error: Operation request error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the AccountSettingsUserMfa model + accountSettingsUserMfaModel := new(iamidentityv1.AccountSettingsUserMfa) + accountSettingsUserMfaModel.IamID = core.StringPtr("testString") + accountSettingsUserMfaModel.Mfa = core.StringPtr("NONE") + + // Construct an instance of the AccountSettingsComponent model + accountSettingsComponentModel := new(iamidentityv1.AccountSettingsComponent) + accountSettingsComponentModel.RestrictCreateServiceID = core.StringPtr("NOT_SET") + accountSettingsComponentModel.RestrictCreatePlatformApikey = core.StringPtr("NOT_SET") + accountSettingsComponentModel.AllowedIPAddresses = core.StringPtr("testString") + accountSettingsComponentModel.Mfa = core.StringPtr("NONE") + accountSettingsComponentModel.UserMfa = []iamidentityv1.AccountSettingsUserMfa{*accountSettingsUserMfaModel} + accountSettingsComponentModel.SessionExpirationInSeconds = core.StringPtr("86400") + accountSettingsComponentModel.SessionInvalidationInSeconds = core.StringPtr("7200") + accountSettingsComponentModel.MaxSessionsPerIdentity = core.StringPtr("testString") + accountSettingsComponentModel.SystemAccessTokenExpirationInSeconds = core.StringPtr("3600") + accountSettingsComponentModel.SystemRefreshTokenExpirationInSeconds = core.StringPtr("259200") + + // Construct an instance of the CreateAccountSettingsTemplateOptions model + createAccountSettingsTemplateOptionsModel := new(iamidentityv1.CreateAccountSettingsTemplateOptions) + createAccountSettingsTemplateOptionsModel.AccountID = core.StringPtr("testString") + createAccountSettingsTemplateOptionsModel.Name = core.StringPtr("testString") + createAccountSettingsTemplateOptionsModel.Description = core.StringPtr("testString") + createAccountSettingsTemplateOptionsModel.AccountSettings = accountSettingsComponentModel + createAccountSettingsTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := iamIdentityService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := iamIdentityService.CreateAccountSettingsTemplate(createAccountSettingsTemplateOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(201) + })) + }) + It(`Invoke CreateAccountSettingsTemplate successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the AccountSettingsUserMfa model + accountSettingsUserMfaModel := new(iamidentityv1.AccountSettingsUserMfa) + accountSettingsUserMfaModel.IamID = core.StringPtr("testString") + accountSettingsUserMfaModel.Mfa = core.StringPtr("NONE") + + // Construct an instance of the AccountSettingsComponent model + accountSettingsComponentModel := new(iamidentityv1.AccountSettingsComponent) + accountSettingsComponentModel.RestrictCreateServiceID = core.StringPtr("NOT_SET") + accountSettingsComponentModel.RestrictCreatePlatformApikey = core.StringPtr("NOT_SET") + accountSettingsComponentModel.AllowedIPAddresses = core.StringPtr("testString") + accountSettingsComponentModel.Mfa = core.StringPtr("NONE") + accountSettingsComponentModel.UserMfa = []iamidentityv1.AccountSettingsUserMfa{*accountSettingsUserMfaModel} + accountSettingsComponentModel.SessionExpirationInSeconds = core.StringPtr("86400") + accountSettingsComponentModel.SessionInvalidationInSeconds = core.StringPtr("7200") + accountSettingsComponentModel.MaxSessionsPerIdentity = core.StringPtr("testString") + accountSettingsComponentModel.SystemAccessTokenExpirationInSeconds = core.StringPtr("3600") + accountSettingsComponentModel.SystemRefreshTokenExpirationInSeconds = core.StringPtr("259200") + + // Construct an instance of the CreateAccountSettingsTemplateOptions model + createAccountSettingsTemplateOptionsModel := new(iamidentityv1.CreateAccountSettingsTemplateOptions) + createAccountSettingsTemplateOptionsModel.AccountID = core.StringPtr("testString") + createAccountSettingsTemplateOptionsModel.Name = core.StringPtr("testString") + createAccountSettingsTemplateOptionsModel.Description = core.StringPtr("testString") + createAccountSettingsTemplateOptionsModel.AccountSettings = accountSettingsComponentModel + createAccountSettingsTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamIdentityService.CreateAccountSettingsTemplate(createAccountSettingsTemplateOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetLatestAccountSettingsTemplateVersion(getLatestAccountSettingsTemplateVersionOptions *GetLatestAccountSettingsTemplateVersionOptions) - Operation response error`, func() { + getLatestAccountSettingsTemplateVersionPath := "/v1/account_settings_templates/testString" + Context(`Using mock server endpoint with invalid JSON response`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getLatestAccountSettingsTemplateVersionPath)) + Expect(req.Method).To(Equal("GET")) + // TODO: Add check for include_history query parameter + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke GetLatestAccountSettingsTemplateVersion with error: Operation response processing error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the GetLatestAccountSettingsTemplateVersionOptions model + getLatestAccountSettingsTemplateVersionOptionsModel := new(iamidentityv1.GetLatestAccountSettingsTemplateVersionOptions) + getLatestAccountSettingsTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + getLatestAccountSettingsTemplateVersionOptionsModel.IncludeHistory = core.BoolPtr(false) + getLatestAccountSettingsTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := iamIdentityService.GetLatestAccountSettingsTemplateVersion(getLatestAccountSettingsTemplateVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + iamIdentityService.EnableRetries(0, 0) + result, response, operationErr = iamIdentityService.GetLatestAccountSettingsTemplateVersion(getLatestAccountSettingsTemplateVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetLatestAccountSettingsTemplateVersion(getLatestAccountSettingsTemplateVersionOptions *GetLatestAccountSettingsTemplateVersionOptions)`, func() { + getLatestAccountSettingsTemplateVersionPath := "/v1/account_settings_templates/testString" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getLatestAccountSettingsTemplateVersionPath)) + Expect(req.Method).To(Equal("GET")) + + // TODO: Add check for include_history query parameter + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"id": "ID", "version": 7, "account_id": "AccountID", "name": "Name", "description": "Description", "committed": false, "account_settings": {"restrict_create_service_id": "NOT_SET", "restrict_create_platform_apikey": "NOT_SET", "allowed_ip_addresses": "AllowedIPAddresses", "mfa": "NONE", "user_mfa": [{"iam_id": "IamID", "mfa": "NONE"}], "session_expiration_in_seconds": "86400", "session_invalidation_in_seconds": "7200", "max_sessions_per_identity": "MaxSessionsPerIdentity", "system_access_token_expiration_in_seconds": "3600", "system_refresh_token_expiration_in_seconds": "259200"}, "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "entity_tag": "EntityTag", "crn": "CRN", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID"}`) + })) + }) + It(`Invoke GetLatestAccountSettingsTemplateVersion successfully with retries`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + iamIdentityService.EnableRetries(0, 0) + + // Construct an instance of the GetLatestAccountSettingsTemplateVersionOptions model + getLatestAccountSettingsTemplateVersionOptionsModel := new(iamidentityv1.GetLatestAccountSettingsTemplateVersionOptions) + getLatestAccountSettingsTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + getLatestAccountSettingsTemplateVersionOptionsModel.IncludeHistory = core.BoolPtr(false) + getLatestAccountSettingsTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := iamIdentityService.GetLatestAccountSettingsTemplateVersionWithContext(ctx, getLatestAccountSettingsTemplateVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + iamIdentityService.DisableRetries() + result, response, operationErr := iamIdentityService.GetLatestAccountSettingsTemplateVersion(getLatestAccountSettingsTemplateVersionOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = iamIdentityService.GetLatestAccountSettingsTemplateVersionWithContext(ctx, getLatestAccountSettingsTemplateVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getLatestAccountSettingsTemplateVersionPath)) + Expect(req.Method).To(Equal("GET")) + + // TODO: Add check for include_history query parameter + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"id": "ID", "version": 7, "account_id": "AccountID", "name": "Name", "description": "Description", "committed": false, "account_settings": {"restrict_create_service_id": "NOT_SET", "restrict_create_platform_apikey": "NOT_SET", "allowed_ip_addresses": "AllowedIPAddresses", "mfa": "NONE", "user_mfa": [{"iam_id": "IamID", "mfa": "NONE"}], "session_expiration_in_seconds": "86400", "session_invalidation_in_seconds": "7200", "max_sessions_per_identity": "MaxSessionsPerIdentity", "system_access_token_expiration_in_seconds": "3600", "system_refresh_token_expiration_in_seconds": "259200"}, "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "entity_tag": "EntityTag", "crn": "CRN", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID"}`) + })) + }) + It(`Invoke GetLatestAccountSettingsTemplateVersion successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := iamIdentityService.GetLatestAccountSettingsTemplateVersion(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the GetLatestAccountSettingsTemplateVersionOptions model + getLatestAccountSettingsTemplateVersionOptionsModel := new(iamidentityv1.GetLatestAccountSettingsTemplateVersionOptions) + getLatestAccountSettingsTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + getLatestAccountSettingsTemplateVersionOptionsModel.IncludeHistory = core.BoolPtr(false) + getLatestAccountSettingsTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = iamIdentityService.GetLatestAccountSettingsTemplateVersion(getLatestAccountSettingsTemplateVersionOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke GetLatestAccountSettingsTemplateVersion with error: Operation validation and request error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the GetLatestAccountSettingsTemplateVersionOptions model + getLatestAccountSettingsTemplateVersionOptionsModel := new(iamidentityv1.GetLatestAccountSettingsTemplateVersionOptions) + getLatestAccountSettingsTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + getLatestAccountSettingsTemplateVersionOptionsModel.IncludeHistory = core.BoolPtr(false) + getLatestAccountSettingsTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := iamIdentityService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := iamIdentityService.GetLatestAccountSettingsTemplateVersion(getLatestAccountSettingsTemplateVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + // Construct a second instance of the GetLatestAccountSettingsTemplateVersionOptions model with no property values + getLatestAccountSettingsTemplateVersionOptionsModelNew := new(iamidentityv1.GetLatestAccountSettingsTemplateVersionOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = iamIdentityService.GetLatestAccountSettingsTemplateVersion(getLatestAccountSettingsTemplateVersionOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(200) + })) + }) + It(`Invoke GetLatestAccountSettingsTemplateVersion successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the GetLatestAccountSettingsTemplateVersionOptions model + getLatestAccountSettingsTemplateVersionOptionsModel := new(iamidentityv1.GetLatestAccountSettingsTemplateVersionOptions) + getLatestAccountSettingsTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + getLatestAccountSettingsTemplateVersionOptionsModel.IncludeHistory = core.BoolPtr(false) + getLatestAccountSettingsTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamIdentityService.GetLatestAccountSettingsTemplateVersion(getLatestAccountSettingsTemplateVersionOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`DeleteAllVersionsOfAccountSettingsTemplate(deleteAllVersionsOfAccountSettingsTemplateOptions *DeleteAllVersionsOfAccountSettingsTemplateOptions)`, func() { + deleteAllVersionsOfAccountSettingsTemplatePath := "/v1/account_settings_templates/testString" + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(deleteAllVersionsOfAccountSettingsTemplatePath)) + Expect(req.Method).To(Equal("DELETE")) + + res.WriteHeader(204) + })) + }) + It(`Invoke DeleteAllVersionsOfAccountSettingsTemplate successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + response, operationErr := iamIdentityService.DeleteAllVersionsOfAccountSettingsTemplate(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + + // Construct an instance of the DeleteAllVersionsOfAccountSettingsTemplateOptions model + deleteAllVersionsOfAccountSettingsTemplateOptionsModel := new(iamidentityv1.DeleteAllVersionsOfAccountSettingsTemplateOptions) + deleteAllVersionsOfAccountSettingsTemplateOptionsModel.TemplateID = core.StringPtr("testString") + deleteAllVersionsOfAccountSettingsTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + response, operationErr = iamIdentityService.DeleteAllVersionsOfAccountSettingsTemplate(deleteAllVersionsOfAccountSettingsTemplateOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + }) + It(`Invoke DeleteAllVersionsOfAccountSettingsTemplate with error: Operation validation and request error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the DeleteAllVersionsOfAccountSettingsTemplateOptions model + deleteAllVersionsOfAccountSettingsTemplateOptionsModel := new(iamidentityv1.DeleteAllVersionsOfAccountSettingsTemplateOptions) + deleteAllVersionsOfAccountSettingsTemplateOptionsModel.TemplateID = core.StringPtr("testString") + deleteAllVersionsOfAccountSettingsTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := iamIdentityService.SetServiceURL("") + Expect(err).To(BeNil()) + response, operationErr := iamIdentityService.DeleteAllVersionsOfAccountSettingsTemplate(deleteAllVersionsOfAccountSettingsTemplateOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + // Construct a second instance of the DeleteAllVersionsOfAccountSettingsTemplateOptions model with no property values + deleteAllVersionsOfAccountSettingsTemplateOptionsModelNew := new(iamidentityv1.DeleteAllVersionsOfAccountSettingsTemplateOptions) + // Invoke operation with invalid model (negative test) + response, operationErr = iamIdentityService.DeleteAllVersionsOfAccountSettingsTemplate(deleteAllVersionsOfAccountSettingsTemplateOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`ListVersionsOfAccountSettingsTemplate(listVersionsOfAccountSettingsTemplateOptions *ListVersionsOfAccountSettingsTemplateOptions) - Operation response error`, func() { + listVersionsOfAccountSettingsTemplatePath := "/v1/account_settings_templates/testString/versions" + Context(`Using mock server endpoint with invalid JSON response`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listVersionsOfAccountSettingsTemplatePath)) + Expect(req.Method).To(Equal("GET")) + Expect(req.URL.Query()["limit"]).To(Equal([]string{"20"})) + Expect(req.URL.Query()["pagetoken"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["sort"]).To(Equal([]string{"created_at"})) + Expect(req.URL.Query()["order"]).To(Equal([]string{"asc"})) + Expect(req.URL.Query()["include_history"]).To(Equal([]string{"false"})) + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke ListVersionsOfAccountSettingsTemplate with error: Operation response processing error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the ListVersionsOfAccountSettingsTemplateOptions model + listVersionsOfAccountSettingsTemplateOptionsModel := new(iamidentityv1.ListVersionsOfAccountSettingsTemplateOptions) + listVersionsOfAccountSettingsTemplateOptionsModel.TemplateID = core.StringPtr("testString") + listVersionsOfAccountSettingsTemplateOptionsModel.Limit = core.StringPtr("20") + listVersionsOfAccountSettingsTemplateOptionsModel.Pagetoken = core.StringPtr("testString") + listVersionsOfAccountSettingsTemplateOptionsModel.Sort = core.StringPtr("created_at") + listVersionsOfAccountSettingsTemplateOptionsModel.Order = core.StringPtr("asc") + listVersionsOfAccountSettingsTemplateOptionsModel.IncludeHistory = core.StringPtr("false") + listVersionsOfAccountSettingsTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := iamIdentityService.ListVersionsOfAccountSettingsTemplate(listVersionsOfAccountSettingsTemplateOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + iamIdentityService.EnableRetries(0, 0) + result, response, operationErr = iamIdentityService.ListVersionsOfAccountSettingsTemplate(listVersionsOfAccountSettingsTemplateOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`ListVersionsOfAccountSettingsTemplate(listVersionsOfAccountSettingsTemplateOptions *ListVersionsOfAccountSettingsTemplateOptions)`, func() { + listVersionsOfAccountSettingsTemplatePath := "/v1/account_settings_templates/testString/versions" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listVersionsOfAccountSettingsTemplatePath)) + Expect(req.Method).To(Equal("GET")) + + Expect(req.URL.Query()["limit"]).To(Equal([]string{"20"})) + Expect(req.URL.Query()["pagetoken"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["sort"]).To(Equal([]string{"created_at"})) + Expect(req.URL.Query()["order"]).To(Equal([]string{"asc"})) + Expect(req.URL.Query()["include_history"]).To(Equal([]string{"false"})) + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"context": {"transaction_id": "TransactionID", "operation": "Operation", "user_agent": "UserAgent", "url": "URL", "instance_id": "InstanceID", "thread_id": "ThreadID", "host": "Host", "start_time": "StartTime", "end_time": "EndTime", "elapsed_time": "ElapsedTime", "cluster_name": "ClusterName"}, "offset": 6, "limit": 20, "first": "First", "previous": "Previous", "next": "Next", "account_settings_templates": [{"id": "ID", "version": 7, "account_id": "AccountID", "name": "Name", "description": "Description", "committed": false, "account_settings": {"restrict_create_service_id": "NOT_SET", "restrict_create_platform_apikey": "NOT_SET", "allowed_ip_addresses": "AllowedIPAddresses", "mfa": "NONE", "user_mfa": [{"iam_id": "IamID", "mfa": "NONE"}], "session_expiration_in_seconds": "86400", "session_invalidation_in_seconds": "7200", "max_sessions_per_identity": "MaxSessionsPerIdentity", "system_access_token_expiration_in_seconds": "3600", "system_refresh_token_expiration_in_seconds": "259200"}, "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "entity_tag": "EntityTag", "crn": "CRN", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID"}]}`) + })) + }) + It(`Invoke ListVersionsOfAccountSettingsTemplate successfully with retries`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + iamIdentityService.EnableRetries(0, 0) + + // Construct an instance of the ListVersionsOfAccountSettingsTemplateOptions model + listVersionsOfAccountSettingsTemplateOptionsModel := new(iamidentityv1.ListVersionsOfAccountSettingsTemplateOptions) + listVersionsOfAccountSettingsTemplateOptionsModel.TemplateID = core.StringPtr("testString") + listVersionsOfAccountSettingsTemplateOptionsModel.Limit = core.StringPtr("20") + listVersionsOfAccountSettingsTemplateOptionsModel.Pagetoken = core.StringPtr("testString") + listVersionsOfAccountSettingsTemplateOptionsModel.Sort = core.StringPtr("created_at") + listVersionsOfAccountSettingsTemplateOptionsModel.Order = core.StringPtr("asc") + listVersionsOfAccountSettingsTemplateOptionsModel.IncludeHistory = core.StringPtr("false") + listVersionsOfAccountSettingsTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := iamIdentityService.ListVersionsOfAccountSettingsTemplateWithContext(ctx, listVersionsOfAccountSettingsTemplateOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + iamIdentityService.DisableRetries() + result, response, operationErr := iamIdentityService.ListVersionsOfAccountSettingsTemplate(listVersionsOfAccountSettingsTemplateOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = iamIdentityService.ListVersionsOfAccountSettingsTemplateWithContext(ctx, listVersionsOfAccountSettingsTemplateOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listVersionsOfAccountSettingsTemplatePath)) + Expect(req.Method).To(Equal("GET")) + + Expect(req.URL.Query()["limit"]).To(Equal([]string{"20"})) + Expect(req.URL.Query()["pagetoken"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["sort"]).To(Equal([]string{"created_at"})) + Expect(req.URL.Query()["order"]).To(Equal([]string{"asc"})) + Expect(req.URL.Query()["include_history"]).To(Equal([]string{"false"})) + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"context": {"transaction_id": "TransactionID", "operation": "Operation", "user_agent": "UserAgent", "url": "URL", "instance_id": "InstanceID", "thread_id": "ThreadID", "host": "Host", "start_time": "StartTime", "end_time": "EndTime", "elapsed_time": "ElapsedTime", "cluster_name": "ClusterName"}, "offset": 6, "limit": 20, "first": "First", "previous": "Previous", "next": "Next", "account_settings_templates": [{"id": "ID", "version": 7, "account_id": "AccountID", "name": "Name", "description": "Description", "committed": false, "account_settings": {"restrict_create_service_id": "NOT_SET", "restrict_create_platform_apikey": "NOT_SET", "allowed_ip_addresses": "AllowedIPAddresses", "mfa": "NONE", "user_mfa": [{"iam_id": "IamID", "mfa": "NONE"}], "session_expiration_in_seconds": "86400", "session_invalidation_in_seconds": "7200", "max_sessions_per_identity": "MaxSessionsPerIdentity", "system_access_token_expiration_in_seconds": "3600", "system_refresh_token_expiration_in_seconds": "259200"}, "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "entity_tag": "EntityTag", "crn": "CRN", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID"}]}`) + })) + }) + It(`Invoke ListVersionsOfAccountSettingsTemplate successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := iamIdentityService.ListVersionsOfAccountSettingsTemplate(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the ListVersionsOfAccountSettingsTemplateOptions model + listVersionsOfAccountSettingsTemplateOptionsModel := new(iamidentityv1.ListVersionsOfAccountSettingsTemplateOptions) + listVersionsOfAccountSettingsTemplateOptionsModel.TemplateID = core.StringPtr("testString") + listVersionsOfAccountSettingsTemplateOptionsModel.Limit = core.StringPtr("20") + listVersionsOfAccountSettingsTemplateOptionsModel.Pagetoken = core.StringPtr("testString") + listVersionsOfAccountSettingsTemplateOptionsModel.Sort = core.StringPtr("created_at") + listVersionsOfAccountSettingsTemplateOptionsModel.Order = core.StringPtr("asc") + listVersionsOfAccountSettingsTemplateOptionsModel.IncludeHistory = core.StringPtr("false") + listVersionsOfAccountSettingsTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = iamIdentityService.ListVersionsOfAccountSettingsTemplate(listVersionsOfAccountSettingsTemplateOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke ListVersionsOfAccountSettingsTemplate with error: Operation validation and request error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the ListVersionsOfAccountSettingsTemplateOptions model + listVersionsOfAccountSettingsTemplateOptionsModel := new(iamidentityv1.ListVersionsOfAccountSettingsTemplateOptions) + listVersionsOfAccountSettingsTemplateOptionsModel.TemplateID = core.StringPtr("testString") + listVersionsOfAccountSettingsTemplateOptionsModel.Limit = core.StringPtr("20") + listVersionsOfAccountSettingsTemplateOptionsModel.Pagetoken = core.StringPtr("testString") + listVersionsOfAccountSettingsTemplateOptionsModel.Sort = core.StringPtr("created_at") + listVersionsOfAccountSettingsTemplateOptionsModel.Order = core.StringPtr("asc") + listVersionsOfAccountSettingsTemplateOptionsModel.IncludeHistory = core.StringPtr("false") + listVersionsOfAccountSettingsTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := iamIdentityService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := iamIdentityService.ListVersionsOfAccountSettingsTemplate(listVersionsOfAccountSettingsTemplateOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + // Construct a second instance of the ListVersionsOfAccountSettingsTemplateOptions model with no property values + listVersionsOfAccountSettingsTemplateOptionsModelNew := new(iamidentityv1.ListVersionsOfAccountSettingsTemplateOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = iamIdentityService.ListVersionsOfAccountSettingsTemplate(listVersionsOfAccountSettingsTemplateOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(200) + })) + }) + It(`Invoke ListVersionsOfAccountSettingsTemplate successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the ListVersionsOfAccountSettingsTemplateOptions model + listVersionsOfAccountSettingsTemplateOptionsModel := new(iamidentityv1.ListVersionsOfAccountSettingsTemplateOptions) + listVersionsOfAccountSettingsTemplateOptionsModel.TemplateID = core.StringPtr("testString") + listVersionsOfAccountSettingsTemplateOptionsModel.Limit = core.StringPtr("20") + listVersionsOfAccountSettingsTemplateOptionsModel.Pagetoken = core.StringPtr("testString") + listVersionsOfAccountSettingsTemplateOptionsModel.Sort = core.StringPtr("created_at") + listVersionsOfAccountSettingsTemplateOptionsModel.Order = core.StringPtr("asc") + listVersionsOfAccountSettingsTemplateOptionsModel.IncludeHistory = core.StringPtr("false") + listVersionsOfAccountSettingsTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamIdentityService.ListVersionsOfAccountSettingsTemplate(listVersionsOfAccountSettingsTemplateOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`CreateAccountSettingsTemplateVersion(createAccountSettingsTemplateVersionOptions *CreateAccountSettingsTemplateVersionOptions) - Operation response error`, func() { + createAccountSettingsTemplateVersionPath := "/v1/account_settings_templates/testString/versions" + Context(`Using mock server endpoint with invalid JSON response`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(createAccountSettingsTemplateVersionPath)) + Expect(req.Method).To(Equal("POST")) + res.Header().Set("Content-type", "application/json") + res.WriteHeader(201) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke CreateAccountSettingsTemplateVersion with error: Operation response processing error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the AccountSettingsUserMfa model + accountSettingsUserMfaModel := new(iamidentityv1.AccountSettingsUserMfa) + accountSettingsUserMfaModel.IamID = core.StringPtr("testString") + accountSettingsUserMfaModel.Mfa = core.StringPtr("NONE") + + // Construct an instance of the AccountSettingsComponent model + accountSettingsComponentModel := new(iamidentityv1.AccountSettingsComponent) + accountSettingsComponentModel.RestrictCreateServiceID = core.StringPtr("NOT_SET") + accountSettingsComponentModel.RestrictCreatePlatformApikey = core.StringPtr("NOT_SET") + accountSettingsComponentModel.AllowedIPAddresses = core.StringPtr("testString") + accountSettingsComponentModel.Mfa = core.StringPtr("NONE") + accountSettingsComponentModel.UserMfa = []iamidentityv1.AccountSettingsUserMfa{*accountSettingsUserMfaModel} + accountSettingsComponentModel.SessionExpirationInSeconds = core.StringPtr("86400") + accountSettingsComponentModel.SessionInvalidationInSeconds = core.StringPtr("7200") + accountSettingsComponentModel.MaxSessionsPerIdentity = core.StringPtr("testString") + accountSettingsComponentModel.SystemAccessTokenExpirationInSeconds = core.StringPtr("3600") + accountSettingsComponentModel.SystemRefreshTokenExpirationInSeconds = core.StringPtr("259200") + + // Construct an instance of the CreateAccountSettingsTemplateVersionOptions model + createAccountSettingsTemplateVersionOptionsModel := new(iamidentityv1.CreateAccountSettingsTemplateVersionOptions) + createAccountSettingsTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + createAccountSettingsTemplateVersionOptionsModel.AccountID = core.StringPtr("testString") + createAccountSettingsTemplateVersionOptionsModel.Name = core.StringPtr("testString") + createAccountSettingsTemplateVersionOptionsModel.Description = core.StringPtr("testString") + createAccountSettingsTemplateVersionOptionsModel.AccountSettings = accountSettingsComponentModel + createAccountSettingsTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := iamIdentityService.CreateAccountSettingsTemplateVersion(createAccountSettingsTemplateVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + iamIdentityService.EnableRetries(0, 0) + result, response, operationErr = iamIdentityService.CreateAccountSettingsTemplateVersion(createAccountSettingsTemplateVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`CreateAccountSettingsTemplateVersion(createAccountSettingsTemplateVersionOptions *CreateAccountSettingsTemplateVersionOptions)`, func() { + createAccountSettingsTemplateVersionPath := "/v1/account_settings_templates/testString/versions" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(createAccountSettingsTemplateVersionPath)) + Expect(req.Method).To(Equal("POST")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(201) + fmt.Fprintf(res, "%s", `{"id": "ID", "version": 7, "account_id": "AccountID", "name": "Name", "description": "Description", "committed": false, "account_settings": {"restrict_create_service_id": "NOT_SET", "restrict_create_platform_apikey": "NOT_SET", "allowed_ip_addresses": "AllowedIPAddresses", "mfa": "NONE", "user_mfa": [{"iam_id": "IamID", "mfa": "NONE"}], "session_expiration_in_seconds": "86400", "session_invalidation_in_seconds": "7200", "max_sessions_per_identity": "MaxSessionsPerIdentity", "system_access_token_expiration_in_seconds": "3600", "system_refresh_token_expiration_in_seconds": "259200"}, "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "entity_tag": "EntityTag", "crn": "CRN", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID"}`) + })) + }) + It(`Invoke CreateAccountSettingsTemplateVersion successfully with retries`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + iamIdentityService.EnableRetries(0, 0) + + // Construct an instance of the AccountSettingsUserMfa model + accountSettingsUserMfaModel := new(iamidentityv1.AccountSettingsUserMfa) + accountSettingsUserMfaModel.IamID = core.StringPtr("testString") + accountSettingsUserMfaModel.Mfa = core.StringPtr("NONE") + + // Construct an instance of the AccountSettingsComponent model + accountSettingsComponentModel := new(iamidentityv1.AccountSettingsComponent) + accountSettingsComponentModel.RestrictCreateServiceID = core.StringPtr("NOT_SET") + accountSettingsComponentModel.RestrictCreatePlatformApikey = core.StringPtr("NOT_SET") + accountSettingsComponentModel.AllowedIPAddresses = core.StringPtr("testString") + accountSettingsComponentModel.Mfa = core.StringPtr("NONE") + accountSettingsComponentModel.UserMfa = []iamidentityv1.AccountSettingsUserMfa{*accountSettingsUserMfaModel} + accountSettingsComponentModel.SessionExpirationInSeconds = core.StringPtr("86400") + accountSettingsComponentModel.SessionInvalidationInSeconds = core.StringPtr("7200") + accountSettingsComponentModel.MaxSessionsPerIdentity = core.StringPtr("testString") + accountSettingsComponentModel.SystemAccessTokenExpirationInSeconds = core.StringPtr("3600") + accountSettingsComponentModel.SystemRefreshTokenExpirationInSeconds = core.StringPtr("259200") + + // Construct an instance of the CreateAccountSettingsTemplateVersionOptions model + createAccountSettingsTemplateVersionOptionsModel := new(iamidentityv1.CreateAccountSettingsTemplateVersionOptions) + createAccountSettingsTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + createAccountSettingsTemplateVersionOptionsModel.AccountID = core.StringPtr("testString") + createAccountSettingsTemplateVersionOptionsModel.Name = core.StringPtr("testString") + createAccountSettingsTemplateVersionOptionsModel.Description = core.StringPtr("testString") + createAccountSettingsTemplateVersionOptionsModel.AccountSettings = accountSettingsComponentModel + createAccountSettingsTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := iamIdentityService.CreateAccountSettingsTemplateVersionWithContext(ctx, createAccountSettingsTemplateVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + iamIdentityService.DisableRetries() + result, response, operationErr := iamIdentityService.CreateAccountSettingsTemplateVersion(createAccountSettingsTemplateVersionOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = iamIdentityService.CreateAccountSettingsTemplateVersionWithContext(ctx, createAccountSettingsTemplateVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(createAccountSettingsTemplateVersionPath)) + Expect(req.Method).To(Equal("POST")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(201) + fmt.Fprintf(res, "%s", `{"id": "ID", "version": 7, "account_id": "AccountID", "name": "Name", "description": "Description", "committed": false, "account_settings": {"restrict_create_service_id": "NOT_SET", "restrict_create_platform_apikey": "NOT_SET", "allowed_ip_addresses": "AllowedIPAddresses", "mfa": "NONE", "user_mfa": [{"iam_id": "IamID", "mfa": "NONE"}], "session_expiration_in_seconds": "86400", "session_invalidation_in_seconds": "7200", "max_sessions_per_identity": "MaxSessionsPerIdentity", "system_access_token_expiration_in_seconds": "3600", "system_refresh_token_expiration_in_seconds": "259200"}, "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "entity_tag": "EntityTag", "crn": "CRN", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID"}`) + })) + }) + It(`Invoke CreateAccountSettingsTemplateVersion successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := iamIdentityService.CreateAccountSettingsTemplateVersion(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the AccountSettingsUserMfa model + accountSettingsUserMfaModel := new(iamidentityv1.AccountSettingsUserMfa) + accountSettingsUserMfaModel.IamID = core.StringPtr("testString") + accountSettingsUserMfaModel.Mfa = core.StringPtr("NONE") + + // Construct an instance of the AccountSettingsComponent model + accountSettingsComponentModel := new(iamidentityv1.AccountSettingsComponent) + accountSettingsComponentModel.RestrictCreateServiceID = core.StringPtr("NOT_SET") + accountSettingsComponentModel.RestrictCreatePlatformApikey = core.StringPtr("NOT_SET") + accountSettingsComponentModel.AllowedIPAddresses = core.StringPtr("testString") + accountSettingsComponentModel.Mfa = core.StringPtr("NONE") + accountSettingsComponentModel.UserMfa = []iamidentityv1.AccountSettingsUserMfa{*accountSettingsUserMfaModel} + accountSettingsComponentModel.SessionExpirationInSeconds = core.StringPtr("86400") + accountSettingsComponentModel.SessionInvalidationInSeconds = core.StringPtr("7200") + accountSettingsComponentModel.MaxSessionsPerIdentity = core.StringPtr("testString") + accountSettingsComponentModel.SystemAccessTokenExpirationInSeconds = core.StringPtr("3600") + accountSettingsComponentModel.SystemRefreshTokenExpirationInSeconds = core.StringPtr("259200") + + // Construct an instance of the CreateAccountSettingsTemplateVersionOptions model + createAccountSettingsTemplateVersionOptionsModel := new(iamidentityv1.CreateAccountSettingsTemplateVersionOptions) + createAccountSettingsTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + createAccountSettingsTemplateVersionOptionsModel.AccountID = core.StringPtr("testString") + createAccountSettingsTemplateVersionOptionsModel.Name = core.StringPtr("testString") + createAccountSettingsTemplateVersionOptionsModel.Description = core.StringPtr("testString") + createAccountSettingsTemplateVersionOptionsModel.AccountSettings = accountSettingsComponentModel + createAccountSettingsTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = iamIdentityService.CreateAccountSettingsTemplateVersion(createAccountSettingsTemplateVersionOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke CreateAccountSettingsTemplateVersion with error: Operation validation and request error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the AccountSettingsUserMfa model + accountSettingsUserMfaModel := new(iamidentityv1.AccountSettingsUserMfa) + accountSettingsUserMfaModel.IamID = core.StringPtr("testString") + accountSettingsUserMfaModel.Mfa = core.StringPtr("NONE") + + // Construct an instance of the AccountSettingsComponent model + accountSettingsComponentModel := new(iamidentityv1.AccountSettingsComponent) + accountSettingsComponentModel.RestrictCreateServiceID = core.StringPtr("NOT_SET") + accountSettingsComponentModel.RestrictCreatePlatformApikey = core.StringPtr("NOT_SET") + accountSettingsComponentModel.AllowedIPAddresses = core.StringPtr("testString") + accountSettingsComponentModel.Mfa = core.StringPtr("NONE") + accountSettingsComponentModel.UserMfa = []iamidentityv1.AccountSettingsUserMfa{*accountSettingsUserMfaModel} + accountSettingsComponentModel.SessionExpirationInSeconds = core.StringPtr("86400") + accountSettingsComponentModel.SessionInvalidationInSeconds = core.StringPtr("7200") + accountSettingsComponentModel.MaxSessionsPerIdentity = core.StringPtr("testString") + accountSettingsComponentModel.SystemAccessTokenExpirationInSeconds = core.StringPtr("3600") + accountSettingsComponentModel.SystemRefreshTokenExpirationInSeconds = core.StringPtr("259200") + + // Construct an instance of the CreateAccountSettingsTemplateVersionOptions model + createAccountSettingsTemplateVersionOptionsModel := new(iamidentityv1.CreateAccountSettingsTemplateVersionOptions) + createAccountSettingsTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + createAccountSettingsTemplateVersionOptionsModel.AccountID = core.StringPtr("testString") + createAccountSettingsTemplateVersionOptionsModel.Name = core.StringPtr("testString") + createAccountSettingsTemplateVersionOptionsModel.Description = core.StringPtr("testString") + createAccountSettingsTemplateVersionOptionsModel.AccountSettings = accountSettingsComponentModel + createAccountSettingsTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := iamIdentityService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := iamIdentityService.CreateAccountSettingsTemplateVersion(createAccountSettingsTemplateVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + // Construct a second instance of the CreateAccountSettingsTemplateVersionOptions model with no property values + createAccountSettingsTemplateVersionOptionsModelNew := new(iamidentityv1.CreateAccountSettingsTemplateVersionOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = iamIdentityService.CreateAccountSettingsTemplateVersion(createAccountSettingsTemplateVersionOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(201) + })) + }) + It(`Invoke CreateAccountSettingsTemplateVersion successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the AccountSettingsUserMfa model + accountSettingsUserMfaModel := new(iamidentityv1.AccountSettingsUserMfa) + accountSettingsUserMfaModel.IamID = core.StringPtr("testString") + accountSettingsUserMfaModel.Mfa = core.StringPtr("NONE") + + // Construct an instance of the AccountSettingsComponent model + accountSettingsComponentModel := new(iamidentityv1.AccountSettingsComponent) + accountSettingsComponentModel.RestrictCreateServiceID = core.StringPtr("NOT_SET") + accountSettingsComponentModel.RestrictCreatePlatformApikey = core.StringPtr("NOT_SET") + accountSettingsComponentModel.AllowedIPAddresses = core.StringPtr("testString") + accountSettingsComponentModel.Mfa = core.StringPtr("NONE") + accountSettingsComponentModel.UserMfa = []iamidentityv1.AccountSettingsUserMfa{*accountSettingsUserMfaModel} + accountSettingsComponentModel.SessionExpirationInSeconds = core.StringPtr("86400") + accountSettingsComponentModel.SessionInvalidationInSeconds = core.StringPtr("7200") + accountSettingsComponentModel.MaxSessionsPerIdentity = core.StringPtr("testString") + accountSettingsComponentModel.SystemAccessTokenExpirationInSeconds = core.StringPtr("3600") + accountSettingsComponentModel.SystemRefreshTokenExpirationInSeconds = core.StringPtr("259200") + + // Construct an instance of the CreateAccountSettingsTemplateVersionOptions model + createAccountSettingsTemplateVersionOptionsModel := new(iamidentityv1.CreateAccountSettingsTemplateVersionOptions) + createAccountSettingsTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + createAccountSettingsTemplateVersionOptionsModel.AccountID = core.StringPtr("testString") + createAccountSettingsTemplateVersionOptionsModel.Name = core.StringPtr("testString") + createAccountSettingsTemplateVersionOptionsModel.Description = core.StringPtr("testString") + createAccountSettingsTemplateVersionOptionsModel.AccountSettings = accountSettingsComponentModel + createAccountSettingsTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamIdentityService.CreateAccountSettingsTemplateVersion(createAccountSettingsTemplateVersionOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetAccountSettingsTemplateVersion(getAccountSettingsTemplateVersionOptions *GetAccountSettingsTemplateVersionOptions) - Operation response error`, func() { + getAccountSettingsTemplateVersionPath := "/v1/account_settings_templates/testString/versions/testString" + Context(`Using mock server endpoint with invalid JSON response`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getAccountSettingsTemplateVersionPath)) + Expect(req.Method).To(Equal("GET")) + // TODO: Add check for include_history query parameter + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke GetAccountSettingsTemplateVersion with error: Operation response processing error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the GetAccountSettingsTemplateVersionOptions model + getAccountSettingsTemplateVersionOptionsModel := new(iamidentityv1.GetAccountSettingsTemplateVersionOptions) + getAccountSettingsTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + getAccountSettingsTemplateVersionOptionsModel.Version = core.StringPtr("testString") + getAccountSettingsTemplateVersionOptionsModel.IncludeHistory = core.BoolPtr(false) + getAccountSettingsTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := iamIdentityService.GetAccountSettingsTemplateVersion(getAccountSettingsTemplateVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + iamIdentityService.EnableRetries(0, 0) + result, response, operationErr = iamIdentityService.GetAccountSettingsTemplateVersion(getAccountSettingsTemplateVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetAccountSettingsTemplateVersion(getAccountSettingsTemplateVersionOptions *GetAccountSettingsTemplateVersionOptions)`, func() { + getAccountSettingsTemplateVersionPath := "/v1/account_settings_templates/testString/versions/testString" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getAccountSettingsTemplateVersionPath)) + Expect(req.Method).To(Equal("GET")) + + // TODO: Add check for include_history query parameter + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"id": "ID", "version": 7, "account_id": "AccountID", "name": "Name", "description": "Description", "committed": false, "account_settings": {"restrict_create_service_id": "NOT_SET", "restrict_create_platform_apikey": "NOT_SET", "allowed_ip_addresses": "AllowedIPAddresses", "mfa": "NONE", "user_mfa": [{"iam_id": "IamID", "mfa": "NONE"}], "session_expiration_in_seconds": "86400", "session_invalidation_in_seconds": "7200", "max_sessions_per_identity": "MaxSessionsPerIdentity", "system_access_token_expiration_in_seconds": "3600", "system_refresh_token_expiration_in_seconds": "259200"}, "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "entity_tag": "EntityTag", "crn": "CRN", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID"}`) + })) + }) + It(`Invoke GetAccountSettingsTemplateVersion successfully with retries`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + iamIdentityService.EnableRetries(0, 0) + + // Construct an instance of the GetAccountSettingsTemplateVersionOptions model + getAccountSettingsTemplateVersionOptionsModel := new(iamidentityv1.GetAccountSettingsTemplateVersionOptions) + getAccountSettingsTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + getAccountSettingsTemplateVersionOptionsModel.Version = core.StringPtr("testString") + getAccountSettingsTemplateVersionOptionsModel.IncludeHistory = core.BoolPtr(false) + getAccountSettingsTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := iamIdentityService.GetAccountSettingsTemplateVersionWithContext(ctx, getAccountSettingsTemplateVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + iamIdentityService.DisableRetries() + result, response, operationErr := iamIdentityService.GetAccountSettingsTemplateVersion(getAccountSettingsTemplateVersionOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = iamIdentityService.GetAccountSettingsTemplateVersionWithContext(ctx, getAccountSettingsTemplateVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getAccountSettingsTemplateVersionPath)) + Expect(req.Method).To(Equal("GET")) + + // TODO: Add check for include_history query parameter + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"id": "ID", "version": 7, "account_id": "AccountID", "name": "Name", "description": "Description", "committed": false, "account_settings": {"restrict_create_service_id": "NOT_SET", "restrict_create_platform_apikey": "NOT_SET", "allowed_ip_addresses": "AllowedIPAddresses", "mfa": "NONE", "user_mfa": [{"iam_id": "IamID", "mfa": "NONE"}], "session_expiration_in_seconds": "86400", "session_invalidation_in_seconds": "7200", "max_sessions_per_identity": "MaxSessionsPerIdentity", "system_access_token_expiration_in_seconds": "3600", "system_refresh_token_expiration_in_seconds": "259200"}, "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "entity_tag": "EntityTag", "crn": "CRN", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID"}`) + })) + }) + It(`Invoke GetAccountSettingsTemplateVersion successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := iamIdentityService.GetAccountSettingsTemplateVersion(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the GetAccountSettingsTemplateVersionOptions model + getAccountSettingsTemplateVersionOptionsModel := new(iamidentityv1.GetAccountSettingsTemplateVersionOptions) + getAccountSettingsTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + getAccountSettingsTemplateVersionOptionsModel.Version = core.StringPtr("testString") + getAccountSettingsTemplateVersionOptionsModel.IncludeHistory = core.BoolPtr(false) + getAccountSettingsTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = iamIdentityService.GetAccountSettingsTemplateVersion(getAccountSettingsTemplateVersionOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke GetAccountSettingsTemplateVersion with error: Operation validation and request error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the GetAccountSettingsTemplateVersionOptions model + getAccountSettingsTemplateVersionOptionsModel := new(iamidentityv1.GetAccountSettingsTemplateVersionOptions) + getAccountSettingsTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + getAccountSettingsTemplateVersionOptionsModel.Version = core.StringPtr("testString") + getAccountSettingsTemplateVersionOptionsModel.IncludeHistory = core.BoolPtr(false) + getAccountSettingsTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := iamIdentityService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := iamIdentityService.GetAccountSettingsTemplateVersion(getAccountSettingsTemplateVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + // Construct a second instance of the GetAccountSettingsTemplateVersionOptions model with no property values + getAccountSettingsTemplateVersionOptionsModelNew := new(iamidentityv1.GetAccountSettingsTemplateVersionOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = iamIdentityService.GetAccountSettingsTemplateVersion(getAccountSettingsTemplateVersionOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(200) + })) + }) + It(`Invoke GetAccountSettingsTemplateVersion successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the GetAccountSettingsTemplateVersionOptions model + getAccountSettingsTemplateVersionOptionsModel := new(iamidentityv1.GetAccountSettingsTemplateVersionOptions) + getAccountSettingsTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + getAccountSettingsTemplateVersionOptionsModel.Version = core.StringPtr("testString") + getAccountSettingsTemplateVersionOptionsModel.IncludeHistory = core.BoolPtr(false) + getAccountSettingsTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamIdentityService.GetAccountSettingsTemplateVersion(getAccountSettingsTemplateVersionOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`UpdateAccountSettingsTemplateVersion(updateAccountSettingsTemplateVersionOptions *UpdateAccountSettingsTemplateVersionOptions) - Operation response error`, func() { + updateAccountSettingsTemplateVersionPath := "/v1/account_settings_templates/testString/versions/testString" + Context(`Using mock server endpoint with invalid JSON response`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(updateAccountSettingsTemplateVersionPath)) + Expect(req.Method).To(Equal("PUT")) + Expect(req.Header["If-Match"]).ToNot(BeNil()) + Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke UpdateAccountSettingsTemplateVersion with error: Operation response processing error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the AccountSettingsUserMfa model + accountSettingsUserMfaModel := new(iamidentityv1.AccountSettingsUserMfa) + accountSettingsUserMfaModel.IamID = core.StringPtr("testString") + accountSettingsUserMfaModel.Mfa = core.StringPtr("NONE") + + // Construct an instance of the AccountSettingsComponent model + accountSettingsComponentModel := new(iamidentityv1.AccountSettingsComponent) + accountSettingsComponentModel.RestrictCreateServiceID = core.StringPtr("NOT_SET") + accountSettingsComponentModel.RestrictCreatePlatformApikey = core.StringPtr("NOT_SET") + accountSettingsComponentModel.AllowedIPAddresses = core.StringPtr("testString") + accountSettingsComponentModel.Mfa = core.StringPtr("NONE") + accountSettingsComponentModel.UserMfa = []iamidentityv1.AccountSettingsUserMfa{*accountSettingsUserMfaModel} + accountSettingsComponentModel.SessionExpirationInSeconds = core.StringPtr("86400") + accountSettingsComponentModel.SessionInvalidationInSeconds = core.StringPtr("7200") + accountSettingsComponentModel.MaxSessionsPerIdentity = core.StringPtr("testString") + accountSettingsComponentModel.SystemAccessTokenExpirationInSeconds = core.StringPtr("3600") + accountSettingsComponentModel.SystemRefreshTokenExpirationInSeconds = core.StringPtr("259200") + + // Construct an instance of the UpdateAccountSettingsTemplateVersionOptions model + updateAccountSettingsTemplateVersionOptionsModel := new(iamidentityv1.UpdateAccountSettingsTemplateVersionOptions) + updateAccountSettingsTemplateVersionOptionsModel.IfMatch = core.StringPtr("testString") + updateAccountSettingsTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + updateAccountSettingsTemplateVersionOptionsModel.Version = core.StringPtr("testString") + updateAccountSettingsTemplateVersionOptionsModel.AccountID = core.StringPtr("testString") + updateAccountSettingsTemplateVersionOptionsModel.Name = core.StringPtr("testString") + updateAccountSettingsTemplateVersionOptionsModel.Description = core.StringPtr("testString") + updateAccountSettingsTemplateVersionOptionsModel.AccountSettings = accountSettingsComponentModel + updateAccountSettingsTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := iamIdentityService.UpdateAccountSettingsTemplateVersion(updateAccountSettingsTemplateVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + iamIdentityService.EnableRetries(0, 0) + result, response, operationErr = iamIdentityService.UpdateAccountSettingsTemplateVersion(updateAccountSettingsTemplateVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`UpdateAccountSettingsTemplateVersion(updateAccountSettingsTemplateVersionOptions *UpdateAccountSettingsTemplateVersionOptions)`, func() { + updateAccountSettingsTemplateVersionPath := "/v1/account_settings_templates/testString/versions/testString" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(updateAccountSettingsTemplateVersionPath)) + Expect(req.Method).To(Equal("PUT")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + + Expect(req.Header["If-Match"]).ToNot(BeNil()) + Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"id": "ID", "version": 7, "account_id": "AccountID", "name": "Name", "description": "Description", "committed": false, "account_settings": {"restrict_create_service_id": "NOT_SET", "restrict_create_platform_apikey": "NOT_SET", "allowed_ip_addresses": "AllowedIPAddresses", "mfa": "NONE", "user_mfa": [{"iam_id": "IamID", "mfa": "NONE"}], "session_expiration_in_seconds": "86400", "session_invalidation_in_seconds": "7200", "max_sessions_per_identity": "MaxSessionsPerIdentity", "system_access_token_expiration_in_seconds": "3600", "system_refresh_token_expiration_in_seconds": "259200"}, "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "entity_tag": "EntityTag", "crn": "CRN", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID"}`) + })) + }) + It(`Invoke UpdateAccountSettingsTemplateVersion successfully with retries`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + iamIdentityService.EnableRetries(0, 0) + + // Construct an instance of the AccountSettingsUserMfa model + accountSettingsUserMfaModel := new(iamidentityv1.AccountSettingsUserMfa) + accountSettingsUserMfaModel.IamID = core.StringPtr("testString") + accountSettingsUserMfaModel.Mfa = core.StringPtr("NONE") + + // Construct an instance of the AccountSettingsComponent model + accountSettingsComponentModel := new(iamidentityv1.AccountSettingsComponent) + accountSettingsComponentModel.RestrictCreateServiceID = core.StringPtr("NOT_SET") + accountSettingsComponentModel.RestrictCreatePlatformApikey = core.StringPtr("NOT_SET") + accountSettingsComponentModel.AllowedIPAddresses = core.StringPtr("testString") + accountSettingsComponentModel.Mfa = core.StringPtr("NONE") + accountSettingsComponentModel.UserMfa = []iamidentityv1.AccountSettingsUserMfa{*accountSettingsUserMfaModel} + accountSettingsComponentModel.SessionExpirationInSeconds = core.StringPtr("86400") + accountSettingsComponentModel.SessionInvalidationInSeconds = core.StringPtr("7200") + accountSettingsComponentModel.MaxSessionsPerIdentity = core.StringPtr("testString") + accountSettingsComponentModel.SystemAccessTokenExpirationInSeconds = core.StringPtr("3600") + accountSettingsComponentModel.SystemRefreshTokenExpirationInSeconds = core.StringPtr("259200") + + // Construct an instance of the UpdateAccountSettingsTemplateVersionOptions model + updateAccountSettingsTemplateVersionOptionsModel := new(iamidentityv1.UpdateAccountSettingsTemplateVersionOptions) + updateAccountSettingsTemplateVersionOptionsModel.IfMatch = core.StringPtr("testString") + updateAccountSettingsTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + updateAccountSettingsTemplateVersionOptionsModel.Version = core.StringPtr("testString") + updateAccountSettingsTemplateVersionOptionsModel.AccountID = core.StringPtr("testString") + updateAccountSettingsTemplateVersionOptionsModel.Name = core.StringPtr("testString") + updateAccountSettingsTemplateVersionOptionsModel.Description = core.StringPtr("testString") + updateAccountSettingsTemplateVersionOptionsModel.AccountSettings = accountSettingsComponentModel + updateAccountSettingsTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := iamIdentityService.UpdateAccountSettingsTemplateVersionWithContext(ctx, updateAccountSettingsTemplateVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + iamIdentityService.DisableRetries() + result, response, operationErr := iamIdentityService.UpdateAccountSettingsTemplateVersion(updateAccountSettingsTemplateVersionOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = iamIdentityService.UpdateAccountSettingsTemplateVersionWithContext(ctx, updateAccountSettingsTemplateVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(updateAccountSettingsTemplateVersionPath)) + Expect(req.Method).To(Equal("PUT")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + + Expect(req.Header["If-Match"]).ToNot(BeNil()) + Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"id": "ID", "version": 7, "account_id": "AccountID", "name": "Name", "description": "Description", "committed": false, "account_settings": {"restrict_create_service_id": "NOT_SET", "restrict_create_platform_apikey": "NOT_SET", "allowed_ip_addresses": "AllowedIPAddresses", "mfa": "NONE", "user_mfa": [{"iam_id": "IamID", "mfa": "NONE"}], "session_expiration_in_seconds": "86400", "session_invalidation_in_seconds": "7200", "max_sessions_per_identity": "MaxSessionsPerIdentity", "system_access_token_expiration_in_seconds": "3600", "system_refresh_token_expiration_in_seconds": "259200"}, "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "entity_tag": "EntityTag", "crn": "CRN", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID"}`) + })) + }) + It(`Invoke UpdateAccountSettingsTemplateVersion successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := iamIdentityService.UpdateAccountSettingsTemplateVersion(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the AccountSettingsUserMfa model + accountSettingsUserMfaModel := new(iamidentityv1.AccountSettingsUserMfa) + accountSettingsUserMfaModel.IamID = core.StringPtr("testString") + accountSettingsUserMfaModel.Mfa = core.StringPtr("NONE") + + // Construct an instance of the AccountSettingsComponent model + accountSettingsComponentModel := new(iamidentityv1.AccountSettingsComponent) + accountSettingsComponentModel.RestrictCreateServiceID = core.StringPtr("NOT_SET") + accountSettingsComponentModel.RestrictCreatePlatformApikey = core.StringPtr("NOT_SET") + accountSettingsComponentModel.AllowedIPAddresses = core.StringPtr("testString") + accountSettingsComponentModel.Mfa = core.StringPtr("NONE") + accountSettingsComponentModel.UserMfa = []iamidentityv1.AccountSettingsUserMfa{*accountSettingsUserMfaModel} + accountSettingsComponentModel.SessionExpirationInSeconds = core.StringPtr("86400") + accountSettingsComponentModel.SessionInvalidationInSeconds = core.StringPtr("7200") + accountSettingsComponentModel.MaxSessionsPerIdentity = core.StringPtr("testString") + accountSettingsComponentModel.SystemAccessTokenExpirationInSeconds = core.StringPtr("3600") + accountSettingsComponentModel.SystemRefreshTokenExpirationInSeconds = core.StringPtr("259200") + + // Construct an instance of the UpdateAccountSettingsTemplateVersionOptions model + updateAccountSettingsTemplateVersionOptionsModel := new(iamidentityv1.UpdateAccountSettingsTemplateVersionOptions) + updateAccountSettingsTemplateVersionOptionsModel.IfMatch = core.StringPtr("testString") + updateAccountSettingsTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + updateAccountSettingsTemplateVersionOptionsModel.Version = core.StringPtr("testString") + updateAccountSettingsTemplateVersionOptionsModel.AccountID = core.StringPtr("testString") + updateAccountSettingsTemplateVersionOptionsModel.Name = core.StringPtr("testString") + updateAccountSettingsTemplateVersionOptionsModel.Description = core.StringPtr("testString") + updateAccountSettingsTemplateVersionOptionsModel.AccountSettings = accountSettingsComponentModel + updateAccountSettingsTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = iamIdentityService.UpdateAccountSettingsTemplateVersion(updateAccountSettingsTemplateVersionOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke UpdateAccountSettingsTemplateVersion with error: Operation validation and request error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the AccountSettingsUserMfa model + accountSettingsUserMfaModel := new(iamidentityv1.AccountSettingsUserMfa) + accountSettingsUserMfaModel.IamID = core.StringPtr("testString") + accountSettingsUserMfaModel.Mfa = core.StringPtr("NONE") + + // Construct an instance of the AccountSettingsComponent model + accountSettingsComponentModel := new(iamidentityv1.AccountSettingsComponent) + accountSettingsComponentModel.RestrictCreateServiceID = core.StringPtr("NOT_SET") + accountSettingsComponentModel.RestrictCreatePlatformApikey = core.StringPtr("NOT_SET") + accountSettingsComponentModel.AllowedIPAddresses = core.StringPtr("testString") + accountSettingsComponentModel.Mfa = core.StringPtr("NONE") + accountSettingsComponentModel.UserMfa = []iamidentityv1.AccountSettingsUserMfa{*accountSettingsUserMfaModel} + accountSettingsComponentModel.SessionExpirationInSeconds = core.StringPtr("86400") + accountSettingsComponentModel.SessionInvalidationInSeconds = core.StringPtr("7200") + accountSettingsComponentModel.MaxSessionsPerIdentity = core.StringPtr("testString") + accountSettingsComponentModel.SystemAccessTokenExpirationInSeconds = core.StringPtr("3600") + accountSettingsComponentModel.SystemRefreshTokenExpirationInSeconds = core.StringPtr("259200") + + // Construct an instance of the UpdateAccountSettingsTemplateVersionOptions model + updateAccountSettingsTemplateVersionOptionsModel := new(iamidentityv1.UpdateAccountSettingsTemplateVersionOptions) + updateAccountSettingsTemplateVersionOptionsModel.IfMatch = core.StringPtr("testString") + updateAccountSettingsTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + updateAccountSettingsTemplateVersionOptionsModel.Version = core.StringPtr("testString") + updateAccountSettingsTemplateVersionOptionsModel.AccountID = core.StringPtr("testString") + updateAccountSettingsTemplateVersionOptionsModel.Name = core.StringPtr("testString") + updateAccountSettingsTemplateVersionOptionsModel.Description = core.StringPtr("testString") + updateAccountSettingsTemplateVersionOptionsModel.AccountSettings = accountSettingsComponentModel + updateAccountSettingsTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := iamIdentityService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := iamIdentityService.UpdateAccountSettingsTemplateVersion(updateAccountSettingsTemplateVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + // Construct a second instance of the UpdateAccountSettingsTemplateVersionOptions model with no property values + updateAccountSettingsTemplateVersionOptionsModelNew := new(iamidentityv1.UpdateAccountSettingsTemplateVersionOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = iamIdentityService.UpdateAccountSettingsTemplateVersion(updateAccountSettingsTemplateVersionOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(200) + })) + }) + It(`Invoke UpdateAccountSettingsTemplateVersion successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the AccountSettingsUserMfa model + accountSettingsUserMfaModel := new(iamidentityv1.AccountSettingsUserMfa) + accountSettingsUserMfaModel.IamID = core.StringPtr("testString") + accountSettingsUserMfaModel.Mfa = core.StringPtr("NONE") + + // Construct an instance of the AccountSettingsComponent model + accountSettingsComponentModel := new(iamidentityv1.AccountSettingsComponent) + accountSettingsComponentModel.RestrictCreateServiceID = core.StringPtr("NOT_SET") + accountSettingsComponentModel.RestrictCreatePlatformApikey = core.StringPtr("NOT_SET") + accountSettingsComponentModel.AllowedIPAddresses = core.StringPtr("testString") + accountSettingsComponentModel.Mfa = core.StringPtr("NONE") + accountSettingsComponentModel.UserMfa = []iamidentityv1.AccountSettingsUserMfa{*accountSettingsUserMfaModel} + accountSettingsComponentModel.SessionExpirationInSeconds = core.StringPtr("86400") + accountSettingsComponentModel.SessionInvalidationInSeconds = core.StringPtr("7200") + accountSettingsComponentModel.MaxSessionsPerIdentity = core.StringPtr("testString") + accountSettingsComponentModel.SystemAccessTokenExpirationInSeconds = core.StringPtr("3600") + accountSettingsComponentModel.SystemRefreshTokenExpirationInSeconds = core.StringPtr("259200") + + // Construct an instance of the UpdateAccountSettingsTemplateVersionOptions model + updateAccountSettingsTemplateVersionOptionsModel := new(iamidentityv1.UpdateAccountSettingsTemplateVersionOptions) + updateAccountSettingsTemplateVersionOptionsModel.IfMatch = core.StringPtr("testString") + updateAccountSettingsTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + updateAccountSettingsTemplateVersionOptionsModel.Version = core.StringPtr("testString") + updateAccountSettingsTemplateVersionOptionsModel.AccountID = core.StringPtr("testString") + updateAccountSettingsTemplateVersionOptionsModel.Name = core.StringPtr("testString") + updateAccountSettingsTemplateVersionOptionsModel.Description = core.StringPtr("testString") + updateAccountSettingsTemplateVersionOptionsModel.AccountSettings = accountSettingsComponentModel + updateAccountSettingsTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamIdentityService.UpdateAccountSettingsTemplateVersion(updateAccountSettingsTemplateVersionOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`DeleteAccountSettingsTemplateVersion(deleteAccountSettingsTemplateVersionOptions *DeleteAccountSettingsTemplateVersionOptions)`, func() { + deleteAccountSettingsTemplateVersionPath := "/v1/account_settings_templates/testString/versions/testString" + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(deleteAccountSettingsTemplateVersionPath)) + Expect(req.Method).To(Equal("DELETE")) + + res.WriteHeader(204) + })) + }) + It(`Invoke DeleteAccountSettingsTemplateVersion successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + response, operationErr := iamIdentityService.DeleteAccountSettingsTemplateVersion(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + + // Construct an instance of the DeleteAccountSettingsTemplateVersionOptions model + deleteAccountSettingsTemplateVersionOptionsModel := new(iamidentityv1.DeleteAccountSettingsTemplateVersionOptions) + deleteAccountSettingsTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + deleteAccountSettingsTemplateVersionOptionsModel.Version = core.StringPtr("testString") + deleteAccountSettingsTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + response, operationErr = iamIdentityService.DeleteAccountSettingsTemplateVersion(deleteAccountSettingsTemplateVersionOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + }) + It(`Invoke DeleteAccountSettingsTemplateVersion with error: Operation validation and request error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the DeleteAccountSettingsTemplateVersionOptions model + deleteAccountSettingsTemplateVersionOptionsModel := new(iamidentityv1.DeleteAccountSettingsTemplateVersionOptions) + deleteAccountSettingsTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + deleteAccountSettingsTemplateVersionOptionsModel.Version = core.StringPtr("testString") + deleteAccountSettingsTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := iamIdentityService.SetServiceURL("") + Expect(err).To(BeNil()) + response, operationErr := iamIdentityService.DeleteAccountSettingsTemplateVersion(deleteAccountSettingsTemplateVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + // Construct a second instance of the DeleteAccountSettingsTemplateVersionOptions model with no property values + deleteAccountSettingsTemplateVersionOptionsModelNew := new(iamidentityv1.DeleteAccountSettingsTemplateVersionOptions) + // Invoke operation with invalid model (negative test) + response, operationErr = iamIdentityService.DeleteAccountSettingsTemplateVersion(deleteAccountSettingsTemplateVersionOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`CommitAccountSettingsTemplate(commitAccountSettingsTemplateOptions *CommitAccountSettingsTemplateOptions)`, func() { + commitAccountSettingsTemplatePath := "/v1/account_settings_templates/testString/versions/testString/commit" + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(commitAccountSettingsTemplatePath)) + Expect(req.Method).To(Equal("POST")) + + res.WriteHeader(204) + })) + }) + It(`Invoke CommitAccountSettingsTemplate successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + response, operationErr := iamIdentityService.CommitAccountSettingsTemplate(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + + // Construct an instance of the CommitAccountSettingsTemplateOptions model + commitAccountSettingsTemplateOptionsModel := new(iamidentityv1.CommitAccountSettingsTemplateOptions) + commitAccountSettingsTemplateOptionsModel.TemplateID = core.StringPtr("testString") + commitAccountSettingsTemplateOptionsModel.Version = core.StringPtr("testString") + commitAccountSettingsTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + response, operationErr = iamIdentityService.CommitAccountSettingsTemplate(commitAccountSettingsTemplateOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + }) + It(`Invoke CommitAccountSettingsTemplate with error: Operation validation and request error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the CommitAccountSettingsTemplateOptions model + commitAccountSettingsTemplateOptionsModel := new(iamidentityv1.CommitAccountSettingsTemplateOptions) + commitAccountSettingsTemplateOptionsModel.TemplateID = core.StringPtr("testString") + commitAccountSettingsTemplateOptionsModel.Version = core.StringPtr("testString") + commitAccountSettingsTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := iamIdentityService.SetServiceURL("") + Expect(err).To(BeNil()) + response, operationErr := iamIdentityService.CommitAccountSettingsTemplate(commitAccountSettingsTemplateOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + // Construct a second instance of the CommitAccountSettingsTemplateOptions model with no property values + commitAccountSettingsTemplateOptionsModelNew := new(iamidentityv1.CommitAccountSettingsTemplateOptions) + // Invoke operation with invalid model (negative test) + response, operationErr = iamIdentityService.CommitAccountSettingsTemplate(commitAccountSettingsTemplateOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) Describe(`CreateReport(createReportOptions *CreateReportOptions) - Operation response error`, func() { createReportPath := "/v1/activity/accounts/testString/report" Context(`Using mock server endpoint with invalid JSON response`, func() { @@ -8325,16 +11765,3335 @@ var _ = Describe(`IamIdentityV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createReportPath)) - Expect(req.Method).To(Equal("POST")) - Expect(req.URL.Query()["type"]).To(Equal([]string{"inactive"})) - Expect(req.URL.Query()["duration"]).To(Equal([]string{"720"})) + Expect(req.URL.EscapedPath()).To(Equal(createReportPath)) + Expect(req.Method).To(Equal("POST")) + Expect(req.URL.Query()["type"]).To(Equal([]string{"inactive"})) + Expect(req.URL.Query()["duration"]).To(Equal([]string{"720"})) + res.Header().Set("Content-type", "application/json") + res.WriteHeader(202) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke CreateReport with error: Operation response processing error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the CreateReportOptions model + createReportOptionsModel := new(iamidentityv1.CreateReportOptions) + createReportOptionsModel.AccountID = core.StringPtr("testString") + createReportOptionsModel.Type = core.StringPtr("inactive") + createReportOptionsModel.Duration = core.StringPtr("720") + createReportOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := iamIdentityService.CreateReport(createReportOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + iamIdentityService.EnableRetries(0, 0) + result, response, operationErr = iamIdentityService.CreateReport(createReportOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`CreateReport(createReportOptions *CreateReportOptions)`, func() { + createReportPath := "/v1/activity/accounts/testString/report" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(createReportPath)) + Expect(req.Method).To(Equal("POST")) + + Expect(req.URL.Query()["type"]).To(Equal([]string{"inactive"})) + Expect(req.URL.Query()["duration"]).To(Equal([]string{"720"})) + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(202) + fmt.Fprintf(res, "%s", `{"reference": "Reference"}`) + })) + }) + It(`Invoke CreateReport successfully with retries`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + iamIdentityService.EnableRetries(0, 0) + + // Construct an instance of the CreateReportOptions model + createReportOptionsModel := new(iamidentityv1.CreateReportOptions) + createReportOptionsModel.AccountID = core.StringPtr("testString") + createReportOptionsModel.Type = core.StringPtr("inactive") + createReportOptionsModel.Duration = core.StringPtr("720") + createReportOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := iamIdentityService.CreateReportWithContext(ctx, createReportOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + iamIdentityService.DisableRetries() + result, response, operationErr := iamIdentityService.CreateReport(createReportOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = iamIdentityService.CreateReportWithContext(ctx, createReportOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(createReportPath)) + Expect(req.Method).To(Equal("POST")) + + Expect(req.URL.Query()["type"]).To(Equal([]string{"inactive"})) + Expect(req.URL.Query()["duration"]).To(Equal([]string{"720"})) + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(202) + fmt.Fprintf(res, "%s", `{"reference": "Reference"}`) + })) + }) + It(`Invoke CreateReport successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := iamIdentityService.CreateReport(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the CreateReportOptions model + createReportOptionsModel := new(iamidentityv1.CreateReportOptions) + createReportOptionsModel.AccountID = core.StringPtr("testString") + createReportOptionsModel.Type = core.StringPtr("inactive") + createReportOptionsModel.Duration = core.StringPtr("720") + createReportOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = iamIdentityService.CreateReport(createReportOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke CreateReport with error: Operation validation and request error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the CreateReportOptions model + createReportOptionsModel := new(iamidentityv1.CreateReportOptions) + createReportOptionsModel.AccountID = core.StringPtr("testString") + createReportOptionsModel.Type = core.StringPtr("inactive") + createReportOptionsModel.Duration = core.StringPtr("720") + createReportOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := iamIdentityService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := iamIdentityService.CreateReport(createReportOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + // Construct a second instance of the CreateReportOptions model with no property values + createReportOptionsModelNew := new(iamidentityv1.CreateReportOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = iamIdentityService.CreateReport(createReportOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(202) + })) + }) + It(`Invoke CreateReport successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the CreateReportOptions model + createReportOptionsModel := new(iamidentityv1.CreateReportOptions) + createReportOptionsModel.AccountID = core.StringPtr("testString") + createReportOptionsModel.Type = core.StringPtr("inactive") + createReportOptionsModel.Duration = core.StringPtr("720") + createReportOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamIdentityService.CreateReport(createReportOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetReport(getReportOptions *GetReportOptions) - Operation response error`, func() { + getReportPath := "/v1/activity/accounts/testString/report/testString" + Context(`Using mock server endpoint with invalid JSON response`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getReportPath)) + Expect(req.Method).To(Equal("GET")) + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke GetReport with error: Operation response processing error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the GetReportOptions model + getReportOptionsModel := new(iamidentityv1.GetReportOptions) + getReportOptionsModel.AccountID = core.StringPtr("testString") + getReportOptionsModel.Reference = core.StringPtr("testString") + getReportOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := iamIdentityService.GetReport(getReportOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + iamIdentityService.EnableRetries(0, 0) + result, response, operationErr = iamIdentityService.GetReport(getReportOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetReport(getReportOptions *GetReportOptions)`, func() { + getReportPath := "/v1/activity/accounts/testString/report/testString" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getReportPath)) + Expect(req.Method).To(Equal("GET")) + + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"created_by": "CreatedBy", "reference": "Reference", "report_duration": "ReportDuration", "report_start_time": "ReportStartTime", "report_end_time": "ReportEndTime", "users": [{"iam_id": "IamID", "name": "Name", "username": "Username", "email": "Email", "last_authn": "LastAuthn"}], "apikeys": [{"id": "ID", "name": "Name", "type": "Type", "serviceid": {"id": "ID", "name": "Name"}, "user": {"iam_id": "IamID", "name": "Name", "username": "Username", "email": "Email"}, "last_authn": "LastAuthn"}], "serviceids": [{"id": "ID", "name": "Name", "last_authn": "LastAuthn"}], "profiles": [{"id": "ID", "name": "Name", "last_authn": "LastAuthn"}]}`) + })) + }) + It(`Invoke GetReport successfully with retries`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + iamIdentityService.EnableRetries(0, 0) + + // Construct an instance of the GetReportOptions model + getReportOptionsModel := new(iamidentityv1.GetReportOptions) + getReportOptionsModel.AccountID = core.StringPtr("testString") + getReportOptionsModel.Reference = core.StringPtr("testString") + getReportOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := iamIdentityService.GetReportWithContext(ctx, getReportOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + iamIdentityService.DisableRetries() + result, response, operationErr := iamIdentityService.GetReport(getReportOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = iamIdentityService.GetReportWithContext(ctx, getReportOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getReportPath)) + Expect(req.Method).To(Equal("GET")) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"created_by": "CreatedBy", "reference": "Reference", "report_duration": "ReportDuration", "report_start_time": "ReportStartTime", "report_end_time": "ReportEndTime", "users": [{"iam_id": "IamID", "name": "Name", "username": "Username", "email": "Email", "last_authn": "LastAuthn"}], "apikeys": [{"id": "ID", "name": "Name", "type": "Type", "serviceid": {"id": "ID", "name": "Name"}, "user": {"iam_id": "IamID", "name": "Name", "username": "Username", "email": "Email"}, "last_authn": "LastAuthn"}], "serviceids": [{"id": "ID", "name": "Name", "last_authn": "LastAuthn"}], "profiles": [{"id": "ID", "name": "Name", "last_authn": "LastAuthn"}]}`) + })) + }) + It(`Invoke GetReport successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := iamIdentityService.GetReport(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the GetReportOptions model + getReportOptionsModel := new(iamidentityv1.GetReportOptions) + getReportOptionsModel.AccountID = core.StringPtr("testString") + getReportOptionsModel.Reference = core.StringPtr("testString") + getReportOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = iamIdentityService.GetReport(getReportOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke GetReport with error: Operation validation and request error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the GetReportOptions model + getReportOptionsModel := new(iamidentityv1.GetReportOptions) + getReportOptionsModel.AccountID = core.StringPtr("testString") + getReportOptionsModel.Reference = core.StringPtr("testString") + getReportOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := iamIdentityService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := iamIdentityService.GetReport(getReportOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + // Construct a second instance of the GetReportOptions model with no property values + getReportOptionsModelNew := new(iamidentityv1.GetReportOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = iamIdentityService.GetReport(getReportOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(200) + })) + }) + It(`Invoke GetReport successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the GetReportOptions model + getReportOptionsModel := new(iamidentityv1.GetReportOptions) + getReportOptionsModel.AccountID = core.StringPtr("testString") + getReportOptionsModel.Reference = core.StringPtr("testString") + getReportOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamIdentityService.GetReport(getReportOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`ListTrustedProfileAssignments(listTrustedProfileAssignmentsOptions *ListTrustedProfileAssignmentsOptions) - Operation response error`, func() { + listTrustedProfileAssignmentsPath := "/v1/profile_assignments/" + Context(`Using mock server endpoint with invalid JSON response`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listTrustedProfileAssignmentsPath)) + Expect(req.Method).To(Equal("GET")) + Expect(req.URL.Query()["account_id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["template_id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["template_version"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["target"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["target_type"]).To(Equal([]string{"Account"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(20))})) + Expect(req.URL.Query()["pagetoken"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["sort"]).To(Equal([]string{"created_at"})) + Expect(req.URL.Query()["order"]).To(Equal([]string{"asc"})) + // TODO: Add check for include_history query parameter + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke ListTrustedProfileAssignments with error: Operation response processing error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the ListTrustedProfileAssignmentsOptions model + listTrustedProfileAssignmentsOptionsModel := new(iamidentityv1.ListTrustedProfileAssignmentsOptions) + listTrustedProfileAssignmentsOptionsModel.AccountID = core.StringPtr("testString") + listTrustedProfileAssignmentsOptionsModel.TemplateID = core.StringPtr("testString") + listTrustedProfileAssignmentsOptionsModel.TemplateVersion = core.StringPtr("testString") + listTrustedProfileAssignmentsOptionsModel.Target = core.StringPtr("testString") + listTrustedProfileAssignmentsOptionsModel.TargetType = core.StringPtr("Account") + listTrustedProfileAssignmentsOptionsModel.Limit = core.Int64Ptr(int64(20)) + listTrustedProfileAssignmentsOptionsModel.Pagetoken = core.StringPtr("testString") + listTrustedProfileAssignmentsOptionsModel.Sort = core.StringPtr("created_at") + listTrustedProfileAssignmentsOptionsModel.Order = core.StringPtr("asc") + listTrustedProfileAssignmentsOptionsModel.IncludeHistory = core.BoolPtr(false) + listTrustedProfileAssignmentsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := iamIdentityService.ListTrustedProfileAssignments(listTrustedProfileAssignmentsOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + iamIdentityService.EnableRetries(0, 0) + result, response, operationErr = iamIdentityService.ListTrustedProfileAssignments(listTrustedProfileAssignmentsOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`ListTrustedProfileAssignments(listTrustedProfileAssignmentsOptions *ListTrustedProfileAssignmentsOptions)`, func() { + listTrustedProfileAssignmentsPath := "/v1/profile_assignments/" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listTrustedProfileAssignmentsPath)) + Expect(req.Method).To(Equal("GET")) + + Expect(req.URL.Query()["account_id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["template_id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["template_version"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["target"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["target_type"]).To(Equal([]string{"Account"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(20))})) + Expect(req.URL.Query()["pagetoken"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["sort"]).To(Equal([]string{"created_at"})) + Expect(req.URL.Query()["order"]).To(Equal([]string{"asc"})) + // TODO: Add check for include_history query parameter + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"context": {"transaction_id": "TransactionID", "operation": "Operation", "user_agent": "UserAgent", "url": "URL", "instance_id": "InstanceID", "thread_id": "ThreadID", "host": "Host", "start_time": "StartTime", "end_time": "EndTime", "elapsed_time": "ElapsedTime", "cluster_name": "ClusterName"}, "offset": 6, "limit": 5, "first": "First", "previous": "Previous", "next": "Next", "assignments": [{"context": {"transaction_id": "TransactionID", "operation": "Operation", "user_agent": "UserAgent", "url": "URL", "instance_id": "InstanceID", "thread_id": "ThreadID", "host": "Host", "start_time": "StartTime", "end_time": "EndTime", "elapsed_time": "ElapsedTime", "cluster_name": "ClusterName"}, "id": "ID", "account_id": "AccountID", "template_id": "TemplateID", "template_version": 15, "target_type": "TargetType", "target": "Target", "status": "Status", "resources": [{"target": "Target", "profile": {"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}, "account_settings": {"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}, "policy_template_refs": [{"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}]}], "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "href": "Href", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID", "entity_tag": "EntityTag"}]}`) + })) + }) + It(`Invoke ListTrustedProfileAssignments successfully with retries`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + iamIdentityService.EnableRetries(0, 0) + + // Construct an instance of the ListTrustedProfileAssignmentsOptions model + listTrustedProfileAssignmentsOptionsModel := new(iamidentityv1.ListTrustedProfileAssignmentsOptions) + listTrustedProfileAssignmentsOptionsModel.AccountID = core.StringPtr("testString") + listTrustedProfileAssignmentsOptionsModel.TemplateID = core.StringPtr("testString") + listTrustedProfileAssignmentsOptionsModel.TemplateVersion = core.StringPtr("testString") + listTrustedProfileAssignmentsOptionsModel.Target = core.StringPtr("testString") + listTrustedProfileAssignmentsOptionsModel.TargetType = core.StringPtr("Account") + listTrustedProfileAssignmentsOptionsModel.Limit = core.Int64Ptr(int64(20)) + listTrustedProfileAssignmentsOptionsModel.Pagetoken = core.StringPtr("testString") + listTrustedProfileAssignmentsOptionsModel.Sort = core.StringPtr("created_at") + listTrustedProfileAssignmentsOptionsModel.Order = core.StringPtr("asc") + listTrustedProfileAssignmentsOptionsModel.IncludeHistory = core.BoolPtr(false) + listTrustedProfileAssignmentsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := iamIdentityService.ListTrustedProfileAssignmentsWithContext(ctx, listTrustedProfileAssignmentsOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + iamIdentityService.DisableRetries() + result, response, operationErr := iamIdentityService.ListTrustedProfileAssignments(listTrustedProfileAssignmentsOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = iamIdentityService.ListTrustedProfileAssignmentsWithContext(ctx, listTrustedProfileAssignmentsOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listTrustedProfileAssignmentsPath)) + Expect(req.Method).To(Equal("GET")) + + Expect(req.URL.Query()["account_id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["template_id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["template_version"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["target"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["target_type"]).To(Equal([]string{"Account"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(20))})) + Expect(req.URL.Query()["pagetoken"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["sort"]).To(Equal([]string{"created_at"})) + Expect(req.URL.Query()["order"]).To(Equal([]string{"asc"})) + // TODO: Add check for include_history query parameter + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"context": {"transaction_id": "TransactionID", "operation": "Operation", "user_agent": "UserAgent", "url": "URL", "instance_id": "InstanceID", "thread_id": "ThreadID", "host": "Host", "start_time": "StartTime", "end_time": "EndTime", "elapsed_time": "ElapsedTime", "cluster_name": "ClusterName"}, "offset": 6, "limit": 5, "first": "First", "previous": "Previous", "next": "Next", "assignments": [{"context": {"transaction_id": "TransactionID", "operation": "Operation", "user_agent": "UserAgent", "url": "URL", "instance_id": "InstanceID", "thread_id": "ThreadID", "host": "Host", "start_time": "StartTime", "end_time": "EndTime", "elapsed_time": "ElapsedTime", "cluster_name": "ClusterName"}, "id": "ID", "account_id": "AccountID", "template_id": "TemplateID", "template_version": 15, "target_type": "TargetType", "target": "Target", "status": "Status", "resources": [{"target": "Target", "profile": {"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}, "account_settings": {"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}, "policy_template_refs": [{"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}]}], "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "href": "Href", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID", "entity_tag": "EntityTag"}]}`) + })) + }) + It(`Invoke ListTrustedProfileAssignments successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := iamIdentityService.ListTrustedProfileAssignments(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the ListTrustedProfileAssignmentsOptions model + listTrustedProfileAssignmentsOptionsModel := new(iamidentityv1.ListTrustedProfileAssignmentsOptions) + listTrustedProfileAssignmentsOptionsModel.AccountID = core.StringPtr("testString") + listTrustedProfileAssignmentsOptionsModel.TemplateID = core.StringPtr("testString") + listTrustedProfileAssignmentsOptionsModel.TemplateVersion = core.StringPtr("testString") + listTrustedProfileAssignmentsOptionsModel.Target = core.StringPtr("testString") + listTrustedProfileAssignmentsOptionsModel.TargetType = core.StringPtr("Account") + listTrustedProfileAssignmentsOptionsModel.Limit = core.Int64Ptr(int64(20)) + listTrustedProfileAssignmentsOptionsModel.Pagetoken = core.StringPtr("testString") + listTrustedProfileAssignmentsOptionsModel.Sort = core.StringPtr("created_at") + listTrustedProfileAssignmentsOptionsModel.Order = core.StringPtr("asc") + listTrustedProfileAssignmentsOptionsModel.IncludeHistory = core.BoolPtr(false) + listTrustedProfileAssignmentsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = iamIdentityService.ListTrustedProfileAssignments(listTrustedProfileAssignmentsOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke ListTrustedProfileAssignments with error: Operation request error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the ListTrustedProfileAssignmentsOptions model + listTrustedProfileAssignmentsOptionsModel := new(iamidentityv1.ListTrustedProfileAssignmentsOptions) + listTrustedProfileAssignmentsOptionsModel.AccountID = core.StringPtr("testString") + listTrustedProfileAssignmentsOptionsModel.TemplateID = core.StringPtr("testString") + listTrustedProfileAssignmentsOptionsModel.TemplateVersion = core.StringPtr("testString") + listTrustedProfileAssignmentsOptionsModel.Target = core.StringPtr("testString") + listTrustedProfileAssignmentsOptionsModel.TargetType = core.StringPtr("Account") + listTrustedProfileAssignmentsOptionsModel.Limit = core.Int64Ptr(int64(20)) + listTrustedProfileAssignmentsOptionsModel.Pagetoken = core.StringPtr("testString") + listTrustedProfileAssignmentsOptionsModel.Sort = core.StringPtr("created_at") + listTrustedProfileAssignmentsOptionsModel.Order = core.StringPtr("asc") + listTrustedProfileAssignmentsOptionsModel.IncludeHistory = core.BoolPtr(false) + listTrustedProfileAssignmentsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := iamIdentityService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := iamIdentityService.ListTrustedProfileAssignments(listTrustedProfileAssignmentsOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(200) + })) + }) + It(`Invoke ListTrustedProfileAssignments successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the ListTrustedProfileAssignmentsOptions model + listTrustedProfileAssignmentsOptionsModel := new(iamidentityv1.ListTrustedProfileAssignmentsOptions) + listTrustedProfileAssignmentsOptionsModel.AccountID = core.StringPtr("testString") + listTrustedProfileAssignmentsOptionsModel.TemplateID = core.StringPtr("testString") + listTrustedProfileAssignmentsOptionsModel.TemplateVersion = core.StringPtr("testString") + listTrustedProfileAssignmentsOptionsModel.Target = core.StringPtr("testString") + listTrustedProfileAssignmentsOptionsModel.TargetType = core.StringPtr("Account") + listTrustedProfileAssignmentsOptionsModel.Limit = core.Int64Ptr(int64(20)) + listTrustedProfileAssignmentsOptionsModel.Pagetoken = core.StringPtr("testString") + listTrustedProfileAssignmentsOptionsModel.Sort = core.StringPtr("created_at") + listTrustedProfileAssignmentsOptionsModel.Order = core.StringPtr("asc") + listTrustedProfileAssignmentsOptionsModel.IncludeHistory = core.BoolPtr(false) + listTrustedProfileAssignmentsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamIdentityService.ListTrustedProfileAssignments(listTrustedProfileAssignmentsOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`CreateTrustedProfileAssignment(createTrustedProfileAssignmentOptions *CreateTrustedProfileAssignmentOptions) - Operation response error`, func() { + createTrustedProfileAssignmentPath := "/v1/profile_assignments/" + Context(`Using mock server endpoint with invalid JSON response`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(createTrustedProfileAssignmentPath)) + Expect(req.Method).To(Equal("POST")) + res.Header().Set("Content-type", "application/json") + res.WriteHeader(202) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke CreateTrustedProfileAssignment with error: Operation response processing error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the CreateTrustedProfileAssignmentOptions model + createTrustedProfileAssignmentOptionsModel := new(iamidentityv1.CreateTrustedProfileAssignmentOptions) + createTrustedProfileAssignmentOptionsModel.TemplateID = core.StringPtr("testString") + createTrustedProfileAssignmentOptionsModel.TemplateVersion = core.Int64Ptr(int64(1)) + createTrustedProfileAssignmentOptionsModel.TargetType = core.StringPtr("Account") + createTrustedProfileAssignmentOptionsModel.Target = core.StringPtr("testString") + createTrustedProfileAssignmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := iamIdentityService.CreateTrustedProfileAssignment(createTrustedProfileAssignmentOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + iamIdentityService.EnableRetries(0, 0) + result, response, operationErr = iamIdentityService.CreateTrustedProfileAssignment(createTrustedProfileAssignmentOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`CreateTrustedProfileAssignment(createTrustedProfileAssignmentOptions *CreateTrustedProfileAssignmentOptions)`, func() { + createTrustedProfileAssignmentPath := "/v1/profile_assignments/" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(createTrustedProfileAssignmentPath)) + Expect(req.Method).To(Equal("POST")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(202) + fmt.Fprintf(res, "%s", `{"context": {"transaction_id": "TransactionID", "operation": "Operation", "user_agent": "UserAgent", "url": "URL", "instance_id": "InstanceID", "thread_id": "ThreadID", "host": "Host", "start_time": "StartTime", "end_time": "EndTime", "elapsed_time": "ElapsedTime", "cluster_name": "ClusterName"}, "id": "ID", "account_id": "AccountID", "template_id": "TemplateID", "template_version": 15, "target_type": "TargetType", "target": "Target", "status": "Status", "resources": [{"target": "Target", "profile": {"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}, "account_settings": {"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}, "policy_template_refs": [{"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}]}], "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "href": "Href", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID", "entity_tag": "EntityTag"}`) + })) + }) + It(`Invoke CreateTrustedProfileAssignment successfully with retries`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + iamIdentityService.EnableRetries(0, 0) + + // Construct an instance of the CreateTrustedProfileAssignmentOptions model + createTrustedProfileAssignmentOptionsModel := new(iamidentityv1.CreateTrustedProfileAssignmentOptions) + createTrustedProfileAssignmentOptionsModel.TemplateID = core.StringPtr("testString") + createTrustedProfileAssignmentOptionsModel.TemplateVersion = core.Int64Ptr(int64(1)) + createTrustedProfileAssignmentOptionsModel.TargetType = core.StringPtr("Account") + createTrustedProfileAssignmentOptionsModel.Target = core.StringPtr("testString") + createTrustedProfileAssignmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := iamIdentityService.CreateTrustedProfileAssignmentWithContext(ctx, createTrustedProfileAssignmentOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + iamIdentityService.DisableRetries() + result, response, operationErr := iamIdentityService.CreateTrustedProfileAssignment(createTrustedProfileAssignmentOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = iamIdentityService.CreateTrustedProfileAssignmentWithContext(ctx, createTrustedProfileAssignmentOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(createTrustedProfileAssignmentPath)) + Expect(req.Method).To(Equal("POST")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(202) + fmt.Fprintf(res, "%s", `{"context": {"transaction_id": "TransactionID", "operation": "Operation", "user_agent": "UserAgent", "url": "URL", "instance_id": "InstanceID", "thread_id": "ThreadID", "host": "Host", "start_time": "StartTime", "end_time": "EndTime", "elapsed_time": "ElapsedTime", "cluster_name": "ClusterName"}, "id": "ID", "account_id": "AccountID", "template_id": "TemplateID", "template_version": 15, "target_type": "TargetType", "target": "Target", "status": "Status", "resources": [{"target": "Target", "profile": {"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}, "account_settings": {"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}, "policy_template_refs": [{"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}]}], "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "href": "Href", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID", "entity_tag": "EntityTag"}`) + })) + }) + It(`Invoke CreateTrustedProfileAssignment successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := iamIdentityService.CreateTrustedProfileAssignment(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the CreateTrustedProfileAssignmentOptions model + createTrustedProfileAssignmentOptionsModel := new(iamidentityv1.CreateTrustedProfileAssignmentOptions) + createTrustedProfileAssignmentOptionsModel.TemplateID = core.StringPtr("testString") + createTrustedProfileAssignmentOptionsModel.TemplateVersion = core.Int64Ptr(int64(1)) + createTrustedProfileAssignmentOptionsModel.TargetType = core.StringPtr("Account") + createTrustedProfileAssignmentOptionsModel.Target = core.StringPtr("testString") + createTrustedProfileAssignmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = iamIdentityService.CreateTrustedProfileAssignment(createTrustedProfileAssignmentOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke CreateTrustedProfileAssignment with error: Operation validation and request error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the CreateTrustedProfileAssignmentOptions model + createTrustedProfileAssignmentOptionsModel := new(iamidentityv1.CreateTrustedProfileAssignmentOptions) + createTrustedProfileAssignmentOptionsModel.TemplateID = core.StringPtr("testString") + createTrustedProfileAssignmentOptionsModel.TemplateVersion = core.Int64Ptr(int64(1)) + createTrustedProfileAssignmentOptionsModel.TargetType = core.StringPtr("Account") + createTrustedProfileAssignmentOptionsModel.Target = core.StringPtr("testString") + createTrustedProfileAssignmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := iamIdentityService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := iamIdentityService.CreateTrustedProfileAssignment(createTrustedProfileAssignmentOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + // Construct a second instance of the CreateTrustedProfileAssignmentOptions model with no property values + createTrustedProfileAssignmentOptionsModelNew := new(iamidentityv1.CreateTrustedProfileAssignmentOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = iamIdentityService.CreateTrustedProfileAssignment(createTrustedProfileAssignmentOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(202) + })) + }) + It(`Invoke CreateTrustedProfileAssignment successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the CreateTrustedProfileAssignmentOptions model + createTrustedProfileAssignmentOptionsModel := new(iamidentityv1.CreateTrustedProfileAssignmentOptions) + createTrustedProfileAssignmentOptionsModel.TemplateID = core.StringPtr("testString") + createTrustedProfileAssignmentOptionsModel.TemplateVersion = core.Int64Ptr(int64(1)) + createTrustedProfileAssignmentOptionsModel.TargetType = core.StringPtr("Account") + createTrustedProfileAssignmentOptionsModel.Target = core.StringPtr("testString") + createTrustedProfileAssignmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamIdentityService.CreateTrustedProfileAssignment(createTrustedProfileAssignmentOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetTrustedProfileAssignment(getTrustedProfileAssignmentOptions *GetTrustedProfileAssignmentOptions) - Operation response error`, func() { + getTrustedProfileAssignmentPath := "/v1/profile_assignments/testString" + Context(`Using mock server endpoint with invalid JSON response`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getTrustedProfileAssignmentPath)) + Expect(req.Method).To(Equal("GET")) + // TODO: Add check for include_history query parameter + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke GetTrustedProfileAssignment with error: Operation response processing error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the GetTrustedProfileAssignmentOptions model + getTrustedProfileAssignmentOptionsModel := new(iamidentityv1.GetTrustedProfileAssignmentOptions) + getTrustedProfileAssignmentOptionsModel.AssignmentID = core.StringPtr("testString") + getTrustedProfileAssignmentOptionsModel.IncludeHistory = core.BoolPtr(false) + getTrustedProfileAssignmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := iamIdentityService.GetTrustedProfileAssignment(getTrustedProfileAssignmentOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + iamIdentityService.EnableRetries(0, 0) + result, response, operationErr = iamIdentityService.GetTrustedProfileAssignment(getTrustedProfileAssignmentOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetTrustedProfileAssignment(getTrustedProfileAssignmentOptions *GetTrustedProfileAssignmentOptions)`, func() { + getTrustedProfileAssignmentPath := "/v1/profile_assignments/testString" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getTrustedProfileAssignmentPath)) + Expect(req.Method).To(Equal("GET")) + + // TODO: Add check for include_history query parameter + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"context": {"transaction_id": "TransactionID", "operation": "Operation", "user_agent": "UserAgent", "url": "URL", "instance_id": "InstanceID", "thread_id": "ThreadID", "host": "Host", "start_time": "StartTime", "end_time": "EndTime", "elapsed_time": "ElapsedTime", "cluster_name": "ClusterName"}, "id": "ID", "account_id": "AccountID", "template_id": "TemplateID", "template_version": 15, "target_type": "TargetType", "target": "Target", "status": "Status", "resources": [{"target": "Target", "profile": {"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}, "account_settings": {"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}, "policy_template_refs": [{"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}]}], "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "href": "Href", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID", "entity_tag": "EntityTag"}`) + })) + }) + It(`Invoke GetTrustedProfileAssignment successfully with retries`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + iamIdentityService.EnableRetries(0, 0) + + // Construct an instance of the GetTrustedProfileAssignmentOptions model + getTrustedProfileAssignmentOptionsModel := new(iamidentityv1.GetTrustedProfileAssignmentOptions) + getTrustedProfileAssignmentOptionsModel.AssignmentID = core.StringPtr("testString") + getTrustedProfileAssignmentOptionsModel.IncludeHistory = core.BoolPtr(false) + getTrustedProfileAssignmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := iamIdentityService.GetTrustedProfileAssignmentWithContext(ctx, getTrustedProfileAssignmentOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + iamIdentityService.DisableRetries() + result, response, operationErr := iamIdentityService.GetTrustedProfileAssignment(getTrustedProfileAssignmentOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = iamIdentityService.GetTrustedProfileAssignmentWithContext(ctx, getTrustedProfileAssignmentOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getTrustedProfileAssignmentPath)) + Expect(req.Method).To(Equal("GET")) + + // TODO: Add check for include_history query parameter + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"context": {"transaction_id": "TransactionID", "operation": "Operation", "user_agent": "UserAgent", "url": "URL", "instance_id": "InstanceID", "thread_id": "ThreadID", "host": "Host", "start_time": "StartTime", "end_time": "EndTime", "elapsed_time": "ElapsedTime", "cluster_name": "ClusterName"}, "id": "ID", "account_id": "AccountID", "template_id": "TemplateID", "template_version": 15, "target_type": "TargetType", "target": "Target", "status": "Status", "resources": [{"target": "Target", "profile": {"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}, "account_settings": {"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}, "policy_template_refs": [{"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}]}], "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "href": "Href", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID", "entity_tag": "EntityTag"}`) + })) + }) + It(`Invoke GetTrustedProfileAssignment successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := iamIdentityService.GetTrustedProfileAssignment(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the GetTrustedProfileAssignmentOptions model + getTrustedProfileAssignmentOptionsModel := new(iamidentityv1.GetTrustedProfileAssignmentOptions) + getTrustedProfileAssignmentOptionsModel.AssignmentID = core.StringPtr("testString") + getTrustedProfileAssignmentOptionsModel.IncludeHistory = core.BoolPtr(false) + getTrustedProfileAssignmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = iamIdentityService.GetTrustedProfileAssignment(getTrustedProfileAssignmentOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke GetTrustedProfileAssignment with error: Operation validation and request error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the GetTrustedProfileAssignmentOptions model + getTrustedProfileAssignmentOptionsModel := new(iamidentityv1.GetTrustedProfileAssignmentOptions) + getTrustedProfileAssignmentOptionsModel.AssignmentID = core.StringPtr("testString") + getTrustedProfileAssignmentOptionsModel.IncludeHistory = core.BoolPtr(false) + getTrustedProfileAssignmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := iamIdentityService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := iamIdentityService.GetTrustedProfileAssignment(getTrustedProfileAssignmentOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + // Construct a second instance of the GetTrustedProfileAssignmentOptions model with no property values + getTrustedProfileAssignmentOptionsModelNew := new(iamidentityv1.GetTrustedProfileAssignmentOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = iamIdentityService.GetTrustedProfileAssignment(getTrustedProfileAssignmentOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(200) + })) + }) + It(`Invoke GetTrustedProfileAssignment successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the GetTrustedProfileAssignmentOptions model + getTrustedProfileAssignmentOptionsModel := new(iamidentityv1.GetTrustedProfileAssignmentOptions) + getTrustedProfileAssignmentOptionsModel.AssignmentID = core.StringPtr("testString") + getTrustedProfileAssignmentOptionsModel.IncludeHistory = core.BoolPtr(false) + getTrustedProfileAssignmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamIdentityService.GetTrustedProfileAssignment(getTrustedProfileAssignmentOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`DeleteTrustedProfileAssignment(deleteTrustedProfileAssignmentOptions *DeleteTrustedProfileAssignmentOptions) - Operation response error`, func() { + deleteTrustedProfileAssignmentPath := "/v1/profile_assignments/testString" + Context(`Using mock server endpoint with invalid JSON response`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(deleteTrustedProfileAssignmentPath)) + Expect(req.Method).To(Equal("DELETE")) + res.Header().Set("Content-type", "application/json") + res.WriteHeader(202) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke DeleteTrustedProfileAssignment with error: Operation response processing error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the DeleteTrustedProfileAssignmentOptions model + deleteTrustedProfileAssignmentOptionsModel := new(iamidentityv1.DeleteTrustedProfileAssignmentOptions) + deleteTrustedProfileAssignmentOptionsModel.AssignmentID = core.StringPtr("testString") + deleteTrustedProfileAssignmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := iamIdentityService.DeleteTrustedProfileAssignment(deleteTrustedProfileAssignmentOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + iamIdentityService.EnableRetries(0, 0) + result, response, operationErr = iamIdentityService.DeleteTrustedProfileAssignment(deleteTrustedProfileAssignmentOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`DeleteTrustedProfileAssignment(deleteTrustedProfileAssignmentOptions *DeleteTrustedProfileAssignmentOptions)`, func() { + deleteTrustedProfileAssignmentPath := "/v1/profile_assignments/testString" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(deleteTrustedProfileAssignmentPath)) + Expect(req.Method).To(Equal("DELETE")) + + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(202) + fmt.Fprintf(res, "%s", `{"context": {"transaction_id": "TransactionID", "operation": "Operation", "user_agent": "UserAgent", "url": "URL", "instance_id": "InstanceID", "thread_id": "ThreadID", "host": "Host", "start_time": "StartTime", "end_time": "EndTime", "elapsed_time": "ElapsedTime", "cluster_name": "ClusterName"}, "status_code": "StatusCode", "errors": [{"code": "Code", "message_code": "MessageCode", "message": "Message", "details": "Details"}], "trace": "Trace"}`) + })) + }) + It(`Invoke DeleteTrustedProfileAssignment successfully with retries`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + iamIdentityService.EnableRetries(0, 0) + + // Construct an instance of the DeleteTrustedProfileAssignmentOptions model + deleteTrustedProfileAssignmentOptionsModel := new(iamidentityv1.DeleteTrustedProfileAssignmentOptions) + deleteTrustedProfileAssignmentOptionsModel.AssignmentID = core.StringPtr("testString") + deleteTrustedProfileAssignmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := iamIdentityService.DeleteTrustedProfileAssignmentWithContext(ctx, deleteTrustedProfileAssignmentOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + iamIdentityService.DisableRetries() + result, response, operationErr := iamIdentityService.DeleteTrustedProfileAssignment(deleteTrustedProfileAssignmentOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = iamIdentityService.DeleteTrustedProfileAssignmentWithContext(ctx, deleteTrustedProfileAssignmentOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(deleteTrustedProfileAssignmentPath)) + Expect(req.Method).To(Equal("DELETE")) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(202) + fmt.Fprintf(res, "%s", `{"context": {"transaction_id": "TransactionID", "operation": "Operation", "user_agent": "UserAgent", "url": "URL", "instance_id": "InstanceID", "thread_id": "ThreadID", "host": "Host", "start_time": "StartTime", "end_time": "EndTime", "elapsed_time": "ElapsedTime", "cluster_name": "ClusterName"}, "status_code": "StatusCode", "errors": [{"code": "Code", "message_code": "MessageCode", "message": "Message", "details": "Details"}], "trace": "Trace"}`) + })) + }) + It(`Invoke DeleteTrustedProfileAssignment successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := iamIdentityService.DeleteTrustedProfileAssignment(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the DeleteTrustedProfileAssignmentOptions model + deleteTrustedProfileAssignmentOptionsModel := new(iamidentityv1.DeleteTrustedProfileAssignmentOptions) + deleteTrustedProfileAssignmentOptionsModel.AssignmentID = core.StringPtr("testString") + deleteTrustedProfileAssignmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = iamIdentityService.DeleteTrustedProfileAssignment(deleteTrustedProfileAssignmentOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke DeleteTrustedProfileAssignment with error: Operation validation and request error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the DeleteTrustedProfileAssignmentOptions model + deleteTrustedProfileAssignmentOptionsModel := new(iamidentityv1.DeleteTrustedProfileAssignmentOptions) + deleteTrustedProfileAssignmentOptionsModel.AssignmentID = core.StringPtr("testString") + deleteTrustedProfileAssignmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := iamIdentityService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := iamIdentityService.DeleteTrustedProfileAssignment(deleteTrustedProfileAssignmentOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + // Construct a second instance of the DeleteTrustedProfileAssignmentOptions model with no property values + deleteTrustedProfileAssignmentOptionsModelNew := new(iamidentityv1.DeleteTrustedProfileAssignmentOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = iamIdentityService.DeleteTrustedProfileAssignment(deleteTrustedProfileAssignmentOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(202) + })) + }) + It(`Invoke DeleteTrustedProfileAssignment successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the DeleteTrustedProfileAssignmentOptions model + deleteTrustedProfileAssignmentOptionsModel := new(iamidentityv1.DeleteTrustedProfileAssignmentOptions) + deleteTrustedProfileAssignmentOptionsModel.AssignmentID = core.StringPtr("testString") + deleteTrustedProfileAssignmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamIdentityService.DeleteTrustedProfileAssignment(deleteTrustedProfileAssignmentOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`UpdateTrustedProfileAssignment(updateTrustedProfileAssignmentOptions *UpdateTrustedProfileAssignmentOptions) - Operation response error`, func() { + updateTrustedProfileAssignmentPath := "/v1/profile_assignments/testString" + Context(`Using mock server endpoint with invalid JSON response`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(updateTrustedProfileAssignmentPath)) + Expect(req.Method).To(Equal("PATCH")) + Expect(req.Header["If-Match"]).ToNot(BeNil()) + Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke UpdateTrustedProfileAssignment with error: Operation response processing error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the UpdateTrustedProfileAssignmentOptions model + updateTrustedProfileAssignmentOptionsModel := new(iamidentityv1.UpdateTrustedProfileAssignmentOptions) + updateTrustedProfileAssignmentOptionsModel.AssignmentID = core.StringPtr("testString") + updateTrustedProfileAssignmentOptionsModel.IfMatch = core.StringPtr("testString") + updateTrustedProfileAssignmentOptionsModel.TemplateVersion = core.Int64Ptr(int64(1)) + updateTrustedProfileAssignmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := iamIdentityService.UpdateTrustedProfileAssignment(updateTrustedProfileAssignmentOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + iamIdentityService.EnableRetries(0, 0) + result, response, operationErr = iamIdentityService.UpdateTrustedProfileAssignment(updateTrustedProfileAssignmentOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`UpdateTrustedProfileAssignment(updateTrustedProfileAssignmentOptions *UpdateTrustedProfileAssignmentOptions)`, func() { + updateTrustedProfileAssignmentPath := "/v1/profile_assignments/testString" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(updateTrustedProfileAssignmentPath)) + Expect(req.Method).To(Equal("PATCH")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + + Expect(req.Header["If-Match"]).ToNot(BeNil()) + Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"context": {"transaction_id": "TransactionID", "operation": "Operation", "user_agent": "UserAgent", "url": "URL", "instance_id": "InstanceID", "thread_id": "ThreadID", "host": "Host", "start_time": "StartTime", "end_time": "EndTime", "elapsed_time": "ElapsedTime", "cluster_name": "ClusterName"}, "id": "ID", "account_id": "AccountID", "template_id": "TemplateID", "template_version": 15, "target_type": "TargetType", "target": "Target", "status": "Status", "resources": [{"target": "Target", "profile": {"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}, "account_settings": {"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}, "policy_template_refs": [{"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}]}], "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "href": "Href", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID", "entity_tag": "EntityTag"}`) + })) + }) + It(`Invoke UpdateTrustedProfileAssignment successfully with retries`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + iamIdentityService.EnableRetries(0, 0) + + // Construct an instance of the UpdateTrustedProfileAssignmentOptions model + updateTrustedProfileAssignmentOptionsModel := new(iamidentityv1.UpdateTrustedProfileAssignmentOptions) + updateTrustedProfileAssignmentOptionsModel.AssignmentID = core.StringPtr("testString") + updateTrustedProfileAssignmentOptionsModel.IfMatch = core.StringPtr("testString") + updateTrustedProfileAssignmentOptionsModel.TemplateVersion = core.Int64Ptr(int64(1)) + updateTrustedProfileAssignmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := iamIdentityService.UpdateTrustedProfileAssignmentWithContext(ctx, updateTrustedProfileAssignmentOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + iamIdentityService.DisableRetries() + result, response, operationErr := iamIdentityService.UpdateTrustedProfileAssignment(updateTrustedProfileAssignmentOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = iamIdentityService.UpdateTrustedProfileAssignmentWithContext(ctx, updateTrustedProfileAssignmentOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(updateTrustedProfileAssignmentPath)) + Expect(req.Method).To(Equal("PATCH")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + + Expect(req.Header["If-Match"]).ToNot(BeNil()) + Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"context": {"transaction_id": "TransactionID", "operation": "Operation", "user_agent": "UserAgent", "url": "URL", "instance_id": "InstanceID", "thread_id": "ThreadID", "host": "Host", "start_time": "StartTime", "end_time": "EndTime", "elapsed_time": "ElapsedTime", "cluster_name": "ClusterName"}, "id": "ID", "account_id": "AccountID", "template_id": "TemplateID", "template_version": 15, "target_type": "TargetType", "target": "Target", "status": "Status", "resources": [{"target": "Target", "profile": {"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}, "account_settings": {"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}, "policy_template_refs": [{"id": "ID", "version": "Version", "resource_created": {"id": "ID"}, "error_message": {"name": "Name", "errorCode": "ErrorCode", "message": "Message", "statusCode": "StatusCode"}, "status": "Status"}]}], "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "href": "Href", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID", "entity_tag": "EntityTag"}`) + })) + }) + It(`Invoke UpdateTrustedProfileAssignment successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := iamIdentityService.UpdateTrustedProfileAssignment(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the UpdateTrustedProfileAssignmentOptions model + updateTrustedProfileAssignmentOptionsModel := new(iamidentityv1.UpdateTrustedProfileAssignmentOptions) + updateTrustedProfileAssignmentOptionsModel.AssignmentID = core.StringPtr("testString") + updateTrustedProfileAssignmentOptionsModel.IfMatch = core.StringPtr("testString") + updateTrustedProfileAssignmentOptionsModel.TemplateVersion = core.Int64Ptr(int64(1)) + updateTrustedProfileAssignmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = iamIdentityService.UpdateTrustedProfileAssignment(updateTrustedProfileAssignmentOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke UpdateTrustedProfileAssignment with error: Operation validation and request error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the UpdateTrustedProfileAssignmentOptions model + updateTrustedProfileAssignmentOptionsModel := new(iamidentityv1.UpdateTrustedProfileAssignmentOptions) + updateTrustedProfileAssignmentOptionsModel.AssignmentID = core.StringPtr("testString") + updateTrustedProfileAssignmentOptionsModel.IfMatch = core.StringPtr("testString") + updateTrustedProfileAssignmentOptionsModel.TemplateVersion = core.Int64Ptr(int64(1)) + updateTrustedProfileAssignmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := iamIdentityService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := iamIdentityService.UpdateTrustedProfileAssignment(updateTrustedProfileAssignmentOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + // Construct a second instance of the UpdateTrustedProfileAssignmentOptions model with no property values + updateTrustedProfileAssignmentOptionsModelNew := new(iamidentityv1.UpdateTrustedProfileAssignmentOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = iamIdentityService.UpdateTrustedProfileAssignment(updateTrustedProfileAssignmentOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(200) + })) + }) + It(`Invoke UpdateTrustedProfileAssignment successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the UpdateTrustedProfileAssignmentOptions model + updateTrustedProfileAssignmentOptionsModel := new(iamidentityv1.UpdateTrustedProfileAssignmentOptions) + updateTrustedProfileAssignmentOptionsModel.AssignmentID = core.StringPtr("testString") + updateTrustedProfileAssignmentOptionsModel.IfMatch = core.StringPtr("testString") + updateTrustedProfileAssignmentOptionsModel.TemplateVersion = core.Int64Ptr(int64(1)) + updateTrustedProfileAssignmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamIdentityService.UpdateTrustedProfileAssignment(updateTrustedProfileAssignmentOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`ListProfileTemplates(listProfileTemplatesOptions *ListProfileTemplatesOptions) - Operation response error`, func() { + listProfileTemplatesPath := "/v1/profile_templates" + Context(`Using mock server endpoint with invalid JSON response`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listProfileTemplatesPath)) + Expect(req.Method).To(Equal("GET")) + Expect(req.URL.Query()["account_id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{"20"})) + Expect(req.URL.Query()["pagetoken"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["sort"]).To(Equal([]string{"created_at"})) + Expect(req.URL.Query()["order"]).To(Equal([]string{"asc"})) + Expect(req.URL.Query()["include_history"]).To(Equal([]string{"false"})) + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke ListProfileTemplates with error: Operation response processing error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the ListProfileTemplatesOptions model + listProfileTemplatesOptionsModel := new(iamidentityv1.ListProfileTemplatesOptions) + listProfileTemplatesOptionsModel.AccountID = core.StringPtr("testString") + listProfileTemplatesOptionsModel.Limit = core.StringPtr("20") + listProfileTemplatesOptionsModel.Pagetoken = core.StringPtr("testString") + listProfileTemplatesOptionsModel.Sort = core.StringPtr("created_at") + listProfileTemplatesOptionsModel.Order = core.StringPtr("asc") + listProfileTemplatesOptionsModel.IncludeHistory = core.StringPtr("false") + listProfileTemplatesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := iamIdentityService.ListProfileTemplates(listProfileTemplatesOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + iamIdentityService.EnableRetries(0, 0) + result, response, operationErr = iamIdentityService.ListProfileTemplates(listProfileTemplatesOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`ListProfileTemplates(listProfileTemplatesOptions *ListProfileTemplatesOptions)`, func() { + listProfileTemplatesPath := "/v1/profile_templates" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listProfileTemplatesPath)) + Expect(req.Method).To(Equal("GET")) + + Expect(req.URL.Query()["account_id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{"20"})) + Expect(req.URL.Query()["pagetoken"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["sort"]).To(Equal([]string{"created_at"})) + Expect(req.URL.Query()["order"]).To(Equal([]string{"asc"})) + Expect(req.URL.Query()["include_history"]).To(Equal([]string{"false"})) + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"context": {"transaction_id": "TransactionID", "operation": "Operation", "user_agent": "UserAgent", "url": "URL", "instance_id": "InstanceID", "thread_id": "ThreadID", "host": "Host", "start_time": "StartTime", "end_time": "EndTime", "elapsed_time": "ElapsedTime", "cluster_name": "ClusterName"}, "offset": 6, "limit": 20, "first": "First", "previous": "Previous", "next": "Next", "profile_templates": [{"id": "ID", "version": 7, "account_id": "AccountID", "name": "Name", "description": "Description", "committed": false, "profile": {"name": "Name", "description": "Description", "rules": [{"name": "Name", "type": "Profile-SAML", "realm_name": "RealmName", "expiration": 10, "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}]}], "identities": [{"iam_id": "IamID", "identifier": "Identifier", "type": "user", "accounts": ["Accounts"], "description": "Description"}]}, "policy_template_references": [{"id": "ID", "version": "Version"}], "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "entity_tag": "EntityTag", "crn": "CRN", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID"}]}`) + })) + }) + It(`Invoke ListProfileTemplates successfully with retries`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + iamIdentityService.EnableRetries(0, 0) + + // Construct an instance of the ListProfileTemplatesOptions model + listProfileTemplatesOptionsModel := new(iamidentityv1.ListProfileTemplatesOptions) + listProfileTemplatesOptionsModel.AccountID = core.StringPtr("testString") + listProfileTemplatesOptionsModel.Limit = core.StringPtr("20") + listProfileTemplatesOptionsModel.Pagetoken = core.StringPtr("testString") + listProfileTemplatesOptionsModel.Sort = core.StringPtr("created_at") + listProfileTemplatesOptionsModel.Order = core.StringPtr("asc") + listProfileTemplatesOptionsModel.IncludeHistory = core.StringPtr("false") + listProfileTemplatesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := iamIdentityService.ListProfileTemplatesWithContext(ctx, listProfileTemplatesOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + iamIdentityService.DisableRetries() + result, response, operationErr := iamIdentityService.ListProfileTemplates(listProfileTemplatesOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = iamIdentityService.ListProfileTemplatesWithContext(ctx, listProfileTemplatesOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listProfileTemplatesPath)) + Expect(req.Method).To(Equal("GET")) + + Expect(req.URL.Query()["account_id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{"20"})) + Expect(req.URL.Query()["pagetoken"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["sort"]).To(Equal([]string{"created_at"})) + Expect(req.URL.Query()["order"]).To(Equal([]string{"asc"})) + Expect(req.URL.Query()["include_history"]).To(Equal([]string{"false"})) + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"context": {"transaction_id": "TransactionID", "operation": "Operation", "user_agent": "UserAgent", "url": "URL", "instance_id": "InstanceID", "thread_id": "ThreadID", "host": "Host", "start_time": "StartTime", "end_time": "EndTime", "elapsed_time": "ElapsedTime", "cluster_name": "ClusterName"}, "offset": 6, "limit": 20, "first": "First", "previous": "Previous", "next": "Next", "profile_templates": [{"id": "ID", "version": 7, "account_id": "AccountID", "name": "Name", "description": "Description", "committed": false, "profile": {"name": "Name", "description": "Description", "rules": [{"name": "Name", "type": "Profile-SAML", "realm_name": "RealmName", "expiration": 10, "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}]}], "identities": [{"iam_id": "IamID", "identifier": "Identifier", "type": "user", "accounts": ["Accounts"], "description": "Description"}]}, "policy_template_references": [{"id": "ID", "version": "Version"}], "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "entity_tag": "EntityTag", "crn": "CRN", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID"}]}`) + })) + }) + It(`Invoke ListProfileTemplates successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := iamIdentityService.ListProfileTemplates(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the ListProfileTemplatesOptions model + listProfileTemplatesOptionsModel := new(iamidentityv1.ListProfileTemplatesOptions) + listProfileTemplatesOptionsModel.AccountID = core.StringPtr("testString") + listProfileTemplatesOptionsModel.Limit = core.StringPtr("20") + listProfileTemplatesOptionsModel.Pagetoken = core.StringPtr("testString") + listProfileTemplatesOptionsModel.Sort = core.StringPtr("created_at") + listProfileTemplatesOptionsModel.Order = core.StringPtr("asc") + listProfileTemplatesOptionsModel.IncludeHistory = core.StringPtr("false") + listProfileTemplatesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = iamIdentityService.ListProfileTemplates(listProfileTemplatesOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke ListProfileTemplates with error: Operation request error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the ListProfileTemplatesOptions model + listProfileTemplatesOptionsModel := new(iamidentityv1.ListProfileTemplatesOptions) + listProfileTemplatesOptionsModel.AccountID = core.StringPtr("testString") + listProfileTemplatesOptionsModel.Limit = core.StringPtr("20") + listProfileTemplatesOptionsModel.Pagetoken = core.StringPtr("testString") + listProfileTemplatesOptionsModel.Sort = core.StringPtr("created_at") + listProfileTemplatesOptionsModel.Order = core.StringPtr("asc") + listProfileTemplatesOptionsModel.IncludeHistory = core.StringPtr("false") + listProfileTemplatesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := iamIdentityService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := iamIdentityService.ListProfileTemplates(listProfileTemplatesOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(200) + })) + }) + It(`Invoke ListProfileTemplates successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the ListProfileTemplatesOptions model + listProfileTemplatesOptionsModel := new(iamidentityv1.ListProfileTemplatesOptions) + listProfileTemplatesOptionsModel.AccountID = core.StringPtr("testString") + listProfileTemplatesOptionsModel.Limit = core.StringPtr("20") + listProfileTemplatesOptionsModel.Pagetoken = core.StringPtr("testString") + listProfileTemplatesOptionsModel.Sort = core.StringPtr("created_at") + listProfileTemplatesOptionsModel.Order = core.StringPtr("asc") + listProfileTemplatesOptionsModel.IncludeHistory = core.StringPtr("false") + listProfileTemplatesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamIdentityService.ListProfileTemplates(listProfileTemplatesOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`CreateProfileTemplate(createProfileTemplateOptions *CreateProfileTemplateOptions) - Operation response error`, func() { + createProfileTemplatePath := "/v1/profile_templates" + Context(`Using mock server endpoint with invalid JSON response`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(createProfileTemplatePath)) + Expect(req.Method).To(Equal("POST")) + res.Header().Set("Content-type", "application/json") + res.WriteHeader(201) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke CreateProfileTemplate with error: Operation response processing error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the ProfileClaimRuleConditions model + profileClaimRuleConditionsModel := new(iamidentityv1.ProfileClaimRuleConditions) + profileClaimRuleConditionsModel.Claim = core.StringPtr("testString") + profileClaimRuleConditionsModel.Operator = core.StringPtr("testString") + profileClaimRuleConditionsModel.Value = core.StringPtr("testString") + + // Construct an instance of the TrustedProfileTemplateClaimRule model + trustedProfileTemplateClaimRuleModel := new(iamidentityv1.TrustedProfileTemplateClaimRule) + trustedProfileTemplateClaimRuleModel.Name = core.StringPtr("testString") + trustedProfileTemplateClaimRuleModel.Type = core.StringPtr("Profile-SAML") + trustedProfileTemplateClaimRuleModel.RealmName = core.StringPtr("testString") + trustedProfileTemplateClaimRuleModel.Expiration = core.Int64Ptr(int64(38)) + trustedProfileTemplateClaimRuleModel.Conditions = []iamidentityv1.ProfileClaimRuleConditions{*profileClaimRuleConditionsModel} + + // Construct an instance of the ProfileIdentityRequest model + profileIdentityRequestModel := new(iamidentityv1.ProfileIdentityRequest) + profileIdentityRequestModel.Identifier = core.StringPtr("testString") + profileIdentityRequestModel.Type = core.StringPtr("user") + profileIdentityRequestModel.Accounts = []string{"testString"} + profileIdentityRequestModel.Description = core.StringPtr("testString") + + // Construct an instance of the TemplateProfileComponentRequest model + templateProfileComponentRequestModel := new(iamidentityv1.TemplateProfileComponentRequest) + templateProfileComponentRequestModel.Name = core.StringPtr("testString") + templateProfileComponentRequestModel.Description = core.StringPtr("testString") + templateProfileComponentRequestModel.Rules = []iamidentityv1.TrustedProfileTemplateClaimRule{*trustedProfileTemplateClaimRuleModel} + templateProfileComponentRequestModel.Identities = []iamidentityv1.ProfileIdentityRequest{*profileIdentityRequestModel} + + // Construct an instance of the PolicyTemplateReference model + policyTemplateReferenceModel := new(iamidentityv1.PolicyTemplateReference) + policyTemplateReferenceModel.ID = core.StringPtr("testString") + policyTemplateReferenceModel.Version = core.StringPtr("testString") + + // Construct an instance of the CreateProfileTemplateOptions model + createProfileTemplateOptionsModel := new(iamidentityv1.CreateProfileTemplateOptions) + createProfileTemplateOptionsModel.AccountID = core.StringPtr("testString") + createProfileTemplateOptionsModel.Name = core.StringPtr("testString") + createProfileTemplateOptionsModel.Description = core.StringPtr("testString") + createProfileTemplateOptionsModel.Profile = templateProfileComponentRequestModel + createProfileTemplateOptionsModel.PolicyTemplateReferences = []iamidentityv1.PolicyTemplateReference{*policyTemplateReferenceModel} + createProfileTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := iamIdentityService.CreateProfileTemplate(createProfileTemplateOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + iamIdentityService.EnableRetries(0, 0) + result, response, operationErr = iamIdentityService.CreateProfileTemplate(createProfileTemplateOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`CreateProfileTemplate(createProfileTemplateOptions *CreateProfileTemplateOptions)`, func() { + createProfileTemplatePath := "/v1/profile_templates" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(createProfileTemplatePath)) + Expect(req.Method).To(Equal("POST")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(201) + fmt.Fprintf(res, "%s", `{"id": "ID", "version": 7, "account_id": "AccountID", "name": "Name", "description": "Description", "committed": false, "profile": {"name": "Name", "description": "Description", "rules": [{"name": "Name", "type": "Profile-SAML", "realm_name": "RealmName", "expiration": 10, "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}]}], "identities": [{"iam_id": "IamID", "identifier": "Identifier", "type": "user", "accounts": ["Accounts"], "description": "Description"}]}, "policy_template_references": [{"id": "ID", "version": "Version"}], "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "entity_tag": "EntityTag", "crn": "CRN", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID"}`) + })) + }) + It(`Invoke CreateProfileTemplate successfully with retries`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + iamIdentityService.EnableRetries(0, 0) + + // Construct an instance of the ProfileClaimRuleConditions model + profileClaimRuleConditionsModel := new(iamidentityv1.ProfileClaimRuleConditions) + profileClaimRuleConditionsModel.Claim = core.StringPtr("testString") + profileClaimRuleConditionsModel.Operator = core.StringPtr("testString") + profileClaimRuleConditionsModel.Value = core.StringPtr("testString") + + // Construct an instance of the TrustedProfileTemplateClaimRule model + trustedProfileTemplateClaimRuleModel := new(iamidentityv1.TrustedProfileTemplateClaimRule) + trustedProfileTemplateClaimRuleModel.Name = core.StringPtr("testString") + trustedProfileTemplateClaimRuleModel.Type = core.StringPtr("Profile-SAML") + trustedProfileTemplateClaimRuleModel.RealmName = core.StringPtr("testString") + trustedProfileTemplateClaimRuleModel.Expiration = core.Int64Ptr(int64(38)) + trustedProfileTemplateClaimRuleModel.Conditions = []iamidentityv1.ProfileClaimRuleConditions{*profileClaimRuleConditionsModel} + + // Construct an instance of the ProfileIdentityRequest model + profileIdentityRequestModel := new(iamidentityv1.ProfileIdentityRequest) + profileIdentityRequestModel.Identifier = core.StringPtr("testString") + profileIdentityRequestModel.Type = core.StringPtr("user") + profileIdentityRequestModel.Accounts = []string{"testString"} + profileIdentityRequestModel.Description = core.StringPtr("testString") + + // Construct an instance of the TemplateProfileComponentRequest model + templateProfileComponentRequestModel := new(iamidentityv1.TemplateProfileComponentRequest) + templateProfileComponentRequestModel.Name = core.StringPtr("testString") + templateProfileComponentRequestModel.Description = core.StringPtr("testString") + templateProfileComponentRequestModel.Rules = []iamidentityv1.TrustedProfileTemplateClaimRule{*trustedProfileTemplateClaimRuleModel} + templateProfileComponentRequestModel.Identities = []iamidentityv1.ProfileIdentityRequest{*profileIdentityRequestModel} + + // Construct an instance of the PolicyTemplateReference model + policyTemplateReferenceModel := new(iamidentityv1.PolicyTemplateReference) + policyTemplateReferenceModel.ID = core.StringPtr("testString") + policyTemplateReferenceModel.Version = core.StringPtr("testString") + + // Construct an instance of the CreateProfileTemplateOptions model + createProfileTemplateOptionsModel := new(iamidentityv1.CreateProfileTemplateOptions) + createProfileTemplateOptionsModel.AccountID = core.StringPtr("testString") + createProfileTemplateOptionsModel.Name = core.StringPtr("testString") + createProfileTemplateOptionsModel.Description = core.StringPtr("testString") + createProfileTemplateOptionsModel.Profile = templateProfileComponentRequestModel + createProfileTemplateOptionsModel.PolicyTemplateReferences = []iamidentityv1.PolicyTemplateReference{*policyTemplateReferenceModel} + createProfileTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := iamIdentityService.CreateProfileTemplateWithContext(ctx, createProfileTemplateOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + iamIdentityService.DisableRetries() + result, response, operationErr := iamIdentityService.CreateProfileTemplate(createProfileTemplateOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = iamIdentityService.CreateProfileTemplateWithContext(ctx, createProfileTemplateOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(createProfileTemplatePath)) + Expect(req.Method).To(Equal("POST")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(201) + fmt.Fprintf(res, "%s", `{"id": "ID", "version": 7, "account_id": "AccountID", "name": "Name", "description": "Description", "committed": false, "profile": {"name": "Name", "description": "Description", "rules": [{"name": "Name", "type": "Profile-SAML", "realm_name": "RealmName", "expiration": 10, "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}]}], "identities": [{"iam_id": "IamID", "identifier": "Identifier", "type": "user", "accounts": ["Accounts"], "description": "Description"}]}, "policy_template_references": [{"id": "ID", "version": "Version"}], "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "entity_tag": "EntityTag", "crn": "CRN", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID"}`) + })) + }) + It(`Invoke CreateProfileTemplate successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := iamIdentityService.CreateProfileTemplate(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the ProfileClaimRuleConditions model + profileClaimRuleConditionsModel := new(iamidentityv1.ProfileClaimRuleConditions) + profileClaimRuleConditionsModel.Claim = core.StringPtr("testString") + profileClaimRuleConditionsModel.Operator = core.StringPtr("testString") + profileClaimRuleConditionsModel.Value = core.StringPtr("testString") + + // Construct an instance of the TrustedProfileTemplateClaimRule model + trustedProfileTemplateClaimRuleModel := new(iamidentityv1.TrustedProfileTemplateClaimRule) + trustedProfileTemplateClaimRuleModel.Name = core.StringPtr("testString") + trustedProfileTemplateClaimRuleModel.Type = core.StringPtr("Profile-SAML") + trustedProfileTemplateClaimRuleModel.RealmName = core.StringPtr("testString") + trustedProfileTemplateClaimRuleModel.Expiration = core.Int64Ptr(int64(38)) + trustedProfileTemplateClaimRuleModel.Conditions = []iamidentityv1.ProfileClaimRuleConditions{*profileClaimRuleConditionsModel} + + // Construct an instance of the ProfileIdentityRequest model + profileIdentityRequestModel := new(iamidentityv1.ProfileIdentityRequest) + profileIdentityRequestModel.Identifier = core.StringPtr("testString") + profileIdentityRequestModel.Type = core.StringPtr("user") + profileIdentityRequestModel.Accounts = []string{"testString"} + profileIdentityRequestModel.Description = core.StringPtr("testString") + + // Construct an instance of the TemplateProfileComponentRequest model + templateProfileComponentRequestModel := new(iamidentityv1.TemplateProfileComponentRequest) + templateProfileComponentRequestModel.Name = core.StringPtr("testString") + templateProfileComponentRequestModel.Description = core.StringPtr("testString") + templateProfileComponentRequestModel.Rules = []iamidentityv1.TrustedProfileTemplateClaimRule{*trustedProfileTemplateClaimRuleModel} + templateProfileComponentRequestModel.Identities = []iamidentityv1.ProfileIdentityRequest{*profileIdentityRequestModel} + + // Construct an instance of the PolicyTemplateReference model + policyTemplateReferenceModel := new(iamidentityv1.PolicyTemplateReference) + policyTemplateReferenceModel.ID = core.StringPtr("testString") + policyTemplateReferenceModel.Version = core.StringPtr("testString") + + // Construct an instance of the CreateProfileTemplateOptions model + createProfileTemplateOptionsModel := new(iamidentityv1.CreateProfileTemplateOptions) + createProfileTemplateOptionsModel.AccountID = core.StringPtr("testString") + createProfileTemplateOptionsModel.Name = core.StringPtr("testString") + createProfileTemplateOptionsModel.Description = core.StringPtr("testString") + createProfileTemplateOptionsModel.Profile = templateProfileComponentRequestModel + createProfileTemplateOptionsModel.PolicyTemplateReferences = []iamidentityv1.PolicyTemplateReference{*policyTemplateReferenceModel} + createProfileTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = iamIdentityService.CreateProfileTemplate(createProfileTemplateOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke CreateProfileTemplate with error: Operation request error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the ProfileClaimRuleConditions model + profileClaimRuleConditionsModel := new(iamidentityv1.ProfileClaimRuleConditions) + profileClaimRuleConditionsModel.Claim = core.StringPtr("testString") + profileClaimRuleConditionsModel.Operator = core.StringPtr("testString") + profileClaimRuleConditionsModel.Value = core.StringPtr("testString") + + // Construct an instance of the TrustedProfileTemplateClaimRule model + trustedProfileTemplateClaimRuleModel := new(iamidentityv1.TrustedProfileTemplateClaimRule) + trustedProfileTemplateClaimRuleModel.Name = core.StringPtr("testString") + trustedProfileTemplateClaimRuleModel.Type = core.StringPtr("Profile-SAML") + trustedProfileTemplateClaimRuleModel.RealmName = core.StringPtr("testString") + trustedProfileTemplateClaimRuleModel.Expiration = core.Int64Ptr(int64(38)) + trustedProfileTemplateClaimRuleModel.Conditions = []iamidentityv1.ProfileClaimRuleConditions{*profileClaimRuleConditionsModel} + + // Construct an instance of the ProfileIdentityRequest model + profileIdentityRequestModel := new(iamidentityv1.ProfileIdentityRequest) + profileIdentityRequestModel.Identifier = core.StringPtr("testString") + profileIdentityRequestModel.Type = core.StringPtr("user") + profileIdentityRequestModel.Accounts = []string{"testString"} + profileIdentityRequestModel.Description = core.StringPtr("testString") + + // Construct an instance of the TemplateProfileComponentRequest model + templateProfileComponentRequestModel := new(iamidentityv1.TemplateProfileComponentRequest) + templateProfileComponentRequestModel.Name = core.StringPtr("testString") + templateProfileComponentRequestModel.Description = core.StringPtr("testString") + templateProfileComponentRequestModel.Rules = []iamidentityv1.TrustedProfileTemplateClaimRule{*trustedProfileTemplateClaimRuleModel} + templateProfileComponentRequestModel.Identities = []iamidentityv1.ProfileIdentityRequest{*profileIdentityRequestModel} + + // Construct an instance of the PolicyTemplateReference model + policyTemplateReferenceModel := new(iamidentityv1.PolicyTemplateReference) + policyTemplateReferenceModel.ID = core.StringPtr("testString") + policyTemplateReferenceModel.Version = core.StringPtr("testString") + + // Construct an instance of the CreateProfileTemplateOptions model + createProfileTemplateOptionsModel := new(iamidentityv1.CreateProfileTemplateOptions) + createProfileTemplateOptionsModel.AccountID = core.StringPtr("testString") + createProfileTemplateOptionsModel.Name = core.StringPtr("testString") + createProfileTemplateOptionsModel.Description = core.StringPtr("testString") + createProfileTemplateOptionsModel.Profile = templateProfileComponentRequestModel + createProfileTemplateOptionsModel.PolicyTemplateReferences = []iamidentityv1.PolicyTemplateReference{*policyTemplateReferenceModel} + createProfileTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := iamIdentityService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := iamIdentityService.CreateProfileTemplate(createProfileTemplateOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(201) + })) + }) + It(`Invoke CreateProfileTemplate successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the ProfileClaimRuleConditions model + profileClaimRuleConditionsModel := new(iamidentityv1.ProfileClaimRuleConditions) + profileClaimRuleConditionsModel.Claim = core.StringPtr("testString") + profileClaimRuleConditionsModel.Operator = core.StringPtr("testString") + profileClaimRuleConditionsModel.Value = core.StringPtr("testString") + + // Construct an instance of the TrustedProfileTemplateClaimRule model + trustedProfileTemplateClaimRuleModel := new(iamidentityv1.TrustedProfileTemplateClaimRule) + trustedProfileTemplateClaimRuleModel.Name = core.StringPtr("testString") + trustedProfileTemplateClaimRuleModel.Type = core.StringPtr("Profile-SAML") + trustedProfileTemplateClaimRuleModel.RealmName = core.StringPtr("testString") + trustedProfileTemplateClaimRuleModel.Expiration = core.Int64Ptr(int64(38)) + trustedProfileTemplateClaimRuleModel.Conditions = []iamidentityv1.ProfileClaimRuleConditions{*profileClaimRuleConditionsModel} + + // Construct an instance of the ProfileIdentityRequest model + profileIdentityRequestModel := new(iamidentityv1.ProfileIdentityRequest) + profileIdentityRequestModel.Identifier = core.StringPtr("testString") + profileIdentityRequestModel.Type = core.StringPtr("user") + profileIdentityRequestModel.Accounts = []string{"testString"} + profileIdentityRequestModel.Description = core.StringPtr("testString") + + // Construct an instance of the TemplateProfileComponentRequest model + templateProfileComponentRequestModel := new(iamidentityv1.TemplateProfileComponentRequest) + templateProfileComponentRequestModel.Name = core.StringPtr("testString") + templateProfileComponentRequestModel.Description = core.StringPtr("testString") + templateProfileComponentRequestModel.Rules = []iamidentityv1.TrustedProfileTemplateClaimRule{*trustedProfileTemplateClaimRuleModel} + templateProfileComponentRequestModel.Identities = []iamidentityv1.ProfileIdentityRequest{*profileIdentityRequestModel} + + // Construct an instance of the PolicyTemplateReference model + policyTemplateReferenceModel := new(iamidentityv1.PolicyTemplateReference) + policyTemplateReferenceModel.ID = core.StringPtr("testString") + policyTemplateReferenceModel.Version = core.StringPtr("testString") + + // Construct an instance of the CreateProfileTemplateOptions model + createProfileTemplateOptionsModel := new(iamidentityv1.CreateProfileTemplateOptions) + createProfileTemplateOptionsModel.AccountID = core.StringPtr("testString") + createProfileTemplateOptionsModel.Name = core.StringPtr("testString") + createProfileTemplateOptionsModel.Description = core.StringPtr("testString") + createProfileTemplateOptionsModel.Profile = templateProfileComponentRequestModel + createProfileTemplateOptionsModel.PolicyTemplateReferences = []iamidentityv1.PolicyTemplateReference{*policyTemplateReferenceModel} + createProfileTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamIdentityService.CreateProfileTemplate(createProfileTemplateOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetLatestProfileTemplateVersion(getLatestProfileTemplateVersionOptions *GetLatestProfileTemplateVersionOptions) - Operation response error`, func() { + getLatestProfileTemplateVersionPath := "/v1/profile_templates/testString" + Context(`Using mock server endpoint with invalid JSON response`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getLatestProfileTemplateVersionPath)) + Expect(req.Method).To(Equal("GET")) + // TODO: Add check for include_history query parameter + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke GetLatestProfileTemplateVersion with error: Operation response processing error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the GetLatestProfileTemplateVersionOptions model + getLatestProfileTemplateVersionOptionsModel := new(iamidentityv1.GetLatestProfileTemplateVersionOptions) + getLatestProfileTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + getLatestProfileTemplateVersionOptionsModel.IncludeHistory = core.BoolPtr(false) + getLatestProfileTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := iamIdentityService.GetLatestProfileTemplateVersion(getLatestProfileTemplateVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + iamIdentityService.EnableRetries(0, 0) + result, response, operationErr = iamIdentityService.GetLatestProfileTemplateVersion(getLatestProfileTemplateVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetLatestProfileTemplateVersion(getLatestProfileTemplateVersionOptions *GetLatestProfileTemplateVersionOptions)`, func() { + getLatestProfileTemplateVersionPath := "/v1/profile_templates/testString" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getLatestProfileTemplateVersionPath)) + Expect(req.Method).To(Equal("GET")) + + // TODO: Add check for include_history query parameter + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"id": "ID", "version": 7, "account_id": "AccountID", "name": "Name", "description": "Description", "committed": false, "profile": {"name": "Name", "description": "Description", "rules": [{"name": "Name", "type": "Profile-SAML", "realm_name": "RealmName", "expiration": 10, "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}]}], "identities": [{"iam_id": "IamID", "identifier": "Identifier", "type": "user", "accounts": ["Accounts"], "description": "Description"}]}, "policy_template_references": [{"id": "ID", "version": "Version"}], "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "entity_tag": "EntityTag", "crn": "CRN", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID"}`) + })) + }) + It(`Invoke GetLatestProfileTemplateVersion successfully with retries`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + iamIdentityService.EnableRetries(0, 0) + + // Construct an instance of the GetLatestProfileTemplateVersionOptions model + getLatestProfileTemplateVersionOptionsModel := new(iamidentityv1.GetLatestProfileTemplateVersionOptions) + getLatestProfileTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + getLatestProfileTemplateVersionOptionsModel.IncludeHistory = core.BoolPtr(false) + getLatestProfileTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := iamIdentityService.GetLatestProfileTemplateVersionWithContext(ctx, getLatestProfileTemplateVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + iamIdentityService.DisableRetries() + result, response, operationErr := iamIdentityService.GetLatestProfileTemplateVersion(getLatestProfileTemplateVersionOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = iamIdentityService.GetLatestProfileTemplateVersionWithContext(ctx, getLatestProfileTemplateVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getLatestProfileTemplateVersionPath)) + Expect(req.Method).To(Equal("GET")) + + // TODO: Add check for include_history query parameter + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"id": "ID", "version": 7, "account_id": "AccountID", "name": "Name", "description": "Description", "committed": false, "profile": {"name": "Name", "description": "Description", "rules": [{"name": "Name", "type": "Profile-SAML", "realm_name": "RealmName", "expiration": 10, "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}]}], "identities": [{"iam_id": "IamID", "identifier": "Identifier", "type": "user", "accounts": ["Accounts"], "description": "Description"}]}, "policy_template_references": [{"id": "ID", "version": "Version"}], "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "entity_tag": "EntityTag", "crn": "CRN", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID"}`) + })) + }) + It(`Invoke GetLatestProfileTemplateVersion successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := iamIdentityService.GetLatestProfileTemplateVersion(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the GetLatestProfileTemplateVersionOptions model + getLatestProfileTemplateVersionOptionsModel := new(iamidentityv1.GetLatestProfileTemplateVersionOptions) + getLatestProfileTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + getLatestProfileTemplateVersionOptionsModel.IncludeHistory = core.BoolPtr(false) + getLatestProfileTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = iamIdentityService.GetLatestProfileTemplateVersion(getLatestProfileTemplateVersionOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke GetLatestProfileTemplateVersion with error: Operation validation and request error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the GetLatestProfileTemplateVersionOptions model + getLatestProfileTemplateVersionOptionsModel := new(iamidentityv1.GetLatestProfileTemplateVersionOptions) + getLatestProfileTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + getLatestProfileTemplateVersionOptionsModel.IncludeHistory = core.BoolPtr(false) + getLatestProfileTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := iamIdentityService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := iamIdentityService.GetLatestProfileTemplateVersion(getLatestProfileTemplateVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + // Construct a second instance of the GetLatestProfileTemplateVersionOptions model with no property values + getLatestProfileTemplateVersionOptionsModelNew := new(iamidentityv1.GetLatestProfileTemplateVersionOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = iamIdentityService.GetLatestProfileTemplateVersion(getLatestProfileTemplateVersionOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(200) + })) + }) + It(`Invoke GetLatestProfileTemplateVersion successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the GetLatestProfileTemplateVersionOptions model + getLatestProfileTemplateVersionOptionsModel := new(iamidentityv1.GetLatestProfileTemplateVersionOptions) + getLatestProfileTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + getLatestProfileTemplateVersionOptionsModel.IncludeHistory = core.BoolPtr(false) + getLatestProfileTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamIdentityService.GetLatestProfileTemplateVersion(getLatestProfileTemplateVersionOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`DeleteAllVersionsOfProfileTemplate(deleteAllVersionsOfProfileTemplateOptions *DeleteAllVersionsOfProfileTemplateOptions)`, func() { + deleteAllVersionsOfProfileTemplatePath := "/v1/profile_templates/testString" + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(deleteAllVersionsOfProfileTemplatePath)) + Expect(req.Method).To(Equal("DELETE")) + + res.WriteHeader(204) + })) + }) + It(`Invoke DeleteAllVersionsOfProfileTemplate successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + response, operationErr := iamIdentityService.DeleteAllVersionsOfProfileTemplate(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + + // Construct an instance of the DeleteAllVersionsOfProfileTemplateOptions model + deleteAllVersionsOfProfileTemplateOptionsModel := new(iamidentityv1.DeleteAllVersionsOfProfileTemplateOptions) + deleteAllVersionsOfProfileTemplateOptionsModel.TemplateID = core.StringPtr("testString") + deleteAllVersionsOfProfileTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + response, operationErr = iamIdentityService.DeleteAllVersionsOfProfileTemplate(deleteAllVersionsOfProfileTemplateOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + }) + It(`Invoke DeleteAllVersionsOfProfileTemplate with error: Operation validation and request error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the DeleteAllVersionsOfProfileTemplateOptions model + deleteAllVersionsOfProfileTemplateOptionsModel := new(iamidentityv1.DeleteAllVersionsOfProfileTemplateOptions) + deleteAllVersionsOfProfileTemplateOptionsModel.TemplateID = core.StringPtr("testString") + deleteAllVersionsOfProfileTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := iamIdentityService.SetServiceURL("") + Expect(err).To(BeNil()) + response, operationErr := iamIdentityService.DeleteAllVersionsOfProfileTemplate(deleteAllVersionsOfProfileTemplateOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + // Construct a second instance of the DeleteAllVersionsOfProfileTemplateOptions model with no property values + deleteAllVersionsOfProfileTemplateOptionsModelNew := new(iamidentityv1.DeleteAllVersionsOfProfileTemplateOptions) + // Invoke operation with invalid model (negative test) + response, operationErr = iamIdentityService.DeleteAllVersionsOfProfileTemplate(deleteAllVersionsOfProfileTemplateOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`ListVersionsOfProfileTemplate(listVersionsOfProfileTemplateOptions *ListVersionsOfProfileTemplateOptions) - Operation response error`, func() { + listVersionsOfProfileTemplatePath := "/v1/profile_templates/testString/versions" + Context(`Using mock server endpoint with invalid JSON response`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listVersionsOfProfileTemplatePath)) + Expect(req.Method).To(Equal("GET")) + Expect(req.URL.Query()["limit"]).To(Equal([]string{"20"})) + Expect(req.URL.Query()["pagetoken"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["sort"]).To(Equal([]string{"created_at"})) + Expect(req.URL.Query()["order"]).To(Equal([]string{"asc"})) + Expect(req.URL.Query()["include_history"]).To(Equal([]string{"false"})) + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke ListVersionsOfProfileTemplate with error: Operation response processing error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the ListVersionsOfProfileTemplateOptions model + listVersionsOfProfileTemplateOptionsModel := new(iamidentityv1.ListVersionsOfProfileTemplateOptions) + listVersionsOfProfileTemplateOptionsModel.TemplateID = core.StringPtr("testString") + listVersionsOfProfileTemplateOptionsModel.Limit = core.StringPtr("20") + listVersionsOfProfileTemplateOptionsModel.Pagetoken = core.StringPtr("testString") + listVersionsOfProfileTemplateOptionsModel.Sort = core.StringPtr("created_at") + listVersionsOfProfileTemplateOptionsModel.Order = core.StringPtr("asc") + listVersionsOfProfileTemplateOptionsModel.IncludeHistory = core.StringPtr("false") + listVersionsOfProfileTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := iamIdentityService.ListVersionsOfProfileTemplate(listVersionsOfProfileTemplateOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + iamIdentityService.EnableRetries(0, 0) + result, response, operationErr = iamIdentityService.ListVersionsOfProfileTemplate(listVersionsOfProfileTemplateOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`ListVersionsOfProfileTemplate(listVersionsOfProfileTemplateOptions *ListVersionsOfProfileTemplateOptions)`, func() { + listVersionsOfProfileTemplatePath := "/v1/profile_templates/testString/versions" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listVersionsOfProfileTemplatePath)) + Expect(req.Method).To(Equal("GET")) + + Expect(req.URL.Query()["limit"]).To(Equal([]string{"20"})) + Expect(req.URL.Query()["pagetoken"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["sort"]).To(Equal([]string{"created_at"})) + Expect(req.URL.Query()["order"]).To(Equal([]string{"asc"})) + Expect(req.URL.Query()["include_history"]).To(Equal([]string{"false"})) + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"context": {"transaction_id": "TransactionID", "operation": "Operation", "user_agent": "UserAgent", "url": "URL", "instance_id": "InstanceID", "thread_id": "ThreadID", "host": "Host", "start_time": "StartTime", "end_time": "EndTime", "elapsed_time": "ElapsedTime", "cluster_name": "ClusterName"}, "offset": 6, "limit": 20, "first": "First", "previous": "Previous", "next": "Next", "profile_templates": [{"id": "ID", "version": 7, "account_id": "AccountID", "name": "Name", "description": "Description", "committed": false, "profile": {"name": "Name", "description": "Description", "rules": [{"name": "Name", "type": "Profile-SAML", "realm_name": "RealmName", "expiration": 10, "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}]}], "identities": [{"iam_id": "IamID", "identifier": "Identifier", "type": "user", "accounts": ["Accounts"], "description": "Description"}]}, "policy_template_references": [{"id": "ID", "version": "Version"}], "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "entity_tag": "EntityTag", "crn": "CRN", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID"}]}`) + })) + }) + It(`Invoke ListVersionsOfProfileTemplate successfully with retries`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + iamIdentityService.EnableRetries(0, 0) + + // Construct an instance of the ListVersionsOfProfileTemplateOptions model + listVersionsOfProfileTemplateOptionsModel := new(iamidentityv1.ListVersionsOfProfileTemplateOptions) + listVersionsOfProfileTemplateOptionsModel.TemplateID = core.StringPtr("testString") + listVersionsOfProfileTemplateOptionsModel.Limit = core.StringPtr("20") + listVersionsOfProfileTemplateOptionsModel.Pagetoken = core.StringPtr("testString") + listVersionsOfProfileTemplateOptionsModel.Sort = core.StringPtr("created_at") + listVersionsOfProfileTemplateOptionsModel.Order = core.StringPtr("asc") + listVersionsOfProfileTemplateOptionsModel.IncludeHistory = core.StringPtr("false") + listVersionsOfProfileTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := iamIdentityService.ListVersionsOfProfileTemplateWithContext(ctx, listVersionsOfProfileTemplateOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + iamIdentityService.DisableRetries() + result, response, operationErr := iamIdentityService.ListVersionsOfProfileTemplate(listVersionsOfProfileTemplateOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = iamIdentityService.ListVersionsOfProfileTemplateWithContext(ctx, listVersionsOfProfileTemplateOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listVersionsOfProfileTemplatePath)) + Expect(req.Method).To(Equal("GET")) + + Expect(req.URL.Query()["limit"]).To(Equal([]string{"20"})) + Expect(req.URL.Query()["pagetoken"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["sort"]).To(Equal([]string{"created_at"})) + Expect(req.URL.Query()["order"]).To(Equal([]string{"asc"})) + Expect(req.URL.Query()["include_history"]).To(Equal([]string{"false"})) + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"context": {"transaction_id": "TransactionID", "operation": "Operation", "user_agent": "UserAgent", "url": "URL", "instance_id": "InstanceID", "thread_id": "ThreadID", "host": "Host", "start_time": "StartTime", "end_time": "EndTime", "elapsed_time": "ElapsedTime", "cluster_name": "ClusterName"}, "offset": 6, "limit": 20, "first": "First", "previous": "Previous", "next": "Next", "profile_templates": [{"id": "ID", "version": 7, "account_id": "AccountID", "name": "Name", "description": "Description", "committed": false, "profile": {"name": "Name", "description": "Description", "rules": [{"name": "Name", "type": "Profile-SAML", "realm_name": "RealmName", "expiration": 10, "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}]}], "identities": [{"iam_id": "IamID", "identifier": "Identifier", "type": "user", "accounts": ["Accounts"], "description": "Description"}]}, "policy_template_references": [{"id": "ID", "version": "Version"}], "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "entity_tag": "EntityTag", "crn": "CRN", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID"}]}`) + })) + }) + It(`Invoke ListVersionsOfProfileTemplate successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := iamIdentityService.ListVersionsOfProfileTemplate(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the ListVersionsOfProfileTemplateOptions model + listVersionsOfProfileTemplateOptionsModel := new(iamidentityv1.ListVersionsOfProfileTemplateOptions) + listVersionsOfProfileTemplateOptionsModel.TemplateID = core.StringPtr("testString") + listVersionsOfProfileTemplateOptionsModel.Limit = core.StringPtr("20") + listVersionsOfProfileTemplateOptionsModel.Pagetoken = core.StringPtr("testString") + listVersionsOfProfileTemplateOptionsModel.Sort = core.StringPtr("created_at") + listVersionsOfProfileTemplateOptionsModel.Order = core.StringPtr("asc") + listVersionsOfProfileTemplateOptionsModel.IncludeHistory = core.StringPtr("false") + listVersionsOfProfileTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = iamIdentityService.ListVersionsOfProfileTemplate(listVersionsOfProfileTemplateOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke ListVersionsOfProfileTemplate with error: Operation validation and request error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the ListVersionsOfProfileTemplateOptions model + listVersionsOfProfileTemplateOptionsModel := new(iamidentityv1.ListVersionsOfProfileTemplateOptions) + listVersionsOfProfileTemplateOptionsModel.TemplateID = core.StringPtr("testString") + listVersionsOfProfileTemplateOptionsModel.Limit = core.StringPtr("20") + listVersionsOfProfileTemplateOptionsModel.Pagetoken = core.StringPtr("testString") + listVersionsOfProfileTemplateOptionsModel.Sort = core.StringPtr("created_at") + listVersionsOfProfileTemplateOptionsModel.Order = core.StringPtr("asc") + listVersionsOfProfileTemplateOptionsModel.IncludeHistory = core.StringPtr("false") + listVersionsOfProfileTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := iamIdentityService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := iamIdentityService.ListVersionsOfProfileTemplate(listVersionsOfProfileTemplateOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + // Construct a second instance of the ListVersionsOfProfileTemplateOptions model with no property values + listVersionsOfProfileTemplateOptionsModelNew := new(iamidentityv1.ListVersionsOfProfileTemplateOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = iamIdentityService.ListVersionsOfProfileTemplate(listVersionsOfProfileTemplateOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(200) + })) + }) + It(`Invoke ListVersionsOfProfileTemplate successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the ListVersionsOfProfileTemplateOptions model + listVersionsOfProfileTemplateOptionsModel := new(iamidentityv1.ListVersionsOfProfileTemplateOptions) + listVersionsOfProfileTemplateOptionsModel.TemplateID = core.StringPtr("testString") + listVersionsOfProfileTemplateOptionsModel.Limit = core.StringPtr("20") + listVersionsOfProfileTemplateOptionsModel.Pagetoken = core.StringPtr("testString") + listVersionsOfProfileTemplateOptionsModel.Sort = core.StringPtr("created_at") + listVersionsOfProfileTemplateOptionsModel.Order = core.StringPtr("asc") + listVersionsOfProfileTemplateOptionsModel.IncludeHistory = core.StringPtr("false") + listVersionsOfProfileTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamIdentityService.ListVersionsOfProfileTemplate(listVersionsOfProfileTemplateOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`CreateProfileTemplateVersion(createProfileTemplateVersionOptions *CreateProfileTemplateVersionOptions) - Operation response error`, func() { + createProfileTemplateVersionPath := "/v1/profile_templates/testString/versions" + Context(`Using mock server endpoint with invalid JSON response`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(createProfileTemplateVersionPath)) + Expect(req.Method).To(Equal("POST")) + res.Header().Set("Content-type", "application/json") + res.WriteHeader(201) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke CreateProfileTemplateVersion with error: Operation response processing error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the ProfileClaimRuleConditions model + profileClaimRuleConditionsModel := new(iamidentityv1.ProfileClaimRuleConditions) + profileClaimRuleConditionsModel.Claim = core.StringPtr("testString") + profileClaimRuleConditionsModel.Operator = core.StringPtr("testString") + profileClaimRuleConditionsModel.Value = core.StringPtr("testString") + + // Construct an instance of the TrustedProfileTemplateClaimRule model + trustedProfileTemplateClaimRuleModel := new(iamidentityv1.TrustedProfileTemplateClaimRule) + trustedProfileTemplateClaimRuleModel.Name = core.StringPtr("testString") + trustedProfileTemplateClaimRuleModel.Type = core.StringPtr("Profile-SAML") + trustedProfileTemplateClaimRuleModel.RealmName = core.StringPtr("testString") + trustedProfileTemplateClaimRuleModel.Expiration = core.Int64Ptr(int64(38)) + trustedProfileTemplateClaimRuleModel.Conditions = []iamidentityv1.ProfileClaimRuleConditions{*profileClaimRuleConditionsModel} + + // Construct an instance of the ProfileIdentityRequest model + profileIdentityRequestModel := new(iamidentityv1.ProfileIdentityRequest) + profileIdentityRequestModel.Identifier = core.StringPtr("testString") + profileIdentityRequestModel.Type = core.StringPtr("user") + profileIdentityRequestModel.Accounts = []string{"testString"} + profileIdentityRequestModel.Description = core.StringPtr("testString") + + // Construct an instance of the TemplateProfileComponentRequest model + templateProfileComponentRequestModel := new(iamidentityv1.TemplateProfileComponentRequest) + templateProfileComponentRequestModel.Name = core.StringPtr("testString") + templateProfileComponentRequestModel.Description = core.StringPtr("testString") + templateProfileComponentRequestModel.Rules = []iamidentityv1.TrustedProfileTemplateClaimRule{*trustedProfileTemplateClaimRuleModel} + templateProfileComponentRequestModel.Identities = []iamidentityv1.ProfileIdentityRequest{*profileIdentityRequestModel} + + // Construct an instance of the PolicyTemplateReference model + policyTemplateReferenceModel := new(iamidentityv1.PolicyTemplateReference) + policyTemplateReferenceModel.ID = core.StringPtr("testString") + policyTemplateReferenceModel.Version = core.StringPtr("testString") + + // Construct an instance of the CreateProfileTemplateVersionOptions model + createProfileTemplateVersionOptionsModel := new(iamidentityv1.CreateProfileTemplateVersionOptions) + createProfileTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + createProfileTemplateVersionOptionsModel.AccountID = core.StringPtr("testString") + createProfileTemplateVersionOptionsModel.Name = core.StringPtr("testString") + createProfileTemplateVersionOptionsModel.Description = core.StringPtr("testString") + createProfileTemplateVersionOptionsModel.Profile = templateProfileComponentRequestModel + createProfileTemplateVersionOptionsModel.PolicyTemplateReferences = []iamidentityv1.PolicyTemplateReference{*policyTemplateReferenceModel} + createProfileTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := iamIdentityService.CreateProfileTemplateVersion(createProfileTemplateVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + iamIdentityService.EnableRetries(0, 0) + result, response, operationErr = iamIdentityService.CreateProfileTemplateVersion(createProfileTemplateVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`CreateProfileTemplateVersion(createProfileTemplateVersionOptions *CreateProfileTemplateVersionOptions)`, func() { + createProfileTemplateVersionPath := "/v1/profile_templates/testString/versions" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(createProfileTemplateVersionPath)) + Expect(req.Method).To(Equal("POST")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(201) + fmt.Fprintf(res, "%s", `{"id": "ID", "version": 7, "account_id": "AccountID", "name": "Name", "description": "Description", "committed": false, "profile": {"name": "Name", "description": "Description", "rules": [{"name": "Name", "type": "Profile-SAML", "realm_name": "RealmName", "expiration": 10, "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}]}], "identities": [{"iam_id": "IamID", "identifier": "Identifier", "type": "user", "accounts": ["Accounts"], "description": "Description"}]}, "policy_template_references": [{"id": "ID", "version": "Version"}], "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "entity_tag": "EntityTag", "crn": "CRN", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID"}`) + })) + }) + It(`Invoke CreateProfileTemplateVersion successfully with retries`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + iamIdentityService.EnableRetries(0, 0) + + // Construct an instance of the ProfileClaimRuleConditions model + profileClaimRuleConditionsModel := new(iamidentityv1.ProfileClaimRuleConditions) + profileClaimRuleConditionsModel.Claim = core.StringPtr("testString") + profileClaimRuleConditionsModel.Operator = core.StringPtr("testString") + profileClaimRuleConditionsModel.Value = core.StringPtr("testString") + + // Construct an instance of the TrustedProfileTemplateClaimRule model + trustedProfileTemplateClaimRuleModel := new(iamidentityv1.TrustedProfileTemplateClaimRule) + trustedProfileTemplateClaimRuleModel.Name = core.StringPtr("testString") + trustedProfileTemplateClaimRuleModel.Type = core.StringPtr("Profile-SAML") + trustedProfileTemplateClaimRuleModel.RealmName = core.StringPtr("testString") + trustedProfileTemplateClaimRuleModel.Expiration = core.Int64Ptr(int64(38)) + trustedProfileTemplateClaimRuleModel.Conditions = []iamidentityv1.ProfileClaimRuleConditions{*profileClaimRuleConditionsModel} + + // Construct an instance of the ProfileIdentityRequest model + profileIdentityRequestModel := new(iamidentityv1.ProfileIdentityRequest) + profileIdentityRequestModel.Identifier = core.StringPtr("testString") + profileIdentityRequestModel.Type = core.StringPtr("user") + profileIdentityRequestModel.Accounts = []string{"testString"} + profileIdentityRequestModel.Description = core.StringPtr("testString") + + // Construct an instance of the TemplateProfileComponentRequest model + templateProfileComponentRequestModel := new(iamidentityv1.TemplateProfileComponentRequest) + templateProfileComponentRequestModel.Name = core.StringPtr("testString") + templateProfileComponentRequestModel.Description = core.StringPtr("testString") + templateProfileComponentRequestModel.Rules = []iamidentityv1.TrustedProfileTemplateClaimRule{*trustedProfileTemplateClaimRuleModel} + templateProfileComponentRequestModel.Identities = []iamidentityv1.ProfileIdentityRequest{*profileIdentityRequestModel} + + // Construct an instance of the PolicyTemplateReference model + policyTemplateReferenceModel := new(iamidentityv1.PolicyTemplateReference) + policyTemplateReferenceModel.ID = core.StringPtr("testString") + policyTemplateReferenceModel.Version = core.StringPtr("testString") + + // Construct an instance of the CreateProfileTemplateVersionOptions model + createProfileTemplateVersionOptionsModel := new(iamidentityv1.CreateProfileTemplateVersionOptions) + createProfileTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + createProfileTemplateVersionOptionsModel.AccountID = core.StringPtr("testString") + createProfileTemplateVersionOptionsModel.Name = core.StringPtr("testString") + createProfileTemplateVersionOptionsModel.Description = core.StringPtr("testString") + createProfileTemplateVersionOptionsModel.Profile = templateProfileComponentRequestModel + createProfileTemplateVersionOptionsModel.PolicyTemplateReferences = []iamidentityv1.PolicyTemplateReference{*policyTemplateReferenceModel} + createProfileTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := iamIdentityService.CreateProfileTemplateVersionWithContext(ctx, createProfileTemplateVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + iamIdentityService.DisableRetries() + result, response, operationErr := iamIdentityService.CreateProfileTemplateVersion(createProfileTemplateVersionOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = iamIdentityService.CreateProfileTemplateVersionWithContext(ctx, createProfileTemplateVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(createProfileTemplateVersionPath)) + Expect(req.Method).To(Equal("POST")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(201) + fmt.Fprintf(res, "%s", `{"id": "ID", "version": 7, "account_id": "AccountID", "name": "Name", "description": "Description", "committed": false, "profile": {"name": "Name", "description": "Description", "rules": [{"name": "Name", "type": "Profile-SAML", "realm_name": "RealmName", "expiration": 10, "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}]}], "identities": [{"iam_id": "IamID", "identifier": "Identifier", "type": "user", "accounts": ["Accounts"], "description": "Description"}]}, "policy_template_references": [{"id": "ID", "version": "Version"}], "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "entity_tag": "EntityTag", "crn": "CRN", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID"}`) + })) + }) + It(`Invoke CreateProfileTemplateVersion successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := iamIdentityService.CreateProfileTemplateVersion(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the ProfileClaimRuleConditions model + profileClaimRuleConditionsModel := new(iamidentityv1.ProfileClaimRuleConditions) + profileClaimRuleConditionsModel.Claim = core.StringPtr("testString") + profileClaimRuleConditionsModel.Operator = core.StringPtr("testString") + profileClaimRuleConditionsModel.Value = core.StringPtr("testString") + + // Construct an instance of the TrustedProfileTemplateClaimRule model + trustedProfileTemplateClaimRuleModel := new(iamidentityv1.TrustedProfileTemplateClaimRule) + trustedProfileTemplateClaimRuleModel.Name = core.StringPtr("testString") + trustedProfileTemplateClaimRuleModel.Type = core.StringPtr("Profile-SAML") + trustedProfileTemplateClaimRuleModel.RealmName = core.StringPtr("testString") + trustedProfileTemplateClaimRuleModel.Expiration = core.Int64Ptr(int64(38)) + trustedProfileTemplateClaimRuleModel.Conditions = []iamidentityv1.ProfileClaimRuleConditions{*profileClaimRuleConditionsModel} + + // Construct an instance of the ProfileIdentityRequest model + profileIdentityRequestModel := new(iamidentityv1.ProfileIdentityRequest) + profileIdentityRequestModel.Identifier = core.StringPtr("testString") + profileIdentityRequestModel.Type = core.StringPtr("user") + profileIdentityRequestModel.Accounts = []string{"testString"} + profileIdentityRequestModel.Description = core.StringPtr("testString") + + // Construct an instance of the TemplateProfileComponentRequest model + templateProfileComponentRequestModel := new(iamidentityv1.TemplateProfileComponentRequest) + templateProfileComponentRequestModel.Name = core.StringPtr("testString") + templateProfileComponentRequestModel.Description = core.StringPtr("testString") + templateProfileComponentRequestModel.Rules = []iamidentityv1.TrustedProfileTemplateClaimRule{*trustedProfileTemplateClaimRuleModel} + templateProfileComponentRequestModel.Identities = []iamidentityv1.ProfileIdentityRequest{*profileIdentityRequestModel} + + // Construct an instance of the PolicyTemplateReference model + policyTemplateReferenceModel := new(iamidentityv1.PolicyTemplateReference) + policyTemplateReferenceModel.ID = core.StringPtr("testString") + policyTemplateReferenceModel.Version = core.StringPtr("testString") + + // Construct an instance of the CreateProfileTemplateVersionOptions model + createProfileTemplateVersionOptionsModel := new(iamidentityv1.CreateProfileTemplateVersionOptions) + createProfileTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + createProfileTemplateVersionOptionsModel.AccountID = core.StringPtr("testString") + createProfileTemplateVersionOptionsModel.Name = core.StringPtr("testString") + createProfileTemplateVersionOptionsModel.Description = core.StringPtr("testString") + createProfileTemplateVersionOptionsModel.Profile = templateProfileComponentRequestModel + createProfileTemplateVersionOptionsModel.PolicyTemplateReferences = []iamidentityv1.PolicyTemplateReference{*policyTemplateReferenceModel} + createProfileTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = iamIdentityService.CreateProfileTemplateVersion(createProfileTemplateVersionOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke CreateProfileTemplateVersion with error: Operation validation and request error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the ProfileClaimRuleConditions model + profileClaimRuleConditionsModel := new(iamidentityv1.ProfileClaimRuleConditions) + profileClaimRuleConditionsModel.Claim = core.StringPtr("testString") + profileClaimRuleConditionsModel.Operator = core.StringPtr("testString") + profileClaimRuleConditionsModel.Value = core.StringPtr("testString") + + // Construct an instance of the TrustedProfileTemplateClaimRule model + trustedProfileTemplateClaimRuleModel := new(iamidentityv1.TrustedProfileTemplateClaimRule) + trustedProfileTemplateClaimRuleModel.Name = core.StringPtr("testString") + trustedProfileTemplateClaimRuleModel.Type = core.StringPtr("Profile-SAML") + trustedProfileTemplateClaimRuleModel.RealmName = core.StringPtr("testString") + trustedProfileTemplateClaimRuleModel.Expiration = core.Int64Ptr(int64(38)) + trustedProfileTemplateClaimRuleModel.Conditions = []iamidentityv1.ProfileClaimRuleConditions{*profileClaimRuleConditionsModel} + + // Construct an instance of the ProfileIdentityRequest model + profileIdentityRequestModel := new(iamidentityv1.ProfileIdentityRequest) + profileIdentityRequestModel.Identifier = core.StringPtr("testString") + profileIdentityRequestModel.Type = core.StringPtr("user") + profileIdentityRequestModel.Accounts = []string{"testString"} + profileIdentityRequestModel.Description = core.StringPtr("testString") + + // Construct an instance of the TemplateProfileComponentRequest model + templateProfileComponentRequestModel := new(iamidentityv1.TemplateProfileComponentRequest) + templateProfileComponentRequestModel.Name = core.StringPtr("testString") + templateProfileComponentRequestModel.Description = core.StringPtr("testString") + templateProfileComponentRequestModel.Rules = []iamidentityv1.TrustedProfileTemplateClaimRule{*trustedProfileTemplateClaimRuleModel} + templateProfileComponentRequestModel.Identities = []iamidentityv1.ProfileIdentityRequest{*profileIdentityRequestModel} + + // Construct an instance of the PolicyTemplateReference model + policyTemplateReferenceModel := new(iamidentityv1.PolicyTemplateReference) + policyTemplateReferenceModel.ID = core.StringPtr("testString") + policyTemplateReferenceModel.Version = core.StringPtr("testString") + + // Construct an instance of the CreateProfileTemplateVersionOptions model + createProfileTemplateVersionOptionsModel := new(iamidentityv1.CreateProfileTemplateVersionOptions) + createProfileTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + createProfileTemplateVersionOptionsModel.AccountID = core.StringPtr("testString") + createProfileTemplateVersionOptionsModel.Name = core.StringPtr("testString") + createProfileTemplateVersionOptionsModel.Description = core.StringPtr("testString") + createProfileTemplateVersionOptionsModel.Profile = templateProfileComponentRequestModel + createProfileTemplateVersionOptionsModel.PolicyTemplateReferences = []iamidentityv1.PolicyTemplateReference{*policyTemplateReferenceModel} + createProfileTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := iamIdentityService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := iamIdentityService.CreateProfileTemplateVersion(createProfileTemplateVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + // Construct a second instance of the CreateProfileTemplateVersionOptions model with no property values + createProfileTemplateVersionOptionsModelNew := new(iamidentityv1.CreateProfileTemplateVersionOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = iamIdentityService.CreateProfileTemplateVersion(createProfileTemplateVersionOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(201) + })) + }) + It(`Invoke CreateProfileTemplateVersion successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the ProfileClaimRuleConditions model + profileClaimRuleConditionsModel := new(iamidentityv1.ProfileClaimRuleConditions) + profileClaimRuleConditionsModel.Claim = core.StringPtr("testString") + profileClaimRuleConditionsModel.Operator = core.StringPtr("testString") + profileClaimRuleConditionsModel.Value = core.StringPtr("testString") + + // Construct an instance of the TrustedProfileTemplateClaimRule model + trustedProfileTemplateClaimRuleModel := new(iamidentityv1.TrustedProfileTemplateClaimRule) + trustedProfileTemplateClaimRuleModel.Name = core.StringPtr("testString") + trustedProfileTemplateClaimRuleModel.Type = core.StringPtr("Profile-SAML") + trustedProfileTemplateClaimRuleModel.RealmName = core.StringPtr("testString") + trustedProfileTemplateClaimRuleModel.Expiration = core.Int64Ptr(int64(38)) + trustedProfileTemplateClaimRuleModel.Conditions = []iamidentityv1.ProfileClaimRuleConditions{*profileClaimRuleConditionsModel} + + // Construct an instance of the ProfileIdentityRequest model + profileIdentityRequestModel := new(iamidentityv1.ProfileIdentityRequest) + profileIdentityRequestModel.Identifier = core.StringPtr("testString") + profileIdentityRequestModel.Type = core.StringPtr("user") + profileIdentityRequestModel.Accounts = []string{"testString"} + profileIdentityRequestModel.Description = core.StringPtr("testString") + + // Construct an instance of the TemplateProfileComponentRequest model + templateProfileComponentRequestModel := new(iamidentityv1.TemplateProfileComponentRequest) + templateProfileComponentRequestModel.Name = core.StringPtr("testString") + templateProfileComponentRequestModel.Description = core.StringPtr("testString") + templateProfileComponentRequestModel.Rules = []iamidentityv1.TrustedProfileTemplateClaimRule{*trustedProfileTemplateClaimRuleModel} + templateProfileComponentRequestModel.Identities = []iamidentityv1.ProfileIdentityRequest{*profileIdentityRequestModel} + + // Construct an instance of the PolicyTemplateReference model + policyTemplateReferenceModel := new(iamidentityv1.PolicyTemplateReference) + policyTemplateReferenceModel.ID = core.StringPtr("testString") + policyTemplateReferenceModel.Version = core.StringPtr("testString") + + // Construct an instance of the CreateProfileTemplateVersionOptions model + createProfileTemplateVersionOptionsModel := new(iamidentityv1.CreateProfileTemplateVersionOptions) + createProfileTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + createProfileTemplateVersionOptionsModel.AccountID = core.StringPtr("testString") + createProfileTemplateVersionOptionsModel.Name = core.StringPtr("testString") + createProfileTemplateVersionOptionsModel.Description = core.StringPtr("testString") + createProfileTemplateVersionOptionsModel.Profile = templateProfileComponentRequestModel + createProfileTemplateVersionOptionsModel.PolicyTemplateReferences = []iamidentityv1.PolicyTemplateReference{*policyTemplateReferenceModel} + createProfileTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamIdentityService.CreateProfileTemplateVersion(createProfileTemplateVersionOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetProfileTemplateVersion(getProfileTemplateVersionOptions *GetProfileTemplateVersionOptions) - Operation response error`, func() { + getProfileTemplateVersionPath := "/v1/profile_templates/testString/versions/testString" + Context(`Using mock server endpoint with invalid JSON response`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getProfileTemplateVersionPath)) + Expect(req.Method).To(Equal("GET")) + // TODO: Add check for include_history query parameter res.Header().Set("Content-type", "application/json") - res.WriteHeader(202) + res.WriteHeader(200) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke CreateReport with error: Operation response processing error`, func() { + It(`Invoke GetProfileTemplateVersion with error: Operation response processing error`, func() { iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -8342,21 +15101,21 @@ var _ = Describe(`IamIdentityV1`, func() { Expect(serviceErr).To(BeNil()) Expect(iamIdentityService).ToNot(BeNil()) - // Construct an instance of the CreateReportOptions model - createReportOptionsModel := new(iamidentityv1.CreateReportOptions) - createReportOptionsModel.AccountID = core.StringPtr("testString") - createReportOptionsModel.Type = core.StringPtr("inactive") - createReportOptionsModel.Duration = core.StringPtr("720") - createReportOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetProfileTemplateVersionOptions model + getProfileTemplateVersionOptionsModel := new(iamidentityv1.GetProfileTemplateVersionOptions) + getProfileTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + getProfileTemplateVersionOptionsModel.Version = core.StringPtr("testString") + getProfileTemplateVersionOptionsModel.IncludeHistory = core.BoolPtr(false) + getProfileTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := iamIdentityService.CreateReport(createReportOptionsModel) + result, response, operationErr := iamIdentityService.GetProfileTemplateVersion(getProfileTemplateVersionOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again iamIdentityService.EnableRetries(0, 0) - result, response, operationErr = iamIdentityService.CreateReport(createReportOptionsModel) + result, response, operationErr = iamIdentityService.GetProfileTemplateVersion(getProfileTemplateVersionOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -8366,29 +15125,28 @@ var _ = Describe(`IamIdentityV1`, func() { }) }) }) - Describe(`CreateReport(createReportOptions *CreateReportOptions)`, func() { - createReportPath := "/v1/activity/accounts/testString/report" + Describe(`GetProfileTemplateVersion(getProfileTemplateVersionOptions *GetProfileTemplateVersionOptions)`, func() { + getProfileTemplateVersionPath := "/v1/profile_templates/testString/versions/testString" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createReportPath)) - Expect(req.Method).To(Equal("POST")) + Expect(req.URL.EscapedPath()).To(Equal(getProfileTemplateVersionPath)) + Expect(req.Method).To(Equal("GET")) - Expect(req.URL.Query()["type"]).To(Equal([]string{"inactive"})) - Expect(req.URL.Query()["duration"]).To(Equal([]string{"720"})) + // TODO: Add check for include_history query parameter // Sleep a short time to support a timeout test time.Sleep(100 * time.Millisecond) // Set mock response res.Header().Set("Content-type", "application/json") - res.WriteHeader(202) - fmt.Fprintf(res, "%s", `{"reference": "Reference"}`) + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"id": "ID", "version": 7, "account_id": "AccountID", "name": "Name", "description": "Description", "committed": false, "profile": {"name": "Name", "description": "Description", "rules": [{"name": "Name", "type": "Profile-SAML", "realm_name": "RealmName", "expiration": 10, "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}]}], "identities": [{"iam_id": "IamID", "identifier": "Identifier", "type": "user", "accounts": ["Accounts"], "description": "Description"}]}, "policy_template_references": [{"id": "ID", "version": "Version"}], "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "entity_tag": "EntityTag", "crn": "CRN", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID"}`) })) }) - It(`Invoke CreateReport successfully with retries`, func() { + It(`Invoke GetProfileTemplateVersion successfully with retries`, func() { iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -8397,23 +15155,23 @@ var _ = Describe(`IamIdentityV1`, func() { Expect(iamIdentityService).ToNot(BeNil()) iamIdentityService.EnableRetries(0, 0) - // Construct an instance of the CreateReportOptions model - createReportOptionsModel := new(iamidentityv1.CreateReportOptions) - createReportOptionsModel.AccountID = core.StringPtr("testString") - createReportOptionsModel.Type = core.StringPtr("inactive") - createReportOptionsModel.Duration = core.StringPtr("720") - createReportOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetProfileTemplateVersionOptions model + getProfileTemplateVersionOptionsModel := new(iamidentityv1.GetProfileTemplateVersionOptions) + getProfileTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + getProfileTemplateVersionOptionsModel.Version = core.StringPtr("testString") + getProfileTemplateVersionOptionsModel.IncludeHistory = core.BoolPtr(false) + getProfileTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := iamIdentityService.CreateReportWithContext(ctx, createReportOptionsModel) + _, _, operationErr := iamIdentityService.GetProfileTemplateVersionWithContext(ctx, getProfileTemplateVersionOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again iamIdentityService.DisableRetries() - result, response, operationErr := iamIdentityService.CreateReport(createReportOptionsModel) + result, response, operationErr := iamIdentityService.GetProfileTemplateVersion(getProfileTemplateVersionOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -8421,7 +15179,7 @@ var _ = Describe(`IamIdentityV1`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = iamIdentityService.CreateReportWithContext(ctx, createReportOptionsModel) + _, _, operationErr = iamIdentityService.GetProfileTemplateVersionWithContext(ctx, getProfileTemplateVersionOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -8435,18 +15193,17 @@ var _ = Describe(`IamIdentityV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createReportPath)) - Expect(req.Method).To(Equal("POST")) + Expect(req.URL.EscapedPath()).To(Equal(getProfileTemplateVersionPath)) + Expect(req.Method).To(Equal("GET")) - Expect(req.URL.Query()["type"]).To(Equal([]string{"inactive"})) - Expect(req.URL.Query()["duration"]).To(Equal([]string{"720"})) + // TODO: Add check for include_history query parameter // Set mock response res.Header().Set("Content-type", "application/json") - res.WriteHeader(202) - fmt.Fprintf(res, "%s", `{"reference": "Reference"}`) + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"id": "ID", "version": 7, "account_id": "AccountID", "name": "Name", "description": "Description", "committed": false, "profile": {"name": "Name", "description": "Description", "rules": [{"name": "Name", "type": "Profile-SAML", "realm_name": "RealmName", "expiration": 10, "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}]}], "identities": [{"iam_id": "IamID", "identifier": "Identifier", "type": "user", "accounts": ["Accounts"], "description": "Description"}]}, "policy_template_references": [{"id": "ID", "version": "Version"}], "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "entity_tag": "EntityTag", "crn": "CRN", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID"}`) })) }) - It(`Invoke CreateReport successfully`, func() { + It(`Invoke GetProfileTemplateVersion successfully`, func() { iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -8455,26 +15212,26 @@ var _ = Describe(`IamIdentityV1`, func() { Expect(iamIdentityService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := iamIdentityService.CreateReport(nil) + result, response, operationErr := iamIdentityService.GetProfileTemplateVersion(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the CreateReportOptions model - createReportOptionsModel := new(iamidentityv1.CreateReportOptions) - createReportOptionsModel.AccountID = core.StringPtr("testString") - createReportOptionsModel.Type = core.StringPtr("inactive") - createReportOptionsModel.Duration = core.StringPtr("720") - createReportOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetProfileTemplateVersionOptions model + getProfileTemplateVersionOptionsModel := new(iamidentityv1.GetProfileTemplateVersionOptions) + getProfileTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + getProfileTemplateVersionOptionsModel.Version = core.StringPtr("testString") + getProfileTemplateVersionOptionsModel.IncludeHistory = core.BoolPtr(false) + getProfileTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = iamIdentityService.CreateReport(createReportOptionsModel) + result, response, operationErr = iamIdentityService.GetProfileTemplateVersion(getProfileTemplateVersionOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke CreateReport with error: Operation validation and request error`, func() { + It(`Invoke GetProfileTemplateVersion with error: Operation validation and request error`, func() { iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -8482,24 +15239,24 @@ var _ = Describe(`IamIdentityV1`, func() { Expect(serviceErr).To(BeNil()) Expect(iamIdentityService).ToNot(BeNil()) - // Construct an instance of the CreateReportOptions model - createReportOptionsModel := new(iamidentityv1.CreateReportOptions) - createReportOptionsModel.AccountID = core.StringPtr("testString") - createReportOptionsModel.Type = core.StringPtr("inactive") - createReportOptionsModel.Duration = core.StringPtr("720") - createReportOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetProfileTemplateVersionOptions model + getProfileTemplateVersionOptionsModel := new(iamidentityv1.GetProfileTemplateVersionOptions) + getProfileTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + getProfileTemplateVersionOptionsModel.Version = core.StringPtr("testString") + getProfileTemplateVersionOptionsModel.IncludeHistory = core.BoolPtr(false) + getProfileTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := iamIdentityService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := iamIdentityService.CreateReport(createReportOptionsModel) + result, response, operationErr := iamIdentityService.GetProfileTemplateVersion(getProfileTemplateVersionOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct a second instance of the CreateReportOptions model with no property values - createReportOptionsModelNew := new(iamidentityv1.CreateReportOptions) + // Construct a second instance of the GetProfileTemplateVersionOptions model with no property values + getProfileTemplateVersionOptionsModelNew := new(iamidentityv1.GetProfileTemplateVersionOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = iamIdentityService.CreateReport(createReportOptionsModelNew) + result, response, operationErr = iamIdentityService.GetProfileTemplateVersion(getProfileTemplateVersionOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -8514,10 +15271,10 @@ var _ = Describe(`IamIdentityV1`, func() { defer GinkgoRecover() // Set success status code with no respoonse body - res.WriteHeader(202) + res.WriteHeader(200) })) }) - It(`Invoke CreateReport successfully`, func() { + It(`Invoke GetProfileTemplateVersion successfully`, func() { iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -8525,42 +15282,330 @@ var _ = Describe(`IamIdentityV1`, func() { Expect(serviceErr).To(BeNil()) Expect(iamIdentityService).ToNot(BeNil()) - // Construct an instance of the CreateReportOptions model - createReportOptionsModel := new(iamidentityv1.CreateReportOptions) - createReportOptionsModel.AccountID = core.StringPtr("testString") - createReportOptionsModel.Type = core.StringPtr("inactive") - createReportOptionsModel.Duration = core.StringPtr("720") - createReportOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetProfileTemplateVersionOptions model + getProfileTemplateVersionOptionsModel := new(iamidentityv1.GetProfileTemplateVersionOptions) + getProfileTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + getProfileTemplateVersionOptionsModel.Version = core.StringPtr("testString") + getProfileTemplateVersionOptionsModel.IncludeHistory = core.BoolPtr(false) + getProfileTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamIdentityService.GetProfileTemplateVersion(getProfileTemplateVersionOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`UpdateProfileTemplateVersion(updateProfileTemplateVersionOptions *UpdateProfileTemplateVersionOptions) - Operation response error`, func() { + updateProfileTemplateVersionPath := "/v1/profile_templates/testString/versions/testString" + Context(`Using mock server endpoint with invalid JSON response`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(updateProfileTemplateVersionPath)) + Expect(req.Method).To(Equal("PUT")) + Expect(req.Header["If-Match"]).ToNot(BeNil()) + Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke UpdateProfileTemplateVersion with error: Operation response processing error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Construct an instance of the ProfileClaimRuleConditions model + profileClaimRuleConditionsModel := new(iamidentityv1.ProfileClaimRuleConditions) + profileClaimRuleConditionsModel.Claim = core.StringPtr("testString") + profileClaimRuleConditionsModel.Operator = core.StringPtr("testString") + profileClaimRuleConditionsModel.Value = core.StringPtr("testString") + + // Construct an instance of the TrustedProfileTemplateClaimRule model + trustedProfileTemplateClaimRuleModel := new(iamidentityv1.TrustedProfileTemplateClaimRule) + trustedProfileTemplateClaimRuleModel.Name = core.StringPtr("testString") + trustedProfileTemplateClaimRuleModel.Type = core.StringPtr("Profile-SAML") + trustedProfileTemplateClaimRuleModel.RealmName = core.StringPtr("testString") + trustedProfileTemplateClaimRuleModel.Expiration = core.Int64Ptr(int64(38)) + trustedProfileTemplateClaimRuleModel.Conditions = []iamidentityv1.ProfileClaimRuleConditions{*profileClaimRuleConditionsModel} + + // Construct an instance of the ProfileIdentityRequest model + profileIdentityRequestModel := new(iamidentityv1.ProfileIdentityRequest) + profileIdentityRequestModel.Identifier = core.StringPtr("testString") + profileIdentityRequestModel.Type = core.StringPtr("user") + profileIdentityRequestModel.Accounts = []string{"testString"} + profileIdentityRequestModel.Description = core.StringPtr("testString") + + // Construct an instance of the TemplateProfileComponentRequest model + templateProfileComponentRequestModel := new(iamidentityv1.TemplateProfileComponentRequest) + templateProfileComponentRequestModel.Name = core.StringPtr("testString") + templateProfileComponentRequestModel.Description = core.StringPtr("testString") + templateProfileComponentRequestModel.Rules = []iamidentityv1.TrustedProfileTemplateClaimRule{*trustedProfileTemplateClaimRuleModel} + templateProfileComponentRequestModel.Identities = []iamidentityv1.ProfileIdentityRequest{*profileIdentityRequestModel} + + // Construct an instance of the PolicyTemplateReference model + policyTemplateReferenceModel := new(iamidentityv1.PolicyTemplateReference) + policyTemplateReferenceModel.ID = core.StringPtr("testString") + policyTemplateReferenceModel.Version = core.StringPtr("testString") + + // Construct an instance of the UpdateProfileTemplateVersionOptions model + updateProfileTemplateVersionOptionsModel := new(iamidentityv1.UpdateProfileTemplateVersionOptions) + updateProfileTemplateVersionOptionsModel.IfMatch = core.StringPtr("testString") + updateProfileTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + updateProfileTemplateVersionOptionsModel.Version = core.StringPtr("testString") + updateProfileTemplateVersionOptionsModel.AccountID = core.StringPtr("testString") + updateProfileTemplateVersionOptionsModel.Name = core.StringPtr("testString") + updateProfileTemplateVersionOptionsModel.Description = core.StringPtr("testString") + updateProfileTemplateVersionOptionsModel.Profile = templateProfileComponentRequestModel + updateProfileTemplateVersionOptionsModel.PolicyTemplateReferences = []iamidentityv1.PolicyTemplateReference{*policyTemplateReferenceModel} + updateProfileTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := iamIdentityService.UpdateProfileTemplateVersion(updateProfileTemplateVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + iamIdentityService.EnableRetries(0, 0) + result, response, operationErr = iamIdentityService.UpdateProfileTemplateVersion(updateProfileTemplateVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`UpdateProfileTemplateVersion(updateProfileTemplateVersionOptions *UpdateProfileTemplateVersionOptions)`, func() { + updateProfileTemplateVersionPath := "/v1/profile_templates/testString/versions/testString" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(updateProfileTemplateVersionPath)) + Expect(req.Method).To(Equal("PUT")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + + Expect(req.Header["If-Match"]).ToNot(BeNil()) + Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"id": "ID", "version": 7, "account_id": "AccountID", "name": "Name", "description": "Description", "committed": false, "profile": {"name": "Name", "description": "Description", "rules": [{"name": "Name", "type": "Profile-SAML", "realm_name": "RealmName", "expiration": 10, "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}]}], "identities": [{"iam_id": "IamID", "identifier": "Identifier", "type": "user", "accounts": ["Accounts"], "description": "Description"}]}, "policy_template_references": [{"id": "ID", "version": "Version"}], "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "entity_tag": "EntityTag", "crn": "CRN", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID"}`) + })) + }) + It(`Invoke UpdateProfileTemplateVersion successfully with retries`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + iamIdentityService.EnableRetries(0, 0) + + // Construct an instance of the ProfileClaimRuleConditions model + profileClaimRuleConditionsModel := new(iamidentityv1.ProfileClaimRuleConditions) + profileClaimRuleConditionsModel.Claim = core.StringPtr("testString") + profileClaimRuleConditionsModel.Operator = core.StringPtr("testString") + profileClaimRuleConditionsModel.Value = core.StringPtr("testString") + + // Construct an instance of the TrustedProfileTemplateClaimRule model + trustedProfileTemplateClaimRuleModel := new(iamidentityv1.TrustedProfileTemplateClaimRule) + trustedProfileTemplateClaimRuleModel.Name = core.StringPtr("testString") + trustedProfileTemplateClaimRuleModel.Type = core.StringPtr("Profile-SAML") + trustedProfileTemplateClaimRuleModel.RealmName = core.StringPtr("testString") + trustedProfileTemplateClaimRuleModel.Expiration = core.Int64Ptr(int64(38)) + trustedProfileTemplateClaimRuleModel.Conditions = []iamidentityv1.ProfileClaimRuleConditions{*profileClaimRuleConditionsModel} + + // Construct an instance of the ProfileIdentityRequest model + profileIdentityRequestModel := new(iamidentityv1.ProfileIdentityRequest) + profileIdentityRequestModel.Identifier = core.StringPtr("testString") + profileIdentityRequestModel.Type = core.StringPtr("user") + profileIdentityRequestModel.Accounts = []string{"testString"} + profileIdentityRequestModel.Description = core.StringPtr("testString") + + // Construct an instance of the TemplateProfileComponentRequest model + templateProfileComponentRequestModel := new(iamidentityv1.TemplateProfileComponentRequest) + templateProfileComponentRequestModel.Name = core.StringPtr("testString") + templateProfileComponentRequestModel.Description = core.StringPtr("testString") + templateProfileComponentRequestModel.Rules = []iamidentityv1.TrustedProfileTemplateClaimRule{*trustedProfileTemplateClaimRuleModel} + templateProfileComponentRequestModel.Identities = []iamidentityv1.ProfileIdentityRequest{*profileIdentityRequestModel} + + // Construct an instance of the PolicyTemplateReference model + policyTemplateReferenceModel := new(iamidentityv1.PolicyTemplateReference) + policyTemplateReferenceModel.ID = core.StringPtr("testString") + policyTemplateReferenceModel.Version = core.StringPtr("testString") + + // Construct an instance of the UpdateProfileTemplateVersionOptions model + updateProfileTemplateVersionOptionsModel := new(iamidentityv1.UpdateProfileTemplateVersionOptions) + updateProfileTemplateVersionOptionsModel.IfMatch = core.StringPtr("testString") + updateProfileTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + updateProfileTemplateVersionOptionsModel.Version = core.StringPtr("testString") + updateProfileTemplateVersionOptionsModel.AccountID = core.StringPtr("testString") + updateProfileTemplateVersionOptionsModel.Name = core.StringPtr("testString") + updateProfileTemplateVersionOptionsModel.Description = core.StringPtr("testString") + updateProfileTemplateVersionOptionsModel.Profile = templateProfileComponentRequestModel + updateProfileTemplateVersionOptionsModel.PolicyTemplateReferences = []iamidentityv1.PolicyTemplateReference{*policyTemplateReferenceModel} + updateProfileTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := iamIdentityService.UpdateProfileTemplateVersionWithContext(ctx, updateProfileTemplateVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + iamIdentityService.DisableRetries() + result, response, operationErr := iamIdentityService.UpdateProfileTemplateVersion(updateProfileTemplateVersionOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = iamIdentityService.UpdateProfileTemplateVersionWithContext(ctx, updateProfileTemplateVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(updateProfileTemplateVersionPath)) + Expect(req.Method).To(Equal("PUT")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + + Expect(req.Header["If-Match"]).ToNot(BeNil()) + Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"id": "ID", "version": 7, "account_id": "AccountID", "name": "Name", "description": "Description", "committed": false, "profile": {"name": "Name", "description": "Description", "rules": [{"name": "Name", "type": "Profile-SAML", "realm_name": "RealmName", "expiration": 10, "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}]}], "identities": [{"iam_id": "IamID", "identifier": "Identifier", "type": "user", "accounts": ["Accounts"], "description": "Description"}]}, "policy_template_references": [{"id": "ID", "version": "Version"}], "history": [{"timestamp": "Timestamp", "iam_id": "IamID", "iam_id_account": "IamIDAccount", "action": "Action", "params": ["Params"], "message": "Message"}], "entity_tag": "EntityTag", "crn": "CRN", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID"}`) + })) + }) + It(`Invoke UpdateProfileTemplateVersion successfully`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := iamIdentityService.UpdateProfileTemplateVersion(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the ProfileClaimRuleConditions model + profileClaimRuleConditionsModel := new(iamidentityv1.ProfileClaimRuleConditions) + profileClaimRuleConditionsModel.Claim = core.StringPtr("testString") + profileClaimRuleConditionsModel.Operator = core.StringPtr("testString") + profileClaimRuleConditionsModel.Value = core.StringPtr("testString") + + // Construct an instance of the TrustedProfileTemplateClaimRule model + trustedProfileTemplateClaimRuleModel := new(iamidentityv1.TrustedProfileTemplateClaimRule) + trustedProfileTemplateClaimRuleModel.Name = core.StringPtr("testString") + trustedProfileTemplateClaimRuleModel.Type = core.StringPtr("Profile-SAML") + trustedProfileTemplateClaimRuleModel.RealmName = core.StringPtr("testString") + trustedProfileTemplateClaimRuleModel.Expiration = core.Int64Ptr(int64(38)) + trustedProfileTemplateClaimRuleModel.Conditions = []iamidentityv1.ProfileClaimRuleConditions{*profileClaimRuleConditionsModel} + + // Construct an instance of the ProfileIdentityRequest model + profileIdentityRequestModel := new(iamidentityv1.ProfileIdentityRequest) + profileIdentityRequestModel.Identifier = core.StringPtr("testString") + profileIdentityRequestModel.Type = core.StringPtr("user") + profileIdentityRequestModel.Accounts = []string{"testString"} + profileIdentityRequestModel.Description = core.StringPtr("testString") + + // Construct an instance of the TemplateProfileComponentRequest model + templateProfileComponentRequestModel := new(iamidentityv1.TemplateProfileComponentRequest) + templateProfileComponentRequestModel.Name = core.StringPtr("testString") + templateProfileComponentRequestModel.Description = core.StringPtr("testString") + templateProfileComponentRequestModel.Rules = []iamidentityv1.TrustedProfileTemplateClaimRule{*trustedProfileTemplateClaimRuleModel} + templateProfileComponentRequestModel.Identities = []iamidentityv1.ProfileIdentityRequest{*profileIdentityRequestModel} + + // Construct an instance of the PolicyTemplateReference model + policyTemplateReferenceModel := new(iamidentityv1.PolicyTemplateReference) + policyTemplateReferenceModel.ID = core.StringPtr("testString") + policyTemplateReferenceModel.Version = core.StringPtr("testString") + + // Construct an instance of the UpdateProfileTemplateVersionOptions model + updateProfileTemplateVersionOptionsModel := new(iamidentityv1.UpdateProfileTemplateVersionOptions) + updateProfileTemplateVersionOptionsModel.IfMatch = core.StringPtr("testString") + updateProfileTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + updateProfileTemplateVersionOptionsModel.Version = core.StringPtr("testString") + updateProfileTemplateVersionOptionsModel.AccountID = core.StringPtr("testString") + updateProfileTemplateVersionOptionsModel.Name = core.StringPtr("testString") + updateProfileTemplateVersionOptionsModel.Description = core.StringPtr("testString") + updateProfileTemplateVersionOptionsModel.Profile = templateProfileComponentRequestModel + updateProfileTemplateVersionOptionsModel.PolicyTemplateReferences = []iamidentityv1.PolicyTemplateReference{*policyTemplateReferenceModel} + updateProfileTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - // Invoke operation - result, response, operationErr := iamIdentityService.CreateReport(createReportOptionsModel) + // Invoke operation with valid options model (positive test) + result, response, operationErr = iamIdentityService.UpdateProfileTemplateVersion(updateProfileTemplateVersionOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) - // Verify a nil result - Expect(result).To(BeNil()) - }) - AfterEach(func() { - testServer.Close() - }) - }) - }) - Describe(`GetReport(getReportOptions *GetReportOptions) - Operation response error`, func() { - getReportPath := "/v1/activity/accounts/testString/report/testString" - Context(`Using mock server endpoint with invalid JSON response`, func() { - BeforeEach(func() { - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getReportPath)) - Expect(req.Method).To(Equal("GET")) - res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - fmt.Fprint(res, `} this is not valid json {`) - })) }) - It(`Invoke GetReport with error: Operation response processing error`, func() { + It(`Invoke UpdateProfileTemplateVersion with error: Operation validation and request error`, func() { iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -8568,105 +15613,160 @@ var _ = Describe(`IamIdentityV1`, func() { Expect(serviceErr).To(BeNil()) Expect(iamIdentityService).ToNot(BeNil()) - // Construct an instance of the GetReportOptions model - getReportOptionsModel := new(iamidentityv1.GetReportOptions) - getReportOptionsModel.AccountID = core.StringPtr("testString") - getReportOptionsModel.Reference = core.StringPtr("testString") - getReportOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := iamIdentityService.GetReport(getReportOptionsModel) + // Construct an instance of the ProfileClaimRuleConditions model + profileClaimRuleConditionsModel := new(iamidentityv1.ProfileClaimRuleConditions) + profileClaimRuleConditionsModel.Claim = core.StringPtr("testString") + profileClaimRuleConditionsModel.Operator = core.StringPtr("testString") + profileClaimRuleConditionsModel.Value = core.StringPtr("testString") + + // Construct an instance of the TrustedProfileTemplateClaimRule model + trustedProfileTemplateClaimRuleModel := new(iamidentityv1.TrustedProfileTemplateClaimRule) + trustedProfileTemplateClaimRuleModel.Name = core.StringPtr("testString") + trustedProfileTemplateClaimRuleModel.Type = core.StringPtr("Profile-SAML") + trustedProfileTemplateClaimRuleModel.RealmName = core.StringPtr("testString") + trustedProfileTemplateClaimRuleModel.Expiration = core.Int64Ptr(int64(38)) + trustedProfileTemplateClaimRuleModel.Conditions = []iamidentityv1.ProfileClaimRuleConditions{*profileClaimRuleConditionsModel} + + // Construct an instance of the ProfileIdentityRequest model + profileIdentityRequestModel := new(iamidentityv1.ProfileIdentityRequest) + profileIdentityRequestModel.Identifier = core.StringPtr("testString") + profileIdentityRequestModel.Type = core.StringPtr("user") + profileIdentityRequestModel.Accounts = []string{"testString"} + profileIdentityRequestModel.Description = core.StringPtr("testString") + + // Construct an instance of the TemplateProfileComponentRequest model + templateProfileComponentRequestModel := new(iamidentityv1.TemplateProfileComponentRequest) + templateProfileComponentRequestModel.Name = core.StringPtr("testString") + templateProfileComponentRequestModel.Description = core.StringPtr("testString") + templateProfileComponentRequestModel.Rules = []iamidentityv1.TrustedProfileTemplateClaimRule{*trustedProfileTemplateClaimRuleModel} + templateProfileComponentRequestModel.Identities = []iamidentityv1.ProfileIdentityRequest{*profileIdentityRequestModel} + + // Construct an instance of the PolicyTemplateReference model + policyTemplateReferenceModel := new(iamidentityv1.PolicyTemplateReference) + policyTemplateReferenceModel.ID = core.StringPtr("testString") + policyTemplateReferenceModel.Version = core.StringPtr("testString") + + // Construct an instance of the UpdateProfileTemplateVersionOptions model + updateProfileTemplateVersionOptionsModel := new(iamidentityv1.UpdateProfileTemplateVersionOptions) + updateProfileTemplateVersionOptionsModel.IfMatch = core.StringPtr("testString") + updateProfileTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + updateProfileTemplateVersionOptionsModel.Version = core.StringPtr("testString") + updateProfileTemplateVersionOptionsModel.AccountID = core.StringPtr("testString") + updateProfileTemplateVersionOptionsModel.Name = core.StringPtr("testString") + updateProfileTemplateVersionOptionsModel.Description = core.StringPtr("testString") + updateProfileTemplateVersionOptionsModel.Profile = templateProfileComponentRequestModel + updateProfileTemplateVersionOptionsModel.PolicyTemplateReferences = []iamidentityv1.PolicyTemplateReference{*policyTemplateReferenceModel} + updateProfileTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := iamIdentityService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := iamIdentityService.UpdateProfileTemplateVersion(updateProfileTemplateVersionOptionsModel) Expect(operationErr).ToNot(BeNil()) - Expect(response).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) Expect(result).To(BeNil()) - - // Enable retries and test again - iamIdentityService.EnableRetries(0, 0) - result, response, operationErr = iamIdentityService.GetReport(getReportOptionsModel) + // Construct a second instance of the UpdateProfileTemplateVersionOptions model with no property values + updateProfileTemplateVersionOptionsModelNew := new(iamidentityv1.UpdateProfileTemplateVersionOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = iamIdentityService.UpdateProfileTemplateVersion(updateProfileTemplateVersionOptionsModelNew) Expect(operationErr).ToNot(BeNil()) - Expect(response).ToNot(BeNil()) + Expect(response).To(BeNil()) Expect(result).To(BeNil()) }) AfterEach(func() { testServer.Close() }) }) - }) - Describe(`GetReport(getReportOptions *GetReportOptions)`, func() { - getReportPath := "/v1/activity/accounts/testString/report/testString" - Context(`Using mock server endpoint with timeout`, func() { + Context(`Using mock server endpoint with missing response body`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() - // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getReportPath)) - Expect(req.Method).To(Equal("GET")) - - // Sleep a short time to support a timeout test - time.Sleep(100 * time.Millisecond) - - // Set mock response - res.Header().Set("Content-type", "application/json") + // Set success status code with no respoonse body res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"created_by": "CreatedBy", "reference": "Reference", "report_duration": "ReportDuration", "report_start_time": "ReportStartTime", "report_end_time": "ReportEndTime", "users": [{"iam_id": "IamID", "name": "Name", "username": "Username", "email": "Email", "last_authn": "LastAuthn"}], "apikeys": [{"id": "ID", "name": "Name", "type": "Type", "serviceid": {"id": "ID", "name": "Name"}, "user": {"iam_id": "IamID", "name": "Name", "username": "Username", "email": "Email"}, "last_authn": "LastAuthn"}], "serviceids": [{"id": "ID", "name": "Name", "last_authn": "LastAuthn"}], "profiles": [{"id": "ID", "name": "Name", "last_authn": "LastAuthn"}]}`) })) }) - It(`Invoke GetReport successfully with retries`, func() { + It(`Invoke UpdateProfileTemplateVersion successfully`, func() { iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, }) Expect(serviceErr).To(BeNil()) Expect(iamIdentityService).ToNot(BeNil()) - iamIdentityService.EnableRetries(0, 0) - // Construct an instance of the GetReportOptions model - getReportOptionsModel := new(iamidentityv1.GetReportOptions) - getReportOptionsModel.AccountID = core.StringPtr("testString") - getReportOptionsModel.Reference = core.StringPtr("testString") - getReportOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ProfileClaimRuleConditions model + profileClaimRuleConditionsModel := new(iamidentityv1.ProfileClaimRuleConditions) + profileClaimRuleConditionsModel.Claim = core.StringPtr("testString") + profileClaimRuleConditionsModel.Operator = core.StringPtr("testString") + profileClaimRuleConditionsModel.Value = core.StringPtr("testString") - // Invoke operation with a Context to test a timeout error - ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) - defer cancelFunc() - _, _, operationErr := iamIdentityService.GetReportWithContext(ctx, getReportOptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + // Construct an instance of the TrustedProfileTemplateClaimRule model + trustedProfileTemplateClaimRuleModel := new(iamidentityv1.TrustedProfileTemplateClaimRule) + trustedProfileTemplateClaimRuleModel.Name = core.StringPtr("testString") + trustedProfileTemplateClaimRuleModel.Type = core.StringPtr("Profile-SAML") + trustedProfileTemplateClaimRuleModel.RealmName = core.StringPtr("testString") + trustedProfileTemplateClaimRuleModel.Expiration = core.Int64Ptr(int64(38)) + trustedProfileTemplateClaimRuleModel.Conditions = []iamidentityv1.ProfileClaimRuleConditions{*profileClaimRuleConditionsModel} + + // Construct an instance of the ProfileIdentityRequest model + profileIdentityRequestModel := new(iamidentityv1.ProfileIdentityRequest) + profileIdentityRequestModel.Identifier = core.StringPtr("testString") + profileIdentityRequestModel.Type = core.StringPtr("user") + profileIdentityRequestModel.Accounts = []string{"testString"} + profileIdentityRequestModel.Description = core.StringPtr("testString") + + // Construct an instance of the TemplateProfileComponentRequest model + templateProfileComponentRequestModel := new(iamidentityv1.TemplateProfileComponentRequest) + templateProfileComponentRequestModel.Name = core.StringPtr("testString") + templateProfileComponentRequestModel.Description = core.StringPtr("testString") + templateProfileComponentRequestModel.Rules = []iamidentityv1.TrustedProfileTemplateClaimRule{*trustedProfileTemplateClaimRuleModel} + templateProfileComponentRequestModel.Identities = []iamidentityv1.ProfileIdentityRequest{*profileIdentityRequestModel} + + // Construct an instance of the PolicyTemplateReference model + policyTemplateReferenceModel := new(iamidentityv1.PolicyTemplateReference) + policyTemplateReferenceModel.ID = core.StringPtr("testString") + policyTemplateReferenceModel.Version = core.StringPtr("testString") + + // Construct an instance of the UpdateProfileTemplateVersionOptions model + updateProfileTemplateVersionOptionsModel := new(iamidentityv1.UpdateProfileTemplateVersionOptions) + updateProfileTemplateVersionOptionsModel.IfMatch = core.StringPtr("testString") + updateProfileTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + updateProfileTemplateVersionOptionsModel.Version = core.StringPtr("testString") + updateProfileTemplateVersionOptionsModel.AccountID = core.StringPtr("testString") + updateProfileTemplateVersionOptionsModel.Name = core.StringPtr("testString") + updateProfileTemplateVersionOptionsModel.Description = core.StringPtr("testString") + updateProfileTemplateVersionOptionsModel.Profile = templateProfileComponentRequestModel + updateProfileTemplateVersionOptionsModel.PolicyTemplateReferences = []iamidentityv1.PolicyTemplateReference{*policyTemplateReferenceModel} + updateProfileTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - // Disable retries and test again - iamIdentityService.DisableRetries() - result, response, operationErr := iamIdentityService.GetReport(getReportOptionsModel) + // Invoke operation + result, response, operationErr := iamIdentityService.UpdateProfileTemplateVersion(updateProfileTemplateVersionOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) - Expect(result).ToNot(BeNil()) - // Re-test the timeout error with retries disabled - ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) - defer cancelFunc2() - _, _, operationErr = iamIdentityService.GetReportWithContext(ctx, getReportOptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + // Verify a nil result + Expect(result).To(BeNil()) }) AfterEach(func() { testServer.Close() }) }) + }) + Describe(`DeleteProfileTemplateVersion(deleteProfileTemplateVersionOptions *DeleteProfileTemplateVersionOptions)`, func() { + deleteProfileTemplateVersionPath := "/v1/profile_templates/testString/versions/testString" Context(`Using mock server endpoint`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getReportPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(deleteProfileTemplateVersionPath)) + Expect(req.Method).To(Equal("DELETE")) - // Set mock response - res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"created_by": "CreatedBy", "reference": "Reference", "report_duration": "ReportDuration", "report_start_time": "ReportStartTime", "report_end_time": "ReportEndTime", "users": [{"iam_id": "IamID", "name": "Name", "username": "Username", "email": "Email", "last_authn": "LastAuthn"}], "apikeys": [{"id": "ID", "name": "Name", "type": "Type", "serviceid": {"id": "ID", "name": "Name"}, "user": {"iam_id": "IamID", "name": "Name", "username": "Username", "email": "Email"}, "last_authn": "LastAuthn"}], "serviceids": [{"id": "ID", "name": "Name", "last_authn": "LastAuthn"}], "profiles": [{"id": "ID", "name": "Name", "last_authn": "LastAuthn"}]}`) + res.WriteHeader(204) })) }) - It(`Invoke GetReport successfully`, func() { + It(`Invoke DeleteProfileTemplateVersion successfully`, func() { iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -8675,25 +15775,22 @@ var _ = Describe(`IamIdentityV1`, func() { Expect(iamIdentityService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := iamIdentityService.GetReport(nil) + response, operationErr := iamIdentityService.DeleteProfileTemplateVersion(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) - Expect(result).To(BeNil()) - // Construct an instance of the GetReportOptions model - getReportOptionsModel := new(iamidentityv1.GetReportOptions) - getReportOptionsModel.AccountID = core.StringPtr("testString") - getReportOptionsModel.Reference = core.StringPtr("testString") - getReportOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the DeleteProfileTemplateVersionOptions model + deleteProfileTemplateVersionOptionsModel := new(iamidentityv1.DeleteProfileTemplateVersionOptions) + deleteProfileTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + deleteProfileTemplateVersionOptionsModel.Version = core.StringPtr("testString") + deleteProfileTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = iamIdentityService.GetReport(getReportOptionsModel) + response, operationErr = iamIdentityService.DeleteProfileTemplateVersion(deleteProfileTemplateVersionOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) - Expect(result).ToNot(BeNil()) - }) - It(`Invoke GetReport with error: Operation validation and request error`, func() { + It(`Invoke DeleteProfileTemplateVersion with error: Operation validation and request error`, func() { iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -8701,41 +15798,45 @@ var _ = Describe(`IamIdentityV1`, func() { Expect(serviceErr).To(BeNil()) Expect(iamIdentityService).ToNot(BeNil()) - // Construct an instance of the GetReportOptions model - getReportOptionsModel := new(iamidentityv1.GetReportOptions) - getReportOptionsModel.AccountID = core.StringPtr("testString") - getReportOptionsModel.Reference = core.StringPtr("testString") - getReportOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the DeleteProfileTemplateVersionOptions model + deleteProfileTemplateVersionOptionsModel := new(iamidentityv1.DeleteProfileTemplateVersionOptions) + deleteProfileTemplateVersionOptionsModel.TemplateID = core.StringPtr("testString") + deleteProfileTemplateVersionOptionsModel.Version = core.StringPtr("testString") + deleteProfileTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := iamIdentityService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := iamIdentityService.GetReport(getReportOptionsModel) + response, operationErr := iamIdentityService.DeleteProfileTemplateVersion(deleteProfileTemplateVersionOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) - Expect(result).To(BeNil()) - // Construct a second instance of the GetReportOptions model with no property values - getReportOptionsModelNew := new(iamidentityv1.GetReportOptions) + // Construct a second instance of the DeleteProfileTemplateVersionOptions model with no property values + deleteProfileTemplateVersionOptionsModelNew := new(iamidentityv1.DeleteProfileTemplateVersionOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = iamIdentityService.GetReport(getReportOptionsModelNew) + response, operationErr = iamIdentityService.DeleteProfileTemplateVersion(deleteProfileTemplateVersionOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) - Expect(result).To(BeNil()) }) AfterEach(func() { testServer.Close() }) }) - Context(`Using mock server endpoint with missing response body`, func() { + }) + Describe(`CommitProfileTemplate(commitProfileTemplateOptions *CommitProfileTemplateOptions)`, func() { + commitProfileTemplatePath := "/v1/profile_templates/testString/versions/testString/commit" + Context(`Using mock server endpoint`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() - // Set success status code with no respoonse body - res.WriteHeader(200) + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(commitProfileTemplatePath)) + Expect(req.Method).To(Equal("POST")) + + res.WriteHeader(204) })) }) - It(`Invoke GetReport successfully`, func() { + It(`Invoke CommitProfileTemplate successfully`, func() { iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -8743,19 +15844,48 @@ var _ = Describe(`IamIdentityV1`, func() { Expect(serviceErr).To(BeNil()) Expect(iamIdentityService).ToNot(BeNil()) - // Construct an instance of the GetReportOptions model - getReportOptionsModel := new(iamidentityv1.GetReportOptions) - getReportOptionsModel.AccountID = core.StringPtr("testString") - getReportOptionsModel.Reference = core.StringPtr("testString") - getReportOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with nil options model (negative test) + response, operationErr := iamIdentityService.CommitProfileTemplate(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) - // Invoke operation - result, response, operationErr := iamIdentityService.GetReport(getReportOptionsModel) + // Construct an instance of the CommitProfileTemplateOptions model + commitProfileTemplateOptionsModel := new(iamidentityv1.CommitProfileTemplateOptions) + commitProfileTemplateOptionsModel.TemplateID = core.StringPtr("testString") + commitProfileTemplateOptionsModel.Version = core.StringPtr("testString") + commitProfileTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + response, operationErr = iamIdentityService.CommitProfileTemplate(commitProfileTemplateOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) + }) + It(`Invoke CommitProfileTemplate with error: Operation validation and request error`, func() { + iamIdentityService, serviceErr := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamIdentityService).ToNot(BeNil()) - // Verify a nil result - Expect(result).To(BeNil()) + // Construct an instance of the CommitProfileTemplateOptions model + commitProfileTemplateOptionsModel := new(iamidentityv1.CommitProfileTemplateOptions) + commitProfileTemplateOptionsModel.TemplateID = core.StringPtr("testString") + commitProfileTemplateOptionsModel.Version = core.StringPtr("testString") + commitProfileTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := iamIdentityService.SetServiceURL("") + Expect(err).To(BeNil()) + response, operationErr := iamIdentityService.CommitProfileTemplate(commitProfileTemplateOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + // Construct a second instance of the CommitProfileTemplateOptions model with no property values + commitProfileTemplateOptionsModelNew := new(iamidentityv1.CommitProfileTemplateOptions) + // Invoke operation with invalid model (negative test) + response, operationErr = iamIdentityService.CommitProfileTemplate(commitProfileTemplateOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) }) AfterEach(func() { testServer.Close() @@ -8781,6 +15911,148 @@ var _ = Describe(`IamIdentityV1`, func() { Expect(_model).ToNot(BeNil()) Expect(err).To(BeNil()) }) + It(`Invoke NewCommitAccountSettingsTemplateOptions successfully`, func() { + // Construct an instance of the CommitAccountSettingsTemplateOptions model + templateID := "testString" + version := "testString" + commitAccountSettingsTemplateOptionsModel := iamIdentityService.NewCommitAccountSettingsTemplateOptions(templateID, version) + commitAccountSettingsTemplateOptionsModel.SetTemplateID("testString") + commitAccountSettingsTemplateOptionsModel.SetVersion("testString") + commitAccountSettingsTemplateOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(commitAccountSettingsTemplateOptionsModel).ToNot(BeNil()) + Expect(commitAccountSettingsTemplateOptionsModel.TemplateID).To(Equal(core.StringPtr("testString"))) + Expect(commitAccountSettingsTemplateOptionsModel.Version).To(Equal(core.StringPtr("testString"))) + Expect(commitAccountSettingsTemplateOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) + It(`Invoke NewCommitProfileTemplateOptions successfully`, func() { + // Construct an instance of the CommitProfileTemplateOptions model + templateID := "testString" + version := "testString" + commitProfileTemplateOptionsModel := iamIdentityService.NewCommitProfileTemplateOptions(templateID, version) + commitProfileTemplateOptionsModel.SetTemplateID("testString") + commitProfileTemplateOptionsModel.SetVersion("testString") + commitProfileTemplateOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(commitProfileTemplateOptionsModel).ToNot(BeNil()) + Expect(commitProfileTemplateOptionsModel.TemplateID).To(Equal(core.StringPtr("testString"))) + Expect(commitProfileTemplateOptionsModel.Version).To(Equal(core.StringPtr("testString"))) + Expect(commitProfileTemplateOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) + It(`Invoke NewCreateAccountSettingsAssignmentOptions successfully`, func() { + // Construct an instance of the CreateAccountSettingsAssignmentOptions model + createAccountSettingsAssignmentOptionsTemplateID := "testString" + createAccountSettingsAssignmentOptionsTemplateVersion := int64(1) + createAccountSettingsAssignmentOptionsTargetType := "Account" + createAccountSettingsAssignmentOptionsTarget := "testString" + createAccountSettingsAssignmentOptionsModel := iamIdentityService.NewCreateAccountSettingsAssignmentOptions(createAccountSettingsAssignmentOptionsTemplateID, createAccountSettingsAssignmentOptionsTemplateVersion, createAccountSettingsAssignmentOptionsTargetType, createAccountSettingsAssignmentOptionsTarget) + createAccountSettingsAssignmentOptionsModel.SetTemplateID("testString") + createAccountSettingsAssignmentOptionsModel.SetTemplateVersion(int64(1)) + createAccountSettingsAssignmentOptionsModel.SetTargetType("Account") + createAccountSettingsAssignmentOptionsModel.SetTarget("testString") + createAccountSettingsAssignmentOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(createAccountSettingsAssignmentOptionsModel).ToNot(BeNil()) + Expect(createAccountSettingsAssignmentOptionsModel.TemplateID).To(Equal(core.StringPtr("testString"))) + Expect(createAccountSettingsAssignmentOptionsModel.TemplateVersion).To(Equal(core.Int64Ptr(int64(1)))) + Expect(createAccountSettingsAssignmentOptionsModel.TargetType).To(Equal(core.StringPtr("Account"))) + Expect(createAccountSettingsAssignmentOptionsModel.Target).To(Equal(core.StringPtr("testString"))) + Expect(createAccountSettingsAssignmentOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) + It(`Invoke NewCreateAccountSettingsTemplateOptions successfully`, func() { + // Construct an instance of the AccountSettingsUserMfa model + accountSettingsUserMfaModel := new(iamidentityv1.AccountSettingsUserMfa) + Expect(accountSettingsUserMfaModel).ToNot(BeNil()) + accountSettingsUserMfaModel.IamID = core.StringPtr("testString") + accountSettingsUserMfaModel.Mfa = core.StringPtr("NONE") + Expect(accountSettingsUserMfaModel.IamID).To(Equal(core.StringPtr("testString"))) + Expect(accountSettingsUserMfaModel.Mfa).To(Equal(core.StringPtr("NONE"))) + + // Construct an instance of the AccountSettingsComponent model + accountSettingsComponentModel := new(iamidentityv1.AccountSettingsComponent) + Expect(accountSettingsComponentModel).ToNot(BeNil()) + accountSettingsComponentModel.RestrictCreateServiceID = core.StringPtr("NOT_SET") + accountSettingsComponentModel.RestrictCreatePlatformApikey = core.StringPtr("NOT_SET") + accountSettingsComponentModel.AllowedIPAddresses = core.StringPtr("testString") + accountSettingsComponentModel.Mfa = core.StringPtr("NONE") + accountSettingsComponentModel.UserMfa = []iamidentityv1.AccountSettingsUserMfa{*accountSettingsUserMfaModel} + accountSettingsComponentModel.SessionExpirationInSeconds = core.StringPtr("86400") + accountSettingsComponentModel.SessionInvalidationInSeconds = core.StringPtr("7200") + accountSettingsComponentModel.MaxSessionsPerIdentity = core.StringPtr("testString") + accountSettingsComponentModel.SystemAccessTokenExpirationInSeconds = core.StringPtr("3600") + accountSettingsComponentModel.SystemRefreshTokenExpirationInSeconds = core.StringPtr("259200") + Expect(accountSettingsComponentModel.RestrictCreateServiceID).To(Equal(core.StringPtr("NOT_SET"))) + Expect(accountSettingsComponentModel.RestrictCreatePlatformApikey).To(Equal(core.StringPtr("NOT_SET"))) + Expect(accountSettingsComponentModel.AllowedIPAddresses).To(Equal(core.StringPtr("testString"))) + Expect(accountSettingsComponentModel.Mfa).To(Equal(core.StringPtr("NONE"))) + Expect(accountSettingsComponentModel.UserMfa).To(Equal([]iamidentityv1.AccountSettingsUserMfa{*accountSettingsUserMfaModel})) + Expect(accountSettingsComponentModel.SessionExpirationInSeconds).To(Equal(core.StringPtr("86400"))) + Expect(accountSettingsComponentModel.SessionInvalidationInSeconds).To(Equal(core.StringPtr("7200"))) + Expect(accountSettingsComponentModel.MaxSessionsPerIdentity).To(Equal(core.StringPtr("testString"))) + Expect(accountSettingsComponentModel.SystemAccessTokenExpirationInSeconds).To(Equal(core.StringPtr("3600"))) + Expect(accountSettingsComponentModel.SystemRefreshTokenExpirationInSeconds).To(Equal(core.StringPtr("259200"))) + + // Construct an instance of the CreateAccountSettingsTemplateOptions model + createAccountSettingsTemplateOptionsModel := iamIdentityService.NewCreateAccountSettingsTemplateOptions() + createAccountSettingsTemplateOptionsModel.SetAccountID("testString") + createAccountSettingsTemplateOptionsModel.SetName("testString") + createAccountSettingsTemplateOptionsModel.SetDescription("testString") + createAccountSettingsTemplateOptionsModel.SetAccountSettings(accountSettingsComponentModel) + createAccountSettingsTemplateOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(createAccountSettingsTemplateOptionsModel).ToNot(BeNil()) + Expect(createAccountSettingsTemplateOptionsModel.AccountID).To(Equal(core.StringPtr("testString"))) + Expect(createAccountSettingsTemplateOptionsModel.Name).To(Equal(core.StringPtr("testString"))) + Expect(createAccountSettingsTemplateOptionsModel.Description).To(Equal(core.StringPtr("testString"))) + Expect(createAccountSettingsTemplateOptionsModel.AccountSettings).To(Equal(accountSettingsComponentModel)) + Expect(createAccountSettingsTemplateOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) + It(`Invoke NewCreateAccountSettingsTemplateVersionOptions successfully`, func() { + // Construct an instance of the AccountSettingsUserMfa model + accountSettingsUserMfaModel := new(iamidentityv1.AccountSettingsUserMfa) + Expect(accountSettingsUserMfaModel).ToNot(BeNil()) + accountSettingsUserMfaModel.IamID = core.StringPtr("testString") + accountSettingsUserMfaModel.Mfa = core.StringPtr("NONE") + Expect(accountSettingsUserMfaModel.IamID).To(Equal(core.StringPtr("testString"))) + Expect(accountSettingsUserMfaModel.Mfa).To(Equal(core.StringPtr("NONE"))) + + // Construct an instance of the AccountSettingsComponent model + accountSettingsComponentModel := new(iamidentityv1.AccountSettingsComponent) + Expect(accountSettingsComponentModel).ToNot(BeNil()) + accountSettingsComponentModel.RestrictCreateServiceID = core.StringPtr("NOT_SET") + accountSettingsComponentModel.RestrictCreatePlatformApikey = core.StringPtr("NOT_SET") + accountSettingsComponentModel.AllowedIPAddresses = core.StringPtr("testString") + accountSettingsComponentModel.Mfa = core.StringPtr("NONE") + accountSettingsComponentModel.UserMfa = []iamidentityv1.AccountSettingsUserMfa{*accountSettingsUserMfaModel} + accountSettingsComponentModel.SessionExpirationInSeconds = core.StringPtr("86400") + accountSettingsComponentModel.SessionInvalidationInSeconds = core.StringPtr("7200") + accountSettingsComponentModel.MaxSessionsPerIdentity = core.StringPtr("testString") + accountSettingsComponentModel.SystemAccessTokenExpirationInSeconds = core.StringPtr("3600") + accountSettingsComponentModel.SystemRefreshTokenExpirationInSeconds = core.StringPtr("259200") + Expect(accountSettingsComponentModel.RestrictCreateServiceID).To(Equal(core.StringPtr("NOT_SET"))) + Expect(accountSettingsComponentModel.RestrictCreatePlatformApikey).To(Equal(core.StringPtr("NOT_SET"))) + Expect(accountSettingsComponentModel.AllowedIPAddresses).To(Equal(core.StringPtr("testString"))) + Expect(accountSettingsComponentModel.Mfa).To(Equal(core.StringPtr("NONE"))) + Expect(accountSettingsComponentModel.UserMfa).To(Equal([]iamidentityv1.AccountSettingsUserMfa{*accountSettingsUserMfaModel})) + Expect(accountSettingsComponentModel.SessionExpirationInSeconds).To(Equal(core.StringPtr("86400"))) + Expect(accountSettingsComponentModel.SessionInvalidationInSeconds).To(Equal(core.StringPtr("7200"))) + Expect(accountSettingsComponentModel.MaxSessionsPerIdentity).To(Equal(core.StringPtr("testString"))) + Expect(accountSettingsComponentModel.SystemAccessTokenExpirationInSeconds).To(Equal(core.StringPtr("3600"))) + Expect(accountSettingsComponentModel.SystemRefreshTokenExpirationInSeconds).To(Equal(core.StringPtr("259200"))) + + // Construct an instance of the CreateAccountSettingsTemplateVersionOptions model + templateID := "testString" + createAccountSettingsTemplateVersionOptionsModel := iamIdentityService.NewCreateAccountSettingsTemplateVersionOptions(templateID) + createAccountSettingsTemplateVersionOptionsModel.SetTemplateID("testString") + createAccountSettingsTemplateVersionOptionsModel.SetAccountID("testString") + createAccountSettingsTemplateVersionOptionsModel.SetName("testString") + createAccountSettingsTemplateVersionOptionsModel.SetDescription("testString") + createAccountSettingsTemplateVersionOptionsModel.SetAccountSettings(accountSettingsComponentModel) + createAccountSettingsTemplateVersionOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(createAccountSettingsTemplateVersionOptionsModel).ToNot(BeNil()) + Expect(createAccountSettingsTemplateVersionOptionsModel.TemplateID).To(Equal(core.StringPtr("testString"))) + Expect(createAccountSettingsTemplateVersionOptionsModel.AccountID).To(Equal(core.StringPtr("testString"))) + Expect(createAccountSettingsTemplateVersionOptionsModel.Name).To(Equal(core.StringPtr("testString"))) + Expect(createAccountSettingsTemplateVersionOptionsModel.Description).To(Equal(core.StringPtr("testString"))) + Expect(createAccountSettingsTemplateVersionOptionsModel.AccountSettings).To(Equal(accountSettingsComponentModel)) + Expect(createAccountSettingsTemplateVersionOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) It(`Invoke NewCreateAPIKeyOptions successfully`, func() { // Construct an instance of the CreateAPIKeyOptions model createAPIKeyOptionsName := "testString" @@ -8928,6 +16200,155 @@ var _ = Describe(`IamIdentityV1`, func() { Expect(createProfileOptionsModel.Description).To(Equal(core.StringPtr("testString"))) Expect(createProfileOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewCreateProfileTemplateOptions successfully`, func() { + // Construct an instance of the ProfileClaimRuleConditions model + profileClaimRuleConditionsModel := new(iamidentityv1.ProfileClaimRuleConditions) + Expect(profileClaimRuleConditionsModel).ToNot(BeNil()) + profileClaimRuleConditionsModel.Claim = core.StringPtr("testString") + profileClaimRuleConditionsModel.Operator = core.StringPtr("testString") + profileClaimRuleConditionsModel.Value = core.StringPtr("testString") + Expect(profileClaimRuleConditionsModel.Claim).To(Equal(core.StringPtr("testString"))) + Expect(profileClaimRuleConditionsModel.Operator).To(Equal(core.StringPtr("testString"))) + Expect(profileClaimRuleConditionsModel.Value).To(Equal(core.StringPtr("testString"))) + + // Construct an instance of the TrustedProfileTemplateClaimRule model + trustedProfileTemplateClaimRuleModel := new(iamidentityv1.TrustedProfileTemplateClaimRule) + Expect(trustedProfileTemplateClaimRuleModel).ToNot(BeNil()) + trustedProfileTemplateClaimRuleModel.Name = core.StringPtr("testString") + trustedProfileTemplateClaimRuleModel.Type = core.StringPtr("Profile-SAML") + trustedProfileTemplateClaimRuleModel.RealmName = core.StringPtr("testString") + trustedProfileTemplateClaimRuleModel.Expiration = core.Int64Ptr(int64(38)) + trustedProfileTemplateClaimRuleModel.Conditions = []iamidentityv1.ProfileClaimRuleConditions{*profileClaimRuleConditionsModel} + Expect(trustedProfileTemplateClaimRuleModel.Name).To(Equal(core.StringPtr("testString"))) + Expect(trustedProfileTemplateClaimRuleModel.Type).To(Equal(core.StringPtr("Profile-SAML"))) + Expect(trustedProfileTemplateClaimRuleModel.RealmName).To(Equal(core.StringPtr("testString"))) + Expect(trustedProfileTemplateClaimRuleModel.Expiration).To(Equal(core.Int64Ptr(int64(38)))) + Expect(trustedProfileTemplateClaimRuleModel.Conditions).To(Equal([]iamidentityv1.ProfileClaimRuleConditions{*profileClaimRuleConditionsModel})) + + // Construct an instance of the ProfileIdentityRequest model + profileIdentityRequestModel := new(iamidentityv1.ProfileIdentityRequest) + Expect(profileIdentityRequestModel).ToNot(BeNil()) + profileIdentityRequestModel.Identifier = core.StringPtr("testString") + profileIdentityRequestModel.Type = core.StringPtr("user") + profileIdentityRequestModel.Accounts = []string{"testString"} + profileIdentityRequestModel.Description = core.StringPtr("testString") + Expect(profileIdentityRequestModel.Identifier).To(Equal(core.StringPtr("testString"))) + Expect(profileIdentityRequestModel.Type).To(Equal(core.StringPtr("user"))) + Expect(profileIdentityRequestModel.Accounts).To(Equal([]string{"testString"})) + Expect(profileIdentityRequestModel.Description).To(Equal(core.StringPtr("testString"))) + + // Construct an instance of the TemplateProfileComponentRequest model + templateProfileComponentRequestModel := new(iamidentityv1.TemplateProfileComponentRequest) + Expect(templateProfileComponentRequestModel).ToNot(BeNil()) + templateProfileComponentRequestModel.Name = core.StringPtr("testString") + templateProfileComponentRequestModel.Description = core.StringPtr("testString") + templateProfileComponentRequestModel.Rules = []iamidentityv1.TrustedProfileTemplateClaimRule{*trustedProfileTemplateClaimRuleModel} + templateProfileComponentRequestModel.Identities = []iamidentityv1.ProfileIdentityRequest{*profileIdentityRequestModel} + Expect(templateProfileComponentRequestModel.Name).To(Equal(core.StringPtr("testString"))) + Expect(templateProfileComponentRequestModel.Description).To(Equal(core.StringPtr("testString"))) + Expect(templateProfileComponentRequestModel.Rules).To(Equal([]iamidentityv1.TrustedProfileTemplateClaimRule{*trustedProfileTemplateClaimRuleModel})) + Expect(templateProfileComponentRequestModel.Identities).To(Equal([]iamidentityv1.ProfileIdentityRequest{*profileIdentityRequestModel})) + + // Construct an instance of the PolicyTemplateReference model + policyTemplateReferenceModel := new(iamidentityv1.PolicyTemplateReference) + Expect(policyTemplateReferenceModel).ToNot(BeNil()) + policyTemplateReferenceModel.ID = core.StringPtr("testString") + policyTemplateReferenceModel.Version = core.StringPtr("testString") + Expect(policyTemplateReferenceModel.ID).To(Equal(core.StringPtr("testString"))) + Expect(policyTemplateReferenceModel.Version).To(Equal(core.StringPtr("testString"))) + + // Construct an instance of the CreateProfileTemplateOptions model + createProfileTemplateOptionsModel := iamIdentityService.NewCreateProfileTemplateOptions() + createProfileTemplateOptionsModel.SetAccountID("testString") + createProfileTemplateOptionsModel.SetName("testString") + createProfileTemplateOptionsModel.SetDescription("testString") + createProfileTemplateOptionsModel.SetProfile(templateProfileComponentRequestModel) + createProfileTemplateOptionsModel.SetPolicyTemplateReferences([]iamidentityv1.PolicyTemplateReference{*policyTemplateReferenceModel}) + createProfileTemplateOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(createProfileTemplateOptionsModel).ToNot(BeNil()) + Expect(createProfileTemplateOptionsModel.AccountID).To(Equal(core.StringPtr("testString"))) + Expect(createProfileTemplateOptionsModel.Name).To(Equal(core.StringPtr("testString"))) + Expect(createProfileTemplateOptionsModel.Description).To(Equal(core.StringPtr("testString"))) + Expect(createProfileTemplateOptionsModel.Profile).To(Equal(templateProfileComponentRequestModel)) + Expect(createProfileTemplateOptionsModel.PolicyTemplateReferences).To(Equal([]iamidentityv1.PolicyTemplateReference{*policyTemplateReferenceModel})) + Expect(createProfileTemplateOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) + It(`Invoke NewCreateProfileTemplateVersionOptions successfully`, func() { + // Construct an instance of the ProfileClaimRuleConditions model + profileClaimRuleConditionsModel := new(iamidentityv1.ProfileClaimRuleConditions) + Expect(profileClaimRuleConditionsModel).ToNot(BeNil()) + profileClaimRuleConditionsModel.Claim = core.StringPtr("testString") + profileClaimRuleConditionsModel.Operator = core.StringPtr("testString") + profileClaimRuleConditionsModel.Value = core.StringPtr("testString") + Expect(profileClaimRuleConditionsModel.Claim).To(Equal(core.StringPtr("testString"))) + Expect(profileClaimRuleConditionsModel.Operator).To(Equal(core.StringPtr("testString"))) + Expect(profileClaimRuleConditionsModel.Value).To(Equal(core.StringPtr("testString"))) + + // Construct an instance of the TrustedProfileTemplateClaimRule model + trustedProfileTemplateClaimRuleModel := new(iamidentityv1.TrustedProfileTemplateClaimRule) + Expect(trustedProfileTemplateClaimRuleModel).ToNot(BeNil()) + trustedProfileTemplateClaimRuleModel.Name = core.StringPtr("testString") + trustedProfileTemplateClaimRuleModel.Type = core.StringPtr("Profile-SAML") + trustedProfileTemplateClaimRuleModel.RealmName = core.StringPtr("testString") + trustedProfileTemplateClaimRuleModel.Expiration = core.Int64Ptr(int64(38)) + trustedProfileTemplateClaimRuleModel.Conditions = []iamidentityv1.ProfileClaimRuleConditions{*profileClaimRuleConditionsModel} + Expect(trustedProfileTemplateClaimRuleModel.Name).To(Equal(core.StringPtr("testString"))) + Expect(trustedProfileTemplateClaimRuleModel.Type).To(Equal(core.StringPtr("Profile-SAML"))) + Expect(trustedProfileTemplateClaimRuleModel.RealmName).To(Equal(core.StringPtr("testString"))) + Expect(trustedProfileTemplateClaimRuleModel.Expiration).To(Equal(core.Int64Ptr(int64(38)))) + Expect(trustedProfileTemplateClaimRuleModel.Conditions).To(Equal([]iamidentityv1.ProfileClaimRuleConditions{*profileClaimRuleConditionsModel})) + + // Construct an instance of the ProfileIdentityRequest model + profileIdentityRequestModel := new(iamidentityv1.ProfileIdentityRequest) + Expect(profileIdentityRequestModel).ToNot(BeNil()) + profileIdentityRequestModel.Identifier = core.StringPtr("testString") + profileIdentityRequestModel.Type = core.StringPtr("user") + profileIdentityRequestModel.Accounts = []string{"testString"} + profileIdentityRequestModel.Description = core.StringPtr("testString") + Expect(profileIdentityRequestModel.Identifier).To(Equal(core.StringPtr("testString"))) + Expect(profileIdentityRequestModel.Type).To(Equal(core.StringPtr("user"))) + Expect(profileIdentityRequestModel.Accounts).To(Equal([]string{"testString"})) + Expect(profileIdentityRequestModel.Description).To(Equal(core.StringPtr("testString"))) + + // Construct an instance of the TemplateProfileComponentRequest model + templateProfileComponentRequestModel := new(iamidentityv1.TemplateProfileComponentRequest) + Expect(templateProfileComponentRequestModel).ToNot(BeNil()) + templateProfileComponentRequestModel.Name = core.StringPtr("testString") + templateProfileComponentRequestModel.Description = core.StringPtr("testString") + templateProfileComponentRequestModel.Rules = []iamidentityv1.TrustedProfileTemplateClaimRule{*trustedProfileTemplateClaimRuleModel} + templateProfileComponentRequestModel.Identities = []iamidentityv1.ProfileIdentityRequest{*profileIdentityRequestModel} + Expect(templateProfileComponentRequestModel.Name).To(Equal(core.StringPtr("testString"))) + Expect(templateProfileComponentRequestModel.Description).To(Equal(core.StringPtr("testString"))) + Expect(templateProfileComponentRequestModel.Rules).To(Equal([]iamidentityv1.TrustedProfileTemplateClaimRule{*trustedProfileTemplateClaimRuleModel})) + Expect(templateProfileComponentRequestModel.Identities).To(Equal([]iamidentityv1.ProfileIdentityRequest{*profileIdentityRequestModel})) + + // Construct an instance of the PolicyTemplateReference model + policyTemplateReferenceModel := new(iamidentityv1.PolicyTemplateReference) + Expect(policyTemplateReferenceModel).ToNot(BeNil()) + policyTemplateReferenceModel.ID = core.StringPtr("testString") + policyTemplateReferenceModel.Version = core.StringPtr("testString") + Expect(policyTemplateReferenceModel.ID).To(Equal(core.StringPtr("testString"))) + Expect(policyTemplateReferenceModel.Version).To(Equal(core.StringPtr("testString"))) + + // Construct an instance of the CreateProfileTemplateVersionOptions model + templateID := "testString" + createProfileTemplateVersionOptionsModel := iamIdentityService.NewCreateProfileTemplateVersionOptions(templateID) + createProfileTemplateVersionOptionsModel.SetTemplateID("testString") + createProfileTemplateVersionOptionsModel.SetAccountID("testString") + createProfileTemplateVersionOptionsModel.SetName("testString") + createProfileTemplateVersionOptionsModel.SetDescription("testString") + createProfileTemplateVersionOptionsModel.SetProfile(templateProfileComponentRequestModel) + createProfileTemplateVersionOptionsModel.SetPolicyTemplateReferences([]iamidentityv1.PolicyTemplateReference{*policyTemplateReferenceModel}) + createProfileTemplateVersionOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(createProfileTemplateVersionOptionsModel).ToNot(BeNil()) + Expect(createProfileTemplateVersionOptionsModel.TemplateID).To(Equal(core.StringPtr("testString"))) + Expect(createProfileTemplateVersionOptionsModel.AccountID).To(Equal(core.StringPtr("testString"))) + Expect(createProfileTemplateVersionOptionsModel.Name).To(Equal(core.StringPtr("testString"))) + Expect(createProfileTemplateVersionOptionsModel.Description).To(Equal(core.StringPtr("testString"))) + Expect(createProfileTemplateVersionOptionsModel.Profile).To(Equal(templateProfileComponentRequestModel)) + Expect(createProfileTemplateVersionOptionsModel.PolicyTemplateReferences).To(Equal([]iamidentityv1.PolicyTemplateReference{*policyTemplateReferenceModel})) + Expect(createProfileTemplateVersionOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) It(`Invoke NewCreateReportOptions successfully`, func() { // Construct an instance of the CreateReportOptions model accountID := "testString" @@ -8975,6 +16396,68 @@ var _ = Describe(`IamIdentityV1`, func() { Expect(createServiceIDOptionsModel.EntityLock).To(Equal(core.StringPtr("false"))) Expect(createServiceIDOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewCreateTrustedProfileAssignmentOptions successfully`, func() { + // Construct an instance of the CreateTrustedProfileAssignmentOptions model + createTrustedProfileAssignmentOptionsTemplateID := "testString" + createTrustedProfileAssignmentOptionsTemplateVersion := int64(1) + createTrustedProfileAssignmentOptionsTargetType := "Account" + createTrustedProfileAssignmentOptionsTarget := "testString" + createTrustedProfileAssignmentOptionsModel := iamIdentityService.NewCreateTrustedProfileAssignmentOptions(createTrustedProfileAssignmentOptionsTemplateID, createTrustedProfileAssignmentOptionsTemplateVersion, createTrustedProfileAssignmentOptionsTargetType, createTrustedProfileAssignmentOptionsTarget) + createTrustedProfileAssignmentOptionsModel.SetTemplateID("testString") + createTrustedProfileAssignmentOptionsModel.SetTemplateVersion(int64(1)) + createTrustedProfileAssignmentOptionsModel.SetTargetType("Account") + createTrustedProfileAssignmentOptionsModel.SetTarget("testString") + createTrustedProfileAssignmentOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(createTrustedProfileAssignmentOptionsModel).ToNot(BeNil()) + Expect(createTrustedProfileAssignmentOptionsModel.TemplateID).To(Equal(core.StringPtr("testString"))) + Expect(createTrustedProfileAssignmentOptionsModel.TemplateVersion).To(Equal(core.Int64Ptr(int64(1)))) + Expect(createTrustedProfileAssignmentOptionsModel.TargetType).To(Equal(core.StringPtr("Account"))) + Expect(createTrustedProfileAssignmentOptionsModel.Target).To(Equal(core.StringPtr("testString"))) + Expect(createTrustedProfileAssignmentOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) + It(`Invoke NewDeleteAccountSettingsAssignmentOptions successfully`, func() { + // Construct an instance of the DeleteAccountSettingsAssignmentOptions model + assignmentID := "testString" + deleteAccountSettingsAssignmentOptionsModel := iamIdentityService.NewDeleteAccountSettingsAssignmentOptions(assignmentID) + deleteAccountSettingsAssignmentOptionsModel.SetAssignmentID("testString") + deleteAccountSettingsAssignmentOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(deleteAccountSettingsAssignmentOptionsModel).ToNot(BeNil()) + Expect(deleteAccountSettingsAssignmentOptionsModel.AssignmentID).To(Equal(core.StringPtr("testString"))) + Expect(deleteAccountSettingsAssignmentOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) + It(`Invoke NewDeleteAccountSettingsTemplateVersionOptions successfully`, func() { + // Construct an instance of the DeleteAccountSettingsTemplateVersionOptions model + templateID := "testString" + version := "testString" + deleteAccountSettingsTemplateVersionOptionsModel := iamIdentityService.NewDeleteAccountSettingsTemplateVersionOptions(templateID, version) + deleteAccountSettingsTemplateVersionOptionsModel.SetTemplateID("testString") + deleteAccountSettingsTemplateVersionOptionsModel.SetVersion("testString") + deleteAccountSettingsTemplateVersionOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(deleteAccountSettingsTemplateVersionOptionsModel).ToNot(BeNil()) + Expect(deleteAccountSettingsTemplateVersionOptionsModel.TemplateID).To(Equal(core.StringPtr("testString"))) + Expect(deleteAccountSettingsTemplateVersionOptionsModel.Version).To(Equal(core.StringPtr("testString"))) + Expect(deleteAccountSettingsTemplateVersionOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) + It(`Invoke NewDeleteAllVersionsOfAccountSettingsTemplateOptions successfully`, func() { + // Construct an instance of the DeleteAllVersionsOfAccountSettingsTemplateOptions model + templateID := "testString" + deleteAllVersionsOfAccountSettingsTemplateOptionsModel := iamIdentityService.NewDeleteAllVersionsOfAccountSettingsTemplateOptions(templateID) + deleteAllVersionsOfAccountSettingsTemplateOptionsModel.SetTemplateID("testString") + deleteAllVersionsOfAccountSettingsTemplateOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(deleteAllVersionsOfAccountSettingsTemplateOptionsModel).ToNot(BeNil()) + Expect(deleteAllVersionsOfAccountSettingsTemplateOptionsModel.TemplateID).To(Equal(core.StringPtr("testString"))) + Expect(deleteAllVersionsOfAccountSettingsTemplateOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) + It(`Invoke NewDeleteAllVersionsOfProfileTemplateOptions successfully`, func() { + // Construct an instance of the DeleteAllVersionsOfProfileTemplateOptions model + templateID := "testString" + deleteAllVersionsOfProfileTemplateOptionsModel := iamIdentityService.NewDeleteAllVersionsOfProfileTemplateOptions(templateID) + deleteAllVersionsOfProfileTemplateOptionsModel.SetTemplateID("testString") + deleteAllVersionsOfProfileTemplateOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(deleteAllVersionsOfProfileTemplateOptionsModel).ToNot(BeNil()) + Expect(deleteAllVersionsOfProfileTemplateOptionsModel.TemplateID).To(Equal(core.StringPtr("testString"))) + Expect(deleteAllVersionsOfProfileTemplateOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) It(`Invoke NewDeleteAPIKeyOptions successfully`, func() { // Construct an instance of the DeleteAPIKeyOptions model id := "testString" @@ -9037,6 +16520,19 @@ var _ = Describe(`IamIdentityV1`, func() { Expect(deleteProfileOptionsModel.ProfileID).To(Equal(core.StringPtr("testString"))) Expect(deleteProfileOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewDeleteProfileTemplateVersionOptions successfully`, func() { + // Construct an instance of the DeleteProfileTemplateVersionOptions model + templateID := "testString" + version := "testString" + deleteProfileTemplateVersionOptionsModel := iamIdentityService.NewDeleteProfileTemplateVersionOptions(templateID, version) + deleteProfileTemplateVersionOptionsModel.SetTemplateID("testString") + deleteProfileTemplateVersionOptionsModel.SetVersion("testString") + deleteProfileTemplateVersionOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(deleteProfileTemplateVersionOptionsModel).ToNot(BeNil()) + Expect(deleteProfileTemplateVersionOptionsModel.TemplateID).To(Equal(core.StringPtr("testString"))) + Expect(deleteProfileTemplateVersionOptionsModel.Version).To(Equal(core.StringPtr("testString"))) + Expect(deleteProfileTemplateVersionOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) It(`Invoke NewDeleteServiceIDOptions successfully`, func() { // Construct an instance of the DeleteServiceIDOptions model id := "testString" @@ -9047,6 +16543,28 @@ var _ = Describe(`IamIdentityV1`, func() { Expect(deleteServiceIDOptionsModel.ID).To(Equal(core.StringPtr("testString"))) Expect(deleteServiceIDOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewDeleteTrustedProfileAssignmentOptions successfully`, func() { + // Construct an instance of the DeleteTrustedProfileAssignmentOptions model + assignmentID := "testString" + deleteTrustedProfileAssignmentOptionsModel := iamIdentityService.NewDeleteTrustedProfileAssignmentOptions(assignmentID) + deleteTrustedProfileAssignmentOptionsModel.SetAssignmentID("testString") + deleteTrustedProfileAssignmentOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(deleteTrustedProfileAssignmentOptionsModel).ToNot(BeNil()) + Expect(deleteTrustedProfileAssignmentOptionsModel.AssignmentID).To(Equal(core.StringPtr("testString"))) + Expect(deleteTrustedProfileAssignmentOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) + It(`Invoke NewGetAccountSettingsAssignmentOptions successfully`, func() { + // Construct an instance of the GetAccountSettingsAssignmentOptions model + assignmentID := "testString" + getAccountSettingsAssignmentOptionsModel := iamIdentityService.NewGetAccountSettingsAssignmentOptions(assignmentID) + getAccountSettingsAssignmentOptionsModel.SetAssignmentID("testString") + getAccountSettingsAssignmentOptionsModel.SetIncludeHistory(false) + getAccountSettingsAssignmentOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(getAccountSettingsAssignmentOptionsModel).ToNot(BeNil()) + Expect(getAccountSettingsAssignmentOptionsModel.AssignmentID).To(Equal(core.StringPtr("testString"))) + Expect(getAccountSettingsAssignmentOptionsModel.IncludeHistory).To(Equal(core.BoolPtr(false))) + Expect(getAccountSettingsAssignmentOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) It(`Invoke NewGetAccountSettingsOptions successfully`, func() { // Construct an instance of the GetAccountSettingsOptions model accountID := "testString" @@ -9059,6 +16577,21 @@ var _ = Describe(`IamIdentityV1`, func() { Expect(getAccountSettingsOptionsModel.IncludeHistory).To(Equal(core.BoolPtr(false))) Expect(getAccountSettingsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewGetAccountSettingsTemplateVersionOptions successfully`, func() { + // Construct an instance of the GetAccountSettingsTemplateVersionOptions model + templateID := "testString" + version := "testString" + getAccountSettingsTemplateVersionOptionsModel := iamIdentityService.NewGetAccountSettingsTemplateVersionOptions(templateID, version) + getAccountSettingsTemplateVersionOptionsModel.SetTemplateID("testString") + getAccountSettingsTemplateVersionOptionsModel.SetVersion("testString") + getAccountSettingsTemplateVersionOptionsModel.SetIncludeHistory(false) + getAccountSettingsTemplateVersionOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(getAccountSettingsTemplateVersionOptionsModel).ToNot(BeNil()) + Expect(getAccountSettingsTemplateVersionOptionsModel.TemplateID).To(Equal(core.StringPtr("testString"))) + Expect(getAccountSettingsTemplateVersionOptionsModel.Version).To(Equal(core.StringPtr("testString"))) + Expect(getAccountSettingsTemplateVersionOptionsModel.IncludeHistory).To(Equal(core.BoolPtr(false))) + Expect(getAccountSettingsTemplateVersionOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) It(`Invoke NewGetAPIKeyOptions successfully`, func() { // Construct an instance of the GetAPIKeyOptions model id := "testString" @@ -9097,6 +16630,30 @@ var _ = Describe(`IamIdentityV1`, func() { Expect(getClaimRuleOptionsModel.RuleID).To(Equal(core.StringPtr("testString"))) Expect(getClaimRuleOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewGetLatestAccountSettingsTemplateVersionOptions successfully`, func() { + // Construct an instance of the GetLatestAccountSettingsTemplateVersionOptions model + templateID := "testString" + getLatestAccountSettingsTemplateVersionOptionsModel := iamIdentityService.NewGetLatestAccountSettingsTemplateVersionOptions(templateID) + getLatestAccountSettingsTemplateVersionOptionsModel.SetTemplateID("testString") + getLatestAccountSettingsTemplateVersionOptionsModel.SetIncludeHistory(false) + getLatestAccountSettingsTemplateVersionOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(getLatestAccountSettingsTemplateVersionOptionsModel).ToNot(BeNil()) + Expect(getLatestAccountSettingsTemplateVersionOptionsModel.TemplateID).To(Equal(core.StringPtr("testString"))) + Expect(getLatestAccountSettingsTemplateVersionOptionsModel.IncludeHistory).To(Equal(core.BoolPtr(false))) + Expect(getLatestAccountSettingsTemplateVersionOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) + It(`Invoke NewGetLatestProfileTemplateVersionOptions successfully`, func() { + // Construct an instance of the GetLatestProfileTemplateVersionOptions model + templateID := "testString" + getLatestProfileTemplateVersionOptionsModel := iamIdentityService.NewGetLatestProfileTemplateVersionOptions(templateID) + getLatestProfileTemplateVersionOptionsModel.SetTemplateID("testString") + getLatestProfileTemplateVersionOptionsModel.SetIncludeHistory(false) + getLatestProfileTemplateVersionOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(getLatestProfileTemplateVersionOptionsModel).ToNot(BeNil()) + Expect(getLatestProfileTemplateVersionOptionsModel.TemplateID).To(Equal(core.StringPtr("testString"))) + Expect(getLatestProfileTemplateVersionOptionsModel.IncludeHistory).To(Equal(core.BoolPtr(false))) + Expect(getLatestProfileTemplateVersionOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) It(`Invoke NewGetLinkOptions successfully`, func() { // Construct an instance of the GetLinkOptions model profileID := "testString" @@ -9174,6 +16731,21 @@ var _ = Describe(`IamIdentityV1`, func() { Expect(getProfileOptionsModel.IncludeActivity).To(Equal(core.BoolPtr(false))) Expect(getProfileOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewGetProfileTemplateVersionOptions successfully`, func() { + // Construct an instance of the GetProfileTemplateVersionOptions model + templateID := "testString" + version := "testString" + getProfileTemplateVersionOptionsModel := iamIdentityService.NewGetProfileTemplateVersionOptions(templateID, version) + getProfileTemplateVersionOptionsModel.SetTemplateID("testString") + getProfileTemplateVersionOptionsModel.SetVersion("testString") + getProfileTemplateVersionOptionsModel.SetIncludeHistory(false) + getProfileTemplateVersionOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(getProfileTemplateVersionOptionsModel).ToNot(BeNil()) + Expect(getProfileTemplateVersionOptionsModel.TemplateID).To(Equal(core.StringPtr("testString"))) + Expect(getProfileTemplateVersionOptionsModel.Version).To(Equal(core.StringPtr("testString"))) + Expect(getProfileTemplateVersionOptionsModel.IncludeHistory).To(Equal(core.BoolPtr(false))) + Expect(getProfileTemplateVersionOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) It(`Invoke NewGetReportOptions successfully`, func() { // Construct an instance of the GetReportOptions model accountID := "testString" @@ -9201,6 +16773,64 @@ var _ = Describe(`IamIdentityV1`, func() { Expect(getServiceIDOptionsModel.IncludeActivity).To(Equal(core.BoolPtr(false))) Expect(getServiceIDOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewGetTrustedProfileAssignmentOptions successfully`, func() { + // Construct an instance of the GetTrustedProfileAssignmentOptions model + assignmentID := "testString" + getTrustedProfileAssignmentOptionsModel := iamIdentityService.NewGetTrustedProfileAssignmentOptions(assignmentID) + getTrustedProfileAssignmentOptionsModel.SetAssignmentID("testString") + getTrustedProfileAssignmentOptionsModel.SetIncludeHistory(false) + getTrustedProfileAssignmentOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(getTrustedProfileAssignmentOptionsModel).ToNot(BeNil()) + Expect(getTrustedProfileAssignmentOptionsModel.AssignmentID).To(Equal(core.StringPtr("testString"))) + Expect(getTrustedProfileAssignmentOptionsModel.IncludeHistory).To(Equal(core.BoolPtr(false))) + Expect(getTrustedProfileAssignmentOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) + It(`Invoke NewListAccountSettingsAssignmentsOptions successfully`, func() { + // Construct an instance of the ListAccountSettingsAssignmentsOptions model + listAccountSettingsAssignmentsOptionsModel := iamIdentityService.NewListAccountSettingsAssignmentsOptions() + listAccountSettingsAssignmentsOptionsModel.SetAccountID("testString") + listAccountSettingsAssignmentsOptionsModel.SetTemplateID("testString") + listAccountSettingsAssignmentsOptionsModel.SetTemplateVersion("testString") + listAccountSettingsAssignmentsOptionsModel.SetTarget("testString") + listAccountSettingsAssignmentsOptionsModel.SetTargetType("Account") + listAccountSettingsAssignmentsOptionsModel.SetLimit(int64(20)) + listAccountSettingsAssignmentsOptionsModel.SetPagetoken("testString") + listAccountSettingsAssignmentsOptionsModel.SetSort("created_at") + listAccountSettingsAssignmentsOptionsModel.SetOrder("asc") + listAccountSettingsAssignmentsOptionsModel.SetIncludeHistory(false) + listAccountSettingsAssignmentsOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(listAccountSettingsAssignmentsOptionsModel).ToNot(BeNil()) + Expect(listAccountSettingsAssignmentsOptionsModel.AccountID).To(Equal(core.StringPtr("testString"))) + Expect(listAccountSettingsAssignmentsOptionsModel.TemplateID).To(Equal(core.StringPtr("testString"))) + Expect(listAccountSettingsAssignmentsOptionsModel.TemplateVersion).To(Equal(core.StringPtr("testString"))) + Expect(listAccountSettingsAssignmentsOptionsModel.Target).To(Equal(core.StringPtr("testString"))) + Expect(listAccountSettingsAssignmentsOptionsModel.TargetType).To(Equal(core.StringPtr("Account"))) + Expect(listAccountSettingsAssignmentsOptionsModel.Limit).To(Equal(core.Int64Ptr(int64(20)))) + Expect(listAccountSettingsAssignmentsOptionsModel.Pagetoken).To(Equal(core.StringPtr("testString"))) + Expect(listAccountSettingsAssignmentsOptionsModel.Sort).To(Equal(core.StringPtr("created_at"))) + Expect(listAccountSettingsAssignmentsOptionsModel.Order).To(Equal(core.StringPtr("asc"))) + Expect(listAccountSettingsAssignmentsOptionsModel.IncludeHistory).To(Equal(core.BoolPtr(false))) + Expect(listAccountSettingsAssignmentsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) + It(`Invoke NewListAccountSettingsTemplatesOptions successfully`, func() { + // Construct an instance of the ListAccountSettingsTemplatesOptions model + listAccountSettingsTemplatesOptionsModel := iamIdentityService.NewListAccountSettingsTemplatesOptions() + listAccountSettingsTemplatesOptionsModel.SetAccountID("testString") + listAccountSettingsTemplatesOptionsModel.SetLimit("20") + listAccountSettingsTemplatesOptionsModel.SetPagetoken("testString") + listAccountSettingsTemplatesOptionsModel.SetSort("created_at") + listAccountSettingsTemplatesOptionsModel.SetOrder("asc") + listAccountSettingsTemplatesOptionsModel.SetIncludeHistory("false") + listAccountSettingsTemplatesOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(listAccountSettingsTemplatesOptionsModel).ToNot(BeNil()) + Expect(listAccountSettingsTemplatesOptionsModel.AccountID).To(Equal(core.StringPtr("testString"))) + Expect(listAccountSettingsTemplatesOptionsModel.Limit).To(Equal(core.StringPtr("20"))) + Expect(listAccountSettingsTemplatesOptionsModel.Pagetoken).To(Equal(core.StringPtr("testString"))) + Expect(listAccountSettingsTemplatesOptionsModel.Sort).To(Equal(core.StringPtr("created_at"))) + Expect(listAccountSettingsTemplatesOptionsModel.Order).To(Equal(core.StringPtr("asc"))) + Expect(listAccountSettingsTemplatesOptionsModel.IncludeHistory).To(Equal(core.StringPtr("false"))) + Expect(listAccountSettingsTemplatesOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) It(`Invoke NewListAPIKeysOptions successfully`, func() { // Construct an instance of the ListAPIKeysOptions model listAPIKeysOptionsModel := iamIdentityService.NewListAPIKeysOptions() @@ -9246,6 +16876,25 @@ var _ = Describe(`IamIdentityV1`, func() { Expect(listLinksOptionsModel.ProfileID).To(Equal(core.StringPtr("testString"))) Expect(listLinksOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewListProfileTemplatesOptions successfully`, func() { + // Construct an instance of the ListProfileTemplatesOptions model + listProfileTemplatesOptionsModel := iamIdentityService.NewListProfileTemplatesOptions() + listProfileTemplatesOptionsModel.SetAccountID("testString") + listProfileTemplatesOptionsModel.SetLimit("20") + listProfileTemplatesOptionsModel.SetPagetoken("testString") + listProfileTemplatesOptionsModel.SetSort("created_at") + listProfileTemplatesOptionsModel.SetOrder("asc") + listProfileTemplatesOptionsModel.SetIncludeHistory("false") + listProfileTemplatesOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(listProfileTemplatesOptionsModel).ToNot(BeNil()) + Expect(listProfileTemplatesOptionsModel.AccountID).To(Equal(core.StringPtr("testString"))) + Expect(listProfileTemplatesOptionsModel.Limit).To(Equal(core.StringPtr("20"))) + Expect(listProfileTemplatesOptionsModel.Pagetoken).To(Equal(core.StringPtr("testString"))) + Expect(listProfileTemplatesOptionsModel.Sort).To(Equal(core.StringPtr("created_at"))) + Expect(listProfileTemplatesOptionsModel.Order).To(Equal(core.StringPtr("asc"))) + Expect(listProfileTemplatesOptionsModel.IncludeHistory).To(Equal(core.StringPtr("false"))) + Expect(listProfileTemplatesOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) It(`Invoke NewListProfilesOptions successfully`, func() { // Construct an instance of the ListProfilesOptions model accountID := "testString" @@ -9289,6 +16938,73 @@ var _ = Describe(`IamIdentityV1`, func() { Expect(listServiceIdsOptionsModel.IncludeHistory).To(Equal(core.BoolPtr(false))) Expect(listServiceIdsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewListTrustedProfileAssignmentsOptions successfully`, func() { + // Construct an instance of the ListTrustedProfileAssignmentsOptions model + listTrustedProfileAssignmentsOptionsModel := iamIdentityService.NewListTrustedProfileAssignmentsOptions() + listTrustedProfileAssignmentsOptionsModel.SetAccountID("testString") + listTrustedProfileAssignmentsOptionsModel.SetTemplateID("testString") + listTrustedProfileAssignmentsOptionsModel.SetTemplateVersion("testString") + listTrustedProfileAssignmentsOptionsModel.SetTarget("testString") + listTrustedProfileAssignmentsOptionsModel.SetTargetType("Account") + listTrustedProfileAssignmentsOptionsModel.SetLimit(int64(20)) + listTrustedProfileAssignmentsOptionsModel.SetPagetoken("testString") + listTrustedProfileAssignmentsOptionsModel.SetSort("created_at") + listTrustedProfileAssignmentsOptionsModel.SetOrder("asc") + listTrustedProfileAssignmentsOptionsModel.SetIncludeHistory(false) + listTrustedProfileAssignmentsOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(listTrustedProfileAssignmentsOptionsModel).ToNot(BeNil()) + Expect(listTrustedProfileAssignmentsOptionsModel.AccountID).To(Equal(core.StringPtr("testString"))) + Expect(listTrustedProfileAssignmentsOptionsModel.TemplateID).To(Equal(core.StringPtr("testString"))) + Expect(listTrustedProfileAssignmentsOptionsModel.TemplateVersion).To(Equal(core.StringPtr("testString"))) + Expect(listTrustedProfileAssignmentsOptionsModel.Target).To(Equal(core.StringPtr("testString"))) + Expect(listTrustedProfileAssignmentsOptionsModel.TargetType).To(Equal(core.StringPtr("Account"))) + Expect(listTrustedProfileAssignmentsOptionsModel.Limit).To(Equal(core.Int64Ptr(int64(20)))) + Expect(listTrustedProfileAssignmentsOptionsModel.Pagetoken).To(Equal(core.StringPtr("testString"))) + Expect(listTrustedProfileAssignmentsOptionsModel.Sort).To(Equal(core.StringPtr("created_at"))) + Expect(listTrustedProfileAssignmentsOptionsModel.Order).To(Equal(core.StringPtr("asc"))) + Expect(listTrustedProfileAssignmentsOptionsModel.IncludeHistory).To(Equal(core.BoolPtr(false))) + Expect(listTrustedProfileAssignmentsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) + It(`Invoke NewListVersionsOfAccountSettingsTemplateOptions successfully`, func() { + // Construct an instance of the ListVersionsOfAccountSettingsTemplateOptions model + templateID := "testString" + listVersionsOfAccountSettingsTemplateOptionsModel := iamIdentityService.NewListVersionsOfAccountSettingsTemplateOptions(templateID) + listVersionsOfAccountSettingsTemplateOptionsModel.SetTemplateID("testString") + listVersionsOfAccountSettingsTemplateOptionsModel.SetLimit("20") + listVersionsOfAccountSettingsTemplateOptionsModel.SetPagetoken("testString") + listVersionsOfAccountSettingsTemplateOptionsModel.SetSort("created_at") + listVersionsOfAccountSettingsTemplateOptionsModel.SetOrder("asc") + listVersionsOfAccountSettingsTemplateOptionsModel.SetIncludeHistory("false") + listVersionsOfAccountSettingsTemplateOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(listVersionsOfAccountSettingsTemplateOptionsModel).ToNot(BeNil()) + Expect(listVersionsOfAccountSettingsTemplateOptionsModel.TemplateID).To(Equal(core.StringPtr("testString"))) + Expect(listVersionsOfAccountSettingsTemplateOptionsModel.Limit).To(Equal(core.StringPtr("20"))) + Expect(listVersionsOfAccountSettingsTemplateOptionsModel.Pagetoken).To(Equal(core.StringPtr("testString"))) + Expect(listVersionsOfAccountSettingsTemplateOptionsModel.Sort).To(Equal(core.StringPtr("created_at"))) + Expect(listVersionsOfAccountSettingsTemplateOptionsModel.Order).To(Equal(core.StringPtr("asc"))) + Expect(listVersionsOfAccountSettingsTemplateOptionsModel.IncludeHistory).To(Equal(core.StringPtr("false"))) + Expect(listVersionsOfAccountSettingsTemplateOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) + It(`Invoke NewListVersionsOfProfileTemplateOptions successfully`, func() { + // Construct an instance of the ListVersionsOfProfileTemplateOptions model + templateID := "testString" + listVersionsOfProfileTemplateOptionsModel := iamIdentityService.NewListVersionsOfProfileTemplateOptions(templateID) + listVersionsOfProfileTemplateOptionsModel.SetTemplateID("testString") + listVersionsOfProfileTemplateOptionsModel.SetLimit("20") + listVersionsOfProfileTemplateOptionsModel.SetPagetoken("testString") + listVersionsOfProfileTemplateOptionsModel.SetSort("created_at") + listVersionsOfProfileTemplateOptionsModel.SetOrder("asc") + listVersionsOfProfileTemplateOptionsModel.SetIncludeHistory("false") + listVersionsOfProfileTemplateOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(listVersionsOfProfileTemplateOptionsModel).ToNot(BeNil()) + Expect(listVersionsOfProfileTemplateOptionsModel.TemplateID).To(Equal(core.StringPtr("testString"))) + Expect(listVersionsOfProfileTemplateOptionsModel.Limit).To(Equal(core.StringPtr("20"))) + Expect(listVersionsOfProfileTemplateOptionsModel.Pagetoken).To(Equal(core.StringPtr("testString"))) + Expect(listVersionsOfProfileTemplateOptionsModel.Sort).To(Equal(core.StringPtr("created_at"))) + Expect(listVersionsOfProfileTemplateOptionsModel.Order).To(Equal(core.StringPtr("asc"))) + Expect(listVersionsOfProfileTemplateOptionsModel.IncludeHistory).To(Equal(core.StringPtr("false"))) + Expect(listVersionsOfProfileTemplateOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) It(`Invoke NewLockAPIKeyOptions successfully`, func() { // Construct an instance of the LockAPIKeyOptions model id := "testString" @@ -9309,6 +17025,13 @@ var _ = Describe(`IamIdentityV1`, func() { Expect(lockServiceIDOptionsModel.ID).To(Equal(core.StringPtr("testString"))) Expect(lockServiceIDOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewPolicyTemplateReference successfully`, func() { + id := "testString" + version := "testString" + _model, err := iamIdentityService.NewPolicyTemplateReference(id, version) + Expect(_model).ToNot(BeNil()) + Expect(err).To(BeNil()) + }) It(`Invoke NewProfileClaimRuleConditions successfully`, func() { claim := "testString" operator := "testString" @@ -9317,27 +17040,25 @@ var _ = Describe(`IamIdentityV1`, func() { Expect(_model).ToNot(BeNil()) Expect(err).To(BeNil()) }) - It(`Invoke NewProfileIdentity successfully`, func() { + It(`Invoke NewProfileIdentityRequest successfully`, func() { identifier := "testString" typeVar := "user" - _model, err := iamIdentityService.NewProfileIdentity(identifier, typeVar) + _model, err := iamIdentityService.NewProfileIdentityRequest(identifier, typeVar) Expect(_model).ToNot(BeNil()) Expect(err).To(BeNil()) }) It(`Invoke NewSetProfileIdentitiesOptions successfully`, func() { - // Construct an instance of the ProfileIdentity model - profileIdentityModel := new(iamidentityv1.ProfileIdentity) - Expect(profileIdentityModel).ToNot(BeNil()) - profileIdentityModel.IamID = core.StringPtr("testString") - profileIdentityModel.Identifier = core.StringPtr("testString") - profileIdentityModel.Type = core.StringPtr("user") - profileIdentityModel.Accounts = []string{"testString"} - profileIdentityModel.Description = core.StringPtr("testString") - Expect(profileIdentityModel.IamID).To(Equal(core.StringPtr("testString"))) - Expect(profileIdentityModel.Identifier).To(Equal(core.StringPtr("testString"))) - Expect(profileIdentityModel.Type).To(Equal(core.StringPtr("user"))) - Expect(profileIdentityModel.Accounts).To(Equal([]string{"testString"})) - Expect(profileIdentityModel.Description).To(Equal(core.StringPtr("testString"))) + // Construct an instance of the ProfileIdentityRequest model + profileIdentityRequestModel := new(iamidentityv1.ProfileIdentityRequest) + Expect(profileIdentityRequestModel).ToNot(BeNil()) + profileIdentityRequestModel.Identifier = core.StringPtr("testString") + profileIdentityRequestModel.Type = core.StringPtr("user") + profileIdentityRequestModel.Accounts = []string{"testString"} + profileIdentityRequestModel.Description = core.StringPtr("testString") + Expect(profileIdentityRequestModel.Identifier).To(Equal(core.StringPtr("testString"))) + Expect(profileIdentityRequestModel.Type).To(Equal(core.StringPtr("user"))) + Expect(profileIdentityRequestModel.Accounts).To(Equal([]string{"testString"})) + Expect(profileIdentityRequestModel.Description).To(Equal(core.StringPtr("testString"))) // Construct an instance of the SetProfileIdentitiesOptions model profileID := "testString" @@ -9345,12 +17066,12 @@ var _ = Describe(`IamIdentityV1`, func() { setProfileIdentitiesOptionsModel := iamIdentityService.NewSetProfileIdentitiesOptions(profileID, ifMatch) setProfileIdentitiesOptionsModel.SetProfileID("testString") setProfileIdentitiesOptionsModel.SetIfMatch("testString") - setProfileIdentitiesOptionsModel.SetIdentities([]iamidentityv1.ProfileIdentity{*profileIdentityModel}) + setProfileIdentitiesOptionsModel.SetIdentities([]iamidentityv1.ProfileIdentityRequest{*profileIdentityRequestModel}) setProfileIdentitiesOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(setProfileIdentitiesOptionsModel).ToNot(BeNil()) Expect(setProfileIdentitiesOptionsModel.ProfileID).To(Equal(core.StringPtr("testString"))) Expect(setProfileIdentitiesOptionsModel.IfMatch).To(Equal(core.StringPtr("testString"))) - Expect(setProfileIdentitiesOptionsModel.Identities).To(Equal([]iamidentityv1.ProfileIdentity{*profileIdentityModel})) + Expect(setProfileIdentitiesOptionsModel.Identities).To(Equal([]iamidentityv1.ProfileIdentityRequest{*profileIdentityRequestModel})) Expect(setProfileIdentitiesOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) It(`Invoke NewSetProfileIdentityOptions successfully`, func() { @@ -9364,7 +17085,6 @@ var _ = Describe(`IamIdentityV1`, func() { setProfileIdentityOptionsModel.SetIdentityType("user") setProfileIdentityOptionsModel.SetIdentifier("testString") setProfileIdentityOptionsModel.SetType("user") - setProfileIdentityOptionsModel.SetIamID("testString") setProfileIdentityOptionsModel.SetAccounts([]string{"testString"}) setProfileIdentityOptionsModel.SetDescription("testString") setProfileIdentityOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) @@ -9373,11 +17093,23 @@ var _ = Describe(`IamIdentityV1`, func() { Expect(setProfileIdentityOptionsModel.IdentityType).To(Equal(core.StringPtr("user"))) Expect(setProfileIdentityOptionsModel.Identifier).To(Equal(core.StringPtr("testString"))) Expect(setProfileIdentityOptionsModel.Type).To(Equal(core.StringPtr("user"))) - Expect(setProfileIdentityOptionsModel.IamID).To(Equal(core.StringPtr("testString"))) Expect(setProfileIdentityOptionsModel.Accounts).To(Equal([]string{"testString"})) Expect(setProfileIdentityOptionsModel.Description).To(Equal(core.StringPtr("testString"))) Expect(setProfileIdentityOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewTemplateProfileComponentRequest successfully`, func() { + name := "testString" + _model, err := iamIdentityService.NewTemplateProfileComponentRequest(name) + Expect(_model).ToNot(BeNil()) + Expect(err).To(BeNil()) + }) + It(`Invoke NewTrustedProfileTemplateClaimRule successfully`, func() { + typeVar := "Profile-SAML" + conditions := []iamidentityv1.ProfileClaimRuleConditions{} + _model, err := iamIdentityService.NewTrustedProfileTemplateClaimRule(typeVar, conditions) + Expect(_model).ToNot(BeNil()) + Expect(err).To(BeNil()) + }) It(`Invoke NewUnlockAPIKeyOptions successfully`, func() { // Construct an instance of the UnlockAPIKeyOptions model id := "testString" @@ -9398,6 +17130,22 @@ var _ = Describe(`IamIdentityV1`, func() { Expect(unlockServiceIDOptionsModel.ID).To(Equal(core.StringPtr("testString"))) Expect(unlockServiceIDOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewUpdateAccountSettingsAssignmentOptions successfully`, func() { + // Construct an instance of the UpdateAccountSettingsAssignmentOptions model + assignmentID := "testString" + ifMatch := "testString" + updateAccountSettingsAssignmentOptionsTemplateVersion := int64(1) + updateAccountSettingsAssignmentOptionsModel := iamIdentityService.NewUpdateAccountSettingsAssignmentOptions(assignmentID, ifMatch, updateAccountSettingsAssignmentOptionsTemplateVersion) + updateAccountSettingsAssignmentOptionsModel.SetAssignmentID("testString") + updateAccountSettingsAssignmentOptionsModel.SetIfMatch("testString") + updateAccountSettingsAssignmentOptionsModel.SetTemplateVersion(int64(1)) + updateAccountSettingsAssignmentOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(updateAccountSettingsAssignmentOptionsModel).ToNot(BeNil()) + Expect(updateAccountSettingsAssignmentOptionsModel.AssignmentID).To(Equal(core.StringPtr("testString"))) + Expect(updateAccountSettingsAssignmentOptionsModel.IfMatch).To(Equal(core.StringPtr("testString"))) + Expect(updateAccountSettingsAssignmentOptionsModel.TemplateVersion).To(Equal(core.Int64Ptr(int64(1)))) + Expect(updateAccountSettingsAssignmentOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) It(`Invoke NewUpdateAccountSettingsOptions successfully`, func() { // Construct an instance of the AccountSettingsUserMfa model accountSettingsUserMfaModel := new(iamidentityv1.AccountSettingsUserMfa) @@ -9439,6 +17187,62 @@ var _ = Describe(`IamIdentityV1`, func() { Expect(updateAccountSettingsOptionsModel.SystemRefreshTokenExpirationInSeconds).To(Equal(core.StringPtr("259200"))) Expect(updateAccountSettingsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewUpdateAccountSettingsTemplateVersionOptions successfully`, func() { + // Construct an instance of the AccountSettingsUserMfa model + accountSettingsUserMfaModel := new(iamidentityv1.AccountSettingsUserMfa) + Expect(accountSettingsUserMfaModel).ToNot(BeNil()) + accountSettingsUserMfaModel.IamID = core.StringPtr("testString") + accountSettingsUserMfaModel.Mfa = core.StringPtr("NONE") + Expect(accountSettingsUserMfaModel.IamID).To(Equal(core.StringPtr("testString"))) + Expect(accountSettingsUserMfaModel.Mfa).To(Equal(core.StringPtr("NONE"))) + + // Construct an instance of the AccountSettingsComponent model + accountSettingsComponentModel := new(iamidentityv1.AccountSettingsComponent) + Expect(accountSettingsComponentModel).ToNot(BeNil()) + accountSettingsComponentModel.RestrictCreateServiceID = core.StringPtr("NOT_SET") + accountSettingsComponentModel.RestrictCreatePlatformApikey = core.StringPtr("NOT_SET") + accountSettingsComponentModel.AllowedIPAddresses = core.StringPtr("testString") + accountSettingsComponentModel.Mfa = core.StringPtr("NONE") + accountSettingsComponentModel.UserMfa = []iamidentityv1.AccountSettingsUserMfa{*accountSettingsUserMfaModel} + accountSettingsComponentModel.SessionExpirationInSeconds = core.StringPtr("86400") + accountSettingsComponentModel.SessionInvalidationInSeconds = core.StringPtr("7200") + accountSettingsComponentModel.MaxSessionsPerIdentity = core.StringPtr("testString") + accountSettingsComponentModel.SystemAccessTokenExpirationInSeconds = core.StringPtr("3600") + accountSettingsComponentModel.SystemRefreshTokenExpirationInSeconds = core.StringPtr("259200") + Expect(accountSettingsComponentModel.RestrictCreateServiceID).To(Equal(core.StringPtr("NOT_SET"))) + Expect(accountSettingsComponentModel.RestrictCreatePlatformApikey).To(Equal(core.StringPtr("NOT_SET"))) + Expect(accountSettingsComponentModel.AllowedIPAddresses).To(Equal(core.StringPtr("testString"))) + Expect(accountSettingsComponentModel.Mfa).To(Equal(core.StringPtr("NONE"))) + Expect(accountSettingsComponentModel.UserMfa).To(Equal([]iamidentityv1.AccountSettingsUserMfa{*accountSettingsUserMfaModel})) + Expect(accountSettingsComponentModel.SessionExpirationInSeconds).To(Equal(core.StringPtr("86400"))) + Expect(accountSettingsComponentModel.SessionInvalidationInSeconds).To(Equal(core.StringPtr("7200"))) + Expect(accountSettingsComponentModel.MaxSessionsPerIdentity).To(Equal(core.StringPtr("testString"))) + Expect(accountSettingsComponentModel.SystemAccessTokenExpirationInSeconds).To(Equal(core.StringPtr("3600"))) + Expect(accountSettingsComponentModel.SystemRefreshTokenExpirationInSeconds).To(Equal(core.StringPtr("259200"))) + + // Construct an instance of the UpdateAccountSettingsTemplateVersionOptions model + ifMatch := "testString" + templateID := "testString" + version := "testString" + updateAccountSettingsTemplateVersionOptionsModel := iamIdentityService.NewUpdateAccountSettingsTemplateVersionOptions(ifMatch, templateID, version) + updateAccountSettingsTemplateVersionOptionsModel.SetIfMatch("testString") + updateAccountSettingsTemplateVersionOptionsModel.SetTemplateID("testString") + updateAccountSettingsTemplateVersionOptionsModel.SetVersion("testString") + updateAccountSettingsTemplateVersionOptionsModel.SetAccountID("testString") + updateAccountSettingsTemplateVersionOptionsModel.SetName("testString") + updateAccountSettingsTemplateVersionOptionsModel.SetDescription("testString") + updateAccountSettingsTemplateVersionOptionsModel.SetAccountSettings(accountSettingsComponentModel) + updateAccountSettingsTemplateVersionOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(updateAccountSettingsTemplateVersionOptionsModel).ToNot(BeNil()) + Expect(updateAccountSettingsTemplateVersionOptionsModel.IfMatch).To(Equal(core.StringPtr("testString"))) + Expect(updateAccountSettingsTemplateVersionOptionsModel.TemplateID).To(Equal(core.StringPtr("testString"))) + Expect(updateAccountSettingsTemplateVersionOptionsModel.Version).To(Equal(core.StringPtr("testString"))) + Expect(updateAccountSettingsTemplateVersionOptionsModel.AccountID).To(Equal(core.StringPtr("testString"))) + Expect(updateAccountSettingsTemplateVersionOptionsModel.Name).To(Equal(core.StringPtr("testString"))) + Expect(updateAccountSettingsTemplateVersionOptionsModel.Description).To(Equal(core.StringPtr("testString"))) + Expect(updateAccountSettingsTemplateVersionOptionsModel.AccountSettings).To(Equal(accountSettingsComponentModel)) + Expect(updateAccountSettingsTemplateVersionOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) It(`Invoke NewUpdateAPIKeyOptions successfully`, func() { // Construct an instance of the UpdateAPIKeyOptions model id := "testString" @@ -9541,6 +17345,88 @@ var _ = Describe(`IamIdentityV1`, func() { Expect(updateProfileOptionsModel.Description).To(Equal(core.StringPtr("testString"))) Expect(updateProfileOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewUpdateProfileTemplateVersionOptions successfully`, func() { + // Construct an instance of the ProfileClaimRuleConditions model + profileClaimRuleConditionsModel := new(iamidentityv1.ProfileClaimRuleConditions) + Expect(profileClaimRuleConditionsModel).ToNot(BeNil()) + profileClaimRuleConditionsModel.Claim = core.StringPtr("testString") + profileClaimRuleConditionsModel.Operator = core.StringPtr("testString") + profileClaimRuleConditionsModel.Value = core.StringPtr("testString") + Expect(profileClaimRuleConditionsModel.Claim).To(Equal(core.StringPtr("testString"))) + Expect(profileClaimRuleConditionsModel.Operator).To(Equal(core.StringPtr("testString"))) + Expect(profileClaimRuleConditionsModel.Value).To(Equal(core.StringPtr("testString"))) + + // Construct an instance of the TrustedProfileTemplateClaimRule model + trustedProfileTemplateClaimRuleModel := new(iamidentityv1.TrustedProfileTemplateClaimRule) + Expect(trustedProfileTemplateClaimRuleModel).ToNot(BeNil()) + trustedProfileTemplateClaimRuleModel.Name = core.StringPtr("testString") + trustedProfileTemplateClaimRuleModel.Type = core.StringPtr("Profile-SAML") + trustedProfileTemplateClaimRuleModel.RealmName = core.StringPtr("testString") + trustedProfileTemplateClaimRuleModel.Expiration = core.Int64Ptr(int64(38)) + trustedProfileTemplateClaimRuleModel.Conditions = []iamidentityv1.ProfileClaimRuleConditions{*profileClaimRuleConditionsModel} + Expect(trustedProfileTemplateClaimRuleModel.Name).To(Equal(core.StringPtr("testString"))) + Expect(trustedProfileTemplateClaimRuleModel.Type).To(Equal(core.StringPtr("Profile-SAML"))) + Expect(trustedProfileTemplateClaimRuleModel.RealmName).To(Equal(core.StringPtr("testString"))) + Expect(trustedProfileTemplateClaimRuleModel.Expiration).To(Equal(core.Int64Ptr(int64(38)))) + Expect(trustedProfileTemplateClaimRuleModel.Conditions).To(Equal([]iamidentityv1.ProfileClaimRuleConditions{*profileClaimRuleConditionsModel})) + + // Construct an instance of the ProfileIdentityRequest model + profileIdentityRequestModel := new(iamidentityv1.ProfileIdentityRequest) + Expect(profileIdentityRequestModel).ToNot(BeNil()) + profileIdentityRequestModel.Identifier = core.StringPtr("testString") + profileIdentityRequestModel.Type = core.StringPtr("user") + profileIdentityRequestModel.Accounts = []string{"testString"} + profileIdentityRequestModel.Description = core.StringPtr("testString") + Expect(profileIdentityRequestModel.Identifier).To(Equal(core.StringPtr("testString"))) + Expect(profileIdentityRequestModel.Type).To(Equal(core.StringPtr("user"))) + Expect(profileIdentityRequestModel.Accounts).To(Equal([]string{"testString"})) + Expect(profileIdentityRequestModel.Description).To(Equal(core.StringPtr("testString"))) + + // Construct an instance of the TemplateProfileComponentRequest model + templateProfileComponentRequestModel := new(iamidentityv1.TemplateProfileComponentRequest) + Expect(templateProfileComponentRequestModel).ToNot(BeNil()) + templateProfileComponentRequestModel.Name = core.StringPtr("testString") + templateProfileComponentRequestModel.Description = core.StringPtr("testString") + templateProfileComponentRequestModel.Rules = []iamidentityv1.TrustedProfileTemplateClaimRule{*trustedProfileTemplateClaimRuleModel} + templateProfileComponentRequestModel.Identities = []iamidentityv1.ProfileIdentityRequest{*profileIdentityRequestModel} + Expect(templateProfileComponentRequestModel.Name).To(Equal(core.StringPtr("testString"))) + Expect(templateProfileComponentRequestModel.Description).To(Equal(core.StringPtr("testString"))) + Expect(templateProfileComponentRequestModel.Rules).To(Equal([]iamidentityv1.TrustedProfileTemplateClaimRule{*trustedProfileTemplateClaimRuleModel})) + Expect(templateProfileComponentRequestModel.Identities).To(Equal([]iamidentityv1.ProfileIdentityRequest{*profileIdentityRequestModel})) + + // Construct an instance of the PolicyTemplateReference model + policyTemplateReferenceModel := new(iamidentityv1.PolicyTemplateReference) + Expect(policyTemplateReferenceModel).ToNot(BeNil()) + policyTemplateReferenceModel.ID = core.StringPtr("testString") + policyTemplateReferenceModel.Version = core.StringPtr("testString") + Expect(policyTemplateReferenceModel.ID).To(Equal(core.StringPtr("testString"))) + Expect(policyTemplateReferenceModel.Version).To(Equal(core.StringPtr("testString"))) + + // Construct an instance of the UpdateProfileTemplateVersionOptions model + ifMatch := "testString" + templateID := "testString" + version := "testString" + updateProfileTemplateVersionOptionsModel := iamIdentityService.NewUpdateProfileTemplateVersionOptions(ifMatch, templateID, version) + updateProfileTemplateVersionOptionsModel.SetIfMatch("testString") + updateProfileTemplateVersionOptionsModel.SetTemplateID("testString") + updateProfileTemplateVersionOptionsModel.SetVersion("testString") + updateProfileTemplateVersionOptionsModel.SetAccountID("testString") + updateProfileTemplateVersionOptionsModel.SetName("testString") + updateProfileTemplateVersionOptionsModel.SetDescription("testString") + updateProfileTemplateVersionOptionsModel.SetProfile(templateProfileComponentRequestModel) + updateProfileTemplateVersionOptionsModel.SetPolicyTemplateReferences([]iamidentityv1.PolicyTemplateReference{*policyTemplateReferenceModel}) + updateProfileTemplateVersionOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(updateProfileTemplateVersionOptionsModel).ToNot(BeNil()) + Expect(updateProfileTemplateVersionOptionsModel.IfMatch).To(Equal(core.StringPtr("testString"))) + Expect(updateProfileTemplateVersionOptionsModel.TemplateID).To(Equal(core.StringPtr("testString"))) + Expect(updateProfileTemplateVersionOptionsModel.Version).To(Equal(core.StringPtr("testString"))) + Expect(updateProfileTemplateVersionOptionsModel.AccountID).To(Equal(core.StringPtr("testString"))) + Expect(updateProfileTemplateVersionOptionsModel.Name).To(Equal(core.StringPtr("testString"))) + Expect(updateProfileTemplateVersionOptionsModel.Description).To(Equal(core.StringPtr("testString"))) + Expect(updateProfileTemplateVersionOptionsModel.Profile).To(Equal(templateProfileComponentRequestModel)) + Expect(updateProfileTemplateVersionOptionsModel.PolicyTemplateReferences).To(Equal([]iamidentityv1.PolicyTemplateReference{*policyTemplateReferenceModel})) + Expect(updateProfileTemplateVersionOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) It(`Invoke NewUpdateServiceIDOptions successfully`, func() { // Construct an instance of the UpdateServiceIDOptions model id := "testString" @@ -9560,6 +17446,22 @@ var _ = Describe(`IamIdentityV1`, func() { Expect(updateServiceIDOptionsModel.UniqueInstanceCrns).To(Equal([]string{"testString"})) Expect(updateServiceIDOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewUpdateTrustedProfileAssignmentOptions successfully`, func() { + // Construct an instance of the UpdateTrustedProfileAssignmentOptions model + assignmentID := "testString" + ifMatch := "testString" + updateTrustedProfileAssignmentOptionsTemplateVersion := int64(1) + updateTrustedProfileAssignmentOptionsModel := iamIdentityService.NewUpdateTrustedProfileAssignmentOptions(assignmentID, ifMatch, updateTrustedProfileAssignmentOptionsTemplateVersion) + updateTrustedProfileAssignmentOptionsModel.SetAssignmentID("testString") + updateTrustedProfileAssignmentOptionsModel.SetIfMatch("testString") + updateTrustedProfileAssignmentOptionsModel.SetTemplateVersion(int64(1)) + updateTrustedProfileAssignmentOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(updateTrustedProfileAssignmentOptionsModel).ToNot(BeNil()) + Expect(updateTrustedProfileAssignmentOptionsModel.AssignmentID).To(Equal(core.StringPtr("testString"))) + Expect(updateTrustedProfileAssignmentOptionsModel.IfMatch).To(Equal(core.StringPtr("testString"))) + Expect(updateTrustedProfileAssignmentOptionsModel.TemplateVersion).To(Equal(core.Int64Ptr(int64(1)))) + Expect(updateTrustedProfileAssignmentOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) }) }) Describe(`Utility function tests`, func() {