diff --git a/iamidentityv1/iam_identity_v1.go b/iamidentityv1/iam_identity_v1.go index d03a5e92..0419efda 100644 --- a/iamidentityv1/iam_identity_v1.go +++ b/iamidentityv1/iam_identity_v1.go @@ -15,7 +15,7 @@ */ /* - * IBM OpenAPI SDK Code Generator Version: 3.64.0-959a5845-20230112-195144 + * IBM OpenAPI SDK Code Generator Version: 3.72.0-5d70f2bb-20230511-203609 */ // Package iamidentityv1 : Operations and models for the IamIdentityV1 service @@ -2085,6 +2085,334 @@ func (iamIdentity *IamIdentityV1) DeleteLinkWithContext(ctx context.Context, del return } +// GetProfileIdentities : Get a list of identities that can assume the trusted profile +// Get a list of identities that can assume the trusted profile. +func (iamIdentity *IamIdentityV1) GetProfileIdentities(getProfileIdentitiesOptions *GetProfileIdentitiesOptions) (result *ProfileIdentitiesResponse, response *core.DetailedResponse, err error) { + return iamIdentity.GetProfileIdentitiesWithContext(context.Background(), getProfileIdentitiesOptions) +} + +// GetProfileIdentitiesWithContext is an alternate form of the GetProfileIdentities method which supports a Context parameter +func (iamIdentity *IamIdentityV1) GetProfileIdentitiesWithContext(ctx context.Context, getProfileIdentitiesOptions *GetProfileIdentitiesOptions) (result *ProfileIdentitiesResponse, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getProfileIdentitiesOptions, "getProfileIdentitiesOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(getProfileIdentitiesOptions, "getProfileIdentitiesOptions") + if err != nil { + return + } + + pathParamsMap := map[string]string{ + "profile-id": *getProfileIdentitiesOptions.ProfileID, + } + + builder := core.NewRequestBuilder(core.GET) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = iamIdentity.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(iamIdentity.Service.Options.URL, `/v1/profiles/{profile-id}/identities`, pathParamsMap) + if err != nil { + return + } + + for headerName, headerValue := range getProfileIdentitiesOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("iam_identity", "V1", "GetProfileIdentities") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") + + 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, UnmarshalProfileIdentitiesResponse) + if err != nil { + return + } + response.Result = result + } + + return +} + +// SetProfileIdentities : Update the list of identities that can assume the trusted profile +// Update the list of identities that can assume the trusted profile. +func (iamIdentity *IamIdentityV1) SetProfileIdentities(setProfileIdentitiesOptions *SetProfileIdentitiesOptions) (result *ProfileIdentitiesResponse, response *core.DetailedResponse, err error) { + return iamIdentity.SetProfileIdentitiesWithContext(context.Background(), setProfileIdentitiesOptions) +} + +// SetProfileIdentitiesWithContext is an alternate form of the SetProfileIdentities method which supports a Context parameter +func (iamIdentity *IamIdentityV1) SetProfileIdentitiesWithContext(ctx context.Context, setProfileIdentitiesOptions *SetProfileIdentitiesOptions) (result *ProfileIdentitiesResponse, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(setProfileIdentitiesOptions, "setProfileIdentitiesOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(setProfileIdentitiesOptions, "setProfileIdentitiesOptions") + if err != nil { + return + } + + pathParamsMap := map[string]string{ + "profile-id": *setProfileIdentitiesOptions.ProfileID, + } + + builder := core.NewRequestBuilder(core.PUT) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = iamIdentity.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(iamIdentity.Service.Options.URL, `/v1/profiles/{profile-id}/identities`, pathParamsMap) + if err != nil { + return + } + + for headerName, headerValue := range setProfileIdentitiesOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("iam_identity", "V1", "SetProfileIdentities") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") + builder.AddHeader("Content-Type", "application/json") + if setProfileIdentitiesOptions.IfMatch != nil { + builder.AddHeader("If-Match", fmt.Sprint(*setProfileIdentitiesOptions.IfMatch)) + } + + body := make(map[string]interface{}) + if setProfileIdentitiesOptions.Identities != nil { + body["identities"] = setProfileIdentitiesOptions.Identities + } + _, err = builder.SetBodyContentJSON(body) + if err != nil { + return + } + + 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, UnmarshalProfileIdentitiesResponse) + if err != nil { + return + } + response.Result = result + } + + return +} + +// 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) { + 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) { + err = core.ValidateNotNil(setProfileIdentityOptions, "setProfileIdentityOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(setProfileIdentityOptions, "setProfileIdentityOptions") + if err != nil { + return + } + + pathParamsMap := map[string]string{ + "profile-id": *setProfileIdentityOptions.ProfileID, + "identity-type": *setProfileIdentityOptions.IdentityType, + } + + builder := core.NewRequestBuilder(core.POST) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = iamIdentity.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(iamIdentity.Service.Options.URL, `/v1/profiles/{profile-id}/identities/{identity-type}`, pathParamsMap) + if err != nil { + return + } + + for headerName, headerValue := range setProfileIdentityOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("iam_identity", "V1", "SetProfileIdentity") + 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 setProfileIdentityOptions.Identifier != nil { + body["identifier"] = setProfileIdentityOptions.Identifier + } + 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 + } + if setProfileIdentityOptions.Description != nil { + body["description"] = setProfileIdentityOptions.Description + } + _, err = builder.SetBodyContentJSON(body) + if err != nil { + return + } + + 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, UnmarshalProfileIdentity) + if err != nil { + return + } + response.Result = result + } + + return +} + +// 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) { + 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) { + err = core.ValidateNotNil(getProfileIdentityOptions, "getProfileIdentityOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(getProfileIdentityOptions, "getProfileIdentityOptions") + if err != nil { + return + } + + pathParamsMap := map[string]string{ + "profile-id": *getProfileIdentityOptions.ProfileID, + "identity-type": *getProfileIdentityOptions.IdentityType, + "identifier-id": *getProfileIdentityOptions.IdentifierID, + } + + builder := core.NewRequestBuilder(core.GET) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = iamIdentity.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(iamIdentity.Service.Options.URL, `/v1/profiles/{profile-id}/identities/{identity-type}/{identifier-id}`, pathParamsMap) + if err != nil { + return + } + + for headerName, headerValue := range getProfileIdentityOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("iam_identity", "V1", "GetProfileIdentity") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") + + 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, UnmarshalProfileIdentity) + if err != nil { + return + } + response.Result = result + } + + return +} + +// DeleteProfileIdentity : Delete the identity that can assume the trusted profile +// Delete the identity that can assume the trusted profile. +func (iamIdentity *IamIdentityV1) DeleteProfileIdentity(deleteProfileIdentityOptions *DeleteProfileIdentityOptions) (response *core.DetailedResponse, err error) { + return iamIdentity.DeleteProfileIdentityWithContext(context.Background(), deleteProfileIdentityOptions) +} + +// DeleteProfileIdentityWithContext is an alternate form of the DeleteProfileIdentity method which supports a Context parameter +func (iamIdentity *IamIdentityV1) DeleteProfileIdentityWithContext(ctx context.Context, deleteProfileIdentityOptions *DeleteProfileIdentityOptions) (response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(deleteProfileIdentityOptions, "deleteProfileIdentityOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(deleteProfileIdentityOptions, "deleteProfileIdentityOptions") + if err != nil { + return + } + + pathParamsMap := map[string]string{ + "profile-id": *deleteProfileIdentityOptions.ProfileID, + "identity-type": *deleteProfileIdentityOptions.IdentityType, + "identifier-id": *deleteProfileIdentityOptions.IdentifierID, + } + + builder := core.NewRequestBuilder(core.DELETE) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = iamIdentity.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(iamIdentity.Service.Options.URL, `/v1/profiles/{profile-id}/identities/{identity-type}/{identifier-id}`, pathParamsMap) + if err != nil { + return + } + + for headerName, headerValue := range deleteProfileIdentityOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("iam_identity", "V1", "DeleteProfileIdentity") + 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 +} + // GetAccountSettings : Get account configurations // Returns the details of an account's configuration. func (iamIdentity *IamIdentityV1) GetAccountSettings(getAccountSettingsOptions *GetAccountSettingsOptions) (result *AccountSettingsResponse, response *core.DetailedResponse, err error) { @@ -2632,6 +2960,7 @@ type AccountSettingsResponse 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 @@ -2696,18 +3025,20 @@ const ( // 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" - AccountSettingsResponseMfaTotpConst = "TOTP" - AccountSettingsResponseMfaTotp4allConst = "TOTP4ALL" + 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. @@ -2780,6 +3111,7 @@ type AccountSettingsUserMfa struct { // 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 @@ -2791,18 +3123,20 @@ type AccountSettingsUserMfa struct { // 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" - AccountSettingsUserMfaMfaTotpConst = "TOTP" - AccountSettingsUserMfaMfaTotp4allConst = "TOTP4ALL" + AccountSettingsUserMfaMfaLevel1Const = "LEVEL1" + AccountSettingsUserMfaMfaLevel2Const = "LEVEL2" + AccountSettingsUserMfaMfaLevel3Const = "LEVEL3" + AccountSettingsUserMfaMfaNoneConst = "NONE" + AccountSettingsUserMfaMfaNoneNoRopcConst = "NONE_NO_ROPC" + AccountSettingsUserMfaMfaTotpConst = "TOTP" + AccountSettingsUserMfaMfaTotp4allConst = "TOTP4ALL" ) // NewAccountSettingsUserMfa : Instantiate AccountSettingsUserMfa (Generic Model Constructor) @@ -3800,6 +4134,62 @@ func (options *DeleteLinkOptions) SetHeaders(param map[string]string) *DeleteLin 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. @@ -4210,6 +4600,90 @@ func (options *GetMfaStatusOptions) SetHeaders(param map[string]string) *GetMfaS 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. @@ -4337,6 +4811,7 @@ func (options *GetServiceIDOptions) SetHeaders(param map[string]string) *GetServ 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 @@ -4346,6 +4821,7 @@ 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 @@ -4355,6 +4831,7 @@ 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 @@ -4369,52 +4846,58 @@ type IDBasedMfaEnrollment struct { // 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" - IDBasedMfaEnrollmentTraitAccountDefaultTotpConst = "TOTP" - IDBasedMfaEnrollmentTraitAccountDefaultTotp4allConst = "TOTP4ALL" + 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" - IDBasedMfaEnrollmentTraitUserSpecificTotpConst = "TOTP" - IDBasedMfaEnrollmentTraitUserSpecificTotp4allConst = "TOTP4ALL" + 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" - IDBasedMfaEnrollmentTraitEffectiveTotpConst = "TOTP" - IDBasedMfaEnrollmentTraitEffectiveTotp4allConst = "TOTP4ALL" + 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. @@ -5054,12 +5537,103 @@ func UnmarshalProfileClaimRuleList(m map[string]json.RawMessage, result interfac return } +// 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"` +} + +// 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 +} + +// ProfileIdentity : ProfileIdentity struct +type ProfileIdentity struct { + // IAM ID of the identity. + IamID *string `json:"iam_id,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"` + + // Type of the identity. + Type *string `json:"type" validate:"required"` + + // Only valid for the type user. Accounts from which a user can assume the trusted profile. + Accounts []string `json:"accounts,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"` +} + +// Constants associated with the ProfileIdentity.Type property. +// Type of the identity. +const ( + ProfileIdentityTypeCRNConst = "crn" + ProfileIdentityTypeServiceidConst = "serviceid" + ProfileIdentityTypeUserConst = "user" +) + +// NewProfileIdentity : Instantiate ProfileIdentity (Generic Model Constructor) +func (*IamIdentityV1) NewProfileIdentity(identifier string, typeVar string) (_model *ProfileIdentity, err error) { + _model = &ProfileIdentity{ + Identifier: core.StringPtr(identifier), + 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 +} + // ProfileLink : Link details. type ProfileLink struct { - // the unique identifier of the claim rule. + // the unique identifier of the link. ID *string `json:"id" validate:"required"` - // version of the claim rule. + // version of the link. EntityTag *string `json:"entity_tag" validate:"required"` // If set contains a date time string of the creation date in ISO format. @@ -5568,6 +6142,160 @@ 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="` + + // 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"` + + // Type of the identity. + Type *string `json:"type" validate:"required"` + + // IAM ID of the identity. + IamID *string `json:"iam_id,omitempty"` + + // Only valid for the type user. Accounts from which a user can assume the trusted profile. + Accounts []string `json:"accounts,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"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// 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), + } +} + +// 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. @@ -5822,6 +6550,7 @@ type UpdateAccountSettingsOptions 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 @@ -5886,18 +6615,20 @@ const ( // 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. const ( - UpdateAccountSettingsOptionsMfaLevel1Const = "LEVEL1" - UpdateAccountSettingsOptionsMfaLevel2Const = "LEVEL2" - UpdateAccountSettingsOptionsMfaLevel3Const = "LEVEL3" - UpdateAccountSettingsOptionsMfaNoneConst = "NONE" - UpdateAccountSettingsOptionsMfaTotpConst = "TOTP" - UpdateAccountSettingsOptionsMfaTotp4allConst = "TOTP4ALL" + UpdateAccountSettingsOptionsMfaLevel1Const = "LEVEL1" + UpdateAccountSettingsOptionsMfaLevel2Const = "LEVEL2" + UpdateAccountSettingsOptionsMfaLevel3Const = "LEVEL3" + UpdateAccountSettingsOptionsMfaNoneConst = "NONE" + UpdateAccountSettingsOptionsMfaNoneNoRopcConst = "NONE_NO_ROPC" + UpdateAccountSettingsOptionsMfaTotpConst = "TOTP" + UpdateAccountSettingsOptionsMfaTotp4allConst = "TOTP4ALL" ) // NewUpdateAccountSettingsOptions : Instantiate UpdateAccountSettingsOptions diff --git a/iamidentityv1/iam_identity_v1_examples_test.go b/iamidentityv1/iam_identity_v1_examples_test.go index a42b0b69..cc4b0766 100644 --- a/iamidentityv1/iam_identity_v1_examples_test.go +++ b/iamidentityv1/iam_identity_v1_examples_test.go @@ -719,6 +719,140 @@ var _ = Describe(`IamIdentityV1 Examples Tests`, func() { Expect(err).To(BeNil()) Expect(response.StatusCode).To(Equal(204)) }) + It(`GetProfileIdentities request example`, func() { + fmt.Println("\nGetProfileIdentities() result:") + // begin-get_profile_identities + + getProfileIdentitiesOptions := iamidentityv1.GetProfileIdentitiesOptions{ + ProfileID: &profileId, + } + + profileIdentities, response, err := iamIdentityService.GetProfileIdentities(&getProfileIdentitiesOptions) + + if err != nil { + panic(err) + } + b, _ := json.MarshalIndent(profileIdentities, "", " ") + fmt.Println(string(b)) + + // end-get_profile_identities + fmt.Printf("\nSetProfileIdentities() response status code: %d\n", response.StatusCode) + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(profileIdentities).ToNot(BeNil()) + Expect(profileEtag).ToNot(BeEmpty()) + profileEtag = *profileIdentities.EntityTag + }) + It(`SetProfileIdentities request example`, func() { + fmt.Println("\nSetProfileIdentities() result:") + // begin-set_profile_identities + + accounts := []string{accountID} + identity := &iamidentityv1.ProfileIdentity{ + Identifier: &iamID, + Accounts: accounts, + Type: core.StringPtr("user"), + Description: core.StringPtr("Identity description"), + } + listProfileIdentity := []iamidentityv1.ProfileIdentity{*identity} + setProfileIdentitiesOptions := iamidentityv1.SetProfileIdentitiesOptions{ + ProfileID: &profileId, + Identities: listProfileIdentity, + IfMatch: &profileEtag, + } + + profileIdnetities, response, err := iamIdentityService.SetProfileIdentities(&setProfileIdentitiesOptions) + + if err != nil { + panic(err) + } + b, _ := json.MarshalIndent(profileIdnetities, "", " ") + fmt.Println(string(b)) + + // end-set_profile_identities + fmt.Printf("\nSetProfileIdentities() response status code: %d\n", response.StatusCode) + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(profileIdnetities).ToNot(BeNil()) + }) + It(`SetProfileIdentity request example`, func() { + fmt.Println("\nSetProfileIdentity() result:") + // begin-set_profile_identity + + accounts := []string{accountID} + setProfileIdentityOptions := iamidentityv1.SetProfileIdentityOptions{ + ProfileID: &profileId, + IdentityType: core.StringPtr("user"), + Identifier: &iamIDMember, + Accounts: accounts, + Type: core.StringPtr("user"), + Description: core.StringPtr("Identity description"), + } + + profileIdnetity, response, err := iamIdentityService.SetProfileIdentity(&setProfileIdentityOptions) + + if err != nil { + panic(err) + } + b, _ := json.MarshalIndent(profileIdnetity, "", " ") + fmt.Println(string(b)) + + // end-set_profile_identity + fmt.Printf("\nSetProfileIdentity() response status code: %d\n", response.StatusCode) + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(profileIdnetity).ToNot(BeNil()) + }) + It(`GetProfileIdentity request example`, func() { + fmt.Println("\nGetProfileIdentity() result:") + // begin-get_profile_identity + + getProfileIdentityOptions := iamidentityv1.GetProfileIdentityOptions{ + ProfileID: &profileId, + IdentityType: core.StringPtr("user"), + IdentifierID: &iamIDMember, + } + + profileIdnetity, response, err := iamIdentityService.GetProfileIdentity(&getProfileIdentityOptions) + + if err != nil { + panic(err) + } + b, _ := json.MarshalIndent(profileIdnetity, "", " ") + fmt.Println(string(b)) + + // end-get_profile_identity + fmt.Printf("\nGetProfileIdentity() response status code: %d\n", response.StatusCode) + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(profileIdnetity).ToNot(BeNil()) + }) + It(`DeleteProfileIdentity request example`, func() { + fmt.Println("\nDeleteProfileIdentity() result:") + // begin-delete_profile_identity + + deleteProfileIdentityOptions := iamidentityv1.DeleteProfileIdentityOptions{ + ProfileID: &profileId, + IdentityType: core.StringPtr("user"), + IdentifierID: &iamIDMember, + } + + response, err := iamIdentityService.DeleteProfileIdentity(&deleteProfileIdentityOptions) + + if err != nil { + panic(err) + } + + // end-delete_profile_identity + fmt.Printf("\nGetProfileIdentity() response status code: %d\n", response.StatusCode) + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(204)) + }) It(`DeleteProfile request example`, func() { // begin-delete_profile diff --git a/iamidentityv1/iam_identity_v1_integration_test.go b/iamidentityv1/iam_identity_v1_integration_test.go index ea9e1807..6440a571 100644 --- a/iamidentityv1/iam_identity_v1_integration_test.go +++ b/iamidentityv1/iam_identity_v1_integration_test.go @@ -1034,6 +1034,125 @@ var _ = Describe(`IamIdentityV1 Integration Tests`, func() { }) }) + Describe(`SetProfileIdentities - Set Profile Identities`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`SetProfileIdentities(setProfileIdentitiesOptions *SetProfileIdentitiesOptions)`, func() { + + accounts := []string{accountID} + identity := &iamidentityv1.ProfileIdentity{ + Identifier: &iamID, + Accounts: accounts, + Type: core.StringPtr("user"), + Description: core.StringPtr("Identity description"), + } + listProfileIdentity := []iamidentityv1.ProfileIdentity{*identity} + setProfileIdentitiesOptions := iamidentityv1.SetProfileIdentitiesOptions{ + ProfileID: &profileId2, + Identities: listProfileIdentity, + IfMatch: core.StringPtr("*"), + } + + profileIdnetities, 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)) + }) + }) + + Describe(`GetProfileIdentities - Get Profile Identities`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`GetProfileIdentities(getProfileIdentitiesOptions *GetProfileIdentitiesOptions)`, func() { + + getProfileIdentitiesOptions := iamidentityv1.GetProfileIdentitiesOptions{ + ProfileID: &profileId2, + } + + profileIdnetities, 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)) + }) + }) + + Describe(`SetProfileIdentity - Set single identity on Trusted Profile`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`SetProfileIdentity(setProfileIdentityOptions *SetProfileIdentityOptions)`, func() { + + accounts := []string{accountID} + + setProfileIdentityOptions := iamidentityv1.SetProfileIdentityOptions{ + ProfileID: &profileId2, + IdentityType: core.StringPtr("user"), + Identifier: &iamIDMember, + Accounts: accounts, + Type: core.StringPtr("user"), + Description: core.StringPtr("Identity description"), + } + + profileIdnetity, response, err := iamIdentityService.SetProfileIdentity(&setProfileIdentityOptions) + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + + Expect(profileIdnetity).ToNot(BeNil()) + fmt.Fprintf(GinkgoWriter, "SetProfileIdentities #1 response:\n%s\n", common.ToJSON(profileIdnetity)) + }) + }) + + Describe(`GetProfileIdentity - Get specific identity of the profile`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`GetProfileIdentity(getProfileIdentityOptions *GetProfileIdentityOptions)`, func() { + + getProfileIdentityOptions := iamidentityv1.GetProfileIdentityOptions{ + ProfileID: &profileId2, + IdentityType: core.StringPtr("user"), + IdentifierID: &iamIDMember, + } + + profileIdnetity, response, err := iamIdentityService.GetProfileIdentity(&getProfileIdentityOptions) + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + + Expect(profileIdnetity.Identifier).ToNot(BeNil()) + fmt.Fprintf(GinkgoWriter, "SetProfileIdentities #1 response:\n%s\n", common.ToJSON(profileIdnetity)) + }) + }) + + Describe(`DeleteProfileIdentity - Delete specific identity of the profile`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`DeleteProfileIdentity(deleteProfileIdentityOptions *DeleteProfileIdentityOptions)`, func() { + + deleteProfileIdentityOptions := iamidentityv1.DeleteProfileIdentityOptions{ + ProfileID: &profileId2, + IdentityType: core.StringPtr("user"), + IdentifierID: &iamIDMember, + } + + response, err := iamIdentityService.DeleteProfileIdentity(&deleteProfileIdentityOptions) + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(204)) + }) + }) + Describe(`DeleteProfile2 - Delete trusted profile #2`, func() { BeforeEach(func() { shouldSkipTest() diff --git a/iamidentityv1/iam_identity_v1_test.go b/iamidentityv1/iam_identity_v1_test.go index 0a628fc6..01abf269 100644 --- a/iamidentityv1/iam_identity_v1_test.go +++ b/iamidentityv1/iam_identity_v1_test.go @@ -6030,6 +6030,1086 @@ var _ = Describe(`IamIdentityV1`, func() { }) }) }) + Describe(`GetProfileIdentities(getProfileIdentitiesOptions *GetProfileIdentitiesOptions) - Operation response error`, func() { + getProfileIdentitiesPath := "/v1/profiles/testString/identities" + 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(getProfileIdentitiesPath)) + 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 GetProfileIdentities 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 GetProfileIdentitiesOptions model + getProfileIdentitiesOptionsModel := new(iamidentityv1.GetProfileIdentitiesOptions) + getProfileIdentitiesOptionsModel.ProfileID = core.StringPtr("testString") + getProfileIdentitiesOptionsModel.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.GetProfileIdentities(getProfileIdentitiesOptionsModel) + 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.GetProfileIdentities(getProfileIdentitiesOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetProfileIdentities(getProfileIdentitiesOptions *GetProfileIdentitiesOptions)`, func() { + getProfileIdentitiesPath := "/v1/profiles/testString/identities" + 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(getProfileIdentitiesPath)) + 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", `{"entity_tag": "EntityTag", "identities": [{"iam_id": "IamID", "identifier": "Identifier", "type": "user", "accounts": ["Accounts"], "description": "Description"}]}`) + })) + }) + It(`Invoke GetProfileIdentities 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 GetProfileIdentitiesOptions model + getProfileIdentitiesOptionsModel := new(iamidentityv1.GetProfileIdentitiesOptions) + getProfileIdentitiesOptionsModel.ProfileID = core.StringPtr("testString") + getProfileIdentitiesOptionsModel.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.GetProfileIdentitiesWithContext(ctx, getProfileIdentitiesOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + iamIdentityService.DisableRetries() + result, response, operationErr := iamIdentityService.GetProfileIdentities(getProfileIdentitiesOptionsModel) + 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.GetProfileIdentitiesWithContext(ctx, getProfileIdentitiesOptionsModel) + 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(getProfileIdentitiesPath)) + Expect(req.Method).To(Equal("GET")) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"entity_tag": "EntityTag", "identities": [{"iam_id": "IamID", "identifier": "Identifier", "type": "user", "accounts": ["Accounts"], "description": "Description"}]}`) + })) + }) + It(`Invoke GetProfileIdentities 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.GetProfileIdentities(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the GetProfileIdentitiesOptions model + getProfileIdentitiesOptionsModel := new(iamidentityv1.GetProfileIdentitiesOptions) + getProfileIdentitiesOptionsModel.ProfileID = core.StringPtr("testString") + getProfileIdentitiesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = iamIdentityService.GetProfileIdentities(getProfileIdentitiesOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke GetProfileIdentities 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 GetProfileIdentitiesOptions model + getProfileIdentitiesOptionsModel := new(iamidentityv1.GetProfileIdentitiesOptions) + getProfileIdentitiesOptionsModel.ProfileID = core.StringPtr("testString") + getProfileIdentitiesOptionsModel.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.GetProfileIdentities(getProfileIdentitiesOptionsModel) + 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 GetProfileIdentitiesOptions model with no property values + getProfileIdentitiesOptionsModelNew := new(iamidentityv1.GetProfileIdentitiesOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = iamIdentityService.GetProfileIdentities(getProfileIdentitiesOptionsModelNew) + 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 GetProfileIdentities 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 GetProfileIdentitiesOptions model + getProfileIdentitiesOptionsModel := new(iamidentityv1.GetProfileIdentitiesOptions) + getProfileIdentitiesOptionsModel.ProfileID = core.StringPtr("testString") + getProfileIdentitiesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamIdentityService.GetProfileIdentities(getProfileIdentitiesOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`SetProfileIdentities(setProfileIdentitiesOptions *SetProfileIdentitiesOptions) - Operation response error`, func() { + setProfileIdentitiesPath := "/v1/profiles/testString/identities" + 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(setProfileIdentitiesPath)) + 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 SetProfileIdentities 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 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 SetProfileIdentitiesOptions model + setProfileIdentitiesOptionsModel := new(iamidentityv1.SetProfileIdentitiesOptions) + setProfileIdentitiesOptionsModel.ProfileID = core.StringPtr("testString") + setProfileIdentitiesOptionsModel.IfMatch = core.StringPtr("testString") + setProfileIdentitiesOptionsModel.Identities = []iamidentityv1.ProfileIdentity{*profileIdentityModel} + 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) + 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.SetProfileIdentities(setProfileIdentitiesOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`SetProfileIdentities(setProfileIdentitiesOptions *SetProfileIdentitiesOptions)`, func() { + setProfileIdentitiesPath := "/v1/profiles/testString/identities" + 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(setProfileIdentitiesPath)) + 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", `{"entity_tag": "EntityTag", "identities": [{"iam_id": "IamID", "identifier": "Identifier", "type": "user", "accounts": ["Accounts"], "description": "Description"}]}`) + })) + }) + It(`Invoke SetProfileIdentities 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 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 SetProfileIdentitiesOptions model + setProfileIdentitiesOptionsModel := new(iamidentityv1.SetProfileIdentitiesOptions) + setProfileIdentitiesOptionsModel.ProfileID = core.StringPtr("testString") + setProfileIdentitiesOptionsModel.IfMatch = core.StringPtr("testString") + setProfileIdentitiesOptionsModel.Identities = []iamidentityv1.ProfileIdentity{*profileIdentityModel} + setProfileIdentitiesOptionsModel.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.SetProfileIdentitiesWithContext(ctx, setProfileIdentitiesOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + iamIdentityService.DisableRetries() + result, response, operationErr := iamIdentityService.SetProfileIdentities(setProfileIdentitiesOptionsModel) + 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.SetProfileIdentitiesWithContext(ctx, setProfileIdentitiesOptionsModel) + 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(setProfileIdentitiesPath)) + 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", `{"entity_tag": "EntityTag", "identities": [{"iam_id": "IamID", "identifier": "Identifier", "type": "user", "accounts": ["Accounts"], "description": "Description"}]}`) + })) + }) + It(`Invoke SetProfileIdentities 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.SetProfileIdentities(nil) + Expect(operationErr).NotTo(BeNil()) + 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 SetProfileIdentitiesOptions model + setProfileIdentitiesOptionsModel := new(iamidentityv1.SetProfileIdentitiesOptions) + setProfileIdentitiesOptionsModel.ProfileID = core.StringPtr("testString") + setProfileIdentitiesOptionsModel.IfMatch = core.StringPtr("testString") + setProfileIdentitiesOptionsModel.Identities = []iamidentityv1.ProfileIdentity{*profileIdentityModel} + setProfileIdentitiesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = iamIdentityService.SetProfileIdentities(setProfileIdentitiesOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke SetProfileIdentities 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 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 SetProfileIdentitiesOptions model + setProfileIdentitiesOptionsModel := new(iamidentityv1.SetProfileIdentitiesOptions) + setProfileIdentitiesOptionsModel.ProfileID = core.StringPtr("testString") + setProfileIdentitiesOptionsModel.IfMatch = core.StringPtr("testString") + setProfileIdentitiesOptionsModel.Identities = []iamidentityv1.ProfileIdentity{*profileIdentityModel} + setProfileIdentitiesOptionsModel.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.SetProfileIdentities(setProfileIdentitiesOptionsModel) + 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 SetProfileIdentitiesOptions model with no property values + setProfileIdentitiesOptionsModelNew := new(iamidentityv1.SetProfileIdentitiesOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = iamIdentityService.SetProfileIdentities(setProfileIdentitiesOptionsModelNew) + 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 SetProfileIdentities 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 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 SetProfileIdentitiesOptions model + setProfileIdentitiesOptionsModel := new(iamidentityv1.SetProfileIdentitiesOptions) + setProfileIdentitiesOptionsModel.ProfileID = core.StringPtr("testString") + setProfileIdentitiesOptionsModel.IfMatch = core.StringPtr("testString") + setProfileIdentitiesOptionsModel.Identities = []iamidentityv1.ProfileIdentity{*profileIdentityModel} + setProfileIdentitiesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamIdentityService.SetProfileIdentities(setProfileIdentitiesOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`SetProfileIdentity(setProfileIdentityOptions *SetProfileIdentityOptions) - Operation response error`, func() { + setProfileIdentityPath := "/v1/profiles/testString/identities/user" + 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(setProfileIdentityPath)) + Expect(req.Method).To(Equal("POST")) + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke SetProfileIdentity 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 SetProfileIdentityOptions model + setProfileIdentityOptionsModel := new(iamidentityv1.SetProfileIdentityOptions) + setProfileIdentityOptionsModel.ProfileID = core.StringPtr("testString") + 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"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := iamIdentityService.SetProfileIdentity(setProfileIdentityOptionsModel) + 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.SetProfileIdentity(setProfileIdentityOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`SetProfileIdentity(setProfileIdentityOptions *SetProfileIdentityOptions)`, func() { + setProfileIdentityPath := "/v1/profiles/testString/identities/user" + 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(setProfileIdentityPath)) + 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(200) + fmt.Fprintf(res, "%s", `{"iam_id": "IamID", "identifier": "Identifier", "type": "user", "accounts": ["Accounts"], "description": "Description"}`) + })) + }) + It(`Invoke SetProfileIdentity 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 SetProfileIdentityOptions model + setProfileIdentityOptionsModel := new(iamidentityv1.SetProfileIdentityOptions) + setProfileIdentityOptionsModel.ProfileID = core.StringPtr("testString") + 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"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := iamIdentityService.SetProfileIdentityWithContext(ctx, setProfileIdentityOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + iamIdentityService.DisableRetries() + result, response, operationErr := iamIdentityService.SetProfileIdentity(setProfileIdentityOptionsModel) + 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.SetProfileIdentityWithContext(ctx, setProfileIdentityOptionsModel) + 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(setProfileIdentityPath)) + 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(200) + fmt.Fprintf(res, "%s", `{"iam_id": "IamID", "identifier": "Identifier", "type": "user", "accounts": ["Accounts"], "description": "Description"}`) + })) + }) + It(`Invoke SetProfileIdentity 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.SetProfileIdentity(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the SetProfileIdentityOptions model + setProfileIdentityOptionsModel := new(iamidentityv1.SetProfileIdentityOptions) + setProfileIdentityOptionsModel.ProfileID = core.StringPtr("testString") + 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"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = iamIdentityService.SetProfileIdentity(setProfileIdentityOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke SetProfileIdentity 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 SetProfileIdentityOptions model + setProfileIdentityOptionsModel := new(iamidentityv1.SetProfileIdentityOptions) + setProfileIdentityOptionsModel.ProfileID = core.StringPtr("testString") + 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"} + // Invoke operation with empty URL (negative test) + err := iamIdentityService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := iamIdentityService.SetProfileIdentity(setProfileIdentityOptionsModel) + 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 SetProfileIdentityOptions model with no property values + setProfileIdentityOptionsModelNew := new(iamidentityv1.SetProfileIdentityOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = iamIdentityService.SetProfileIdentity(setProfileIdentityOptionsModelNew) + 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 SetProfileIdentity 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 SetProfileIdentityOptions model + setProfileIdentityOptionsModel := new(iamidentityv1.SetProfileIdentityOptions) + setProfileIdentityOptionsModel.ProfileID = core.StringPtr("testString") + 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"} + + // Invoke operation + result, response, operationErr := iamIdentityService.SetProfileIdentity(setProfileIdentityOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetProfileIdentity(getProfileIdentityOptions *GetProfileIdentityOptions) - Operation response error`, func() { + getProfileIdentityPath := "/v1/profiles/testString/identities/user/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(getProfileIdentityPath)) + 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 GetProfileIdentity 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 GetProfileIdentityOptions model + getProfileIdentityOptionsModel := new(iamidentityv1.GetProfileIdentityOptions) + getProfileIdentityOptionsModel.ProfileID = core.StringPtr("testString") + getProfileIdentityOptionsModel.IdentityType = core.StringPtr("user") + getProfileIdentityOptionsModel.IdentifierID = core.StringPtr("testString") + getProfileIdentityOptionsModel.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.GetProfileIdentity(getProfileIdentityOptionsModel) + 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.GetProfileIdentity(getProfileIdentityOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetProfileIdentity(getProfileIdentityOptions *GetProfileIdentityOptions)`, func() { + getProfileIdentityPath := "/v1/profiles/testString/identities/user/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(getProfileIdentityPath)) + 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", `{"iam_id": "IamID", "identifier": "Identifier", "type": "user", "accounts": ["Accounts"], "description": "Description"}`) + })) + }) + It(`Invoke GetProfileIdentity 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 GetProfileIdentityOptions model + getProfileIdentityOptionsModel := new(iamidentityv1.GetProfileIdentityOptions) + getProfileIdentityOptionsModel.ProfileID = core.StringPtr("testString") + getProfileIdentityOptionsModel.IdentityType = core.StringPtr("user") + getProfileIdentityOptionsModel.IdentifierID = core.StringPtr("testString") + getProfileIdentityOptionsModel.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.GetProfileIdentityWithContext(ctx, getProfileIdentityOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + iamIdentityService.DisableRetries() + result, response, operationErr := iamIdentityService.GetProfileIdentity(getProfileIdentityOptionsModel) + 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.GetProfileIdentityWithContext(ctx, getProfileIdentityOptionsModel) + 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(getProfileIdentityPath)) + Expect(req.Method).To(Equal("GET")) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"iam_id": "IamID", "identifier": "Identifier", "type": "user", "accounts": ["Accounts"], "description": "Description"}`) + })) + }) + It(`Invoke GetProfileIdentity 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.GetProfileIdentity(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the GetProfileIdentityOptions model + getProfileIdentityOptionsModel := new(iamidentityv1.GetProfileIdentityOptions) + getProfileIdentityOptionsModel.ProfileID = core.StringPtr("testString") + getProfileIdentityOptionsModel.IdentityType = core.StringPtr("user") + getProfileIdentityOptionsModel.IdentifierID = core.StringPtr("testString") + getProfileIdentityOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = iamIdentityService.GetProfileIdentity(getProfileIdentityOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke GetProfileIdentity 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 GetProfileIdentityOptions model + getProfileIdentityOptionsModel := new(iamidentityv1.GetProfileIdentityOptions) + getProfileIdentityOptionsModel.ProfileID = core.StringPtr("testString") + getProfileIdentityOptionsModel.IdentityType = core.StringPtr("user") + getProfileIdentityOptionsModel.IdentifierID = core.StringPtr("testString") + getProfileIdentityOptionsModel.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.GetProfileIdentity(getProfileIdentityOptionsModel) + 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 GetProfileIdentityOptions model with no property values + getProfileIdentityOptionsModelNew := new(iamidentityv1.GetProfileIdentityOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = iamIdentityService.GetProfileIdentity(getProfileIdentityOptionsModelNew) + 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 GetProfileIdentity 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 GetProfileIdentityOptions model + getProfileIdentityOptionsModel := new(iamidentityv1.GetProfileIdentityOptions) + getProfileIdentityOptionsModel.ProfileID = core.StringPtr("testString") + getProfileIdentityOptionsModel.IdentityType = core.StringPtr("user") + getProfileIdentityOptionsModel.IdentifierID = core.StringPtr("testString") + getProfileIdentityOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamIdentityService.GetProfileIdentity(getProfileIdentityOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`DeleteProfileIdentity(deleteProfileIdentityOptions *DeleteProfileIdentityOptions)`, func() { + deleteProfileIdentityPath := "/v1/profiles/testString/identities/user/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(deleteProfileIdentityPath)) + Expect(req.Method).To(Equal("DELETE")) + + res.WriteHeader(204) + })) + }) + It(`Invoke DeleteProfileIdentity 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.DeleteProfileIdentity(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + + // Construct an instance of the DeleteProfileIdentityOptions model + deleteProfileIdentityOptionsModel := new(iamidentityv1.DeleteProfileIdentityOptions) + deleteProfileIdentityOptionsModel.ProfileID = core.StringPtr("testString") + deleteProfileIdentityOptionsModel.IdentityType = core.StringPtr("user") + deleteProfileIdentityOptionsModel.IdentifierID = core.StringPtr("testString") + deleteProfileIdentityOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + response, operationErr = iamIdentityService.DeleteProfileIdentity(deleteProfileIdentityOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + }) + It(`Invoke DeleteProfileIdentity 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 DeleteProfileIdentityOptions model + deleteProfileIdentityOptionsModel := new(iamidentityv1.DeleteProfileIdentityOptions) + deleteProfileIdentityOptionsModel.ProfileID = core.StringPtr("testString") + deleteProfileIdentityOptionsModel.IdentityType = core.StringPtr("user") + deleteProfileIdentityOptionsModel.IdentifierID = core.StringPtr("testString") + deleteProfileIdentityOptionsModel.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.DeleteProfileIdentity(deleteProfileIdentityOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + // Construct a second instance of the DeleteProfileIdentityOptions model with no property values + deleteProfileIdentityOptionsModelNew := new(iamidentityv1.DeleteProfileIdentityOptions) + // Invoke operation with invalid model (negative test) + response, operationErr = iamIdentityService.DeleteProfileIdentity(deleteProfileIdentityOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) Describe(`GetAccountSettings(getAccountSettingsOptions *GetAccountSettingsOptions) - Operation response error`, func() { getAccountSettingsPath := "/v1/accounts/testString/settings/identity" Context(`Using mock server endpoint with invalid JSON response`, func() { @@ -7931,6 +9011,22 @@ var _ = Describe(`IamIdentityV1`, func() { Expect(deleteLinkOptionsModel.LinkID).To(Equal(core.StringPtr("testString"))) Expect(deleteLinkOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewDeleteProfileIdentityOptions successfully`, func() { + // Construct an instance of the DeleteProfileIdentityOptions model + profileID := "testString" + identityType := "user" + identifierID := "testString" + deleteProfileIdentityOptionsModel := iamIdentityService.NewDeleteProfileIdentityOptions(profileID, identityType, identifierID) + deleteProfileIdentityOptionsModel.SetProfileID("testString") + deleteProfileIdentityOptionsModel.SetIdentityType("user") + deleteProfileIdentityOptionsModel.SetIdentifierID("testString") + deleteProfileIdentityOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(deleteProfileIdentityOptionsModel).ToNot(BeNil()) + Expect(deleteProfileIdentityOptionsModel.ProfileID).To(Equal(core.StringPtr("testString"))) + Expect(deleteProfileIdentityOptionsModel.IdentityType).To(Equal(core.StringPtr("user"))) + Expect(deleteProfileIdentityOptionsModel.IdentifierID).To(Equal(core.StringPtr("testString"))) + Expect(deleteProfileIdentityOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) It(`Invoke NewDeleteProfileOptions successfully`, func() { // Construct an instance of the DeleteProfileOptions model profileID := "testString" @@ -8040,6 +9136,32 @@ var _ = Describe(`IamIdentityV1`, func() { Expect(getMfaStatusOptionsModel.IamID).To(Equal(core.StringPtr("testString"))) Expect(getMfaStatusOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewGetProfileIdentitiesOptions successfully`, func() { + // Construct an instance of the GetProfileIdentitiesOptions model + profileID := "testString" + getProfileIdentitiesOptionsModel := iamIdentityService.NewGetProfileIdentitiesOptions(profileID) + getProfileIdentitiesOptionsModel.SetProfileID("testString") + getProfileIdentitiesOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(getProfileIdentitiesOptionsModel).ToNot(BeNil()) + Expect(getProfileIdentitiesOptionsModel.ProfileID).To(Equal(core.StringPtr("testString"))) + Expect(getProfileIdentitiesOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) + It(`Invoke NewGetProfileIdentityOptions successfully`, func() { + // Construct an instance of the GetProfileIdentityOptions model + profileID := "testString" + identityType := "user" + identifierID := "testString" + getProfileIdentityOptionsModel := iamIdentityService.NewGetProfileIdentityOptions(profileID, identityType, identifierID) + getProfileIdentityOptionsModel.SetProfileID("testString") + getProfileIdentityOptionsModel.SetIdentityType("user") + getProfileIdentityOptionsModel.SetIdentifierID("testString") + getProfileIdentityOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(getProfileIdentityOptionsModel).ToNot(BeNil()) + Expect(getProfileIdentityOptionsModel.ProfileID).To(Equal(core.StringPtr("testString"))) + Expect(getProfileIdentityOptionsModel.IdentityType).To(Equal(core.StringPtr("user"))) + Expect(getProfileIdentityOptionsModel.IdentifierID).To(Equal(core.StringPtr("testString"))) + Expect(getProfileIdentityOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) It(`Invoke NewGetProfileOptions successfully`, func() { // Construct an instance of the GetProfileOptions model profileID := "testString" @@ -8195,6 +9317,67 @@ var _ = Describe(`IamIdentityV1`, func() { Expect(_model).ToNot(BeNil()) Expect(err).To(BeNil()) }) + It(`Invoke NewProfileIdentity successfully`, func() { + identifier := "testString" + typeVar := "user" + _model, err := iamIdentityService.NewProfileIdentity(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 SetProfileIdentitiesOptions model + profileID := "testString" + ifMatch := "testString" + setProfileIdentitiesOptionsModel := iamIdentityService.NewSetProfileIdentitiesOptions(profileID, ifMatch) + setProfileIdentitiesOptionsModel.SetProfileID("testString") + setProfileIdentitiesOptionsModel.SetIfMatch("testString") + setProfileIdentitiesOptionsModel.SetIdentities([]iamidentityv1.ProfileIdentity{*profileIdentityModel}) + 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.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) + It(`Invoke NewSetProfileIdentityOptions successfully`, func() { + // Construct an instance of the SetProfileIdentityOptions model + profileID := "testString" + identityType := "user" + setProfileIdentityOptionsIdentifier := "testString" + setProfileIdentityOptionsType := "user" + setProfileIdentityOptionsModel := iamIdentityService.NewSetProfileIdentityOptions(profileID, identityType, setProfileIdentityOptionsIdentifier, setProfileIdentityOptionsType) + setProfileIdentityOptionsModel.SetProfileID("testString") + 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"}) + Expect(setProfileIdentityOptionsModel).ToNot(BeNil()) + Expect(setProfileIdentityOptionsModel.ProfileID).To(Equal(core.StringPtr("testString"))) + 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 NewUnlockAPIKeyOptions successfully`, func() { // Construct an instance of the UnlockAPIKeyOptions model id := "testString"