From 0b54331b42b62f2313f450f674b6d60dde6ea1d6 Mon Sep 17 00:00:00 2001 From: Nagarjuna Mamillapalle Date: Sat, 26 Jun 2021 01:24:33 +0530 Subject: [PATCH] fix(IAM Access Groups): update service after recent api changes (#133) --- iamaccessgroupsv2/iam_access_groups_v2.go | 723 +++++----- .../iam_access_groups_v2_suite_test.go | 3 +- .../iam_access_groups_v2_test.go | 1171 ++++++++++------- 3 files changed, 1117 insertions(+), 780 deletions(-) diff --git a/iamaccessgroupsv2/iam_access_groups_v2.go b/iamaccessgroupsv2/iam_access_groups_v2.go index 9f7651b8..3cd2c968 100644 --- a/iamaccessgroupsv2/iam_access_groups_v2.go +++ b/iamaccessgroupsv2/iam_access_groups_v2.go @@ -15,7 +15,7 @@ */ /* - * IBM OpenAPI SDK Code Generator Version: 3.29.1-b338fb38-20210313-010605 + * IBM OpenAPI SDK Code Generator Version: 3.34.1-ad041667-20210617-195430 */ // Package iamaccessgroupsv2 : Operations and models for the IamAccessGroupsV2 service @@ -27,6 +27,7 @@ import ( "fmt" "net/http" "reflect" + "strconv" "time" "github.com/IBM/go-sdk-core/v5/core" @@ -227,11 +228,13 @@ func (iamAccessGroups *IamAccessGroupsV2) CreateAccessGroupWithContext(ctx conte if err != nil { return } - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalGroup) - if err != nil { - return + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalGroup) + if err != nil { + return + } + response.Result = result } - response.Result = result return } @@ -307,11 +310,13 @@ func (iamAccessGroups *IamAccessGroupsV2) ListAccessGroupsWithContext(ctx contex if err != nil { return } - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalGroupsList) - if err != nil { - return + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalGroupsList) + if err != nil { + return + } + response.Result = result } - response.Result = result return } @@ -374,11 +379,13 @@ func (iamAccessGroups *IamAccessGroupsV2) GetAccessGroupWithContext(ctx context. if err != nil { return } - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalGroup) - if err != nil { - return + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalGroup) + if err != nil { + return + } + response.Result = result } - response.Result = result return } @@ -452,11 +459,13 @@ func (iamAccessGroups *IamAccessGroupsV2) UpdateAccessGroupWithContext(ctx conte if err != nil { return } - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalGroup) - if err != nil { - return + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalGroup) + if err != nil { + return + } + response.Result = result } - response.Result = result return } @@ -539,7 +548,7 @@ func (iamAccessGroups *IamAccessGroupsV2) IsMemberOfAccessGroupWithContext(ctx c pathParamsMap := map[string]string{ "access_group_id": *isMemberOfAccessGroupOptions.AccessGroupID, - "iam_id": *isMemberOfAccessGroupOptions.IamID, + "iam_id": *isMemberOfAccessGroupOptions.IamID, } builder := core.NewRequestBuilder(core.HEAD) @@ -637,11 +646,13 @@ func (iamAccessGroups *IamAccessGroupsV2) AddMembersToAccessGroupWithContext(ctx if err != nil { return } - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalAddGroupMembersResponse) - if err != nil { - return + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalAddGroupMembersResponse) + if err != nil { + return + } + response.Result = result } - response.Result = result return } @@ -717,11 +728,13 @@ func (iamAccessGroups *IamAccessGroupsV2) ListAccessGroupMembersWithContext(ctx if err != nil { return } - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalGroupMembersList) - if err != nil { - return + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalGroupMembersList) + if err != nil { + return + } + response.Result = result } - response.Result = result return } @@ -746,7 +759,7 @@ func (iamAccessGroups *IamAccessGroupsV2) RemoveMemberFromAccessGroupWithContext pathParamsMap := map[string]string{ "access_group_id": *removeMemberFromAccessGroupOptions.AccessGroupID, - "iam_id": *removeMemberFromAccessGroupOptions.IamID, + "iam_id": *removeMemberFromAccessGroupOptions.IamID, } builder := core.NewRequestBuilder(core.DELETE) @@ -843,11 +856,13 @@ func (iamAccessGroups *IamAccessGroupsV2) RemoveMembersFromAccessGroupWithContex if err != nil { return } - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalDeleteGroupBulkMembersResponse) - if err != nil { - return + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalDeleteGroupBulkMembersResponse) + if err != nil { + return + } + response.Result = result } - response.Result = result return } @@ -908,11 +923,13 @@ func (iamAccessGroups *IamAccessGroupsV2) RemoveMemberFromAllAccessGroupsWithCon if err != nil { return } - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalDeleteFromAllGroupsResponse) - if err != nil { - return + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalDeleteFromAllGroupsResponse) + if err != nil { + return + } + response.Result = result } - response.Result = result return } @@ -985,11 +1002,13 @@ func (iamAccessGroups *IamAccessGroupsV2) AddMemberToMultipleAccessGroupsWithCon if err != nil { return } - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalAddMembershipMultipleGroupsResponse) - if err != nil { - return + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalAddMembershipMultipleGroupsResponse) + if err != nil { + return + } + response.Result = result } - response.Result = result return } @@ -1069,11 +1088,13 @@ func (iamAccessGroups *IamAccessGroupsV2) AddAccessGroupRuleWithContext(ctx cont if err != nil { return } - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalRule) - if err != nil { - return + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalRule) + if err != nil { + return + } + response.Result = result } - response.Result = result return } @@ -1131,11 +1152,13 @@ func (iamAccessGroups *IamAccessGroupsV2) ListAccessGroupRulesWithContext(ctx co if err != nil { return } - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalRulesList) - if err != nil { - return + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalRulesList) + if err != nil { + return + } + response.Result = result } - response.Result = result return } @@ -1160,7 +1183,7 @@ func (iamAccessGroups *IamAccessGroupsV2) GetAccessGroupRuleWithContext(ctx cont pathParamsMap := map[string]string{ "access_group_id": *getAccessGroupRuleOptions.AccessGroupID, - "rule_id": *getAccessGroupRuleOptions.RuleID, + "rule_id": *getAccessGroupRuleOptions.RuleID, } builder := core.NewRequestBuilder(core.GET) @@ -1194,11 +1217,13 @@ func (iamAccessGroups *IamAccessGroupsV2) GetAccessGroupRuleWithContext(ctx cont if err != nil { return } - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalRule) - if err != nil { - return + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalRule) + if err != nil { + return + } + response.Result = result } - response.Result = result return } @@ -1223,7 +1248,7 @@ func (iamAccessGroups *IamAccessGroupsV2) ReplaceAccessGroupRuleWithContext(ctx pathParamsMap := map[string]string{ "access_group_id": *replaceAccessGroupRuleOptions.AccessGroupID, - "rule_id": *replaceAccessGroupRuleOptions.RuleID, + "rule_id": *replaceAccessGroupRuleOptions.RuleID, } builder := core.NewRequestBuilder(core.PUT) @@ -1279,11 +1304,13 @@ func (iamAccessGroups *IamAccessGroupsV2) ReplaceAccessGroupRuleWithContext(ctx if err != nil { return } - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalRule) - if err != nil { - return + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalRule) + if err != nil { + return + } + response.Result = result } - response.Result = result return } @@ -1308,7 +1335,7 @@ func (iamAccessGroups *IamAccessGroupsV2) RemoveAccessGroupRuleWithContext(ctx c pathParamsMap := map[string]string{ "access_group_id": *removeAccessGroupRuleOptions.AccessGroupID, - "rule_id": *removeAccessGroupRuleOptions.RuleID, + "rule_id": *removeAccessGroupRuleOptions.RuleID, } builder := core.NewRequestBuilder(core.DELETE) @@ -1391,11 +1418,13 @@ func (iamAccessGroups *IamAccessGroupsV2) GetAccountSettingsWithContext(ctx cont if err != nil { return } - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalAccountSettings) - if err != nil { - return + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalAccountSettings) + if err != nil { + return + } + response.Result = result } - response.Result = result return } @@ -1462,11 +1491,13 @@ func (iamAccessGroups *IamAccessGroupsV2) UpdateAccountSettingsWithContext(ctx c if err != nil { return } - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalAccountSettings) - if err != nil { - return + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalAccountSettings) + if err != nil { + return + } + response.Result = result } - response.Result = result return } @@ -1540,46 +1571,46 @@ type AddAccessGroupRuleOptions struct { func (*IamAccessGroupsV2) NewAddAccessGroupRuleOptions(accessGroupID string, expiration int64, realmName string, conditions []RuleConditions) *AddAccessGroupRuleOptions { return &AddAccessGroupRuleOptions{ AccessGroupID: core.StringPtr(accessGroupID), - Expiration: core.Int64Ptr(expiration), - RealmName: core.StringPtr(realmName), - Conditions: conditions, + Expiration: core.Int64Ptr(expiration), + RealmName: core.StringPtr(realmName), + Conditions: conditions, } } // SetAccessGroupID : Allow user to set AccessGroupID -func (options *AddAccessGroupRuleOptions) SetAccessGroupID(accessGroupID string) *AddAccessGroupRuleOptions { - options.AccessGroupID = core.StringPtr(accessGroupID) - return options +func (_options *AddAccessGroupRuleOptions) SetAccessGroupID(accessGroupID string) *AddAccessGroupRuleOptions { + _options.AccessGroupID = core.StringPtr(accessGroupID) + return _options } // SetExpiration : Allow user to set Expiration -func (options *AddAccessGroupRuleOptions) SetExpiration(expiration int64) *AddAccessGroupRuleOptions { - options.Expiration = core.Int64Ptr(expiration) - return options +func (_options *AddAccessGroupRuleOptions) SetExpiration(expiration int64) *AddAccessGroupRuleOptions { + _options.Expiration = core.Int64Ptr(expiration) + return _options } // SetRealmName : Allow user to set RealmName -func (options *AddAccessGroupRuleOptions) SetRealmName(realmName string) *AddAccessGroupRuleOptions { - options.RealmName = core.StringPtr(realmName) - return options +func (_options *AddAccessGroupRuleOptions) SetRealmName(realmName string) *AddAccessGroupRuleOptions { + _options.RealmName = core.StringPtr(realmName) + return _options } // SetConditions : Allow user to set Conditions -func (options *AddAccessGroupRuleOptions) SetConditions(conditions []RuleConditions) *AddAccessGroupRuleOptions { - options.Conditions = conditions - return options +func (_options *AddAccessGroupRuleOptions) SetConditions(conditions []RuleConditions) *AddAccessGroupRuleOptions { + _options.Conditions = conditions + return _options } // SetName : Allow user to set Name -func (options *AddAccessGroupRuleOptions) SetName(name string) *AddAccessGroupRuleOptions { - options.Name = core.StringPtr(name) - return options +func (_options *AddAccessGroupRuleOptions) SetName(name string) *AddAccessGroupRuleOptions { + _options.Name = core.StringPtr(name) + return _options } // SetTransactionID : Allow user to set TransactionID -func (options *AddAccessGroupRuleOptions) SetTransactionID(transactionID string) *AddAccessGroupRuleOptions { - options.TransactionID = core.StringPtr(transactionID) - return options +func (_options *AddAccessGroupRuleOptions) SetTransactionID(transactionID string) *AddAccessGroupRuleOptions { + _options.TransactionID = core.StringPtr(transactionID) + return _options } // SetHeaders : Allow user to set Headers @@ -1598,12 +1629,12 @@ type AddGroupMembersRequestMembersItem struct { } // NewAddGroupMembersRequestMembersItem : Instantiate AddGroupMembersRequestMembersItem (Generic Model Constructor) -func (*IamAccessGroupsV2) NewAddGroupMembersRequestMembersItem(iamID string, typeVar string) (model *AddGroupMembersRequestMembersItem, err error) { - model = &AddGroupMembersRequestMembersItem{ +func (*IamAccessGroupsV2) NewAddGroupMembersRequestMembersItem(iamID string, typeVar string) (_model *AddGroupMembersRequestMembersItem, err error) { + _model = &AddGroupMembersRequestMembersItem{ IamID: core.StringPtr(iamID), - Type: core.StringPtr(typeVar), + Type: core.StringPtr(typeVar), } - err = core.ValidateStruct(model, "required parameters") + err = core.ValidateStruct(_model, "required parameters") return } @@ -1727,38 +1758,38 @@ type AddMemberToMultipleAccessGroupsOptions struct { func (*IamAccessGroupsV2) NewAddMemberToMultipleAccessGroupsOptions(accountID string, iamID string) *AddMemberToMultipleAccessGroupsOptions { return &AddMemberToMultipleAccessGroupsOptions{ AccountID: core.StringPtr(accountID), - IamID: core.StringPtr(iamID), + IamID: core.StringPtr(iamID), } } // SetAccountID : Allow user to set AccountID -func (options *AddMemberToMultipleAccessGroupsOptions) SetAccountID(accountID string) *AddMemberToMultipleAccessGroupsOptions { - options.AccountID = core.StringPtr(accountID) - return options +func (_options *AddMemberToMultipleAccessGroupsOptions) SetAccountID(accountID string) *AddMemberToMultipleAccessGroupsOptions { + _options.AccountID = core.StringPtr(accountID) + return _options } // SetIamID : Allow user to set IamID -func (options *AddMemberToMultipleAccessGroupsOptions) SetIamID(iamID string) *AddMemberToMultipleAccessGroupsOptions { - options.IamID = core.StringPtr(iamID) - return options +func (_options *AddMemberToMultipleAccessGroupsOptions) SetIamID(iamID string) *AddMemberToMultipleAccessGroupsOptions { + _options.IamID = core.StringPtr(iamID) + return _options } // SetType : Allow user to set Type -func (options *AddMemberToMultipleAccessGroupsOptions) SetType(typeVar string) *AddMemberToMultipleAccessGroupsOptions { - options.Type = core.StringPtr(typeVar) - return options +func (_options *AddMemberToMultipleAccessGroupsOptions) SetType(typeVar string) *AddMemberToMultipleAccessGroupsOptions { + _options.Type = core.StringPtr(typeVar) + return _options } // SetGroups : Allow user to set Groups -func (options *AddMemberToMultipleAccessGroupsOptions) SetGroups(groups []string) *AddMemberToMultipleAccessGroupsOptions { - options.Groups = groups - return options +func (_options *AddMemberToMultipleAccessGroupsOptions) SetGroups(groups []string) *AddMemberToMultipleAccessGroupsOptions { + _options.Groups = groups + return _options } // SetTransactionID : Allow user to set TransactionID -func (options *AddMemberToMultipleAccessGroupsOptions) SetTransactionID(transactionID string) *AddMemberToMultipleAccessGroupsOptions { - options.TransactionID = core.StringPtr(transactionID) - return options +func (_options *AddMemberToMultipleAccessGroupsOptions) SetTransactionID(transactionID string) *AddMemberToMultipleAccessGroupsOptions { + _options.TransactionID = core.StringPtr(transactionID) + return _options } // SetHeaders : Allow user to set Headers @@ -1792,21 +1823,21 @@ func (*IamAccessGroupsV2) NewAddMembersToAccessGroupOptions(accessGroupID string } // SetAccessGroupID : Allow user to set AccessGroupID -func (options *AddMembersToAccessGroupOptions) SetAccessGroupID(accessGroupID string) *AddMembersToAccessGroupOptions { - options.AccessGroupID = core.StringPtr(accessGroupID) - return options +func (_options *AddMembersToAccessGroupOptions) SetAccessGroupID(accessGroupID string) *AddMembersToAccessGroupOptions { + _options.AccessGroupID = core.StringPtr(accessGroupID) + return _options } // SetMembers : Allow user to set Members -func (options *AddMembersToAccessGroupOptions) SetMembers(members []AddGroupMembersRequestMembersItem) *AddMembersToAccessGroupOptions { - options.Members = members - return options +func (_options *AddMembersToAccessGroupOptions) SetMembers(members []AddGroupMembersRequestMembersItem) *AddMembersToAccessGroupOptions { + _options.Members = members + return _options } // SetTransactionID : Allow user to set TransactionID -func (options *AddMembersToAccessGroupOptions) SetTransactionID(transactionID string) *AddMembersToAccessGroupOptions { - options.TransactionID = core.StringPtr(transactionID) - return options +func (_options *AddMembersToAccessGroupOptions) SetTransactionID(transactionID string) *AddMembersToAccessGroupOptions { + _options.TransactionID = core.StringPtr(transactionID) + return _options } // SetHeaders : Allow user to set Headers @@ -1884,7 +1915,7 @@ type CreateAccessGroupOptions struct { // Authorization token. AccountID *string `validate:"required"` - // Assign the specified name to the access group. This field is case-sensitive and has a limit of 100 characters. The + // Assign the specified name to the access group. This field is case-insensitive and has a limit of 100 characters. The // group name has to be unique within an account. Name *string `validate:"required"` @@ -1904,32 +1935,32 @@ type CreateAccessGroupOptions struct { func (*IamAccessGroupsV2) NewCreateAccessGroupOptions(accountID string, name string) *CreateAccessGroupOptions { return &CreateAccessGroupOptions{ AccountID: core.StringPtr(accountID), - Name: core.StringPtr(name), + Name: core.StringPtr(name), } } // SetAccountID : Allow user to set AccountID -func (options *CreateAccessGroupOptions) SetAccountID(accountID string) *CreateAccessGroupOptions { - options.AccountID = core.StringPtr(accountID) - return options +func (_options *CreateAccessGroupOptions) SetAccountID(accountID string) *CreateAccessGroupOptions { + _options.AccountID = core.StringPtr(accountID) + return _options } // SetName : Allow user to set Name -func (options *CreateAccessGroupOptions) SetName(name string) *CreateAccessGroupOptions { - options.Name = core.StringPtr(name) - return options +func (_options *CreateAccessGroupOptions) SetName(name string) *CreateAccessGroupOptions { + _options.Name = core.StringPtr(name) + return _options } // SetDescription : Allow user to set Description -func (options *CreateAccessGroupOptions) SetDescription(description string) *CreateAccessGroupOptions { - options.Description = core.StringPtr(description) - return options +func (_options *CreateAccessGroupOptions) SetDescription(description string) *CreateAccessGroupOptions { + _options.Description = core.StringPtr(description) + return _options } // SetTransactionID : Allow user to set TransactionID -func (options *CreateAccessGroupOptions) SetTransactionID(transactionID string) *CreateAccessGroupOptions { - options.TransactionID = core.StringPtr(transactionID) - return options +func (_options *CreateAccessGroupOptions) SetTransactionID(transactionID string) *CreateAccessGroupOptions { + _options.TransactionID = core.StringPtr(transactionID) + return _options } // SetHeaders : Allow user to set Headers @@ -1963,21 +1994,21 @@ func (*IamAccessGroupsV2) NewDeleteAccessGroupOptions(accessGroupID string) *Del } // SetAccessGroupID : Allow user to set AccessGroupID -func (options *DeleteAccessGroupOptions) SetAccessGroupID(accessGroupID string) *DeleteAccessGroupOptions { - options.AccessGroupID = core.StringPtr(accessGroupID) - return options +func (_options *DeleteAccessGroupOptions) SetAccessGroupID(accessGroupID string) *DeleteAccessGroupOptions { + _options.AccessGroupID = core.StringPtr(accessGroupID) + return _options } // SetTransactionID : Allow user to set TransactionID -func (options *DeleteAccessGroupOptions) SetTransactionID(transactionID string) *DeleteAccessGroupOptions { - options.TransactionID = core.StringPtr(transactionID) - return options +func (_options *DeleteAccessGroupOptions) SetTransactionID(transactionID string) *DeleteAccessGroupOptions { + _options.TransactionID = core.StringPtr(transactionID) + return _options } // SetForce : Allow user to set Force -func (options *DeleteAccessGroupOptions) SetForce(force bool) *DeleteAccessGroupOptions { - options.Force = core.BoolPtr(force) - return options +func (_options *DeleteAccessGroupOptions) SetForce(force bool) *DeleteAccessGroupOptions { + _options.Force = core.BoolPtr(force) + return _options } // SetHeaders : Allow user to set Headers @@ -2162,21 +2193,21 @@ func (*IamAccessGroupsV2) NewGetAccessGroupOptions(accessGroupID string) *GetAcc } // SetAccessGroupID : Allow user to set AccessGroupID -func (options *GetAccessGroupOptions) SetAccessGroupID(accessGroupID string) *GetAccessGroupOptions { - options.AccessGroupID = core.StringPtr(accessGroupID) - return options +func (_options *GetAccessGroupOptions) SetAccessGroupID(accessGroupID string) *GetAccessGroupOptions { + _options.AccessGroupID = core.StringPtr(accessGroupID) + return _options } // SetTransactionID : Allow user to set TransactionID -func (options *GetAccessGroupOptions) SetTransactionID(transactionID string) *GetAccessGroupOptions { - options.TransactionID = core.StringPtr(transactionID) - return options +func (_options *GetAccessGroupOptions) SetTransactionID(transactionID string) *GetAccessGroupOptions { + _options.TransactionID = core.StringPtr(transactionID) + return _options } // SetShowFederated : Allow user to set ShowFederated -func (options *GetAccessGroupOptions) SetShowFederated(showFederated bool) *GetAccessGroupOptions { - options.ShowFederated = core.BoolPtr(showFederated) - return options +func (_options *GetAccessGroupOptions) SetShowFederated(showFederated bool) *GetAccessGroupOptions { + _options.ShowFederated = core.BoolPtr(showFederated) + return _options } // SetHeaders : Allow user to set Headers @@ -2206,26 +2237,26 @@ type GetAccessGroupRuleOptions struct { func (*IamAccessGroupsV2) NewGetAccessGroupRuleOptions(accessGroupID string, ruleID string) *GetAccessGroupRuleOptions { return &GetAccessGroupRuleOptions{ AccessGroupID: core.StringPtr(accessGroupID), - RuleID: core.StringPtr(ruleID), + RuleID: core.StringPtr(ruleID), } } // SetAccessGroupID : Allow user to set AccessGroupID -func (options *GetAccessGroupRuleOptions) SetAccessGroupID(accessGroupID string) *GetAccessGroupRuleOptions { - options.AccessGroupID = core.StringPtr(accessGroupID) - return options +func (_options *GetAccessGroupRuleOptions) SetAccessGroupID(accessGroupID string) *GetAccessGroupRuleOptions { + _options.AccessGroupID = core.StringPtr(accessGroupID) + return _options } // SetRuleID : Allow user to set RuleID -func (options *GetAccessGroupRuleOptions) SetRuleID(ruleID string) *GetAccessGroupRuleOptions { - options.RuleID = core.StringPtr(ruleID) - return options +func (_options *GetAccessGroupRuleOptions) SetRuleID(ruleID string) *GetAccessGroupRuleOptions { + _options.RuleID = core.StringPtr(ruleID) + return _options } // SetTransactionID : Allow user to set TransactionID -func (options *GetAccessGroupRuleOptions) SetTransactionID(transactionID string) *GetAccessGroupRuleOptions { - options.TransactionID = core.StringPtr(transactionID) - return options +func (_options *GetAccessGroupRuleOptions) SetTransactionID(transactionID string) *GetAccessGroupRuleOptions { + _options.TransactionID = core.StringPtr(transactionID) + return _options } // SetHeaders : Allow user to set Headers @@ -2258,15 +2289,15 @@ func (*IamAccessGroupsV2) NewGetAccountSettingsOptions(accountID string) *GetAcc } // SetAccountID : Allow user to set AccountID -func (options *GetAccountSettingsOptions) SetAccountID(accountID string) *GetAccountSettingsOptions { - options.AccountID = core.StringPtr(accountID) - return options +func (_options *GetAccountSettingsOptions) SetAccountID(accountID string) *GetAccountSettingsOptions { + _options.AccountID = core.StringPtr(accountID) + return _options } // SetTransactionID : Allow user to set TransactionID -func (options *GetAccountSettingsOptions) SetTransactionID(transactionID string) *GetAccountSettingsOptions { - options.TransactionID = core.StringPtr(transactionID) - return options +func (_options *GetAccountSettingsOptions) SetTransactionID(transactionID string) *GetAccountSettingsOptions { + _options.TransactionID = core.StringPtr(transactionID) + return _options } // SetHeaders : Allow user to set Headers @@ -2421,6 +2452,23 @@ func UnmarshalGroupMembersList(m map[string]json.RawMessage, result interface{}) return } +// Retrieve the value to be passed to a request to access the next page of results +func (resp *GroupMembersList) GetNextOffset() (*int64, error) { + if core.IsNil(resp.Next) { + return nil, nil + } + offset, err := core.GetQueryParam(resp.Next.Href, "offset") + if err != nil || offset == nil { + return nil, err + } + var offsetValue int64 + offsetValue, err = strconv.ParseInt(*offset, 10, 64) + if err != nil { + return nil, err + } + return core.Int64Ptr(offsetValue), nil +} + // GroupsList : The list of access groups returned as part of a response. type GroupsList struct { // Limit on how many items can be returned. @@ -2487,6 +2535,23 @@ func UnmarshalGroupsList(m map[string]json.RawMessage, result interface{}) (err return } +// Retrieve the value to be passed to a request to access the next page of results +func (resp *GroupsList) GetNextOffset() (*int64, error) { + if core.IsNil(resp.Next) { + return nil, nil + } + offset, err := core.GetQueryParam(resp.Next.Href, "offset") + if err != nil || offset == nil { + return nil, err + } + var offsetValue int64 + offsetValue, err = strconv.ParseInt(*offset, 10, 64) + if err != nil { + return nil, err + } + return core.Int64Ptr(offsetValue), nil +} + // HrefStruct : A link object. type HrefStruct struct { // A string containing the link’s URL. @@ -2525,26 +2590,26 @@ type IsMemberOfAccessGroupOptions struct { func (*IamAccessGroupsV2) NewIsMemberOfAccessGroupOptions(accessGroupID string, iamID string) *IsMemberOfAccessGroupOptions { return &IsMemberOfAccessGroupOptions{ AccessGroupID: core.StringPtr(accessGroupID), - IamID: core.StringPtr(iamID), + IamID: core.StringPtr(iamID), } } // SetAccessGroupID : Allow user to set AccessGroupID -func (options *IsMemberOfAccessGroupOptions) SetAccessGroupID(accessGroupID string) *IsMemberOfAccessGroupOptions { - options.AccessGroupID = core.StringPtr(accessGroupID) - return options +func (_options *IsMemberOfAccessGroupOptions) SetAccessGroupID(accessGroupID string) *IsMemberOfAccessGroupOptions { + _options.AccessGroupID = core.StringPtr(accessGroupID) + return _options } // SetIamID : Allow user to set IamID -func (options *IsMemberOfAccessGroupOptions) SetIamID(iamID string) *IsMemberOfAccessGroupOptions { - options.IamID = core.StringPtr(iamID) - return options +func (_options *IsMemberOfAccessGroupOptions) SetIamID(iamID string) *IsMemberOfAccessGroupOptions { + _options.IamID = core.StringPtr(iamID) + return _options } // SetTransactionID : Allow user to set TransactionID -func (options *IsMemberOfAccessGroupOptions) SetTransactionID(transactionID string) *IsMemberOfAccessGroupOptions { - options.TransactionID = core.StringPtr(transactionID) - return options +func (_options *IsMemberOfAccessGroupOptions) SetTransactionID(transactionID string) *IsMemberOfAccessGroupOptions { + _options.TransactionID = core.StringPtr(transactionID) + return _options } // SetHeaders : Allow user to set Headers @@ -2590,45 +2655,45 @@ func (*IamAccessGroupsV2) NewListAccessGroupMembersOptions(accessGroupID string) } // SetAccessGroupID : Allow user to set AccessGroupID -func (options *ListAccessGroupMembersOptions) SetAccessGroupID(accessGroupID string) *ListAccessGroupMembersOptions { - options.AccessGroupID = core.StringPtr(accessGroupID) - return options +func (_options *ListAccessGroupMembersOptions) SetAccessGroupID(accessGroupID string) *ListAccessGroupMembersOptions { + _options.AccessGroupID = core.StringPtr(accessGroupID) + return _options } // SetTransactionID : Allow user to set TransactionID -func (options *ListAccessGroupMembersOptions) SetTransactionID(transactionID string) *ListAccessGroupMembersOptions { - options.TransactionID = core.StringPtr(transactionID) - return options +func (_options *ListAccessGroupMembersOptions) SetTransactionID(transactionID string) *ListAccessGroupMembersOptions { + _options.TransactionID = core.StringPtr(transactionID) + return _options } // SetLimit : Allow user to set Limit -func (options *ListAccessGroupMembersOptions) SetLimit(limit int64) *ListAccessGroupMembersOptions { - options.Limit = core.Int64Ptr(limit) - return options +func (_options *ListAccessGroupMembersOptions) SetLimit(limit int64) *ListAccessGroupMembersOptions { + _options.Limit = core.Int64Ptr(limit) + return _options } // SetOffset : Allow user to set Offset -func (options *ListAccessGroupMembersOptions) SetOffset(offset int64) *ListAccessGroupMembersOptions { - options.Offset = core.Int64Ptr(offset) - return options +func (_options *ListAccessGroupMembersOptions) SetOffset(offset int64) *ListAccessGroupMembersOptions { + _options.Offset = core.Int64Ptr(offset) + return _options } // SetType : Allow user to set Type -func (options *ListAccessGroupMembersOptions) SetType(typeVar string) *ListAccessGroupMembersOptions { - options.Type = core.StringPtr(typeVar) - return options +func (_options *ListAccessGroupMembersOptions) SetType(typeVar string) *ListAccessGroupMembersOptions { + _options.Type = core.StringPtr(typeVar) + return _options } // SetVerbose : Allow user to set Verbose -func (options *ListAccessGroupMembersOptions) SetVerbose(verbose bool) *ListAccessGroupMembersOptions { - options.Verbose = core.BoolPtr(verbose) - return options +func (_options *ListAccessGroupMembersOptions) SetVerbose(verbose bool) *ListAccessGroupMembersOptions { + _options.Verbose = core.BoolPtr(verbose) + return _options } // SetSort : Allow user to set Sort -func (options *ListAccessGroupMembersOptions) SetSort(sort string) *ListAccessGroupMembersOptions { - options.Sort = core.StringPtr(sort) - return options +func (_options *ListAccessGroupMembersOptions) SetSort(sort string) *ListAccessGroupMembersOptions { + _options.Sort = core.StringPtr(sort) + return _options } // SetHeaders : Allow user to set Headers @@ -2659,15 +2724,15 @@ func (*IamAccessGroupsV2) NewListAccessGroupRulesOptions(accessGroupID string) * } // SetAccessGroupID : Allow user to set AccessGroupID -func (options *ListAccessGroupRulesOptions) SetAccessGroupID(accessGroupID string) *ListAccessGroupRulesOptions { - options.AccessGroupID = core.StringPtr(accessGroupID) - return options +func (_options *ListAccessGroupRulesOptions) SetAccessGroupID(accessGroupID string) *ListAccessGroupRulesOptions { + _options.AccessGroupID = core.StringPtr(accessGroupID) + return _options } // SetTransactionID : Allow user to set TransactionID -func (options *ListAccessGroupRulesOptions) SetTransactionID(transactionID string) *ListAccessGroupRulesOptions { - options.TransactionID = core.StringPtr(transactionID) - return options +func (_options *ListAccessGroupRulesOptions) SetTransactionID(transactionID string) *ListAccessGroupRulesOptions { + _options.TransactionID = core.StringPtr(transactionID) + return _options } // SetHeaders : Allow user to set Headers @@ -2719,51 +2784,51 @@ func (*IamAccessGroupsV2) NewListAccessGroupsOptions(accountID string) *ListAcce } // SetAccountID : Allow user to set AccountID -func (options *ListAccessGroupsOptions) SetAccountID(accountID string) *ListAccessGroupsOptions { - options.AccountID = core.StringPtr(accountID) - return options +func (_options *ListAccessGroupsOptions) SetAccountID(accountID string) *ListAccessGroupsOptions { + _options.AccountID = core.StringPtr(accountID) + return _options } // SetTransactionID : Allow user to set TransactionID -func (options *ListAccessGroupsOptions) SetTransactionID(transactionID string) *ListAccessGroupsOptions { - options.TransactionID = core.StringPtr(transactionID) - return options +func (_options *ListAccessGroupsOptions) SetTransactionID(transactionID string) *ListAccessGroupsOptions { + _options.TransactionID = core.StringPtr(transactionID) + return _options } // SetIamID : Allow user to set IamID -func (options *ListAccessGroupsOptions) SetIamID(iamID string) *ListAccessGroupsOptions { - options.IamID = core.StringPtr(iamID) - return options +func (_options *ListAccessGroupsOptions) SetIamID(iamID string) *ListAccessGroupsOptions { + _options.IamID = core.StringPtr(iamID) + return _options } // SetLimit : Allow user to set Limit -func (options *ListAccessGroupsOptions) SetLimit(limit int64) *ListAccessGroupsOptions { - options.Limit = core.Int64Ptr(limit) - return options +func (_options *ListAccessGroupsOptions) SetLimit(limit int64) *ListAccessGroupsOptions { + _options.Limit = core.Int64Ptr(limit) + return _options } // SetOffset : Allow user to set Offset -func (options *ListAccessGroupsOptions) SetOffset(offset int64) *ListAccessGroupsOptions { - options.Offset = core.Int64Ptr(offset) - return options +func (_options *ListAccessGroupsOptions) SetOffset(offset int64) *ListAccessGroupsOptions { + _options.Offset = core.Int64Ptr(offset) + return _options } // SetSort : Allow user to set Sort -func (options *ListAccessGroupsOptions) SetSort(sort string) *ListAccessGroupsOptions { - options.Sort = core.StringPtr(sort) - return options +func (_options *ListAccessGroupsOptions) SetSort(sort string) *ListAccessGroupsOptions { + _options.Sort = core.StringPtr(sort) + return _options } // SetShowFederated : Allow user to set ShowFederated -func (options *ListAccessGroupsOptions) SetShowFederated(showFederated bool) *ListAccessGroupsOptions { - options.ShowFederated = core.BoolPtr(showFederated) - return options +func (_options *ListAccessGroupsOptions) SetShowFederated(showFederated bool) *ListAccessGroupsOptions { + _options.ShowFederated = core.BoolPtr(showFederated) + return _options } // SetHidePublicAccess : Allow user to set HidePublicAccess -func (options *ListAccessGroupsOptions) SetHidePublicAccess(hidePublicAccess bool) *ListAccessGroupsOptions { - options.HidePublicAccess = core.BoolPtr(hidePublicAccess) - return options +func (_options *ListAccessGroupsOptions) SetHidePublicAccess(hidePublicAccess bool) *ListAccessGroupsOptions { + _options.HidePublicAccess = core.BoolPtr(hidePublicAccess) + return _options } // SetHeaders : Allow user to set Headers @@ -2859,26 +2924,26 @@ type RemoveAccessGroupRuleOptions struct { func (*IamAccessGroupsV2) NewRemoveAccessGroupRuleOptions(accessGroupID string, ruleID string) *RemoveAccessGroupRuleOptions { return &RemoveAccessGroupRuleOptions{ AccessGroupID: core.StringPtr(accessGroupID), - RuleID: core.StringPtr(ruleID), + RuleID: core.StringPtr(ruleID), } } // SetAccessGroupID : Allow user to set AccessGroupID -func (options *RemoveAccessGroupRuleOptions) SetAccessGroupID(accessGroupID string) *RemoveAccessGroupRuleOptions { - options.AccessGroupID = core.StringPtr(accessGroupID) - return options +func (_options *RemoveAccessGroupRuleOptions) SetAccessGroupID(accessGroupID string) *RemoveAccessGroupRuleOptions { + _options.AccessGroupID = core.StringPtr(accessGroupID) + return _options } // SetRuleID : Allow user to set RuleID -func (options *RemoveAccessGroupRuleOptions) SetRuleID(ruleID string) *RemoveAccessGroupRuleOptions { - options.RuleID = core.StringPtr(ruleID) - return options +func (_options *RemoveAccessGroupRuleOptions) SetRuleID(ruleID string) *RemoveAccessGroupRuleOptions { + _options.RuleID = core.StringPtr(ruleID) + return _options } // SetTransactionID : Allow user to set TransactionID -func (options *RemoveAccessGroupRuleOptions) SetTransactionID(transactionID string) *RemoveAccessGroupRuleOptions { - options.TransactionID = core.StringPtr(transactionID) - return options +func (_options *RemoveAccessGroupRuleOptions) SetTransactionID(transactionID string) *RemoveAccessGroupRuleOptions { + _options.TransactionID = core.StringPtr(transactionID) + return _options } // SetHeaders : Allow user to set Headers @@ -2908,26 +2973,26 @@ type RemoveMemberFromAccessGroupOptions struct { func (*IamAccessGroupsV2) NewRemoveMemberFromAccessGroupOptions(accessGroupID string, iamID string) *RemoveMemberFromAccessGroupOptions { return &RemoveMemberFromAccessGroupOptions{ AccessGroupID: core.StringPtr(accessGroupID), - IamID: core.StringPtr(iamID), + IamID: core.StringPtr(iamID), } } // SetAccessGroupID : Allow user to set AccessGroupID -func (options *RemoveMemberFromAccessGroupOptions) SetAccessGroupID(accessGroupID string) *RemoveMemberFromAccessGroupOptions { - options.AccessGroupID = core.StringPtr(accessGroupID) - return options +func (_options *RemoveMemberFromAccessGroupOptions) SetAccessGroupID(accessGroupID string) *RemoveMemberFromAccessGroupOptions { + _options.AccessGroupID = core.StringPtr(accessGroupID) + return _options } // SetIamID : Allow user to set IamID -func (options *RemoveMemberFromAccessGroupOptions) SetIamID(iamID string) *RemoveMemberFromAccessGroupOptions { - options.IamID = core.StringPtr(iamID) - return options +func (_options *RemoveMemberFromAccessGroupOptions) SetIamID(iamID string) *RemoveMemberFromAccessGroupOptions { + _options.IamID = core.StringPtr(iamID) + return _options } // SetTransactionID : Allow user to set TransactionID -func (options *RemoveMemberFromAccessGroupOptions) SetTransactionID(transactionID string) *RemoveMemberFromAccessGroupOptions { - options.TransactionID = core.StringPtr(transactionID) - return options +func (_options *RemoveMemberFromAccessGroupOptions) SetTransactionID(transactionID string) *RemoveMemberFromAccessGroupOptions { + _options.TransactionID = core.StringPtr(transactionID) + return _options } // SetHeaders : Allow user to set Headers @@ -2959,26 +3024,26 @@ type RemoveMemberFromAllAccessGroupsOptions struct { func (*IamAccessGroupsV2) NewRemoveMemberFromAllAccessGroupsOptions(accountID string, iamID string) *RemoveMemberFromAllAccessGroupsOptions { return &RemoveMemberFromAllAccessGroupsOptions{ AccountID: core.StringPtr(accountID), - IamID: core.StringPtr(iamID), + IamID: core.StringPtr(iamID), } } // SetAccountID : Allow user to set AccountID -func (options *RemoveMemberFromAllAccessGroupsOptions) SetAccountID(accountID string) *RemoveMemberFromAllAccessGroupsOptions { - options.AccountID = core.StringPtr(accountID) - return options +func (_options *RemoveMemberFromAllAccessGroupsOptions) SetAccountID(accountID string) *RemoveMemberFromAllAccessGroupsOptions { + _options.AccountID = core.StringPtr(accountID) + return _options } // SetIamID : Allow user to set IamID -func (options *RemoveMemberFromAllAccessGroupsOptions) SetIamID(iamID string) *RemoveMemberFromAllAccessGroupsOptions { - options.IamID = core.StringPtr(iamID) - return options +func (_options *RemoveMemberFromAllAccessGroupsOptions) SetIamID(iamID string) *RemoveMemberFromAllAccessGroupsOptions { + _options.IamID = core.StringPtr(iamID) + return _options } // SetTransactionID : Allow user to set TransactionID -func (options *RemoveMemberFromAllAccessGroupsOptions) SetTransactionID(transactionID string) *RemoveMemberFromAllAccessGroupsOptions { - options.TransactionID = core.StringPtr(transactionID) - return options +func (_options *RemoveMemberFromAllAccessGroupsOptions) SetTransactionID(transactionID string) *RemoveMemberFromAllAccessGroupsOptions { + _options.TransactionID = core.StringPtr(transactionID) + return _options } // SetHeaders : Allow user to set Headers @@ -3012,21 +3077,21 @@ func (*IamAccessGroupsV2) NewRemoveMembersFromAccessGroupOptions(accessGroupID s } // SetAccessGroupID : Allow user to set AccessGroupID -func (options *RemoveMembersFromAccessGroupOptions) SetAccessGroupID(accessGroupID string) *RemoveMembersFromAccessGroupOptions { - options.AccessGroupID = core.StringPtr(accessGroupID) - return options +func (_options *RemoveMembersFromAccessGroupOptions) SetAccessGroupID(accessGroupID string) *RemoveMembersFromAccessGroupOptions { + _options.AccessGroupID = core.StringPtr(accessGroupID) + return _options } // SetMembers : Allow user to set Members -func (options *RemoveMembersFromAccessGroupOptions) SetMembers(members []string) *RemoveMembersFromAccessGroupOptions { - options.Members = members - return options +func (_options *RemoveMembersFromAccessGroupOptions) SetMembers(members []string) *RemoveMembersFromAccessGroupOptions { + _options.Members = members + return _options } // SetTransactionID : Allow user to set TransactionID -func (options *RemoveMembersFromAccessGroupOptions) SetTransactionID(transactionID string) *RemoveMembersFromAccessGroupOptions { - options.TransactionID = core.StringPtr(transactionID) - return options +func (_options *RemoveMembersFromAccessGroupOptions) SetTransactionID(transactionID string) *RemoveMembersFromAccessGroupOptions { + _options.TransactionID = core.StringPtr(transactionID) + return _options } // SetHeaders : Allow user to set Headers @@ -3071,60 +3136,60 @@ type ReplaceAccessGroupRuleOptions struct { func (*IamAccessGroupsV2) NewReplaceAccessGroupRuleOptions(accessGroupID string, ruleID string, ifMatch string, expiration int64, realmName string, conditions []RuleConditions) *ReplaceAccessGroupRuleOptions { return &ReplaceAccessGroupRuleOptions{ AccessGroupID: core.StringPtr(accessGroupID), - RuleID: core.StringPtr(ruleID), - IfMatch: core.StringPtr(ifMatch), - Expiration: core.Int64Ptr(expiration), - RealmName: core.StringPtr(realmName), - Conditions: conditions, + RuleID: core.StringPtr(ruleID), + IfMatch: core.StringPtr(ifMatch), + Expiration: core.Int64Ptr(expiration), + RealmName: core.StringPtr(realmName), + Conditions: conditions, } } // SetAccessGroupID : Allow user to set AccessGroupID -func (options *ReplaceAccessGroupRuleOptions) SetAccessGroupID(accessGroupID string) *ReplaceAccessGroupRuleOptions { - options.AccessGroupID = core.StringPtr(accessGroupID) - return options +func (_options *ReplaceAccessGroupRuleOptions) SetAccessGroupID(accessGroupID string) *ReplaceAccessGroupRuleOptions { + _options.AccessGroupID = core.StringPtr(accessGroupID) + return _options } // SetRuleID : Allow user to set RuleID -func (options *ReplaceAccessGroupRuleOptions) SetRuleID(ruleID string) *ReplaceAccessGroupRuleOptions { - options.RuleID = core.StringPtr(ruleID) - return options +func (_options *ReplaceAccessGroupRuleOptions) SetRuleID(ruleID string) *ReplaceAccessGroupRuleOptions { + _options.RuleID = core.StringPtr(ruleID) + return _options } // SetIfMatch : Allow user to set IfMatch -func (options *ReplaceAccessGroupRuleOptions) SetIfMatch(ifMatch string) *ReplaceAccessGroupRuleOptions { - options.IfMatch = core.StringPtr(ifMatch) - return options +func (_options *ReplaceAccessGroupRuleOptions) SetIfMatch(ifMatch string) *ReplaceAccessGroupRuleOptions { + _options.IfMatch = core.StringPtr(ifMatch) + return _options } // SetExpiration : Allow user to set Expiration -func (options *ReplaceAccessGroupRuleOptions) SetExpiration(expiration int64) *ReplaceAccessGroupRuleOptions { - options.Expiration = core.Int64Ptr(expiration) - return options +func (_options *ReplaceAccessGroupRuleOptions) SetExpiration(expiration int64) *ReplaceAccessGroupRuleOptions { + _options.Expiration = core.Int64Ptr(expiration) + return _options } // SetRealmName : Allow user to set RealmName -func (options *ReplaceAccessGroupRuleOptions) SetRealmName(realmName string) *ReplaceAccessGroupRuleOptions { - options.RealmName = core.StringPtr(realmName) - return options +func (_options *ReplaceAccessGroupRuleOptions) SetRealmName(realmName string) *ReplaceAccessGroupRuleOptions { + _options.RealmName = core.StringPtr(realmName) + return _options } // SetConditions : Allow user to set Conditions -func (options *ReplaceAccessGroupRuleOptions) SetConditions(conditions []RuleConditions) *ReplaceAccessGroupRuleOptions { - options.Conditions = conditions - return options +func (_options *ReplaceAccessGroupRuleOptions) SetConditions(conditions []RuleConditions) *ReplaceAccessGroupRuleOptions { + _options.Conditions = conditions + return _options } // SetName : Allow user to set Name -func (options *ReplaceAccessGroupRuleOptions) SetName(name string) *ReplaceAccessGroupRuleOptions { - options.Name = core.StringPtr(name) - return options +func (_options *ReplaceAccessGroupRuleOptions) SetName(name string) *ReplaceAccessGroupRuleOptions { + _options.Name = core.StringPtr(name) + return _options } // SetTransactionID : Allow user to set TransactionID -func (options *ReplaceAccessGroupRuleOptions) SetTransactionID(transactionID string) *ReplaceAccessGroupRuleOptions { - options.TransactionID = core.StringPtr(transactionID) - return options +func (_options *ReplaceAccessGroupRuleOptions) SetTransactionID(transactionID string) *ReplaceAccessGroupRuleOptions { + _options.TransactionID = core.StringPtr(transactionID) + return _options } // SetHeaders : Allow user to set Headers @@ -3235,22 +3300,22 @@ type RuleConditions struct { // Constants associated with the RuleConditions.Operator property. // The operation to perform on the claim. const ( - RuleConditionsOperatorContainsConst = "CONTAINS" - RuleConditionsOperatorEqualsConst = "EQUALS" - RuleConditionsOperatorEqualsIgnoreCaseConst = "EQUALS_IGNORE_CASE" - RuleConditionsOperatorInConst = "IN" - RuleConditionsOperatorNotEqualsConst = "NOT_EQUALS" + RuleConditionsOperatorContainsConst = "CONTAINS" + RuleConditionsOperatorEqualsConst = "EQUALS" + RuleConditionsOperatorEqualsIgnoreCaseConst = "EQUALS_IGNORE_CASE" + RuleConditionsOperatorInConst = "IN" + RuleConditionsOperatorNotEqualsConst = "NOT_EQUALS" RuleConditionsOperatorNotEqualsIgnoreCaseConst = "NOT_EQUALS_IGNORE_CASE" ) // NewRuleConditions : Instantiate RuleConditions (Generic Model Constructor) -func (*IamAccessGroupsV2) NewRuleConditions(claim string, operator string, value string) (model *RuleConditions, err error) { - model = &RuleConditions{ - Claim: core.StringPtr(claim), +func (*IamAccessGroupsV2) NewRuleConditions(claim string, operator string, value string) (_model *RuleConditions, err error) { + _model = &RuleConditions{ + Claim: core.StringPtr(claim), Operator: core.StringPtr(operator), - Value: core.StringPtr(value), + Value: core.StringPtr(value), } - err = core.ValidateStruct(model, "required parameters") + err = core.ValidateStruct(_model, "required parameters") return } @@ -3299,7 +3364,7 @@ type UpdateAccessGroupOptions struct { // ETag header. IfMatch *string `validate:"required"` - // Assign the specified name to the access group. This field is case-sensitive and has a limit of 100 characters. The + // Assign the specified name to the access group. This field is case-insensitive and has a limit of 100 characters. The // group name has to be unique within an account. Name *string @@ -3319,38 +3384,38 @@ type UpdateAccessGroupOptions struct { func (*IamAccessGroupsV2) NewUpdateAccessGroupOptions(accessGroupID string, ifMatch string) *UpdateAccessGroupOptions { return &UpdateAccessGroupOptions{ AccessGroupID: core.StringPtr(accessGroupID), - IfMatch: core.StringPtr(ifMatch), + IfMatch: core.StringPtr(ifMatch), } } // SetAccessGroupID : Allow user to set AccessGroupID -func (options *UpdateAccessGroupOptions) SetAccessGroupID(accessGroupID string) *UpdateAccessGroupOptions { - options.AccessGroupID = core.StringPtr(accessGroupID) - return options +func (_options *UpdateAccessGroupOptions) SetAccessGroupID(accessGroupID string) *UpdateAccessGroupOptions { + _options.AccessGroupID = core.StringPtr(accessGroupID) + return _options } // SetIfMatch : Allow user to set IfMatch -func (options *UpdateAccessGroupOptions) SetIfMatch(ifMatch string) *UpdateAccessGroupOptions { - options.IfMatch = core.StringPtr(ifMatch) - return options +func (_options *UpdateAccessGroupOptions) SetIfMatch(ifMatch string) *UpdateAccessGroupOptions { + _options.IfMatch = core.StringPtr(ifMatch) + return _options } // SetName : Allow user to set Name -func (options *UpdateAccessGroupOptions) SetName(name string) *UpdateAccessGroupOptions { - options.Name = core.StringPtr(name) - return options +func (_options *UpdateAccessGroupOptions) SetName(name string) *UpdateAccessGroupOptions { + _options.Name = core.StringPtr(name) + return _options } // SetDescription : Allow user to set Description -func (options *UpdateAccessGroupOptions) SetDescription(description string) *UpdateAccessGroupOptions { - options.Description = core.StringPtr(description) - return options +func (_options *UpdateAccessGroupOptions) SetDescription(description string) *UpdateAccessGroupOptions { + _options.Description = core.StringPtr(description) + return _options } // SetTransactionID : Allow user to set TransactionID -func (options *UpdateAccessGroupOptions) SetTransactionID(transactionID string) *UpdateAccessGroupOptions { - options.TransactionID = core.StringPtr(transactionID) - return options +func (_options *UpdateAccessGroupOptions) SetTransactionID(transactionID string) *UpdateAccessGroupOptions { + _options.TransactionID = core.StringPtr(transactionID) + return _options } // SetHeaders : Allow user to set Headers @@ -3387,21 +3452,21 @@ func (*IamAccessGroupsV2) NewUpdateAccountSettingsOptions(accountID string) *Upd } // SetAccountID : Allow user to set AccountID -func (options *UpdateAccountSettingsOptions) SetAccountID(accountID string) *UpdateAccountSettingsOptions { - options.AccountID = core.StringPtr(accountID) - return options +func (_options *UpdateAccountSettingsOptions) SetAccountID(accountID string) *UpdateAccountSettingsOptions { + _options.AccountID = core.StringPtr(accountID) + return _options } // SetPublicAccessEnabled : Allow user to set PublicAccessEnabled -func (options *UpdateAccountSettingsOptions) SetPublicAccessEnabled(publicAccessEnabled bool) *UpdateAccountSettingsOptions { - options.PublicAccessEnabled = core.BoolPtr(publicAccessEnabled) - return options +func (_options *UpdateAccountSettingsOptions) SetPublicAccessEnabled(publicAccessEnabled bool) *UpdateAccountSettingsOptions { + _options.PublicAccessEnabled = core.BoolPtr(publicAccessEnabled) + return _options } // SetTransactionID : Allow user to set TransactionID -func (options *UpdateAccountSettingsOptions) SetTransactionID(transactionID string) *UpdateAccountSettingsOptions { - options.TransactionID = core.StringPtr(transactionID) - return options +func (_options *UpdateAccountSettingsOptions) SetTransactionID(transactionID string) *UpdateAccountSettingsOptions { + _options.TransactionID = core.StringPtr(transactionID) + return _options } // SetHeaders : Allow user to set Headers diff --git a/iamaccessgroupsv2/iam_access_groups_v2_suite_test.go b/iamaccessgroupsv2/iam_access_groups_v2_suite_test.go index 2d133958..ffaef54a 100644 --- a/iamaccessgroupsv2/iam_access_groups_v2_suite_test.go +++ b/iamaccessgroupsv2/iam_access_groups_v2_suite_test.go @@ -17,9 +17,10 @@ package iamaccessgroupsv2_test import ( + "testing" + . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "testing" ) func TestIamAccessGroupsV2(t *testing.T) { diff --git a/iamaccessgroupsv2/iam_access_groups_v2_test.go b/iamaccessgroupsv2/iam_access_groups_v2_test.go index 1441bc73..eb63b56b 100644 --- a/iamaccessgroupsv2/iam_access_groups_v2_test.go +++ b/iamaccessgroupsv2/iam_access_groups_v2_test.go @@ -20,17 +20,18 @@ import ( "bytes" "context" "fmt" - "github.com/IBM/go-sdk-core/v5/core" - "github.com/IBM/platform-services-go-sdk/iamaccessgroupsv2" - "github.com/go-openapi/strfmt" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" "io" "io/ioutil" "net/http" "net/http/httptest" "os" "time" + + "github.com/IBM/go-sdk-core/v5/core" + "github.com/IBM/platform-services-go-sdk/iamaccessgroupsv2" + "github.com/go-openapi/strfmt" + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" ) var _ = Describe(`IamAccessGroupsV2`, func() { @@ -66,13 +67,14 @@ var _ = Describe(`IamAccessGroupsV2`, func() { Context(`Using external config, construct service client instances`, func() { // Map containing environment variables used in testing. var testEnvironment = map[string]string{ - "IAM_ACCESS_GROUPS_URL": "https://iamaccessgroupsv2/api", + "IAM_ACCESS_GROUPS_URL": "https://iamaccessgroupsv2/api", "IAM_ACCESS_GROUPS_AUTH_TYPE": "noauth", } It(`Create service client using external config successfully`, func() { SetTestEnvironment(testEnvironment) - iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2UsingExternalConfig(&iamaccessgroupsv2.IamAccessGroupsV2Options{}) + iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2UsingExternalConfig(&iamaccessgroupsv2.IamAccessGroupsV2Options{ + }) Expect(iamAccessGroupsService).ToNot(BeNil()) Expect(serviceErr).To(BeNil()) ClearTestEnvironment(testEnvironment) @@ -101,7 +103,8 @@ var _ = Describe(`IamAccessGroupsV2`, func() { }) It(`Create service client using external config and set url programatically successfully`, func() { SetTestEnvironment(testEnvironment) - iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2UsingExternalConfig(&iamaccessgroupsv2.IamAccessGroupsV2Options{}) + iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2UsingExternalConfig(&iamaccessgroupsv2.IamAccessGroupsV2Options{ + }) err := iamAccessGroupsService.SetServiceURL("https://testService/api") Expect(err).To(BeNil()) Expect(iamAccessGroupsService).ToNot(BeNil()) @@ -119,12 +122,13 @@ var _ = Describe(`IamAccessGroupsV2`, func() { Context(`Using external config, construct service client instances with error: Invalid Auth`, func() { // Map containing environment variables used in testing. var testEnvironment = map[string]string{ - "IAM_ACCESS_GROUPS_URL": "https://iamaccessgroupsv2/api", + "IAM_ACCESS_GROUPS_URL": "https://iamaccessgroupsv2/api", "IAM_ACCESS_GROUPS_AUTH_TYPE": "someOtherAuth", } SetTestEnvironment(testEnvironment) - iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2UsingExternalConfig(&iamaccessgroupsv2.IamAccessGroupsV2Options{}) + iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2UsingExternalConfig(&iamaccessgroupsv2.IamAccessGroupsV2Options{ + }) It(`Instantiate service client with error`, func() { Expect(iamAccessGroupsService).To(BeNil()) @@ -135,7 +139,7 @@ var _ = Describe(`IamAccessGroupsV2`, func() { Context(`Using external config, construct service client instances with error: Invalid URL`, func() { // Map containing environment variables used in testing. var testEnvironment = map[string]string{ - "IAM_ACCESS_GROUPS_AUTH_TYPE": "NOAuth", + "IAM_ACCESS_GROUPS_AUTH_TYPE": "NOAuth", } SetTestEnvironment(testEnvironment) @@ -162,7 +166,7 @@ var _ = Describe(`IamAccessGroupsV2`, func() { }) Describe(`CreateAccessGroup(createAccessGroupOptions *CreateAccessGroupOptions) - Operation response error`, func() { createAccessGroupPath := "/groups" - Context(`Using mock server endpoint`, func() { + 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() @@ -211,7 +215,6 @@ var _ = Describe(`IamAccessGroupsV2`, func() { }) }) }) - Describe(`CreateAccessGroup(createAccessGroupOptions *CreateAccessGroupOptions)`, func() { createAccessGroupPath := "/groups" Context(`Using mock server endpoint with timeout`, func() { @@ -391,10 +394,47 @@ var _ = Describe(`IamAccessGroupsV2`, func() { testServer.Close() }) }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(201) + })) + }) + It(`Invoke CreateAccessGroup successfully`, func() { + iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2(&iamaccessgroupsv2.IamAccessGroupsV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamAccessGroupsService).ToNot(BeNil()) + + // Construct an instance of the CreateAccessGroupOptions model + createAccessGroupOptionsModel := new(iamaccessgroupsv2.CreateAccessGroupOptions) + createAccessGroupOptionsModel.AccountID = core.StringPtr("testString") + createAccessGroupOptionsModel.Name = core.StringPtr("Managers") + createAccessGroupOptionsModel.Description = core.StringPtr("Group for managers") + createAccessGroupOptionsModel.TransactionID = core.StringPtr("testString") + createAccessGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamAccessGroupsService.CreateAccessGroup(createAccessGroupOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) }) Describe(`ListAccessGroups(listAccessGroupsOptions *ListAccessGroupsOptions) - Operation response error`, func() { listAccessGroupsPath := "/groups" - Context(`Using mock server endpoint`, func() { + 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() @@ -453,7 +493,6 @@ var _ = Describe(`IamAccessGroupsV2`, func() { }) }) }) - Describe(`ListAccessGroups(listAccessGroupsOptions *ListAccessGroupsOptions)`, func() { listAccessGroupsPath := "/groups" Context(`Using mock server endpoint with timeout`, func() { @@ -625,10 +664,90 @@ var _ = Describe(`IamAccessGroupsV2`, 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 ListAccessGroups successfully`, func() { + iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2(&iamaccessgroupsv2.IamAccessGroupsV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamAccessGroupsService).ToNot(BeNil()) + + // Construct an instance of the ListAccessGroupsOptions model + listAccessGroupsOptionsModel := new(iamaccessgroupsv2.ListAccessGroupsOptions) + listAccessGroupsOptionsModel.AccountID = core.StringPtr("testString") + listAccessGroupsOptionsModel.TransactionID = core.StringPtr("testString") + listAccessGroupsOptionsModel.IamID = core.StringPtr("testString") + listAccessGroupsOptionsModel.Limit = core.Int64Ptr(int64(38)) + listAccessGroupsOptionsModel.Offset = core.Int64Ptr(int64(38)) + listAccessGroupsOptionsModel.Sort = core.StringPtr("testString") + listAccessGroupsOptionsModel.ShowFederated = core.BoolPtr(true) + listAccessGroupsOptionsModel.HidePublicAccess = core.BoolPtr(true) + listAccessGroupsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamAccessGroupsService.ListAccessGroups(listAccessGroupsOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Test pagination helper method on response`, func() { + It(`Invoke GetNextOffset successfully`, func() { + responseObject := new(iamaccessgroupsv2.GroupsList) + nextObject := new(iamaccessgroupsv2.HrefStruct) + nextObject.Href = core.StringPtr("ibm.com?offset=135") + responseObject.Next = nextObject + + value, err := responseObject.GetNextOffset() + Expect(err).To(BeNil()) + Expect(value).To(Equal(core.Int64Ptr(int64(135)))) + }) + It(`Invoke GetNextOffset without a "Next" property in the response`, func() { + responseObject := new(iamaccessgroupsv2.GroupsList) + + value, err := responseObject.GetNextOffset() + Expect(err).To(BeNil()) + Expect(value).To(BeNil()) + }) + It(`Invoke GetNextOffset without any query params in the "Next" URL`, func() { + responseObject := new(iamaccessgroupsv2.GroupsList) + nextObject := new(iamaccessgroupsv2.HrefStruct) + nextObject.Href = core.StringPtr("ibm.com") + responseObject.Next = nextObject + + value, err := responseObject.GetNextOffset() + Expect(err).To(BeNil()) + Expect(value).To(BeNil()) + }) + It(`Invoke GetNextOffset with a non-integer query param in the "Next" URL`, func() { + responseObject := new(iamaccessgroupsv2.GroupsList) + nextObject := new(iamaccessgroupsv2.HrefStruct) + nextObject.Href = core.StringPtr("ibm.com?offset=tiger") + responseObject.Next = nextObject + + value, err := responseObject.GetNextOffset() + Expect(err).NotTo(BeNil()) + Expect(value).To(BeNil()) + }) + }) }) Describe(`GetAccessGroup(getAccessGroupOptions *GetAccessGroupOptions) - Operation response error`, func() { getAccessGroupPath := "/groups/testString" - Context(`Using mock server endpoint`, func() { + 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() @@ -676,7 +795,6 @@ var _ = Describe(`IamAccessGroupsV2`, func() { }) }) }) - Describe(`GetAccessGroup(getAccessGroupOptions *GetAccessGroupOptions)`, func() { getAccessGroupPath := "/groups/testString" Context(`Using mock server endpoint with timeout`, func() { @@ -821,10 +939,46 @@ var _ = Describe(`IamAccessGroupsV2`, 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 GetAccessGroup successfully`, func() { + iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2(&iamaccessgroupsv2.IamAccessGroupsV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamAccessGroupsService).ToNot(BeNil()) + + // Construct an instance of the GetAccessGroupOptions model + getAccessGroupOptionsModel := new(iamaccessgroupsv2.GetAccessGroupOptions) + getAccessGroupOptionsModel.AccessGroupID = core.StringPtr("testString") + getAccessGroupOptionsModel.TransactionID = core.StringPtr("testString") + getAccessGroupOptionsModel.ShowFederated = core.BoolPtr(true) + getAccessGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamAccessGroupsService.GetAccessGroup(getAccessGroupOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) }) Describe(`UpdateAccessGroup(updateAccessGroupOptions *UpdateAccessGroupOptions) - Operation response error`, func() { updateAccessGroupPath := "/groups/testString" - Context(`Using mock server endpoint`, func() { + 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() @@ -875,7 +1029,6 @@ var _ = Describe(`IamAccessGroupsV2`, func() { }) }) }) - Describe(`UpdateAccessGroup(updateAccessGroupOptions *UpdateAccessGroupOptions)`, func() { updateAccessGroupPath := "/groups/testString" Context(`Using mock server endpoint with timeout`, func() { @@ -1060,8 +1213,45 @@ var _ = Describe(`IamAccessGroupsV2`, 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 UpdateAccessGroup successfully`, func() { + iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2(&iamaccessgroupsv2.IamAccessGroupsV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamAccessGroupsService).ToNot(BeNil()) + + // Construct an instance of the UpdateAccessGroupOptions model + updateAccessGroupOptionsModel := new(iamaccessgroupsv2.UpdateAccessGroupOptions) + updateAccessGroupOptionsModel.AccessGroupID = core.StringPtr("testString") + updateAccessGroupOptionsModel.IfMatch = core.StringPtr("testString") + updateAccessGroupOptionsModel.Name = core.StringPtr("Awesome Managers") + updateAccessGroupOptionsModel.Description = core.StringPtr("Group for awesome managers.") + updateAccessGroupOptionsModel.TransactionID = core.StringPtr("testString") + updateAccessGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamAccessGroupsService.UpdateAccessGroup(updateAccessGroupOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) Describe(`DeleteAccessGroup(deleteAccessGroupOptions *DeleteAccessGroupOptions)`, func() { deleteAccessGroupPath := "/groups/testString" Context(`Using mock server endpoint`, func() { @@ -1137,152 +1327,26 @@ var _ = Describe(`IamAccessGroupsV2`, func() { }) }) }) - Describe(`Service constructor tests`, func() { - It(`Instantiate service client`, func() { - iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2(&iamaccessgroupsv2.IamAccessGroupsV2Options{ - Authenticator: &core.NoAuthAuthenticator{}, - }) - Expect(iamAccessGroupsService).ToNot(BeNil()) - Expect(serviceErr).To(BeNil()) - }) - It(`Instantiate service client with error: Invalid URL`, func() { - iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2(&iamaccessgroupsv2.IamAccessGroupsV2Options{ - URL: "{BAD_URL_STRING", - }) - Expect(iamAccessGroupsService).To(BeNil()) - Expect(serviceErr).ToNot(BeNil()) - }) - It(`Instantiate service client with error: Invalid Auth`, func() { - iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2(&iamaccessgroupsv2.IamAccessGroupsV2Options{ - URL: "https://iamaccessgroupsv2/api", - Authenticator: &core.BasicAuthenticator{ - Username: "", - Password: "", - }, - }) - Expect(iamAccessGroupsService).To(BeNil()) - Expect(serviceErr).ToNot(BeNil()) - }) - }) - Describe(`Service constructor tests using external config`, func() { - Context(`Using external config, construct service client instances`, func() { - // Map containing environment variables used in testing. - var testEnvironment = map[string]string{ - "IAM_ACCESS_GROUPS_URL": "https://iamaccessgroupsv2/api", - "IAM_ACCESS_GROUPS_AUTH_TYPE": "noauth", - } + Describe(`IsMemberOfAccessGroup(isMemberOfAccessGroupOptions *IsMemberOfAccessGroupOptions)`, func() { + isMemberOfAccessGroupPath := "/groups/testString/members/testString" + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() - It(`Create service client using external config successfully`, func() { - SetTestEnvironment(testEnvironment) - iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2UsingExternalConfig(&iamaccessgroupsv2.IamAccessGroupsV2Options{}) - Expect(iamAccessGroupsService).ToNot(BeNil()) - Expect(serviceErr).To(BeNil()) - ClearTestEnvironment(testEnvironment) + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(isMemberOfAccessGroupPath)) + Expect(req.Method).To(Equal("HEAD")) - clone := iamAccessGroupsService.Clone() - Expect(clone).ToNot(BeNil()) - Expect(clone.Service != iamAccessGroupsService.Service).To(BeTrue()) - Expect(clone.GetServiceURL()).To(Equal(iamAccessGroupsService.GetServiceURL())) - Expect(clone.Service.Options.Authenticator).To(Equal(iamAccessGroupsService.Service.Options.Authenticator)) + Expect(req.Header["Transaction-Id"]).ToNot(BeNil()) + Expect(req.Header["Transaction-Id"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) + res.WriteHeader(204) + })) }) - It(`Create service client using external config and set url from constructor successfully`, func() { - SetTestEnvironment(testEnvironment) - iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2UsingExternalConfig(&iamaccessgroupsv2.IamAccessGroupsV2Options{ - URL: "https://testService/api", - }) - Expect(iamAccessGroupsService).ToNot(BeNil()) - Expect(serviceErr).To(BeNil()) - Expect(iamAccessGroupsService.Service.GetServiceURL()).To(Equal("https://testService/api")) - ClearTestEnvironment(testEnvironment) - - clone := iamAccessGroupsService.Clone() - Expect(clone).ToNot(BeNil()) - Expect(clone.Service != iamAccessGroupsService.Service).To(BeTrue()) - Expect(clone.GetServiceURL()).To(Equal(iamAccessGroupsService.GetServiceURL())) - Expect(clone.Service.Options.Authenticator).To(Equal(iamAccessGroupsService.Service.Options.Authenticator)) - }) - It(`Create service client using external config and set url programatically successfully`, func() { - SetTestEnvironment(testEnvironment) - iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2UsingExternalConfig(&iamaccessgroupsv2.IamAccessGroupsV2Options{}) - err := iamAccessGroupsService.SetServiceURL("https://testService/api") - Expect(err).To(BeNil()) - Expect(iamAccessGroupsService).ToNot(BeNil()) - Expect(serviceErr).To(BeNil()) - Expect(iamAccessGroupsService.Service.GetServiceURL()).To(Equal("https://testService/api")) - ClearTestEnvironment(testEnvironment) - - clone := iamAccessGroupsService.Clone() - Expect(clone).ToNot(BeNil()) - Expect(clone.Service != iamAccessGroupsService.Service).To(BeTrue()) - Expect(clone.GetServiceURL()).To(Equal(iamAccessGroupsService.GetServiceURL())) - Expect(clone.Service.Options.Authenticator).To(Equal(iamAccessGroupsService.Service.Options.Authenticator)) - }) - }) - Context(`Using external config, construct service client instances with error: Invalid Auth`, func() { - // Map containing environment variables used in testing. - var testEnvironment = map[string]string{ - "IAM_ACCESS_GROUPS_URL": "https://iamaccessgroupsv2/api", - "IAM_ACCESS_GROUPS_AUTH_TYPE": "someOtherAuth", - } - - SetTestEnvironment(testEnvironment) - iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2UsingExternalConfig(&iamaccessgroupsv2.IamAccessGroupsV2Options{}) - - It(`Instantiate service client with error`, func() { - Expect(iamAccessGroupsService).To(BeNil()) - Expect(serviceErr).ToNot(BeNil()) - ClearTestEnvironment(testEnvironment) - }) - }) - Context(`Using external config, construct service client instances with error: Invalid URL`, func() { - // Map containing environment variables used in testing. - var testEnvironment = map[string]string{ - "IAM_ACCESS_GROUPS_AUTH_TYPE": "NOAuth", - } - - SetTestEnvironment(testEnvironment) - iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2UsingExternalConfig(&iamaccessgroupsv2.IamAccessGroupsV2Options{ - URL: "{BAD_URL_STRING", - }) - - It(`Instantiate service client with error`, func() { - Expect(iamAccessGroupsService).To(BeNil()) - Expect(serviceErr).ToNot(BeNil()) - ClearTestEnvironment(testEnvironment) - }) - }) - }) - Describe(`Regional endpoint tests`, func() { - It(`GetServiceURLForRegion(region string)`, func() { - var url string - var err error - url, err = iamaccessgroupsv2.GetServiceURLForRegion("INVALID_REGION") - Expect(url).To(BeEmpty()) - Expect(err).ToNot(BeNil()) - fmt.Fprintf(GinkgoWriter, "Expected error: %s\n", err.Error()) - }) - }) - - Describe(`IsMemberOfAccessGroup(isMemberOfAccessGroupOptions *IsMemberOfAccessGroupOptions)`, func() { - isMemberOfAccessGroupPath := "/groups/testString/members/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(isMemberOfAccessGroupPath)) - Expect(req.Method).To(Equal("HEAD")) - - Expect(req.Header["Transaction-Id"]).ToNot(BeNil()) - Expect(req.Header["Transaction-Id"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) - res.WriteHeader(204) - })) - }) - It(`Invoke IsMemberOfAccessGroup successfully`, func() { - iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2(&iamaccessgroupsv2.IamAccessGroupsV2Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, + It(`Invoke IsMemberOfAccessGroup successfully`, func() { + iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2(&iamaccessgroupsv2.IamAccessGroupsV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, }) Expect(serviceErr).To(BeNil()) Expect(iamAccessGroupsService).ToNot(BeNil()) @@ -1339,7 +1403,7 @@ var _ = Describe(`IamAccessGroupsV2`, func() { }) Describe(`AddMembersToAccessGroup(addMembersToAccessGroupOptions *AddMembersToAccessGroupOptions) - Operation response error`, func() { addMembersToAccessGroupPath := "/groups/testString/members" - Context(`Using mock server endpoint`, func() { + 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() @@ -1391,7 +1455,6 @@ var _ = Describe(`IamAccessGroupsV2`, func() { }) }) }) - Describe(`AddMembersToAccessGroup(addMembersToAccessGroupOptions *AddMembersToAccessGroupOptions)`, func() { addMembersToAccessGroupPath := "/groups/testString/members" Context(`Using mock server endpoint with timeout`, func() { @@ -1581,10 +1644,51 @@ var _ = Describe(`IamAccessGroupsV2`, 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(207) + })) + }) + It(`Invoke AddMembersToAccessGroup successfully`, func() { + iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2(&iamaccessgroupsv2.IamAccessGroupsV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamAccessGroupsService).ToNot(BeNil()) + + // Construct an instance of the AddGroupMembersRequestMembersItem model + addGroupMembersRequestMembersItemModel := new(iamaccessgroupsv2.AddGroupMembersRequestMembersItem) + addGroupMembersRequestMembersItemModel.IamID = core.StringPtr("IBMid-user1") + addGroupMembersRequestMembersItemModel.Type = core.StringPtr("user") + + // Construct an instance of the AddMembersToAccessGroupOptions model + addMembersToAccessGroupOptionsModel := new(iamaccessgroupsv2.AddMembersToAccessGroupOptions) + addMembersToAccessGroupOptionsModel.AccessGroupID = core.StringPtr("testString") + addMembersToAccessGroupOptionsModel.Members = []iamaccessgroupsv2.AddGroupMembersRequestMembersItem{*addGroupMembersRequestMembersItemModel} + addMembersToAccessGroupOptionsModel.TransactionID = core.StringPtr("testString") + addMembersToAccessGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamAccessGroupsService.AddMembersToAccessGroup(addMembersToAccessGroupOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) }) Describe(`ListAccessGroupMembers(listAccessGroupMembersOptions *ListAccessGroupMembersOptions) - Operation response error`, func() { listAccessGroupMembersPath := "/groups/testString/members" - Context(`Using mock server endpoint`, func() { + 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() @@ -1640,7 +1744,6 @@ var _ = Describe(`IamAccessGroupsV2`, func() { }) }) }) - Describe(`ListAccessGroupMembers(listAccessGroupMembersOptions *ListAccessGroupMembersOptions)`, func() { listAccessGroupMembersPath := "/groups/testString/members" Context(`Using mock server endpoint with timeout`, func() { @@ -1805,8 +1908,86 @@ var _ = Describe(`IamAccessGroupsV2`, 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 ListAccessGroupMembers successfully`, func() { + iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2(&iamaccessgroupsv2.IamAccessGroupsV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamAccessGroupsService).ToNot(BeNil()) + + // Construct an instance of the ListAccessGroupMembersOptions model + listAccessGroupMembersOptionsModel := new(iamaccessgroupsv2.ListAccessGroupMembersOptions) + listAccessGroupMembersOptionsModel.AccessGroupID = core.StringPtr("testString") + listAccessGroupMembersOptionsModel.TransactionID = core.StringPtr("testString") + listAccessGroupMembersOptionsModel.Limit = core.Int64Ptr(int64(38)) + listAccessGroupMembersOptionsModel.Offset = core.Int64Ptr(int64(38)) + listAccessGroupMembersOptionsModel.Type = core.StringPtr("testString") + listAccessGroupMembersOptionsModel.Verbose = core.BoolPtr(true) + listAccessGroupMembersOptionsModel.Sort = core.StringPtr("testString") + listAccessGroupMembersOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamAccessGroupsService.ListAccessGroupMembers(listAccessGroupMembersOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Test pagination helper method on response`, func() { + It(`Invoke GetNextOffset successfully`, func() { + responseObject := new(iamaccessgroupsv2.GroupMembersList) + nextObject := new(iamaccessgroupsv2.HrefStruct) + nextObject.Href = core.StringPtr("ibm.com?offset=135") + responseObject.Next = nextObject + + value, err := responseObject.GetNextOffset() + Expect(err).To(BeNil()) + Expect(value).To(Equal(core.Int64Ptr(int64(135)))) + }) + It(`Invoke GetNextOffset without a "Next" property in the response`, func() { + responseObject := new(iamaccessgroupsv2.GroupMembersList) + + value, err := responseObject.GetNextOffset() + Expect(err).To(BeNil()) + Expect(value).To(BeNil()) + }) + It(`Invoke GetNextOffset without any query params in the "Next" URL`, func() { + responseObject := new(iamaccessgroupsv2.GroupMembersList) + nextObject := new(iamaccessgroupsv2.HrefStruct) + nextObject.Href = core.StringPtr("ibm.com") + responseObject.Next = nextObject + + value, err := responseObject.GetNextOffset() + Expect(err).To(BeNil()) + Expect(value).To(BeNil()) + }) + It(`Invoke GetNextOffset with a non-integer query param in the "Next" URL`, func() { + responseObject := new(iamaccessgroupsv2.GroupMembersList) + nextObject := new(iamaccessgroupsv2.HrefStruct) + nextObject.Href = core.StringPtr("ibm.com?offset=tiger") + responseObject.Next = nextObject + + value, err := responseObject.GetNextOffset() + Expect(err).NotTo(BeNil()) + Expect(value).To(BeNil()) + }) + }) + }) Describe(`RemoveMemberFromAccessGroup(removeMemberFromAccessGroupOptions *RemoveMemberFromAccessGroupOptions)`, func() { removeMemberFromAccessGroupPath := "/groups/testString/members/testString" Context(`Using mock server endpoint`, func() { @@ -1883,7 +2064,7 @@ var _ = Describe(`IamAccessGroupsV2`, func() { }) Describe(`RemoveMembersFromAccessGroup(removeMembersFromAccessGroupOptions *RemoveMembersFromAccessGroupOptions) - Operation response error`, func() { removeMembersFromAccessGroupPath := "/groups/testString/members/delete" - Context(`Using mock server endpoint`, func() { + 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() @@ -1930,7 +2111,6 @@ var _ = Describe(`IamAccessGroupsV2`, func() { }) }) }) - Describe(`RemoveMembersFromAccessGroup(removeMembersFromAccessGroupOptions *RemoveMembersFromAccessGroupOptions)`, func() { removeMembersFromAccessGroupPath := "/groups/testString/members/delete" Context(`Using mock server endpoint with timeout`, func() { @@ -2105,10 +2285,46 @@ var _ = Describe(`IamAccessGroupsV2`, 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(207) + })) + }) + It(`Invoke RemoveMembersFromAccessGroup successfully`, func() { + iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2(&iamaccessgroupsv2.IamAccessGroupsV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamAccessGroupsService).ToNot(BeNil()) + + // Construct an instance of the RemoveMembersFromAccessGroupOptions model + removeMembersFromAccessGroupOptionsModel := new(iamaccessgroupsv2.RemoveMembersFromAccessGroupOptions) + removeMembersFromAccessGroupOptionsModel.AccessGroupID = core.StringPtr("testString") + removeMembersFromAccessGroupOptionsModel.Members = []string{"IBMId-user1", "iam-ServiceId-123"} + removeMembersFromAccessGroupOptionsModel.TransactionID = core.StringPtr("testString") + removeMembersFromAccessGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamAccessGroupsService.RemoveMembersFromAccessGroup(removeMembersFromAccessGroupOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) }) Describe(`RemoveMemberFromAllAccessGroups(removeMemberFromAllAccessGroupsOptions *RemoveMemberFromAllAccessGroupsOptions) - Operation response error`, func() { removeMemberFromAllAccessGroupsPath := "/groups/_allgroups/members/testString" - Context(`Using mock server endpoint`, func() { + 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() @@ -2156,7 +2372,6 @@ var _ = Describe(`IamAccessGroupsV2`, func() { }) }) }) - Describe(`RemoveMemberFromAllAccessGroups(removeMemberFromAllAccessGroupsOptions *RemoveMemberFromAllAccessGroupsOptions)`, func() { removeMemberFromAllAccessGroupsPath := "/groups/_allgroups/members/testString" Context(`Using mock server endpoint with timeout`, func() { @@ -2301,10 +2516,46 @@ var _ = Describe(`IamAccessGroupsV2`, 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(207) + })) + }) + It(`Invoke RemoveMemberFromAllAccessGroups successfully`, func() { + iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2(&iamaccessgroupsv2.IamAccessGroupsV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamAccessGroupsService).ToNot(BeNil()) + + // Construct an instance of the RemoveMemberFromAllAccessGroupsOptions model + removeMemberFromAllAccessGroupsOptionsModel := new(iamaccessgroupsv2.RemoveMemberFromAllAccessGroupsOptions) + removeMemberFromAllAccessGroupsOptionsModel.AccountID = core.StringPtr("testString") + removeMemberFromAllAccessGroupsOptionsModel.IamID = core.StringPtr("testString") + removeMemberFromAllAccessGroupsOptionsModel.TransactionID = core.StringPtr("testString") + removeMemberFromAllAccessGroupsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamAccessGroupsService.RemoveMemberFromAllAccessGroups(removeMemberFromAllAccessGroupsOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) }) Describe(`AddMemberToMultipleAccessGroups(addMemberToMultipleAccessGroupsOptions *AddMemberToMultipleAccessGroupsOptions) - Operation response error`, func() { addMemberToMultipleAccessGroupsPath := "/groups/_allgroups/members/testString" - Context(`Using mock server endpoint`, func() { + 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() @@ -2354,7 +2605,6 @@ var _ = Describe(`IamAccessGroupsV2`, func() { }) }) }) - Describe(`AddMemberToMultipleAccessGroups(addMemberToMultipleAccessGroupsOptions *AddMemberToMultipleAccessGroupsOptions)`, func() { addMemberToMultipleAccessGroupsPath := "/groups/_allgroups/members/testString" Context(`Using mock server endpoint with timeout`, func() { @@ -2537,135 +2787,48 @@ var _ = Describe(`IamAccessGroupsV2`, func() { testServer.Close() }) }) - }) - Describe(`Service constructor tests`, func() { - It(`Instantiate service client`, func() { - iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2(&iamaccessgroupsv2.IamAccessGroupsV2Options{ - Authenticator: &core.NoAuthAuthenticator{}, - }) - Expect(iamAccessGroupsService).ToNot(BeNil()) - Expect(serviceErr).To(BeNil()) - }) - It(`Instantiate service client with error: Invalid URL`, func() { - iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2(&iamaccessgroupsv2.IamAccessGroupsV2Options{ - URL: "{BAD_URL_STRING", - }) - Expect(iamAccessGroupsService).To(BeNil()) - Expect(serviceErr).ToNot(BeNil()) - }) - It(`Instantiate service client with error: Invalid Auth`, func() { - iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2(&iamaccessgroupsv2.IamAccessGroupsV2Options{ - URL: "https://iamaccessgroupsv2/api", - Authenticator: &core.BasicAuthenticator{ - Username: "", - Password: "", - }, - }) - Expect(iamAccessGroupsService).To(BeNil()) - Expect(serviceErr).ToNot(BeNil()) - }) - }) - Describe(`Service constructor tests using external config`, func() { - Context(`Using external config, construct service client instances`, func() { - // Map containing environment variables used in testing. - var testEnvironment = map[string]string{ - "IAM_ACCESS_GROUPS_URL": "https://iamaccessgroupsv2/api", - "IAM_ACCESS_GROUPS_AUTH_TYPE": "noauth", - } - - It(`Create service client using external config successfully`, func() { - SetTestEnvironment(testEnvironment) - iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2UsingExternalConfig(&iamaccessgroupsv2.IamAccessGroupsV2Options{}) - Expect(iamAccessGroupsService).ToNot(BeNil()) - Expect(serviceErr).To(BeNil()) - ClearTestEnvironment(testEnvironment) + 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() - clone := iamAccessGroupsService.Clone() - Expect(clone).ToNot(BeNil()) - Expect(clone.Service != iamAccessGroupsService.Service).To(BeTrue()) - Expect(clone.GetServiceURL()).To(Equal(iamAccessGroupsService.GetServiceURL())) - Expect(clone.Service.Options.Authenticator).To(Equal(iamAccessGroupsService.Service.Options.Authenticator)) + // Set success status code with no respoonse body + res.WriteHeader(207) + })) }) - It(`Create service client using external config and set url from constructor successfully`, func() { - SetTestEnvironment(testEnvironment) - iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2UsingExternalConfig(&iamaccessgroupsv2.IamAccessGroupsV2Options{ - URL: "https://testService/api", + It(`Invoke AddMemberToMultipleAccessGroups successfully`, func() { + iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2(&iamaccessgroupsv2.IamAccessGroupsV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, }) - Expect(iamAccessGroupsService).ToNot(BeNil()) Expect(serviceErr).To(BeNil()) - Expect(iamAccessGroupsService.Service.GetServiceURL()).To(Equal("https://testService/api")) - ClearTestEnvironment(testEnvironment) - - clone := iamAccessGroupsService.Clone() - Expect(clone).ToNot(BeNil()) - Expect(clone.Service != iamAccessGroupsService.Service).To(BeTrue()) - Expect(clone.GetServiceURL()).To(Equal(iamAccessGroupsService.GetServiceURL())) - Expect(clone.Service.Options.Authenticator).To(Equal(iamAccessGroupsService.Service.Options.Authenticator)) - }) - It(`Create service client using external config and set url programatically successfully`, func() { - SetTestEnvironment(testEnvironment) - iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2UsingExternalConfig(&iamaccessgroupsv2.IamAccessGroupsV2Options{}) - err := iamAccessGroupsService.SetServiceURL("https://testService/api") - Expect(err).To(BeNil()) Expect(iamAccessGroupsService).ToNot(BeNil()) - Expect(serviceErr).To(BeNil()) - Expect(iamAccessGroupsService.Service.GetServiceURL()).To(Equal("https://testService/api")) - ClearTestEnvironment(testEnvironment) - - clone := iamAccessGroupsService.Clone() - Expect(clone).ToNot(BeNil()) - Expect(clone.Service != iamAccessGroupsService.Service).To(BeTrue()) - Expect(clone.GetServiceURL()).To(Equal(iamAccessGroupsService.GetServiceURL())) - Expect(clone.Service.Options.Authenticator).To(Equal(iamAccessGroupsService.Service.Options.Authenticator)) - }) - }) - Context(`Using external config, construct service client instances with error: Invalid Auth`, func() { - // Map containing environment variables used in testing. - var testEnvironment = map[string]string{ - "IAM_ACCESS_GROUPS_URL": "https://iamaccessgroupsv2/api", - "IAM_ACCESS_GROUPS_AUTH_TYPE": "someOtherAuth", - } - SetTestEnvironment(testEnvironment) - iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2UsingExternalConfig(&iamaccessgroupsv2.IamAccessGroupsV2Options{}) + // Construct an instance of the AddMemberToMultipleAccessGroupsOptions model + addMemberToMultipleAccessGroupsOptionsModel := new(iamaccessgroupsv2.AddMemberToMultipleAccessGroupsOptions) + addMemberToMultipleAccessGroupsOptionsModel.AccountID = core.StringPtr("testString") + addMemberToMultipleAccessGroupsOptionsModel.IamID = core.StringPtr("testString") + addMemberToMultipleAccessGroupsOptionsModel.Type = core.StringPtr("user") + addMemberToMultipleAccessGroupsOptionsModel.Groups = []string{"access-group-id-1"} + addMemberToMultipleAccessGroupsOptionsModel.TransactionID = core.StringPtr("testString") + addMemberToMultipleAccessGroupsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - It(`Instantiate service client with error`, func() { - Expect(iamAccessGroupsService).To(BeNil()) - Expect(serviceErr).ToNot(BeNil()) - ClearTestEnvironment(testEnvironment) - }) - }) - Context(`Using external config, construct service client instances with error: Invalid URL`, func() { - // Map containing environment variables used in testing. - var testEnvironment = map[string]string{ - "IAM_ACCESS_GROUPS_AUTH_TYPE": "NOAuth", - } + // Invoke operation + result, response, operationErr := iamAccessGroupsService.AddMemberToMultipleAccessGroups(addMemberToMultipleAccessGroupsOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) - SetTestEnvironment(testEnvironment) - iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2UsingExternalConfig(&iamaccessgroupsv2.IamAccessGroupsV2Options{ - URL: "{BAD_URL_STRING", + // Verify a nil result + Expect(result).To(BeNil()) }) - - It(`Instantiate service client with error`, func() { - Expect(iamAccessGroupsService).To(BeNil()) - Expect(serviceErr).ToNot(BeNil()) - ClearTestEnvironment(testEnvironment) + AfterEach(func() { + testServer.Close() }) }) }) - Describe(`Regional endpoint tests`, func() { - It(`GetServiceURLForRegion(region string)`, func() { - var url string - var err error - url, err = iamaccessgroupsv2.GetServiceURLForRegion("INVALID_REGION") - Expect(url).To(BeEmpty()) - Expect(err).ToNot(BeNil()) - fmt.Fprintf(GinkgoWriter, "Expected error: %s\n", err.Error()) - }) - }) Describe(`AddAccessGroupRule(addAccessGroupRuleOptions *AddAccessGroupRuleOptions) - Operation response error`, func() { addAccessGroupRulePath := "/groups/testString/rules" - Context(`Using mock server endpoint`, func() { + 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() @@ -2721,7 +2884,6 @@ var _ = Describe(`IamAccessGroupsV2`, func() { }) }) }) - Describe(`AddAccessGroupRule(addAccessGroupRuleOptions *AddAccessGroupRuleOptions)`, func() { addAccessGroupRulePath := "/groups/testString/rules" Context(`Using mock server endpoint with timeout`, func() { @@ -2923,10 +3085,55 @@ var _ = Describe(`IamAccessGroupsV2`, func() { testServer.Close() }) }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(201) + })) + }) + It(`Invoke AddAccessGroupRule successfully`, func() { + iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2(&iamaccessgroupsv2.IamAccessGroupsV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamAccessGroupsService).ToNot(BeNil()) + + // Construct an instance of the RuleConditions model + ruleConditionsModel := new(iamaccessgroupsv2.RuleConditions) + ruleConditionsModel.Claim = core.StringPtr("isManager") + ruleConditionsModel.Operator = core.StringPtr("EQUALS") + ruleConditionsModel.Value = core.StringPtr("true") + + // Construct an instance of the AddAccessGroupRuleOptions model + addAccessGroupRuleOptionsModel := new(iamaccessgroupsv2.AddAccessGroupRuleOptions) + addAccessGroupRuleOptionsModel.AccessGroupID = core.StringPtr("testString") + addAccessGroupRuleOptionsModel.Expiration = core.Int64Ptr(int64(12)) + addAccessGroupRuleOptionsModel.RealmName = core.StringPtr("https://idp.example.org/SAML2") + addAccessGroupRuleOptionsModel.Conditions = []iamaccessgroupsv2.RuleConditions{*ruleConditionsModel} + addAccessGroupRuleOptionsModel.Name = core.StringPtr("Manager group rule") + addAccessGroupRuleOptionsModel.TransactionID = core.StringPtr("testString") + addAccessGroupRuleOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamAccessGroupsService.AddAccessGroupRule(addAccessGroupRuleOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) }) Describe(`ListAccessGroupRules(listAccessGroupRulesOptions *ListAccessGroupRulesOptions) - Operation response error`, func() { listAccessGroupRulesPath := "/groups/testString/rules" - Context(`Using mock server endpoint`, func() { + 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() @@ -2972,7 +3179,6 @@ var _ = Describe(`IamAccessGroupsV2`, func() { }) }) }) - Describe(`ListAccessGroupRules(listAccessGroupRulesOptions *ListAccessGroupRulesOptions)`, func() { listAccessGroupRulesPath := "/groups/testString/rules" Context(`Using mock server endpoint with timeout`, func() { @@ -3112,10 +3318,45 @@ var _ = Describe(`IamAccessGroupsV2`, 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 ListAccessGroupRules successfully`, func() { + iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2(&iamaccessgroupsv2.IamAccessGroupsV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamAccessGroupsService).ToNot(BeNil()) + + // Construct an instance of the ListAccessGroupRulesOptions model + listAccessGroupRulesOptionsModel := new(iamaccessgroupsv2.ListAccessGroupRulesOptions) + listAccessGroupRulesOptionsModel.AccessGroupID = core.StringPtr("testString") + listAccessGroupRulesOptionsModel.TransactionID = core.StringPtr("testString") + listAccessGroupRulesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamAccessGroupsService.ListAccessGroupRules(listAccessGroupRulesOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) }) Describe(`GetAccessGroupRule(getAccessGroupRuleOptions *GetAccessGroupRuleOptions) - Operation response error`, func() { getAccessGroupRulePath := "/groups/testString/rules/testString" - Context(`Using mock server endpoint`, func() { + 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() @@ -3162,7 +3403,6 @@ var _ = Describe(`IamAccessGroupsV2`, func() { }) }) }) - Describe(`GetAccessGroupRule(getAccessGroupRuleOptions *GetAccessGroupRuleOptions)`, func() { getAccessGroupRulePath := "/groups/testString/rules/testString" Context(`Using mock server endpoint with timeout`, func() { @@ -3271,7 +3511,50 @@ var _ = Describe(`IamAccessGroupsV2`, func() { Expect(result).ToNot(BeNil()) }) - It(`Invoke GetAccessGroupRule with error: Operation validation and request error`, func() { + It(`Invoke GetAccessGroupRule with error: Operation validation and request error`, func() { + iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2(&iamaccessgroupsv2.IamAccessGroupsV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamAccessGroupsService).ToNot(BeNil()) + + // Construct an instance of the GetAccessGroupRuleOptions model + getAccessGroupRuleOptionsModel := new(iamaccessgroupsv2.GetAccessGroupRuleOptions) + getAccessGroupRuleOptionsModel.AccessGroupID = core.StringPtr("testString") + getAccessGroupRuleOptionsModel.RuleID = core.StringPtr("testString") + getAccessGroupRuleOptionsModel.TransactionID = core.StringPtr("testString") + getAccessGroupRuleOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := iamAccessGroupsService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := iamAccessGroupsService.GetAccessGroupRule(getAccessGroupRuleOptionsModel) + 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 GetAccessGroupRuleOptions model with no property values + getAccessGroupRuleOptionsModelNew := new(iamaccessgroupsv2.GetAccessGroupRuleOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = iamAccessGroupsService.GetAccessGroupRule(getAccessGroupRuleOptionsModelNew) + 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 GetAccessGroupRule successfully`, func() { iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2(&iamaccessgroupsv2.IamAccessGroupsV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -3285,20 +3568,13 @@ var _ = Describe(`IamAccessGroupsV2`, func() { getAccessGroupRuleOptionsModel.RuleID = core.StringPtr("testString") getAccessGroupRuleOptionsModel.TransactionID = core.StringPtr("testString") getAccessGroupRuleOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - // Invoke operation with empty URL (negative test) - err := iamAccessGroupsService.SetServiceURL("") - Expect(err).To(BeNil()) + + // Invoke operation result, response, operationErr := iamAccessGroupsService.GetAccessGroupRule(getAccessGroupRuleOptionsModel) - 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 GetAccessGroupRuleOptions model with no property values - getAccessGroupRuleOptionsModelNew := new(iamaccessgroupsv2.GetAccessGroupRuleOptions) - // Invoke operation with invalid model (negative test) - result, response, operationErr = iamAccessGroupsService.GetAccessGroupRule(getAccessGroupRuleOptionsModelNew) - Expect(operationErr).ToNot(BeNil()) - Expect(response).To(BeNil()) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result Expect(result).To(BeNil()) }) AfterEach(func() { @@ -3308,7 +3584,7 @@ var _ = Describe(`IamAccessGroupsV2`, func() { }) Describe(`ReplaceAccessGroupRule(replaceAccessGroupRuleOptions *ReplaceAccessGroupRuleOptions) - Operation response error`, func() { replaceAccessGroupRulePath := "/groups/testString/rules/testString" - Context(`Using mock server endpoint`, func() { + 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() @@ -3368,7 +3644,6 @@ var _ = Describe(`IamAccessGroupsV2`, func() { }) }) }) - Describe(`ReplaceAccessGroupRule(replaceAccessGroupRuleOptions *ReplaceAccessGroupRuleOptions)`, func() { replaceAccessGroupRulePath := "/groups/testString/rules/testString" Context(`Using mock server endpoint with timeout`, func() { @@ -3580,8 +3855,54 @@ var _ = Describe(`IamAccessGroupsV2`, 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 ReplaceAccessGroupRule successfully`, func() { + iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2(&iamaccessgroupsv2.IamAccessGroupsV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamAccessGroupsService).ToNot(BeNil()) + + // Construct an instance of the RuleConditions model + ruleConditionsModel := new(iamaccessgroupsv2.RuleConditions) + ruleConditionsModel.Claim = core.StringPtr("isManager") + ruleConditionsModel.Operator = core.StringPtr("EQUALS") + ruleConditionsModel.Value = core.StringPtr("true") + + // Construct an instance of the ReplaceAccessGroupRuleOptions model + replaceAccessGroupRuleOptionsModel := new(iamaccessgroupsv2.ReplaceAccessGroupRuleOptions) + replaceAccessGroupRuleOptionsModel.AccessGroupID = core.StringPtr("testString") + replaceAccessGroupRuleOptionsModel.RuleID = core.StringPtr("testString") + replaceAccessGroupRuleOptionsModel.IfMatch = core.StringPtr("testString") + replaceAccessGroupRuleOptionsModel.Expiration = core.Int64Ptr(int64(12)) + replaceAccessGroupRuleOptionsModel.RealmName = core.StringPtr("https://idp.example.org/SAML2") + replaceAccessGroupRuleOptionsModel.Conditions = []iamaccessgroupsv2.RuleConditions{*ruleConditionsModel} + replaceAccessGroupRuleOptionsModel.Name = core.StringPtr("Manager group rule") + replaceAccessGroupRuleOptionsModel.TransactionID = core.StringPtr("testString") + replaceAccessGroupRuleOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamAccessGroupsService.ReplaceAccessGroupRule(replaceAccessGroupRuleOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) Describe(`RemoveAccessGroupRule(removeAccessGroupRuleOptions *RemoveAccessGroupRuleOptions)`, func() { removeAccessGroupRulePath := "/groups/testString/rules/testString" Context(`Using mock server endpoint`, func() { @@ -3656,134 +3977,9 @@ var _ = Describe(`IamAccessGroupsV2`, func() { }) }) }) - Describe(`Service constructor tests`, func() { - It(`Instantiate service client`, func() { - iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2(&iamaccessgroupsv2.IamAccessGroupsV2Options{ - Authenticator: &core.NoAuthAuthenticator{}, - }) - Expect(iamAccessGroupsService).ToNot(BeNil()) - Expect(serviceErr).To(BeNil()) - }) - It(`Instantiate service client with error: Invalid URL`, func() { - iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2(&iamaccessgroupsv2.IamAccessGroupsV2Options{ - URL: "{BAD_URL_STRING", - }) - Expect(iamAccessGroupsService).To(BeNil()) - Expect(serviceErr).ToNot(BeNil()) - }) - It(`Instantiate service client with error: Invalid Auth`, func() { - iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2(&iamaccessgroupsv2.IamAccessGroupsV2Options{ - URL: "https://iamaccessgroupsv2/api", - Authenticator: &core.BasicAuthenticator{ - Username: "", - Password: "", - }, - }) - Expect(iamAccessGroupsService).To(BeNil()) - Expect(serviceErr).ToNot(BeNil()) - }) - }) - Describe(`Service constructor tests using external config`, func() { - Context(`Using external config, construct service client instances`, func() { - // Map containing environment variables used in testing. - var testEnvironment = map[string]string{ - "IAM_ACCESS_GROUPS_URL": "https://iamaccessgroupsv2/api", - "IAM_ACCESS_GROUPS_AUTH_TYPE": "noauth", - } - - It(`Create service client using external config successfully`, func() { - SetTestEnvironment(testEnvironment) - iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2UsingExternalConfig(&iamaccessgroupsv2.IamAccessGroupsV2Options{}) - Expect(iamAccessGroupsService).ToNot(BeNil()) - Expect(serviceErr).To(BeNil()) - ClearTestEnvironment(testEnvironment) - - clone := iamAccessGroupsService.Clone() - Expect(clone).ToNot(BeNil()) - Expect(clone.Service != iamAccessGroupsService.Service).To(BeTrue()) - Expect(clone.GetServiceURL()).To(Equal(iamAccessGroupsService.GetServiceURL())) - Expect(clone.Service.Options.Authenticator).To(Equal(iamAccessGroupsService.Service.Options.Authenticator)) - }) - It(`Create service client using external config and set url from constructor successfully`, func() { - SetTestEnvironment(testEnvironment) - iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2UsingExternalConfig(&iamaccessgroupsv2.IamAccessGroupsV2Options{ - URL: "https://testService/api", - }) - Expect(iamAccessGroupsService).ToNot(BeNil()) - Expect(serviceErr).To(BeNil()) - Expect(iamAccessGroupsService.Service.GetServiceURL()).To(Equal("https://testService/api")) - ClearTestEnvironment(testEnvironment) - - clone := iamAccessGroupsService.Clone() - Expect(clone).ToNot(BeNil()) - Expect(clone.Service != iamAccessGroupsService.Service).To(BeTrue()) - Expect(clone.GetServiceURL()).To(Equal(iamAccessGroupsService.GetServiceURL())) - Expect(clone.Service.Options.Authenticator).To(Equal(iamAccessGroupsService.Service.Options.Authenticator)) - }) - It(`Create service client using external config and set url programatically successfully`, func() { - SetTestEnvironment(testEnvironment) - iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2UsingExternalConfig(&iamaccessgroupsv2.IamAccessGroupsV2Options{}) - err := iamAccessGroupsService.SetServiceURL("https://testService/api") - Expect(err).To(BeNil()) - Expect(iamAccessGroupsService).ToNot(BeNil()) - Expect(serviceErr).To(BeNil()) - Expect(iamAccessGroupsService.Service.GetServiceURL()).To(Equal("https://testService/api")) - ClearTestEnvironment(testEnvironment) - - clone := iamAccessGroupsService.Clone() - Expect(clone).ToNot(BeNil()) - Expect(clone.Service != iamAccessGroupsService.Service).To(BeTrue()) - Expect(clone.GetServiceURL()).To(Equal(iamAccessGroupsService.GetServiceURL())) - Expect(clone.Service.Options.Authenticator).To(Equal(iamAccessGroupsService.Service.Options.Authenticator)) - }) - }) - Context(`Using external config, construct service client instances with error: Invalid Auth`, func() { - // Map containing environment variables used in testing. - var testEnvironment = map[string]string{ - "IAM_ACCESS_GROUPS_URL": "https://iamaccessgroupsv2/api", - "IAM_ACCESS_GROUPS_AUTH_TYPE": "someOtherAuth", - } - - SetTestEnvironment(testEnvironment) - iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2UsingExternalConfig(&iamaccessgroupsv2.IamAccessGroupsV2Options{}) - - It(`Instantiate service client with error`, func() { - Expect(iamAccessGroupsService).To(BeNil()) - Expect(serviceErr).ToNot(BeNil()) - ClearTestEnvironment(testEnvironment) - }) - }) - Context(`Using external config, construct service client instances with error: Invalid URL`, func() { - // Map containing environment variables used in testing. - var testEnvironment = map[string]string{ - "IAM_ACCESS_GROUPS_AUTH_TYPE": "NOAuth", - } - - SetTestEnvironment(testEnvironment) - iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2UsingExternalConfig(&iamaccessgroupsv2.IamAccessGroupsV2Options{ - URL: "{BAD_URL_STRING", - }) - - It(`Instantiate service client with error`, func() { - Expect(iamAccessGroupsService).To(BeNil()) - Expect(serviceErr).ToNot(BeNil()) - ClearTestEnvironment(testEnvironment) - }) - }) - }) - Describe(`Regional endpoint tests`, func() { - It(`GetServiceURLForRegion(region string)`, func() { - var url string - var err error - url, err = iamaccessgroupsv2.GetServiceURLForRegion("INVALID_REGION") - Expect(url).To(BeEmpty()) - Expect(err).ToNot(BeNil()) - fmt.Fprintf(GinkgoWriter, "Expected error: %s\n", err.Error()) - }) - }) Describe(`GetAccountSettings(getAccountSettingsOptions *GetAccountSettingsOptions) - Operation response error`, func() { getAccountSettingsPath := "/groups/settings" - Context(`Using mock server endpoint`, func() { + 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() @@ -3830,7 +4026,6 @@ var _ = Describe(`IamAccessGroupsV2`, func() { }) }) }) - Describe(`GetAccountSettings(getAccountSettingsOptions *GetAccountSettingsOptions)`, func() { getAccountSettingsPath := "/groups/settings" Context(`Using mock server endpoint with timeout`, func() { @@ -3972,10 +4167,45 @@ var _ = Describe(`IamAccessGroupsV2`, 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 GetAccountSettings successfully`, func() { + iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2(&iamaccessgroupsv2.IamAccessGroupsV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamAccessGroupsService).ToNot(BeNil()) + + // Construct an instance of the GetAccountSettingsOptions model + getAccountSettingsOptionsModel := new(iamaccessgroupsv2.GetAccountSettingsOptions) + getAccountSettingsOptionsModel.AccountID = core.StringPtr("testString") + getAccountSettingsOptionsModel.TransactionID = core.StringPtr("testString") + getAccountSettingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamAccessGroupsService.GetAccountSettings(getAccountSettingsOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) }) Describe(`UpdateAccountSettings(updateAccountSettingsOptions *UpdateAccountSettingsOptions) - Operation response error`, func() { updateAccountSettingsPath := "/groups/settings" - Context(`Using mock server endpoint`, func() { + 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() @@ -4023,7 +4253,6 @@ var _ = Describe(`IamAccessGroupsV2`, func() { }) }) }) - Describe(`UpdateAccountSettings(updateAccountSettingsOptions *UpdateAccountSettingsOptions)`, func() { updateAccountSettingsPath := "/groups/settings" Context(`Using mock server endpoint with timeout`, func() { @@ -4200,6 +4429,42 @@ var _ = Describe(`IamAccessGroupsV2`, 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 UpdateAccountSettings successfully`, func() { + iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2(&iamaccessgroupsv2.IamAccessGroupsV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamAccessGroupsService).ToNot(BeNil()) + + // Construct an instance of the UpdateAccountSettingsOptions model + updateAccountSettingsOptionsModel := new(iamaccessgroupsv2.UpdateAccountSettingsOptions) + updateAccountSettingsOptionsModel.AccountID = core.StringPtr("testString") + updateAccountSettingsOptionsModel.PublicAccessEnabled = core.BoolPtr(true) + updateAccountSettingsOptionsModel.TransactionID = core.StringPtr("testString") + updateAccountSettingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamAccessGroupsService.UpdateAccountSettings(updateAccountSettingsOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) }) Describe(`Model constructor tests`, func() { Context(`Using a service client instance`, func() { @@ -4243,8 +4508,8 @@ var _ = Describe(`IamAccessGroupsV2`, func() { It(`Invoke NewAddGroupMembersRequestMembersItem successfully`, func() { iamID := "testString" typeVar := "testString" - model, err := iamAccessGroupsService.NewAddGroupMembersRequestMembersItem(iamID, typeVar) - Expect(model).ToNot(BeNil()) + _model, err := iamAccessGroupsService.NewAddGroupMembersRequestMembersItem(iamID, typeVar) + Expect(_model).ToNot(BeNil()) Expect(err).To(BeNil()) }) It(`Invoke NewAddMemberToMultipleAccessGroupsOptions successfully`, func() { @@ -4535,8 +4800,8 @@ var _ = Describe(`IamAccessGroupsV2`, func() { claim := "testString" operator := "EQUALS" value := "testString" - model, err := iamAccessGroupsService.NewRuleConditions(claim, operator, value) - Expect(model).ToNot(BeNil()) + _model, err := iamAccessGroupsService.NewRuleConditions(claim, operator, value) + Expect(_model).ToNot(BeNil()) Expect(err).To(BeNil()) }) It(`Invoke NewUpdateAccessGroupOptions successfully`, func() { @@ -4588,11 +4853,11 @@ var _ = Describe(`IamAccessGroupsV2`, func() { Expect(mockReader).ToNot(BeNil()) }) It(`Invoke CreateMockDate() successfully`, func() { - mockDate := CreateMockDate() + mockDate := CreateMockDate("2019-01-01") Expect(mockDate).ToNot(BeNil()) }) It(`Invoke CreateMockDateTime() successfully`, func() { - mockDateTime := CreateMockDateTime() + mockDateTime := CreateMockDateTime("2019-01-01T12:00:00.000Z") Expect(mockDateTime).ToNot(BeNil()) }) }) @@ -4617,13 +4882,19 @@ func CreateMockReader(mockData string) io.ReadCloser { return ioutil.NopCloser(bytes.NewReader([]byte(mockData))) } -func CreateMockDate() *strfmt.Date { - d := strfmt.Date(time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC)) +func CreateMockDate(mockData string) *strfmt.Date { + d, err := core.ParseDate(mockData) + if err != nil { + return nil + } return &d } -func CreateMockDateTime() *strfmt.DateTime { - d := strfmt.DateTime(time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC)) +func CreateMockDateTime(mockData string) *strfmt.DateTime { + d, err := core.ParseDateTime(mockData) + if err != nil { + return nil + } return &d }