From 770827da59cfd1b888a6aa1dba11d3d83a1f89d7 Mon Sep 17 00:00:00 2001 From: Rajesh <78408189+Rajesh-Pirati@users.noreply.github.com> Date: Wed, 20 Oct 2021 19:24:52 +0530 Subject: [PATCH] feat(IAM Policy Management): support of new query params for v2/roles (#156) Support of new query parameters for v2/roles --- .../iam_policy_management_v1.go | 720 +++++++++------ .../iam_policy_management_v1_suite_test.go | 3 +- .../iam_policy_management_v1_test.go | 857 ++++++++++++------ 3 files changed, 1027 insertions(+), 553 deletions(-) diff --git a/iampolicymanagementv1/iam_policy_management_v1.go b/iampolicymanagementv1/iam_policy_management_v1.go index 9a61804f..b480fbb1 100644 --- a/iampolicymanagementv1/iam_policy_management_v1.go +++ b/iampolicymanagementv1/iam_policy_management_v1.go @@ -15,7 +15,7 @@ */ /* - * IBM OpenAPI SDK Code Generator Version: 3.29.1-b338fb38-20210313-010605 + * IBM OpenAPI SDK Code Generator Version: 3.39.0-748eb4ca-20210917-165907 */ // Package iampolicymanagementv1 : Operations and models for the IamPolicyManagementV1 service @@ -25,17 +25,18 @@ import ( "context" "encoding/json" "fmt" - "github.com/IBM/go-sdk-core/v5/core" - common "github.com/IBM/platform-services-go-sdk/common" - "github.com/go-openapi/strfmt" "net/http" "reflect" "time" + + "github.com/IBM/go-sdk-core/v5/core" + common "github.com/IBM/platform-services-go-sdk/common" + "github.com/go-openapi/strfmt" ) // IamPolicyManagementV1 : IAM Policy Management API // -// Version: 1.0.1 +// API Version: 1.0.1 type IamPolicyManagementV1 struct { Service *core.BaseService } @@ -240,11 +241,13 @@ func (iamPolicyManagement *IamPolicyManagementV1) ListPoliciesWithContext(ctx co if err != nil { return } - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalPolicyList) - if err != nil { - return + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalPolicyList) + if err != nil { + return + } + response.Result = result } - response.Result = result return } @@ -276,6 +279,18 @@ func (iamPolicyManagement *IamPolicyManagementV1) ListPoliciesWithContext(ctx co // greater to the target resource in order to grant the role. The resource attributes must be a subset of a service's or // the platform's supported attributes. Both the policy subject and the policy resource must include the // **`serviceName`** and **`accountId`** attributes. +// +// ### Attribute Operators +// +// Currently, only the `stringEquals` and the `stringMatch` operators are available. Resource attributes may support one +// or both operators. For more information, see [how to assign access by using wildcards +// policies](https://cloud.ibm.com/docs/account?topic=account-wildcard). +// +// ### Attribute Validations +// +// Policy attribute values must be between 1 and 1,000 characters in length. If location related attributes like +// geography, country, metro, region, satellite, and locationvalues are supported by the service, they are validated +// against Global Catalog locations. func (iamPolicyManagement *IamPolicyManagementV1) CreatePolicy(createPolicyOptions *CreatePolicyOptions) (result *Policy, response *core.DetailedResponse, err error) { return iamPolicyManagement.CreatePolicyWithContext(context.Background(), createPolicyOptions) } @@ -344,11 +359,13 @@ func (iamPolicyManagement *IamPolicyManagementV1) CreatePolicyWithContext(ctx co if err != nil { return } - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalPolicy) - if err != nil { - return + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalPolicy) + if err != nil { + return + } + response.Result = result } - response.Result = result return } @@ -377,6 +394,18 @@ func (iamPolicyManagement *IamPolicyManagementV1) CreatePolicyWithContext(ctx co // greater to the target resource in order to grant the role. The resource attributes must be a subset of a service's or // the platform's supported attributes. Both the policy subject and the policy resource must include the // **`serviceName`** and **`accountId`** attributes. +// +// ### Attribute Operators +// +// Currently, only the `stringEquals` and the `stringMatch` operators are available. Resource attributes might support +// one or both operators. For more information, see [how to assign access by using wildcards +// policies](https://cloud.ibm.com/docs/account?topic=account-wildcard). +// +// ### Attribute Validations +// +// Policy attribute values must be between 1 and 1,000 characters in length. If location related attributes like +// geography, country, metro, region, satellite, and locationvalues are supported by the service, they are validated +// against Global Catalog locations. func (iamPolicyManagement *IamPolicyManagementV1) UpdatePolicy(updatePolicyOptions *UpdatePolicyOptions) (result *Policy, response *core.DetailedResponse, err error) { return iamPolicyManagement.UpdatePolicyWithContext(context.Background(), updatePolicyOptions) } @@ -449,11 +478,13 @@ func (iamPolicyManagement *IamPolicyManagementV1) UpdatePolicyWithContext(ctx co if err != nil { return } - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalPolicy) - if err != nil { - return + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalPolicy) + if err != nil { + return + } + response.Result = result } - response.Result = result return } @@ -507,11 +538,13 @@ func (iamPolicyManagement *IamPolicyManagementV1) GetPolicyWithContext(ctx conte if err != nil { return } - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalPolicy) - if err != nil { - return + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalPolicy) + if err != nil { + return + } + response.Result = result } - response.Result = result return } @@ -628,20 +661,22 @@ func (iamPolicyManagement *IamPolicyManagementV1) PatchPolicyWithContext(ctx con if err != nil { return } - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalPolicy) - if err != nil { - return + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalPolicy) + if err != nil { + return + } + response.Result = result } - response.Result = result return } // ListRoles : Get roles by filters // Get roles based on the filters. While managing roles, you may want to retrieve roles and filter by usages. This can -// be done through query parameters. Currently, we only support the following attributes: account_id, and service_name. -// Only roles that match the filter and that the caller has read access to are returned. If the caller does not have -// read access to any roles an empty array is returned. +// be done through query parameters. Currently, we only support the following attributes: account_id, service_name, +// source_service_name and policy_type. Only roles that match the filter and that the caller has read access to are +// returned. If the caller does not have read access to any roles an empty array is returned. func (iamPolicyManagement *IamPolicyManagementV1) ListRoles(listRolesOptions *ListRolesOptions) (result *RoleList, response *core.DetailedResponse, err error) { return iamPolicyManagement.ListRolesWithContext(context.Background(), listRolesOptions) } @@ -680,6 +715,12 @@ func (iamPolicyManagement *IamPolicyManagementV1) ListRolesWithContext(ctx conte if listRolesOptions.ServiceName != nil { builder.AddQuery("service_name", fmt.Sprint(*listRolesOptions.ServiceName)) } + if listRolesOptions.SourceServiceName != nil { + builder.AddQuery("source_service_name", fmt.Sprint(*listRolesOptions.SourceServiceName)) + } + if listRolesOptions.PolicyType != nil { + builder.AddQuery("policy_type", fmt.Sprint(*listRolesOptions.PolicyType)) + } request, err := builder.Build() if err != nil { @@ -691,11 +732,13 @@ func (iamPolicyManagement *IamPolicyManagementV1) ListRolesWithContext(ctx conte if err != nil { return } - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalRoleList) - if err != nil { - return + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalRoleList) + if err != nil { + return + } + response.Result = result } - response.Result = result return } @@ -776,11 +819,13 @@ func (iamPolicyManagement *IamPolicyManagementV1) CreateRoleWithContext(ctx cont if err != nil { return } - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalCustomRole) - if err != nil { - return + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalCustomRole) + if err != nil { + return + } + response.Result = result } - response.Result = result return } @@ -854,11 +899,13 @@ func (iamPolicyManagement *IamPolicyManagementV1) UpdateRoleWithContext(ctx cont if err != nil { return } - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalCustomRole) - if err != nil { - return + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalCustomRole) + if err != nil { + return + } + response.Result = result } - response.Result = result return } @@ -912,11 +959,13 @@ func (iamPolicyManagement *IamPolicyManagementV1) GetRoleWithContext(ctx context if err != nil { return } - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalCustomRole) - if err != nil { - return + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalCustomRole) + if err != nil { + return + } + response.Result = result } - response.Result = result return } @@ -972,22 +1021,33 @@ func (iamPolicyManagement *IamPolicyManagementV1) DeleteRoleWithContext(ctx cont // CreatePolicyOptions : The CreatePolicy options. type CreatePolicyOptions struct { // The policy type; either 'access' or 'authorization'. - Type *string `validate:"required"` + Type *string `json:"type" validate:"required"` // The subjects associated with a policy. - Subjects []PolicySubject `validate:"required"` + Subjects []PolicySubject `json:"subjects" validate:"required"` // A set of role cloud resource names (CRNs) granted by the policy. - Roles []PolicyRole `validate:"required"` + Roles []PolicyRole `json:"roles" validate:"required"` // The resources associated with a policy. - Resources []PolicyResource `validate:"required"` + Resources []PolicyResource `json:"resources" validate:"required"` // Customer-defined description. - Description *string + Description *string `json:"description,omitempty"` - // Translation language code. - AcceptLanguage *string + // Language code for translations + // * `default` - English + // * `de` - German (Standard) + // * `en` - English + // * `es` - Spanish (Spain) + // * `fr` - French (Standard) + // * `it` - Italian (Standard) + // * `ja` - Japanese + // * `ko` - Korean + // * `pt-br` - Portuguese (Brazil) + // * `zh-cn` - Chinese (Simplified, PRC) + // * `zh-tw` - (Chinese, Taiwan). + AcceptLanguage *string `json:"Accept-Language,omitempty"` // Allows users to set headers on API requests Headers map[string]string @@ -1004,39 +1064,39 @@ func (*IamPolicyManagementV1) NewCreatePolicyOptions(typeVar string, subjects [] } // SetType : Allow user to set Type -func (options *CreatePolicyOptions) SetType(typeVar string) *CreatePolicyOptions { - options.Type = core.StringPtr(typeVar) - return options +func (_options *CreatePolicyOptions) SetType(typeVar string) *CreatePolicyOptions { + _options.Type = core.StringPtr(typeVar) + return _options } // SetSubjects : Allow user to set Subjects -func (options *CreatePolicyOptions) SetSubjects(subjects []PolicySubject) *CreatePolicyOptions { - options.Subjects = subjects - return options +func (_options *CreatePolicyOptions) SetSubjects(subjects []PolicySubject) *CreatePolicyOptions { + _options.Subjects = subjects + return _options } // SetRoles : Allow user to set Roles -func (options *CreatePolicyOptions) SetRoles(roles []PolicyRole) *CreatePolicyOptions { - options.Roles = roles - return options +func (_options *CreatePolicyOptions) SetRoles(roles []PolicyRole) *CreatePolicyOptions { + _options.Roles = roles + return _options } // SetResources : Allow user to set Resources -func (options *CreatePolicyOptions) SetResources(resources []PolicyResource) *CreatePolicyOptions { - options.Resources = resources - return options +func (_options *CreatePolicyOptions) SetResources(resources []PolicyResource) *CreatePolicyOptions { + _options.Resources = resources + return _options } // SetDescription : Allow user to set Description -func (options *CreatePolicyOptions) SetDescription(description string) *CreatePolicyOptions { - options.Description = core.StringPtr(description) - return options +func (_options *CreatePolicyOptions) SetDescription(description string) *CreatePolicyOptions { + _options.Description = core.StringPtr(description) + return _options } // SetAcceptLanguage : Allow user to set AcceptLanguage -func (options *CreatePolicyOptions) SetAcceptLanguage(acceptLanguage string) *CreatePolicyOptions { - options.AcceptLanguage = core.StringPtr(acceptLanguage) - return options +func (_options *CreatePolicyOptions) SetAcceptLanguage(acceptLanguage string) *CreatePolicyOptions { + _options.AcceptLanguage = core.StringPtr(acceptLanguage) + return _options } // SetHeaders : Allow user to set Headers @@ -1048,25 +1108,37 @@ func (options *CreatePolicyOptions) SetHeaders(param map[string]string) *CreateP // CreateRoleOptions : The CreateRole options. type CreateRoleOptions struct { // The display name of the role that is shown in the console. - DisplayName *string `validate:"required"` + DisplayName *string `json:"display_name" validate:"required"` - // The actions of the role. - Actions []string `validate:"required"` + // The actions of the role. Please refer to [IAM roles and + // actions](https://cloud.ibm.com/docs/account?topic=account-iam-service-roles-actions). + Actions []string `json:"actions" validate:"required"` // The name of the role that is used in the CRN. Can only be alphanumeric and has to be capitalized. - Name *string `validate:"required"` + Name *string `json:"name" validate:"required"` // The account GUID. - AccountID *string `validate:"required"` + AccountID *string `json:"account_id" validate:"required"` // The service name. - ServiceName *string `validate:"required"` + ServiceName *string `json:"service_name" validate:"required"` // The description of the role. - Description *string + Description *string `json:"description,omitempty"` - // Translation language code. - AcceptLanguage *string + // Language code for translations + // * `default` - English + // * `de` - German (Standard) + // * `en` - English + // * `es` - Spanish (Spain) + // * `fr` - French (Standard) + // * `it` - Italian (Standard) + // * `ja` - Japanese + // * `ko` - Korean + // * `pt-br` - Portuguese (Brazil) + // * `zh-cn` - Chinese (Simplified, PRC) + // * `zh-tw` - (Chinese, Taiwan). + AcceptLanguage *string `json:"Accept-Language,omitempty"` // Allows users to set headers on API requests Headers map[string]string @@ -1084,45 +1156,45 @@ func (*IamPolicyManagementV1) NewCreateRoleOptions(displayName string, actions [ } // SetDisplayName : Allow user to set DisplayName -func (options *CreateRoleOptions) SetDisplayName(displayName string) *CreateRoleOptions { - options.DisplayName = core.StringPtr(displayName) - return options +func (_options *CreateRoleOptions) SetDisplayName(displayName string) *CreateRoleOptions { + _options.DisplayName = core.StringPtr(displayName) + return _options } // SetActions : Allow user to set Actions -func (options *CreateRoleOptions) SetActions(actions []string) *CreateRoleOptions { - options.Actions = actions - return options +func (_options *CreateRoleOptions) SetActions(actions []string) *CreateRoleOptions { + _options.Actions = actions + return _options } // SetName : Allow user to set Name -func (options *CreateRoleOptions) SetName(name string) *CreateRoleOptions { - options.Name = core.StringPtr(name) - return options +func (_options *CreateRoleOptions) SetName(name string) *CreateRoleOptions { + _options.Name = core.StringPtr(name) + return _options } // SetAccountID : Allow user to set AccountID -func (options *CreateRoleOptions) SetAccountID(accountID string) *CreateRoleOptions { - options.AccountID = core.StringPtr(accountID) - return options +func (_options *CreateRoleOptions) SetAccountID(accountID string) *CreateRoleOptions { + _options.AccountID = core.StringPtr(accountID) + return _options } // SetServiceName : Allow user to set ServiceName -func (options *CreateRoleOptions) SetServiceName(serviceName string) *CreateRoleOptions { - options.ServiceName = core.StringPtr(serviceName) - return options +func (_options *CreateRoleOptions) SetServiceName(serviceName string) *CreateRoleOptions { + _options.ServiceName = core.StringPtr(serviceName) + return _options } // SetDescription : Allow user to set Description -func (options *CreateRoleOptions) SetDescription(description string) *CreateRoleOptions { - options.Description = core.StringPtr(description) - return options +func (_options *CreateRoleOptions) SetDescription(description string) *CreateRoleOptions { + _options.Description = core.StringPtr(description) + return _options } // SetAcceptLanguage : Allow user to set AcceptLanguage -func (options *CreateRoleOptions) SetAcceptLanguage(acceptLanguage string) *CreateRoleOptions { - options.AcceptLanguage = core.StringPtr(acceptLanguage) - return options +func (_options *CreateRoleOptions) SetAcceptLanguage(acceptLanguage string) *CreateRoleOptions { + _options.AcceptLanguage = core.StringPtr(acceptLanguage) + return _options } // SetHeaders : Allow user to set Headers @@ -1134,7 +1206,7 @@ func (options *CreateRoleOptions) SetHeaders(param map[string]string) *CreateRol // DeletePolicyOptions : The DeletePolicy options. type DeletePolicyOptions struct { // The policy ID. - PolicyID *string `validate:"required,ne="` + PolicyID *string `json:"policy_id" validate:"required,ne="` // Allows users to set headers on API requests Headers map[string]string @@ -1148,9 +1220,9 @@ func (*IamPolicyManagementV1) NewDeletePolicyOptions(policyID string) *DeletePol } // SetPolicyID : Allow user to set PolicyID -func (options *DeletePolicyOptions) SetPolicyID(policyID string) *DeletePolicyOptions { - options.PolicyID = core.StringPtr(policyID) - return options +func (_options *DeletePolicyOptions) SetPolicyID(policyID string) *DeletePolicyOptions { + _options.PolicyID = core.StringPtr(policyID) + return _options } // SetHeaders : Allow user to set Headers @@ -1162,7 +1234,7 @@ func (options *DeletePolicyOptions) SetHeaders(param map[string]string) *DeleteP // DeleteRoleOptions : The DeleteRole options. type DeleteRoleOptions struct { // The role ID. - RoleID *string `validate:"required,ne="` + RoleID *string `json:"role_id" validate:"required,ne="` // Allows users to set headers on API requests Headers map[string]string @@ -1176,9 +1248,9 @@ func (*IamPolicyManagementV1) NewDeleteRoleOptions(roleID string) *DeleteRoleOpt } // SetRoleID : Allow user to set RoleID -func (options *DeleteRoleOptions) SetRoleID(roleID string) *DeleteRoleOptions { - options.RoleID = core.StringPtr(roleID) - return options +func (_options *DeleteRoleOptions) SetRoleID(roleID string) *DeleteRoleOptions { + _options.RoleID = core.StringPtr(roleID) + return _options } // SetHeaders : Allow user to set Headers @@ -1190,7 +1262,7 @@ func (options *DeleteRoleOptions) SetHeaders(param map[string]string) *DeleteRol // GetPolicyOptions : The GetPolicy options. type GetPolicyOptions struct { // The policy ID. - PolicyID *string `validate:"required,ne="` + PolicyID *string `json:"policy_id" validate:"required,ne="` // Allows users to set headers on API requests Headers map[string]string @@ -1204,9 +1276,9 @@ func (*IamPolicyManagementV1) NewGetPolicyOptions(policyID string) *GetPolicyOpt } // SetPolicyID : Allow user to set PolicyID -func (options *GetPolicyOptions) SetPolicyID(policyID string) *GetPolicyOptions { - options.PolicyID = core.StringPtr(policyID) - return options +func (_options *GetPolicyOptions) SetPolicyID(policyID string) *GetPolicyOptions { + _options.PolicyID = core.StringPtr(policyID) + return _options } // SetHeaders : Allow user to set Headers @@ -1218,7 +1290,7 @@ func (options *GetPolicyOptions) SetHeaders(param map[string]string) *GetPolicyO // GetRoleOptions : The GetRole options. type GetRoleOptions struct { // The role ID. - RoleID *string `validate:"required,ne="` + RoleID *string `json:"role_id" validate:"required,ne="` // Allows users to set headers on API requests Headers map[string]string @@ -1232,9 +1304,9 @@ func (*IamPolicyManagementV1) NewGetRoleOptions(roleID string) *GetRoleOptions { } // SetRoleID : Allow user to set RoleID -func (options *GetRoleOptions) SetRoleID(roleID string) *GetRoleOptions { - options.RoleID = core.StringPtr(roleID) - return options +func (_options *GetRoleOptions) SetRoleID(roleID string) *GetRoleOptions { + _options.RoleID = core.StringPtr(roleID) + return _options } // SetHeaders : Allow user to set Headers @@ -1246,41 +1318,105 @@ func (options *GetRoleOptions) SetHeaders(param map[string]string) *GetRoleOptio // ListPoliciesOptions : The ListPolicies options. type ListPoliciesOptions struct { // The account GUID in which the policies belong to. - AccountID *string `validate:"required"` + AccountID *string `json:"account_id" validate:"required"` + + // Language code for translations + // * `default` - English + // * `de` - German (Standard) + // * `en` - English + // * `es` - Spanish (Spain) + // * `fr` - French (Standard) + // * `it` - Italian (Standard) + // * `ja` - Japanese + // * `ko` - Korean + // * `pt-br` - Portuguese (Brazil) + // * `zh-cn` - Chinese (Simplified, PRC) + // * `zh-tw` - (Chinese, Taiwan). + AcceptLanguage *string `json:"Accept-Language,omitempty"` + + // Optional IAM ID used to identify the subject. + IamID *string `json:"iam_id,omitempty"` + + // Optional access group id. + AccessGroupID *string `json:"access_group_id,omitempty"` + + // Optional type of policy. + Type *string `json:"type,omitempty"` - // Translation language code. - AcceptLanguage *string + // Optional type of service. + ServiceType *string `json:"service_type,omitempty"` - // The IAM ID used to identify the subject. - IamID *string + // Optional name of the access management tag in the policy. + TagName *string `json:"tag_name,omitempty"` - // The access group id. - AccessGroupID *string + // Optional value of the access management tag in the policy. + TagValue *string `json:"tag_value,omitempty"` - // The type of policy (access or authorization). - Type *string + // Optional top level policy field to sort results. Ascending sort is default. Descending sort available by prepending + // '-' to field. Example '-last_modified_at'. + Sort *string `json:"sort,omitempty"` - // The type of service. - ServiceType *string + // Include additional data per policy returned + // * `include_last_permit` - returns details of when the policy last granted a permit decision and the number of times + // it has done so + // * `display` - returns the list of all actions included in each of the policy roles. + Format *string `json:"format,omitempty"` - // The name of the access management tag in the policy. - TagName *string + // The state of the policy. + // * `active` - returns active policies + // * `deleted` - returns non-active policies. + State *string `json:"state,omitempty"` - // The value of the access management tag in the policy. - TagValue *string + // Allows users to set headers on API requests + Headers map[string]string +} + +// Constants associated with the ListPoliciesOptions.Type property. +// Optional type of policy. +const ( + ListPoliciesOptionsTypeAccessConst = "access" + ListPoliciesOptionsTypeAuthorizationConst = "authorization" +) - // Sort the results by any of the top level policy fields (id, created_at, created_by_id, last_modified_at, etc). - Sort *string +// Constants associated with the ListPoliciesOptions.ServiceType property. +// Optional type of service. +const ( + ListPoliciesOptionsServiceTypePlatformServiceConst = "platform_service" + ListPoliciesOptionsServiceTypeServiceConst = "service" +) - // Include additional data per policy returned [include_last_permit, display]. - Format *string +// Constants associated with the ListPoliciesOptions.Sort property. +// Optional top level policy field to sort results. Ascending sort is default. Descending sort available by prepending +// '-' to field. Example '-last_modified_at'. +const ( + ListPoliciesOptionsSortCreatedAtConst = "created_at" + ListPoliciesOptionsSortCreatedByIDConst = "created_by_id" + ListPoliciesOptionsSortHrefConst = "href" + ListPoliciesOptionsSortIDConst = "id" + ListPoliciesOptionsSortLastModifiedAtConst = "last_modified_at" + ListPoliciesOptionsSortLastModifiedByIDConst = "last_modified_by_id" + ListPoliciesOptionsSortStateConst = "state" + ListPoliciesOptionsSortTypeConst = "type" +) - // The state of the policy, 'active' or 'deleted'. - State *string +// Constants associated with the ListPoliciesOptions.Format property. +// Include additional data per policy returned +// * `include_last_permit` - returns details of when the policy last granted a permit decision and the number of times +// it has done so +// * `display` - returns the list of all actions included in each of the policy roles. +const ( + ListPoliciesOptionsFormatDisplayConst = "display" + ListPoliciesOptionsFormatIncludeLastPermitConst = "include_last_permit" +) - // Allows users to set headers on API requests - Headers map[string]string -} +// Constants associated with the ListPoliciesOptions.State property. +// The state of the policy. +// * `active` - returns active policies +// * `deleted` - returns non-active policies. +const ( + ListPoliciesOptionsStateActiveConst = "active" + ListPoliciesOptionsStateDeletedConst = "deleted" +) // NewListPoliciesOptions : Instantiate ListPoliciesOptions func (*IamPolicyManagementV1) NewListPoliciesOptions(accountID string) *ListPoliciesOptions { @@ -1290,69 +1426,69 @@ func (*IamPolicyManagementV1) NewListPoliciesOptions(accountID string) *ListPoli } // SetAccountID : Allow user to set AccountID -func (options *ListPoliciesOptions) SetAccountID(accountID string) *ListPoliciesOptions { - options.AccountID = core.StringPtr(accountID) - return options +func (_options *ListPoliciesOptions) SetAccountID(accountID string) *ListPoliciesOptions { + _options.AccountID = core.StringPtr(accountID) + return _options } // SetAcceptLanguage : Allow user to set AcceptLanguage -func (options *ListPoliciesOptions) SetAcceptLanguage(acceptLanguage string) *ListPoliciesOptions { - options.AcceptLanguage = core.StringPtr(acceptLanguage) - return options +func (_options *ListPoliciesOptions) SetAcceptLanguage(acceptLanguage string) *ListPoliciesOptions { + _options.AcceptLanguage = core.StringPtr(acceptLanguage) + return _options } // SetIamID : Allow user to set IamID -func (options *ListPoliciesOptions) SetIamID(iamID string) *ListPoliciesOptions { - options.IamID = core.StringPtr(iamID) - return options +func (_options *ListPoliciesOptions) SetIamID(iamID string) *ListPoliciesOptions { + _options.IamID = core.StringPtr(iamID) + return _options } // SetAccessGroupID : Allow user to set AccessGroupID -func (options *ListPoliciesOptions) SetAccessGroupID(accessGroupID string) *ListPoliciesOptions { - options.AccessGroupID = core.StringPtr(accessGroupID) - return options +func (_options *ListPoliciesOptions) SetAccessGroupID(accessGroupID string) *ListPoliciesOptions { + _options.AccessGroupID = core.StringPtr(accessGroupID) + return _options } // SetType : Allow user to set Type -func (options *ListPoliciesOptions) SetType(typeVar string) *ListPoliciesOptions { - options.Type = core.StringPtr(typeVar) - return options +func (_options *ListPoliciesOptions) SetType(typeVar string) *ListPoliciesOptions { + _options.Type = core.StringPtr(typeVar) + return _options } // SetServiceType : Allow user to set ServiceType -func (options *ListPoliciesOptions) SetServiceType(serviceType string) *ListPoliciesOptions { - options.ServiceType = core.StringPtr(serviceType) - return options +func (_options *ListPoliciesOptions) SetServiceType(serviceType string) *ListPoliciesOptions { + _options.ServiceType = core.StringPtr(serviceType) + return _options } // SetTagName : Allow user to set TagName -func (options *ListPoliciesOptions) SetTagName(tagName string) *ListPoliciesOptions { - options.TagName = core.StringPtr(tagName) - return options +func (_options *ListPoliciesOptions) SetTagName(tagName string) *ListPoliciesOptions { + _options.TagName = core.StringPtr(tagName) + return _options } // SetTagValue : Allow user to set TagValue -func (options *ListPoliciesOptions) SetTagValue(tagValue string) *ListPoliciesOptions { - options.TagValue = core.StringPtr(tagValue) - return options +func (_options *ListPoliciesOptions) SetTagValue(tagValue string) *ListPoliciesOptions { + _options.TagValue = core.StringPtr(tagValue) + return _options } // SetSort : Allow user to set Sort -func (options *ListPoliciesOptions) SetSort(sort string) *ListPoliciesOptions { - options.Sort = core.StringPtr(sort) - return options +func (_options *ListPoliciesOptions) SetSort(sort string) *ListPoliciesOptions { + _options.Sort = core.StringPtr(sort) + return _options } // SetFormat : Allow user to set Format -func (options *ListPoliciesOptions) SetFormat(format string) *ListPoliciesOptions { - options.Format = core.StringPtr(format) - return options +func (_options *ListPoliciesOptions) SetFormat(format string) *ListPoliciesOptions { + _options.Format = core.StringPtr(format) + return _options } // SetState : Allow user to set State -func (options *ListPoliciesOptions) SetState(state string) *ListPoliciesOptions { - options.State = core.StringPtr(state) - return options +func (_options *ListPoliciesOptions) SetState(state string) *ListPoliciesOptions { + _options.State = core.StringPtr(state) + return _options } // SetHeaders : Allow user to set Headers @@ -1363,14 +1499,31 @@ func (options *ListPoliciesOptions) SetHeaders(param map[string]string) *ListPol // ListRolesOptions : The ListRoles options. type ListRolesOptions struct { - // Translation language code. - AcceptLanguage *string + // Language code for translations + // * `default` - English + // * `de` - German (Standard) + // * `en` - English + // * `es` - Spanish (Spain) + // * `fr` - French (Standard) + // * `it` - Italian (Standard) + // * `ja` - Japanese + // * `ko` - Korean + // * `pt-br` - Portuguese (Brazil) + // * `zh-cn` - Chinese (Simplified, PRC) + // * `zh-tw` - (Chinese, Taiwan). + AcceptLanguage *string `json:"Accept-Language,omitempty"` + + // Optional account GUID in which the roles belong to. + AccountID *string `json:"account_id,omitempty"` + + // Optional name of IAM enabled service. + ServiceName *string `json:"service_name,omitempty"` - // The account GUID in which the roles belong to. - AccountID *string + // Optional name of source IAM enabled service. + SourceServiceName *string `json:"source_service_name,omitempty"` - // The name of service. - ServiceName *string + // Optional Policy Type. + PolicyType *string `json:"policy_type,omitempty"` // Allows users to set headers on API requests Headers map[string]string @@ -1382,21 +1535,33 @@ func (*IamPolicyManagementV1) NewListRolesOptions() *ListRolesOptions { } // SetAcceptLanguage : Allow user to set AcceptLanguage -func (options *ListRolesOptions) SetAcceptLanguage(acceptLanguage string) *ListRolesOptions { - options.AcceptLanguage = core.StringPtr(acceptLanguage) - return options +func (_options *ListRolesOptions) SetAcceptLanguage(acceptLanguage string) *ListRolesOptions { + _options.AcceptLanguage = core.StringPtr(acceptLanguage) + return _options } // SetAccountID : Allow user to set AccountID -func (options *ListRolesOptions) SetAccountID(accountID string) *ListRolesOptions { - options.AccountID = core.StringPtr(accountID) - return options +func (_options *ListRolesOptions) SetAccountID(accountID string) *ListRolesOptions { + _options.AccountID = core.StringPtr(accountID) + return _options } // SetServiceName : Allow user to set ServiceName -func (options *ListRolesOptions) SetServiceName(serviceName string) *ListRolesOptions { - options.ServiceName = core.StringPtr(serviceName) - return options +func (_options *ListRolesOptions) SetServiceName(serviceName string) *ListRolesOptions { + _options.ServiceName = core.StringPtr(serviceName) + return _options +} + +// SetSourceServiceName : Allow user to set SourceServiceName +func (_options *ListRolesOptions) SetSourceServiceName(sourceServiceName string) *ListRolesOptions { + _options.SourceServiceName = core.StringPtr(sourceServiceName) + return _options +} + +// SetPolicyType : Allow user to set PolicyType +func (_options *ListRolesOptions) SetPolicyType(policyType string) *ListRolesOptions { + _options.PolicyType = core.StringPtr(policyType) + return _options } // SetHeaders : Allow user to set Headers @@ -1408,19 +1573,26 @@ func (options *ListRolesOptions) SetHeaders(param map[string]string) *ListRolesO // PatchPolicyOptions : The PatchPolicy options. type PatchPolicyOptions struct { // The policy ID. - PolicyID *string `validate:"required,ne="` + PolicyID *string `json:"policy_id" validate:"required,ne="` // The revision number for updating a policy and must match the ETag value of the existing policy. The Etag can be // retrieved using the GET /v1/policies/{policy_id} API and looking at the ETag response header. - IfMatch *string `validate:"required"` + IfMatch *string `json:"If-Match" validate:"required"` - // The policy state; either 'active' or 'deleted'. - State *string + // The policy state. + State *string `json:"state,omitempty"` // Allows users to set headers on API requests Headers map[string]string } +// Constants associated with the PatchPolicyOptions.State property. +// The policy state. +const ( + PatchPolicyOptionsStateActiveConst = "active" + PatchPolicyOptionsStateDeletedConst = "deleted" +) + // NewPatchPolicyOptions : Instantiate PatchPolicyOptions func (*IamPolicyManagementV1) NewPatchPolicyOptions(policyID string, ifMatch string) *PatchPolicyOptions { return &PatchPolicyOptions{ @@ -1430,21 +1602,21 @@ func (*IamPolicyManagementV1) NewPatchPolicyOptions(policyID string, ifMatch str } // SetPolicyID : Allow user to set PolicyID -func (options *PatchPolicyOptions) SetPolicyID(policyID string) *PatchPolicyOptions { - options.PolicyID = core.StringPtr(policyID) - return options +func (_options *PatchPolicyOptions) SetPolicyID(policyID string) *PatchPolicyOptions { + _options.PolicyID = core.StringPtr(policyID) + return _options } // SetIfMatch : Allow user to set IfMatch -func (options *PatchPolicyOptions) SetIfMatch(ifMatch string) *PatchPolicyOptions { - options.IfMatch = core.StringPtr(ifMatch) - return options +func (_options *PatchPolicyOptions) SetIfMatch(ifMatch string) *PatchPolicyOptions { + _options.IfMatch = core.StringPtr(ifMatch) + return _options } // SetState : Allow user to set State -func (options *PatchPolicyOptions) SetState(state string) *PatchPolicyOptions { - options.State = core.StringPtr(state) - return options +func (_options *PatchPolicyOptions) SetState(state string) *PatchPolicyOptions { + _options.State = core.StringPtr(state) + return _options } // SetHeaders : Allow user to set Headers @@ -1456,26 +1628,26 @@ func (options *PatchPolicyOptions) SetHeaders(param map[string]string) *PatchPol // UpdatePolicyOptions : The UpdatePolicy options. type UpdatePolicyOptions struct { // The policy ID. - PolicyID *string `validate:"required,ne="` + PolicyID *string `json:"policy_id" validate:"required,ne="` // The revision number for updating a policy and must match the ETag value of the existing policy. The Etag can be // retrieved using the GET /v1/policies/{policy_id} API and looking at the ETag response header. - IfMatch *string `validate:"required"` + IfMatch *string `json:"If-Match" validate:"required"` // The policy type; either 'access' or 'authorization'. - Type *string `validate:"required"` + Type *string `json:"type" validate:"required"` // The subjects associated with a policy. - Subjects []PolicySubject `validate:"required"` + Subjects []PolicySubject `json:"subjects" validate:"required"` // A set of role cloud resource names (CRNs) granted by the policy. - Roles []PolicyRole `validate:"required"` + Roles []PolicyRole `json:"roles" validate:"required"` // The resources associated with a policy. - Resources []PolicyResource `validate:"required"` + Resources []PolicyResource `json:"resources" validate:"required"` // Customer-defined description. - Description *string + Description *string `json:"description,omitempty"` // Allows users to set headers on API requests Headers map[string]string @@ -1494,45 +1666,45 @@ func (*IamPolicyManagementV1) NewUpdatePolicyOptions(policyID string, ifMatch st } // SetPolicyID : Allow user to set PolicyID -func (options *UpdatePolicyOptions) SetPolicyID(policyID string) *UpdatePolicyOptions { - options.PolicyID = core.StringPtr(policyID) - return options +func (_options *UpdatePolicyOptions) SetPolicyID(policyID string) *UpdatePolicyOptions { + _options.PolicyID = core.StringPtr(policyID) + return _options } // SetIfMatch : Allow user to set IfMatch -func (options *UpdatePolicyOptions) SetIfMatch(ifMatch string) *UpdatePolicyOptions { - options.IfMatch = core.StringPtr(ifMatch) - return options +func (_options *UpdatePolicyOptions) SetIfMatch(ifMatch string) *UpdatePolicyOptions { + _options.IfMatch = core.StringPtr(ifMatch) + return _options } // SetType : Allow user to set Type -func (options *UpdatePolicyOptions) SetType(typeVar string) *UpdatePolicyOptions { - options.Type = core.StringPtr(typeVar) - return options +func (_options *UpdatePolicyOptions) SetType(typeVar string) *UpdatePolicyOptions { + _options.Type = core.StringPtr(typeVar) + return _options } // SetSubjects : Allow user to set Subjects -func (options *UpdatePolicyOptions) SetSubjects(subjects []PolicySubject) *UpdatePolicyOptions { - options.Subjects = subjects - return options +func (_options *UpdatePolicyOptions) SetSubjects(subjects []PolicySubject) *UpdatePolicyOptions { + _options.Subjects = subjects + return _options } // SetRoles : Allow user to set Roles -func (options *UpdatePolicyOptions) SetRoles(roles []PolicyRole) *UpdatePolicyOptions { - options.Roles = roles - return options +func (_options *UpdatePolicyOptions) SetRoles(roles []PolicyRole) *UpdatePolicyOptions { + _options.Roles = roles + return _options } // SetResources : Allow user to set Resources -func (options *UpdatePolicyOptions) SetResources(resources []PolicyResource) *UpdatePolicyOptions { - options.Resources = resources - return options +func (_options *UpdatePolicyOptions) SetResources(resources []PolicyResource) *UpdatePolicyOptions { + _options.Resources = resources + return _options } // SetDescription : Allow user to set Description -func (options *UpdatePolicyOptions) SetDescription(description string) *UpdatePolicyOptions { - options.Description = core.StringPtr(description) - return options +func (_options *UpdatePolicyOptions) SetDescription(description string) *UpdatePolicyOptions { + _options.Description = core.StringPtr(description) + return _options } // SetHeaders : Allow user to set Headers @@ -1544,20 +1716,21 @@ func (options *UpdatePolicyOptions) SetHeaders(param map[string]string) *UpdateP // UpdateRoleOptions : The UpdateRole options. type UpdateRoleOptions struct { // The role ID. - RoleID *string `validate:"required,ne="` + RoleID *string `json:"role_id" validate:"required,ne="` // The revision number for updating a role and must match the ETag value of the existing role. The Etag can be // retrieved using the GET /v2/roles/{role_id} API and looking at the ETag response header. - IfMatch *string `validate:"required"` + IfMatch *string `json:"If-Match" validate:"required"` // The display name of the role that is shown in the console. - DisplayName *string + DisplayName *string `json:"display_name,omitempty"` // The description of the role. - Description *string + Description *string `json:"description,omitempty"` - // The actions of the role. - Actions []string + // The actions of the role. Please refer to [IAM roles and + // actions](https://cloud.ibm.com/docs/account?topic=account-iam-service-roles-actions). + Actions []string `json:"actions,omitempty"` // Allows users to set headers on API requests Headers map[string]string @@ -1572,33 +1745,33 @@ func (*IamPolicyManagementV1) NewUpdateRoleOptions(roleID string, ifMatch string } // SetRoleID : Allow user to set RoleID -func (options *UpdateRoleOptions) SetRoleID(roleID string) *UpdateRoleOptions { - options.RoleID = core.StringPtr(roleID) - return options +func (_options *UpdateRoleOptions) SetRoleID(roleID string) *UpdateRoleOptions { + _options.RoleID = core.StringPtr(roleID) + return _options } // SetIfMatch : Allow user to set IfMatch -func (options *UpdateRoleOptions) SetIfMatch(ifMatch string) *UpdateRoleOptions { - options.IfMatch = core.StringPtr(ifMatch) - return options +func (_options *UpdateRoleOptions) SetIfMatch(ifMatch string) *UpdateRoleOptions { + _options.IfMatch = core.StringPtr(ifMatch) + return _options } // SetDisplayName : Allow user to set DisplayName -func (options *UpdateRoleOptions) SetDisplayName(displayName string) *UpdateRoleOptions { - options.DisplayName = core.StringPtr(displayName) - return options +func (_options *UpdateRoleOptions) SetDisplayName(displayName string) *UpdateRoleOptions { + _options.DisplayName = core.StringPtr(displayName) + return _options } // SetDescription : Allow user to set Description -func (options *UpdateRoleOptions) SetDescription(description string) *UpdateRoleOptions { - options.Description = core.StringPtr(description) - return options +func (_options *UpdateRoleOptions) SetDescription(description string) *UpdateRoleOptions { + _options.Description = core.StringPtr(description) + return _options } // SetActions : Allow user to set Actions -func (options *UpdateRoleOptions) SetActions(actions []string) *UpdateRoleOptions { - options.Actions = actions - return options +func (_options *UpdateRoleOptions) SetActions(actions []string) *UpdateRoleOptions { + _options.Actions = actions + return _options } // SetHeaders : Allow user to set Headers @@ -1609,7 +1782,7 @@ func (options *UpdateRoleOptions) SetHeaders(param map[string]string) *UpdateRol // CustomRole : An additional set of properties associated with a role. type CustomRole struct { - // The role ID. + // The role ID. Composed of hexadecimal characters. ID *string `json:"id,omitempty"` // The display name of the role that is shown in the console. @@ -1618,10 +1791,12 @@ type CustomRole struct { // The description of the role. Description *string `json:"description,omitempty"` - // The actions of the role. + // The actions of the role. Please refer to [IAM roles and + // actions](https://cloud.ibm.com/docs/account?topic=account-iam-service-roles-actions). Actions []string `json:"actions,omitempty"` - // The role CRN. + // The role Cloud Resource Name (CRN). Example CRN: + // 'crn:v1:ibmcloud:public:iam-access-management::a/exampleAccountId::customRole:ExampleRoleName'. CRN *string `json:"crn,omitempty"` // The name of the role that is used in the CRN. Can only be alphanumeric and has to be capitalized. @@ -1743,10 +1918,17 @@ type Policy struct { // The iam ID of the entity that last modified the policy. LastModifiedByID *string `json:"last_modified_by_id,omitempty"` - // The policy state; either 'active' or 'deleted'. + // The policy state. State *string `json:"state,omitempty"` } +// Constants associated with the Policy.State property. +// The policy state. +const ( + PolicyStateActiveConst = "active" + PolicyStateDeletedConst = "deleted" +) + // UnmarshalPolicy unmarshals an instance of Policy from the specified map of raw messages. func UnmarshalPolicy(m map[string]json.RawMessage, result interface{}) (err error) { obj := new(Policy) @@ -1845,7 +2027,7 @@ func UnmarshalPolicyResource(m map[string]json.RawMessage, result interface{}) ( // PolicyRole : A role associated with a policy. type PolicyRole struct { - // The role cloud resource name granted by the policy. + // The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'. RoleID *string `json:"role_id" validate:"required"` // The display name of the role. @@ -1856,11 +2038,11 @@ type PolicyRole struct { } // NewPolicyRole : Instantiate PolicyRole (Generic Model Constructor) -func (*IamPolicyManagementV1) NewPolicyRole(roleID string) (model *PolicyRole, err error) { - model = &PolicyRole{ +func (*IamPolicyManagementV1) NewPolicyRole(roleID string) (_model *PolicyRole, err error) { + _model = &PolicyRole{ RoleID: core.StringPtr(roleID), } - err = core.ValidateStruct(model, "required parameters") + err = core.ValidateStruct(_model, "required parameters") return } @@ -1913,12 +2095,12 @@ type ResourceAttribute struct { } // NewResourceAttribute : Instantiate ResourceAttribute (Generic Model Constructor) -func (*IamPolicyManagementV1) NewResourceAttribute(name string, value string) (model *ResourceAttribute, err error) { - model = &ResourceAttribute{ +func (*IamPolicyManagementV1) NewResourceAttribute(name string, value string) (_model *ResourceAttribute, err error) { + _model = &ResourceAttribute{ Name: core.StringPtr(name), Value: core.StringPtr(value), } - err = core.ValidateStruct(model, "required parameters") + err = core.ValidateStruct(_model, "required parameters") return } @@ -1954,12 +2136,12 @@ type ResourceTag struct { } // NewResourceTag : Instantiate ResourceTag (Generic Model Constructor) -func (*IamPolicyManagementV1) NewResourceTag(name string, value string) (model *ResourceTag, err error) { - model = &ResourceTag{ +func (*IamPolicyManagementV1) NewResourceTag(name string, value string) (_model *ResourceTag, err error) { + _model = &ResourceTag{ Name: core.StringPtr(name), Value: core.StringPtr(value), } - err = core.ValidateStruct(model, "required parameters") + err = core.ValidateStruct(_model, "required parameters") return } @@ -1990,10 +2172,12 @@ type Role struct { // The description of the role. Description *string `json:"description,omitempty"` - // The actions of the role. + // The actions of the role. Please refer to [IAM roles and + // actions](https://cloud.ibm.com/docs/account?topic=account-iam-service-roles-actions). Actions []string `json:"actions,omitempty"` - // The role CRN. + // The role Cloud Resource Name (CRN). Example CRN: + // 'crn:v1:ibmcloud:public:iam-access-management::a/exampleAccountId::customRole:ExampleRoleName'. CRN *string `json:"crn,omitempty"` } @@ -2061,12 +2245,12 @@ type SubjectAttribute struct { } // NewSubjectAttribute : Instantiate SubjectAttribute (Generic Model Constructor) -func (*IamPolicyManagementV1) NewSubjectAttribute(name string, value string) (model *SubjectAttribute, err error) { - model = &SubjectAttribute{ +func (*IamPolicyManagementV1) NewSubjectAttribute(name string, value string) (_model *SubjectAttribute, err error) { + _model = &SubjectAttribute{ Name: core.StringPtr(name), Value: core.StringPtr(value), } - err = core.ValidateStruct(model, "required parameters") + err = core.ValidateStruct(_model, "required parameters") return } diff --git a/iampolicymanagementv1/iam_policy_management_v1_suite_test.go b/iampolicymanagementv1/iam_policy_management_v1_suite_test.go index f130b5f0..6b615196 100644 --- a/iampolicymanagementv1/iam_policy_management_v1_suite_test.go +++ b/iampolicymanagementv1/iam_policy_management_v1_suite_test.go @@ -17,9 +17,10 @@ package iampolicymanagementv1_test import ( + "testing" + . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "testing" ) func TestIamPolicyManagementV1(t *testing.T) { diff --git a/iampolicymanagementv1/iam_policy_management_v1_test.go b/iampolicymanagementv1/iam_policy_management_v1_test.go index 7d6c302a..58b2db4b 100644 --- a/iampolicymanagementv1/iam_policy_management_v1_test.go +++ b/iampolicymanagementv1/iam_policy_management_v1_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/iampolicymanagementv1" - "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/iampolicymanagementv1" + "github.com/go-openapi/strfmt" + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" ) var _ = Describe(`IamPolicyManagementV1`, func() { @@ -165,7 +166,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { }) Describe(`ListPolicies(listPoliciesOptions *ListPoliciesOptions) - Operation response error`, func() { listPoliciesPath := "/v1/policies" - 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() @@ -174,17 +175,17 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(req.URL.EscapedPath()).To(Equal(listPoliciesPath)) Expect(req.Method).To(Equal("GET")) Expect(req.Header["Accept-Language"]).ToNot(BeNil()) - Expect(req.Header["Accept-Language"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) + Expect(req.Header["Accept-Language"][0]).To(Equal(fmt.Sprintf("%v", "default"))) Expect(req.URL.Query()["account_id"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["iam_id"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["access_group_id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["type"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["service_type"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["type"]).To(Equal([]string{"access"})) + Expect(req.URL.Query()["service_type"]).To(Equal([]string{"service"})) Expect(req.URL.Query()["tag_name"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["tag_value"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["sort"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["format"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["state"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["sort"]).To(Equal([]string{"id"})) + Expect(req.URL.Query()["format"]).To(Equal([]string{"include_last_permit"})) + Expect(req.URL.Query()["state"]).To(Equal([]string{"active"})) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) fmt.Fprintf(res, `} this is not valid json {`) @@ -201,16 +202,16 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Construct an instance of the ListPoliciesOptions model listPoliciesOptionsModel := new(iampolicymanagementv1.ListPoliciesOptions) listPoliciesOptionsModel.AccountID = core.StringPtr("testString") - listPoliciesOptionsModel.AcceptLanguage = core.StringPtr("testString") + listPoliciesOptionsModel.AcceptLanguage = core.StringPtr("default") listPoliciesOptionsModel.IamID = core.StringPtr("testString") listPoliciesOptionsModel.AccessGroupID = core.StringPtr("testString") - listPoliciesOptionsModel.Type = core.StringPtr("testString") - listPoliciesOptionsModel.ServiceType = core.StringPtr("testString") + listPoliciesOptionsModel.Type = core.StringPtr("access") + listPoliciesOptionsModel.ServiceType = core.StringPtr("service") listPoliciesOptionsModel.TagName = core.StringPtr("testString") listPoliciesOptionsModel.TagValue = core.StringPtr("testString") - listPoliciesOptionsModel.Sort = core.StringPtr("testString") - listPoliciesOptionsModel.Format = core.StringPtr("testString") - listPoliciesOptionsModel.State = core.StringPtr("testString") + listPoliciesOptionsModel.Sort = core.StringPtr("id") + listPoliciesOptionsModel.Format = core.StringPtr("include_last_permit") + listPoliciesOptionsModel.State = core.StringPtr("active") listPoliciesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response result, response, operationErr := iamPolicyManagementService.ListPolicies(listPoliciesOptionsModel) @@ -230,7 +231,6 @@ var _ = Describe(`IamPolicyManagementV1`, func() { }) }) }) - Describe(`ListPolicies(listPoliciesOptions *ListPoliciesOptions)`, func() { listPoliciesPath := "/v1/policies" Context(`Using mock server endpoint with timeout`, func() { @@ -243,24 +243,24 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(req.Method).To(Equal("GET")) Expect(req.Header["Accept-Language"]).ToNot(BeNil()) - Expect(req.Header["Accept-Language"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) + Expect(req.Header["Accept-Language"][0]).To(Equal(fmt.Sprintf("%v", "default"))) Expect(req.URL.Query()["account_id"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["iam_id"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["access_group_id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["type"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["service_type"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["type"]).To(Equal([]string{"access"})) + Expect(req.URL.Query()["service_type"]).To(Equal([]string{"service"})) Expect(req.URL.Query()["tag_name"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["tag_value"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["sort"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["format"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["state"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["sort"]).To(Equal([]string{"id"})) + Expect(req.URL.Query()["format"]).To(Equal([]string{"include_last_permit"})) + Expect(req.URL.Query()["state"]).To(Equal([]string{"active"})) // Sleep a short time to support a timeout test time.Sleep(100 * time.Millisecond) // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"policies": [{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "State"}]}`) + fmt.Fprintf(res, "%s", `{"policies": [{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active"}]}`) })) }) It(`Invoke ListPolicies successfully with retries`, func() { @@ -275,16 +275,16 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Construct an instance of the ListPoliciesOptions model listPoliciesOptionsModel := new(iampolicymanagementv1.ListPoliciesOptions) listPoliciesOptionsModel.AccountID = core.StringPtr("testString") - listPoliciesOptionsModel.AcceptLanguage = core.StringPtr("testString") + listPoliciesOptionsModel.AcceptLanguage = core.StringPtr("default") listPoliciesOptionsModel.IamID = core.StringPtr("testString") listPoliciesOptionsModel.AccessGroupID = core.StringPtr("testString") - listPoliciesOptionsModel.Type = core.StringPtr("testString") - listPoliciesOptionsModel.ServiceType = core.StringPtr("testString") + listPoliciesOptionsModel.Type = core.StringPtr("access") + listPoliciesOptionsModel.ServiceType = core.StringPtr("service") listPoliciesOptionsModel.TagName = core.StringPtr("testString") listPoliciesOptionsModel.TagValue = core.StringPtr("testString") - listPoliciesOptionsModel.Sort = core.StringPtr("testString") - listPoliciesOptionsModel.Format = core.StringPtr("testString") - listPoliciesOptionsModel.State = core.StringPtr("testString") + listPoliciesOptionsModel.Sort = core.StringPtr("id") + listPoliciesOptionsModel.Format = core.StringPtr("include_last_permit") + listPoliciesOptionsModel.State = core.StringPtr("active") listPoliciesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error @@ -322,21 +322,21 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(req.Method).To(Equal("GET")) Expect(req.Header["Accept-Language"]).ToNot(BeNil()) - Expect(req.Header["Accept-Language"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) + Expect(req.Header["Accept-Language"][0]).To(Equal(fmt.Sprintf("%v", "default"))) Expect(req.URL.Query()["account_id"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["iam_id"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["access_group_id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["type"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["service_type"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["type"]).To(Equal([]string{"access"})) + Expect(req.URL.Query()["service_type"]).To(Equal([]string{"service"})) Expect(req.URL.Query()["tag_name"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["tag_value"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["sort"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["format"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["state"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["sort"]).To(Equal([]string{"id"})) + Expect(req.URL.Query()["format"]).To(Equal([]string{"include_last_permit"})) + Expect(req.URL.Query()["state"]).To(Equal([]string{"active"})) // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"policies": [{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "State"}]}`) + fmt.Fprintf(res, "%s", `{"policies": [{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active"}]}`) })) }) It(`Invoke ListPolicies successfully`, func() { @@ -356,16 +356,16 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Construct an instance of the ListPoliciesOptions model listPoliciesOptionsModel := new(iampolicymanagementv1.ListPoliciesOptions) listPoliciesOptionsModel.AccountID = core.StringPtr("testString") - listPoliciesOptionsModel.AcceptLanguage = core.StringPtr("testString") + listPoliciesOptionsModel.AcceptLanguage = core.StringPtr("default") listPoliciesOptionsModel.IamID = core.StringPtr("testString") listPoliciesOptionsModel.AccessGroupID = core.StringPtr("testString") - listPoliciesOptionsModel.Type = core.StringPtr("testString") - listPoliciesOptionsModel.ServiceType = core.StringPtr("testString") + listPoliciesOptionsModel.Type = core.StringPtr("access") + listPoliciesOptionsModel.ServiceType = core.StringPtr("service") listPoliciesOptionsModel.TagName = core.StringPtr("testString") listPoliciesOptionsModel.TagValue = core.StringPtr("testString") - listPoliciesOptionsModel.Sort = core.StringPtr("testString") - listPoliciesOptionsModel.Format = core.StringPtr("testString") - listPoliciesOptionsModel.State = core.StringPtr("testString") + listPoliciesOptionsModel.Sort = core.StringPtr("id") + listPoliciesOptionsModel.Format = core.StringPtr("include_last_permit") + listPoliciesOptionsModel.State = core.StringPtr("active") listPoliciesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) @@ -386,16 +386,16 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Construct an instance of the ListPoliciesOptions model listPoliciesOptionsModel := new(iampolicymanagementv1.ListPoliciesOptions) listPoliciesOptionsModel.AccountID = core.StringPtr("testString") - listPoliciesOptionsModel.AcceptLanguage = core.StringPtr("testString") + listPoliciesOptionsModel.AcceptLanguage = core.StringPtr("default") listPoliciesOptionsModel.IamID = core.StringPtr("testString") listPoliciesOptionsModel.AccessGroupID = core.StringPtr("testString") - listPoliciesOptionsModel.Type = core.StringPtr("testString") - listPoliciesOptionsModel.ServiceType = core.StringPtr("testString") + listPoliciesOptionsModel.Type = core.StringPtr("access") + listPoliciesOptionsModel.ServiceType = core.StringPtr("service") listPoliciesOptionsModel.TagName = core.StringPtr("testString") listPoliciesOptionsModel.TagValue = core.StringPtr("testString") - listPoliciesOptionsModel.Sort = core.StringPtr("testString") - listPoliciesOptionsModel.Format = core.StringPtr("testString") - listPoliciesOptionsModel.State = core.StringPtr("testString") + listPoliciesOptionsModel.Sort = core.StringPtr("id") + listPoliciesOptionsModel.Format = core.StringPtr("include_last_permit") + listPoliciesOptionsModel.State = core.StringPtr("active") listPoliciesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := iamPolicyManagementService.SetServiceURL("") @@ -417,10 +417,54 @@ var _ = Describe(`IamPolicyManagementV1`, 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 ListPolicies successfully`, func() { + iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamPolicyManagementService).ToNot(BeNil()) + + // Construct an instance of the ListPoliciesOptions model + listPoliciesOptionsModel := new(iampolicymanagementv1.ListPoliciesOptions) + listPoliciesOptionsModel.AccountID = core.StringPtr("testString") + listPoliciesOptionsModel.AcceptLanguage = core.StringPtr("default") + listPoliciesOptionsModel.IamID = core.StringPtr("testString") + listPoliciesOptionsModel.AccessGroupID = core.StringPtr("testString") + listPoliciesOptionsModel.Type = core.StringPtr("access") + listPoliciesOptionsModel.ServiceType = core.StringPtr("service") + listPoliciesOptionsModel.TagName = core.StringPtr("testString") + listPoliciesOptionsModel.TagValue = core.StringPtr("testString") + listPoliciesOptionsModel.Sort = core.StringPtr("id") + listPoliciesOptionsModel.Format = core.StringPtr("include_last_permit") + listPoliciesOptionsModel.State = core.StringPtr("active") + listPoliciesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamPolicyManagementService.ListPolicies(listPoliciesOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) }) Describe(`CreatePolicy(createPolicyOptions *CreatePolicyOptions) - Operation response error`, func() { createPolicyPath := "/v1/policies" - 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() @@ -429,7 +473,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(req.URL.EscapedPath()).To(Equal(createPolicyPath)) Expect(req.Method).To(Equal("POST")) Expect(req.Header["Accept-Language"]).ToNot(BeNil()) - Expect(req.Header["Accept-Language"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) + Expect(req.Header["Accept-Language"][0]).To(Equal(fmt.Sprintf("%v", "default"))) res.Header().Set("Content-type", "application/json") res.WriteHeader(201) fmt.Fprintf(res, `} this is not valid json {`) @@ -480,7 +524,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { createPolicyOptionsModel.Roles = []iampolicymanagementv1.PolicyRole{*policyRoleModel} createPolicyOptionsModel.Resources = []iampolicymanagementv1.PolicyResource{*policyResourceModel} createPolicyOptionsModel.Description = core.StringPtr("testString") - createPolicyOptionsModel.AcceptLanguage = core.StringPtr("testString") + createPolicyOptionsModel.AcceptLanguage = core.StringPtr("default") createPolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response result, response, operationErr := iamPolicyManagementService.CreatePolicy(createPolicyOptionsModel) @@ -500,7 +544,6 @@ var _ = Describe(`IamPolicyManagementV1`, func() { }) }) }) - Describe(`CreatePolicy(createPolicyOptions *CreatePolicyOptions)`, func() { createPolicyPath := "/v1/policies" Context(`Using mock server endpoint with timeout`, func() { @@ -529,14 +572,14 @@ var _ = Describe(`IamPolicyManagementV1`, func() { fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) Expect(req.Header["Accept-Language"]).ToNot(BeNil()) - Expect(req.Header["Accept-Language"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) + Expect(req.Header["Accept-Language"][0]).To(Equal(fmt.Sprintf("%v", "default"))) // Sleep a short time to support a timeout test time.Sleep(100 * time.Millisecond) // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "State"}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active"}`) })) }) It(`Invoke CreatePolicy successfully with retries`, func() { @@ -585,7 +628,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { createPolicyOptionsModel.Roles = []iampolicymanagementv1.PolicyRole{*policyRoleModel} createPolicyOptionsModel.Resources = []iampolicymanagementv1.PolicyResource{*policyResourceModel} createPolicyOptionsModel.Description = core.StringPtr("testString") - createPolicyOptionsModel.AcceptLanguage = core.StringPtr("testString") + createPolicyOptionsModel.AcceptLanguage = core.StringPtr("default") createPolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error @@ -639,11 +682,11 @@ var _ = Describe(`IamPolicyManagementV1`, func() { fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) Expect(req.Header["Accept-Language"]).ToNot(BeNil()) - Expect(req.Header["Accept-Language"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) + Expect(req.Header["Accept-Language"][0]).To(Equal(fmt.Sprintf("%v", "default"))) // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "State"}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active"}`) })) }) It(`Invoke CreatePolicy successfully`, func() { @@ -697,7 +740,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { createPolicyOptionsModel.Roles = []iampolicymanagementv1.PolicyRole{*policyRoleModel} createPolicyOptionsModel.Resources = []iampolicymanagementv1.PolicyResource{*policyResourceModel} createPolicyOptionsModel.Description = core.StringPtr("testString") - createPolicyOptionsModel.AcceptLanguage = core.StringPtr("testString") + createPolicyOptionsModel.AcceptLanguage = core.StringPtr("default") createPolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) @@ -752,7 +795,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { createPolicyOptionsModel.Roles = []iampolicymanagementv1.PolicyRole{*policyRoleModel} createPolicyOptionsModel.Resources = []iampolicymanagementv1.PolicyResource{*policyResourceModel} createPolicyOptionsModel.Description = core.StringPtr("testString") - createPolicyOptionsModel.AcceptLanguage = core.StringPtr("testString") + createPolicyOptionsModel.AcceptLanguage = core.StringPtr("default") createPolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := iamPolicyManagementService.SetServiceURL("") @@ -774,10 +817,79 @@ var _ = Describe(`IamPolicyManagementV1`, 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 CreatePolicy successfully`, func() { + iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamPolicyManagementService).ToNot(BeNil()) + + // Construct an instance of the SubjectAttribute model + subjectAttributeModel := new(iampolicymanagementv1.SubjectAttribute) + subjectAttributeModel.Name = core.StringPtr("testString") + subjectAttributeModel.Value = core.StringPtr("testString") + + // Construct an instance of the PolicySubject model + policySubjectModel := new(iampolicymanagementv1.PolicySubject) + policySubjectModel.Attributes = []iampolicymanagementv1.SubjectAttribute{*subjectAttributeModel} + + // Construct an instance of the PolicyRole model + policyRoleModel := new(iampolicymanagementv1.PolicyRole) + policyRoleModel.RoleID = core.StringPtr("testString") + + // Construct an instance of the ResourceAttribute model + resourceAttributeModel := new(iampolicymanagementv1.ResourceAttribute) + resourceAttributeModel.Name = core.StringPtr("testString") + resourceAttributeModel.Value = core.StringPtr("testString") + resourceAttributeModel.Operator = core.StringPtr("testString") + + // Construct an instance of the ResourceTag model + resourceTagModel := new(iampolicymanagementv1.ResourceTag) + resourceTagModel.Name = core.StringPtr("testString") + resourceTagModel.Value = core.StringPtr("testString") + resourceTagModel.Operator = core.StringPtr("testString") + + // Construct an instance of the PolicyResource model + policyResourceModel := new(iampolicymanagementv1.PolicyResource) + policyResourceModel.Attributes = []iampolicymanagementv1.ResourceAttribute{*resourceAttributeModel} + policyResourceModel.Tags = []iampolicymanagementv1.ResourceTag{*resourceTagModel} + + // Construct an instance of the CreatePolicyOptions model + createPolicyOptionsModel := new(iampolicymanagementv1.CreatePolicyOptions) + createPolicyOptionsModel.Type = core.StringPtr("testString") + createPolicyOptionsModel.Subjects = []iampolicymanagementv1.PolicySubject{*policySubjectModel} + createPolicyOptionsModel.Roles = []iampolicymanagementv1.PolicyRole{*policyRoleModel} + createPolicyOptionsModel.Resources = []iampolicymanagementv1.PolicyResource{*policyResourceModel} + createPolicyOptionsModel.Description = core.StringPtr("testString") + createPolicyOptionsModel.AcceptLanguage = core.StringPtr("default") + createPolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamPolicyManagementService.CreatePolicy(createPolicyOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) }) Describe(`UpdatePolicy(updatePolicyOptions *UpdatePolicyOptions) - Operation response error`, func() { updatePolicyPath := "/v1/policies/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() @@ -858,7 +970,6 @@ var _ = Describe(`IamPolicyManagementV1`, func() { }) }) }) - Describe(`UpdatePolicy(updatePolicyOptions *UpdatePolicyOptions)`, func() { updatePolicyPath := "/v1/policies/testString" Context(`Using mock server endpoint with timeout`, func() { @@ -894,7 +1005,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "State"}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active"}`) })) }) It(`Invoke UpdatePolicy successfully with retries`, func() { @@ -1002,7 +1113,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "State"}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active"}`) })) }) It(`Invoke UpdatePolicy successfully`, func() { @@ -1135,10 +1246,80 @@ var _ = Describe(`IamPolicyManagementV1`, 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 UpdatePolicy successfully`, func() { + iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamPolicyManagementService).ToNot(BeNil()) + + // Construct an instance of the SubjectAttribute model + subjectAttributeModel := new(iampolicymanagementv1.SubjectAttribute) + subjectAttributeModel.Name = core.StringPtr("testString") + subjectAttributeModel.Value = core.StringPtr("testString") + + // Construct an instance of the PolicySubject model + policySubjectModel := new(iampolicymanagementv1.PolicySubject) + policySubjectModel.Attributes = []iampolicymanagementv1.SubjectAttribute{*subjectAttributeModel} + + // Construct an instance of the PolicyRole model + policyRoleModel := new(iampolicymanagementv1.PolicyRole) + policyRoleModel.RoleID = core.StringPtr("testString") + + // Construct an instance of the ResourceAttribute model + resourceAttributeModel := new(iampolicymanagementv1.ResourceAttribute) + resourceAttributeModel.Name = core.StringPtr("testString") + resourceAttributeModel.Value = core.StringPtr("testString") + resourceAttributeModel.Operator = core.StringPtr("testString") + + // Construct an instance of the ResourceTag model + resourceTagModel := new(iampolicymanagementv1.ResourceTag) + resourceTagModel.Name = core.StringPtr("testString") + resourceTagModel.Value = core.StringPtr("testString") + resourceTagModel.Operator = core.StringPtr("testString") + + // Construct an instance of the PolicyResource model + policyResourceModel := new(iampolicymanagementv1.PolicyResource) + policyResourceModel.Attributes = []iampolicymanagementv1.ResourceAttribute{*resourceAttributeModel} + policyResourceModel.Tags = []iampolicymanagementv1.ResourceTag{*resourceTagModel} + + // Construct an instance of the UpdatePolicyOptions model + updatePolicyOptionsModel := new(iampolicymanagementv1.UpdatePolicyOptions) + updatePolicyOptionsModel.PolicyID = core.StringPtr("testString") + updatePolicyOptionsModel.IfMatch = core.StringPtr("testString") + updatePolicyOptionsModel.Type = core.StringPtr("testString") + updatePolicyOptionsModel.Subjects = []iampolicymanagementv1.PolicySubject{*policySubjectModel} + updatePolicyOptionsModel.Roles = []iampolicymanagementv1.PolicyRole{*policyRoleModel} + updatePolicyOptionsModel.Resources = []iampolicymanagementv1.PolicyResource{*policyResourceModel} + updatePolicyOptionsModel.Description = core.StringPtr("testString") + updatePolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamPolicyManagementService.UpdatePolicy(updatePolicyOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) }) Describe(`GetPolicy(getPolicyOptions *GetPolicyOptions) - Operation response error`, func() { getPolicyPath := "/v1/policies/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() @@ -1181,7 +1362,6 @@ var _ = Describe(`IamPolicyManagementV1`, func() { }) }) }) - Describe(`GetPolicy(getPolicyOptions *GetPolicyOptions)`, func() { getPolicyPath := "/v1/policies/testString" Context(`Using mock server endpoint with timeout`, func() { @@ -1199,7 +1379,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "State"}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active"}`) })) }) It(`Invoke GetPolicy successfully with retries`, func() { @@ -1253,7 +1433,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "State"}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active"}`) })) }) It(`Invoke GetPolicy successfully`, func() { @@ -1314,8 +1494,41 @@ var _ = Describe(`IamPolicyManagementV1`, 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 GetPolicy successfully`, func() { + iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamPolicyManagementService).ToNot(BeNil()) + // Construct an instance of the GetPolicyOptions model + getPolicyOptionsModel := new(iampolicymanagementv1.GetPolicyOptions) + getPolicyOptionsModel.PolicyID = core.StringPtr("testString") + getPolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamPolicyManagementService.GetPolicy(getPolicyOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) Describe(`DeletePolicy(deletePolicyOptions *DeletePolicyOptions)`, func() { deletePolicyPath := "/v1/policies/testString" Context(`Using mock server endpoint`, func() { @@ -1386,7 +1599,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { }) Describe(`PatchPolicy(patchPolicyOptions *PatchPolicyOptions) - Operation response error`, func() { patchPolicyPath := "/v1/policies/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() @@ -1413,7 +1626,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { patchPolicyOptionsModel := new(iampolicymanagementv1.PatchPolicyOptions) patchPolicyOptionsModel.PolicyID = core.StringPtr("testString") patchPolicyOptionsModel.IfMatch = core.StringPtr("testString") - patchPolicyOptionsModel.State = core.StringPtr("testString") + patchPolicyOptionsModel.State = core.StringPtr("active") patchPolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response result, response, operationErr := iamPolicyManagementService.PatchPolicy(patchPolicyOptionsModel) @@ -1433,7 +1646,6 @@ var _ = Describe(`IamPolicyManagementV1`, func() { }) }) }) - Describe(`PatchPolicy(patchPolicyOptions *PatchPolicyOptions)`, func() { patchPolicyPath := "/v1/policies/testString" Context(`Using mock server endpoint with timeout`, func() { @@ -1469,7 +1681,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "State"}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active"}`) })) }) It(`Invoke PatchPolicy successfully with retries`, func() { @@ -1485,7 +1697,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { patchPolicyOptionsModel := new(iampolicymanagementv1.PatchPolicyOptions) patchPolicyOptionsModel.PolicyID = core.StringPtr("testString") patchPolicyOptionsModel.IfMatch = core.StringPtr("testString") - patchPolicyOptionsModel.State = core.StringPtr("testString") + patchPolicyOptionsModel.State = core.StringPtr("active") patchPolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error @@ -1543,7 +1755,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "State"}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active"}`) })) }) It(`Invoke PatchPolicy successfully`, func() { @@ -1564,7 +1776,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { patchPolicyOptionsModel := new(iampolicymanagementv1.PatchPolicyOptions) patchPolicyOptionsModel.PolicyID = core.StringPtr("testString") patchPolicyOptionsModel.IfMatch = core.StringPtr("testString") - patchPolicyOptionsModel.State = core.StringPtr("testString") + patchPolicyOptionsModel.State = core.StringPtr("active") patchPolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) @@ -1586,7 +1798,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { patchPolicyOptionsModel := new(iampolicymanagementv1.PatchPolicyOptions) patchPolicyOptionsModel.PolicyID = core.StringPtr("testString") patchPolicyOptionsModel.IfMatch = core.StringPtr("testString") - patchPolicyOptionsModel.State = core.StringPtr("testString") + patchPolicyOptionsModel.State = core.StringPtr("active") patchPolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := iamPolicyManagementService.SetServiceURL("") @@ -1608,138 +1820,46 @@ var _ = Describe(`IamPolicyManagementV1`, func() { testServer.Close() }) }) - }) - Describe(`Service constructor tests`, func() { - It(`Instantiate service client`, func() { - iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ - Authenticator: &core.NoAuthAuthenticator{}, - }) - Expect(iamPolicyManagementService).ToNot(BeNil()) - Expect(serviceErr).To(BeNil()) - }) - It(`Instantiate service client with error: Invalid URL`, func() { - iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ - URL: "{BAD_URL_STRING", - }) - Expect(iamPolicyManagementService).To(BeNil()) - Expect(serviceErr).ToNot(BeNil()) - }) - It(`Instantiate service client with error: Invalid Auth`, func() { - iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ - URL: "https://iampolicymanagementv1/api", - Authenticator: &core.BasicAuthenticator{ - Username: "", - Password: "", - }, - }) - Expect(iamPolicyManagementService).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_POLICY_MANAGEMENT_URL": "https://iampolicymanagementv1/api", - "IAM_POLICY_MANAGEMENT_AUTH_TYPE": "noauth", - } - - It(`Create service client using external config successfully`, func() { - SetTestEnvironment(testEnvironment) - iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1UsingExternalConfig(&iampolicymanagementv1.IamPolicyManagementV1Options{ - }) - Expect(iamPolicyManagementService).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 := iamPolicyManagementService.Clone() - Expect(clone).ToNot(BeNil()) - Expect(clone.Service != iamPolicyManagementService.Service).To(BeTrue()) - Expect(clone.GetServiceURL()).To(Equal(iamPolicyManagementService.GetServiceURL())) - Expect(clone.Service.Options.Authenticator).To(Equal(iamPolicyManagementService.Service.Options.Authenticator)) + // Set success status code with no respoonse body + res.WriteHeader(200) + })) }) - It(`Create service client using external config and set url from constructor successfully`, func() { - SetTestEnvironment(testEnvironment) - iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1UsingExternalConfig(&iampolicymanagementv1.IamPolicyManagementV1Options{ - URL: "https://testService/api", + It(`Invoke PatchPolicy successfully`, func() { + iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, }) - Expect(iamPolicyManagementService).ToNot(BeNil()) Expect(serviceErr).To(BeNil()) - Expect(iamPolicyManagementService.Service.GetServiceURL()).To(Equal("https://testService/api")) - ClearTestEnvironment(testEnvironment) - - clone := iamPolicyManagementService.Clone() - Expect(clone).ToNot(BeNil()) - Expect(clone.Service != iamPolicyManagementService.Service).To(BeTrue()) - Expect(clone.GetServiceURL()).To(Equal(iamPolicyManagementService.GetServiceURL())) - Expect(clone.Service.Options.Authenticator).To(Equal(iamPolicyManagementService.Service.Options.Authenticator)) - }) - It(`Create service client using external config and set url programatically successfully`, func() { - SetTestEnvironment(testEnvironment) - iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1UsingExternalConfig(&iampolicymanagementv1.IamPolicyManagementV1Options{ - }) - err := iamPolicyManagementService.SetServiceURL("https://testService/api") - Expect(err).To(BeNil()) Expect(iamPolicyManagementService).ToNot(BeNil()) - Expect(serviceErr).To(BeNil()) - Expect(iamPolicyManagementService.Service.GetServiceURL()).To(Equal("https://testService/api")) - ClearTestEnvironment(testEnvironment) - clone := iamPolicyManagementService.Clone() - Expect(clone).ToNot(BeNil()) - Expect(clone.Service != iamPolicyManagementService.Service).To(BeTrue()) - Expect(clone.GetServiceURL()).To(Equal(iamPolicyManagementService.GetServiceURL())) - Expect(clone.Service.Options.Authenticator).To(Equal(iamPolicyManagementService.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_POLICY_MANAGEMENT_URL": "https://iampolicymanagementv1/api", - "IAM_POLICY_MANAGEMENT_AUTH_TYPE": "someOtherAuth", - } - - SetTestEnvironment(testEnvironment) - iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1UsingExternalConfig(&iampolicymanagementv1.IamPolicyManagementV1Options{ - }) + // Construct an instance of the PatchPolicyOptions model + patchPolicyOptionsModel := new(iampolicymanagementv1.PatchPolicyOptions) + patchPolicyOptionsModel.PolicyID = core.StringPtr("testString") + patchPolicyOptionsModel.IfMatch = core.StringPtr("testString") + patchPolicyOptionsModel.State = core.StringPtr("active") + patchPolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - It(`Instantiate service client with error`, func() { - Expect(iamPolicyManagementService).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_POLICY_MANAGEMENT_AUTH_TYPE": "NOAuth", - } + // Invoke operation + result, response, operationErr := iamPolicyManagementService.PatchPolicy(patchPolicyOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) - SetTestEnvironment(testEnvironment) - iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1UsingExternalConfig(&iampolicymanagementv1.IamPolicyManagementV1Options{ - URL: "{BAD_URL_STRING", + // Verify a nil result + Expect(result).To(BeNil()) }) - - It(`Instantiate service client with error`, func() { - Expect(iamPolicyManagementService).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 = iampolicymanagementv1.GetServiceURLForRegion("INVALID_REGION") - Expect(url).To(BeEmpty()) - Expect(err).ToNot(BeNil()) - fmt.Fprintf(GinkgoWriter, "Expected error: %s\n", err.Error()) - }) - }) Describe(`ListRoles(listRolesOptions *ListRolesOptions) - Operation response error`, func() { listRolesPath := "/v2/roles" - 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() @@ -1748,9 +1868,11 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(req.URL.EscapedPath()).To(Equal(listRolesPath)) Expect(req.Method).To(Equal("GET")) Expect(req.Header["Accept-Language"]).ToNot(BeNil()) - Expect(req.Header["Accept-Language"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) + Expect(req.Header["Accept-Language"][0]).To(Equal(fmt.Sprintf("%v", "default"))) Expect(req.URL.Query()["account_id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["service_name"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["service_name"]).To(Equal([]string{"iam-groups"})) + Expect(req.URL.Query()["source_service_name"]).To(Equal([]string{"iam-groups"})) + Expect(req.URL.Query()["policy_type"]).To(Equal([]string{"authorization"})) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) fmt.Fprintf(res, `} this is not valid json {`) @@ -1766,9 +1888,11 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Construct an instance of the ListRolesOptions model listRolesOptionsModel := new(iampolicymanagementv1.ListRolesOptions) - listRolesOptionsModel.AcceptLanguage = core.StringPtr("testString") + listRolesOptionsModel.AcceptLanguage = core.StringPtr("default") listRolesOptionsModel.AccountID = core.StringPtr("testString") - listRolesOptionsModel.ServiceName = core.StringPtr("testString") + listRolesOptionsModel.ServiceName = core.StringPtr("iam-groups") + listRolesOptionsModel.SourceServiceName = core.StringPtr("iam-groups") + listRolesOptionsModel.PolicyType = core.StringPtr("authorization") listRolesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response result, response, operationErr := iamPolicyManagementService.ListRoles(listRolesOptionsModel) @@ -1788,7 +1912,6 @@ var _ = Describe(`IamPolicyManagementV1`, func() { }) }) }) - Describe(`ListRoles(listRolesOptions *ListRolesOptions)`, func() { listRolesPath := "/v2/roles" Context(`Using mock server endpoint with timeout`, func() { @@ -1801,16 +1924,18 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(req.Method).To(Equal("GET")) Expect(req.Header["Accept-Language"]).ToNot(BeNil()) - Expect(req.Header["Accept-Language"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) + Expect(req.Header["Accept-Language"][0]).To(Equal(fmt.Sprintf("%v", "default"))) Expect(req.URL.Query()["account_id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["service_name"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["service_name"]).To(Equal([]string{"iam-groups"})) + Expect(req.URL.Query()["source_service_name"]).To(Equal([]string{"iam-groups"})) + Expect(req.URL.Query()["policy_type"]).To(Equal([]string{"authorization"})) // Sleep a short time to support a timeout test time.Sleep(100 * time.Millisecond) // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"custom_roles": [{"id": "ID", "display_name": "DisplayName", "description": "Description", "actions": ["Actions"], "crn": "CRN", "name": "Name", "account_id": "AccountID", "service_name": "ServiceName", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "href": "Href"}], "service_roles": [{"display_name": "DisplayName", "description": "Description", "actions": ["Actions"], "crn": "CRN"}], "system_roles": [{"display_name": "DisplayName", "description": "Description", "actions": ["Actions"], "crn": "CRN"}]}`) + fmt.Fprintf(res, "%s", `{"custom_roles": [{"id": "ID", "display_name": "DisplayName", "description": "Description", "actions": ["Actions"], "crn": "CRN", "name": "Developer", "account_id": "AccountID", "service_name": "iam-groups", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "href": "Href"}], "service_roles": [{"display_name": "DisplayName", "description": "Description", "actions": ["Actions"], "crn": "CRN"}], "system_roles": [{"display_name": "DisplayName", "description": "Description", "actions": ["Actions"], "crn": "CRN"}]}`) })) }) It(`Invoke ListRoles successfully with retries`, func() { @@ -1824,9 +1949,11 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Construct an instance of the ListRolesOptions model listRolesOptionsModel := new(iampolicymanagementv1.ListRolesOptions) - listRolesOptionsModel.AcceptLanguage = core.StringPtr("testString") + listRolesOptionsModel.AcceptLanguage = core.StringPtr("default") listRolesOptionsModel.AccountID = core.StringPtr("testString") - listRolesOptionsModel.ServiceName = core.StringPtr("testString") + listRolesOptionsModel.ServiceName = core.StringPtr("iam-groups") + listRolesOptionsModel.SourceServiceName = core.StringPtr("iam-groups") + listRolesOptionsModel.PolicyType = core.StringPtr("authorization") listRolesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error @@ -1864,13 +1991,15 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(req.Method).To(Equal("GET")) Expect(req.Header["Accept-Language"]).ToNot(BeNil()) - Expect(req.Header["Accept-Language"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) + Expect(req.Header["Accept-Language"][0]).To(Equal(fmt.Sprintf("%v", "default"))) Expect(req.URL.Query()["account_id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["service_name"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["service_name"]).To(Equal([]string{"iam-groups"})) + Expect(req.URL.Query()["source_service_name"]).To(Equal([]string{"iam-groups"})) + Expect(req.URL.Query()["policy_type"]).To(Equal([]string{"authorization"})) // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"custom_roles": [{"id": "ID", "display_name": "DisplayName", "description": "Description", "actions": ["Actions"], "crn": "CRN", "name": "Name", "account_id": "AccountID", "service_name": "ServiceName", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "href": "Href"}], "service_roles": [{"display_name": "DisplayName", "description": "Description", "actions": ["Actions"], "crn": "CRN"}], "system_roles": [{"display_name": "DisplayName", "description": "Description", "actions": ["Actions"], "crn": "CRN"}]}`) + fmt.Fprintf(res, "%s", `{"custom_roles": [{"id": "ID", "display_name": "DisplayName", "description": "Description", "actions": ["Actions"], "crn": "CRN", "name": "Developer", "account_id": "AccountID", "service_name": "iam-groups", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "href": "Href"}], "service_roles": [{"display_name": "DisplayName", "description": "Description", "actions": ["Actions"], "crn": "CRN"}], "system_roles": [{"display_name": "DisplayName", "description": "Description", "actions": ["Actions"], "crn": "CRN"}]}`) })) }) It(`Invoke ListRoles successfully`, func() { @@ -1889,9 +2018,11 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Construct an instance of the ListRolesOptions model listRolesOptionsModel := new(iampolicymanagementv1.ListRolesOptions) - listRolesOptionsModel.AcceptLanguage = core.StringPtr("testString") + listRolesOptionsModel.AcceptLanguage = core.StringPtr("default") listRolesOptionsModel.AccountID = core.StringPtr("testString") - listRolesOptionsModel.ServiceName = core.StringPtr("testString") + listRolesOptionsModel.ServiceName = core.StringPtr("iam-groups") + listRolesOptionsModel.SourceServiceName = core.StringPtr("iam-groups") + listRolesOptionsModel.PolicyType = core.StringPtr("authorization") listRolesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) @@ -1911,9 +2042,11 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Construct an instance of the ListRolesOptions model listRolesOptionsModel := new(iampolicymanagementv1.ListRolesOptions) - listRolesOptionsModel.AcceptLanguage = core.StringPtr("testString") + listRolesOptionsModel.AcceptLanguage = core.StringPtr("default") listRolesOptionsModel.AccountID = core.StringPtr("testString") - listRolesOptionsModel.ServiceName = core.StringPtr("testString") + listRolesOptionsModel.ServiceName = core.StringPtr("iam-groups") + listRolesOptionsModel.SourceServiceName = core.StringPtr("iam-groups") + listRolesOptionsModel.PolicyType = core.StringPtr("authorization") listRolesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := iamPolicyManagementService.SetServiceURL("") @@ -1928,10 +2061,48 @@ var _ = Describe(`IamPolicyManagementV1`, 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 ListRoles successfully`, func() { + iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamPolicyManagementService).ToNot(BeNil()) + + // Construct an instance of the ListRolesOptions model + listRolesOptionsModel := new(iampolicymanagementv1.ListRolesOptions) + listRolesOptionsModel.AcceptLanguage = core.StringPtr("default") + listRolesOptionsModel.AccountID = core.StringPtr("testString") + listRolesOptionsModel.ServiceName = core.StringPtr("iam-groups") + listRolesOptionsModel.SourceServiceName = core.StringPtr("iam-groups") + listRolesOptionsModel.PolicyType = core.StringPtr("authorization") + listRolesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamPolicyManagementService.ListRoles(listRolesOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) }) Describe(`CreateRole(createRoleOptions *CreateRoleOptions) - Operation response error`, func() { createRolePath := "/v2/roles" - 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() @@ -1940,7 +2111,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(req.URL.EscapedPath()).To(Equal(createRolePath)) Expect(req.Method).To(Equal("POST")) Expect(req.Header["Accept-Language"]).ToNot(BeNil()) - Expect(req.Header["Accept-Language"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) + Expect(req.Header["Accept-Language"][0]).To(Equal(fmt.Sprintf("%v", "default"))) res.Header().Set("Content-type", "application/json") res.WriteHeader(201) fmt.Fprintf(res, `} this is not valid json {`) @@ -1958,11 +2129,11 @@ var _ = Describe(`IamPolicyManagementV1`, func() { createRoleOptionsModel := new(iampolicymanagementv1.CreateRoleOptions) createRoleOptionsModel.DisplayName = core.StringPtr("testString") createRoleOptionsModel.Actions = []string{"testString"} - createRoleOptionsModel.Name = core.StringPtr("testString") + createRoleOptionsModel.Name = core.StringPtr("Developer") createRoleOptionsModel.AccountID = core.StringPtr("testString") - createRoleOptionsModel.ServiceName = core.StringPtr("testString") + createRoleOptionsModel.ServiceName = core.StringPtr("iam-groups") createRoleOptionsModel.Description = core.StringPtr("testString") - createRoleOptionsModel.AcceptLanguage = core.StringPtr("testString") + createRoleOptionsModel.AcceptLanguage = core.StringPtr("default") createRoleOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response result, response, operationErr := iamPolicyManagementService.CreateRole(createRoleOptionsModel) @@ -1982,7 +2153,6 @@ var _ = Describe(`IamPolicyManagementV1`, func() { }) }) }) - Describe(`CreateRole(createRoleOptions *CreateRoleOptions)`, func() { createRolePath := "/v2/roles" Context(`Using mock server endpoint with timeout`, func() { @@ -2011,14 +2181,14 @@ var _ = Describe(`IamPolicyManagementV1`, func() { fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) Expect(req.Header["Accept-Language"]).ToNot(BeNil()) - Expect(req.Header["Accept-Language"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) + Expect(req.Header["Accept-Language"][0]).To(Equal(fmt.Sprintf("%v", "default"))) // Sleep a short time to support a timeout test time.Sleep(100 * time.Millisecond) // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"id": "ID", "display_name": "DisplayName", "description": "Description", "actions": ["Actions"], "crn": "CRN", "name": "Name", "account_id": "AccountID", "service_name": "ServiceName", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "href": "Href"}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "display_name": "DisplayName", "description": "Description", "actions": ["Actions"], "crn": "CRN", "name": "Developer", "account_id": "AccountID", "service_name": "iam-groups", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "href": "Href"}`) })) }) It(`Invoke CreateRole successfully with retries`, func() { @@ -2034,11 +2204,11 @@ var _ = Describe(`IamPolicyManagementV1`, func() { createRoleOptionsModel := new(iampolicymanagementv1.CreateRoleOptions) createRoleOptionsModel.DisplayName = core.StringPtr("testString") createRoleOptionsModel.Actions = []string{"testString"} - createRoleOptionsModel.Name = core.StringPtr("testString") + createRoleOptionsModel.Name = core.StringPtr("Developer") createRoleOptionsModel.AccountID = core.StringPtr("testString") - createRoleOptionsModel.ServiceName = core.StringPtr("testString") + createRoleOptionsModel.ServiceName = core.StringPtr("iam-groups") createRoleOptionsModel.Description = core.StringPtr("testString") - createRoleOptionsModel.AcceptLanguage = core.StringPtr("testString") + createRoleOptionsModel.AcceptLanguage = core.StringPtr("default") createRoleOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error @@ -2092,11 +2262,11 @@ var _ = Describe(`IamPolicyManagementV1`, func() { fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) Expect(req.Header["Accept-Language"]).ToNot(BeNil()) - Expect(req.Header["Accept-Language"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) + Expect(req.Header["Accept-Language"][0]).To(Equal(fmt.Sprintf("%v", "default"))) // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"id": "ID", "display_name": "DisplayName", "description": "Description", "actions": ["Actions"], "crn": "CRN", "name": "Name", "account_id": "AccountID", "service_name": "ServiceName", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "href": "Href"}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "display_name": "DisplayName", "description": "Description", "actions": ["Actions"], "crn": "CRN", "name": "Developer", "account_id": "AccountID", "service_name": "iam-groups", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "href": "Href"}`) })) }) It(`Invoke CreateRole successfully`, func() { @@ -2117,11 +2287,11 @@ var _ = Describe(`IamPolicyManagementV1`, func() { createRoleOptionsModel := new(iampolicymanagementv1.CreateRoleOptions) createRoleOptionsModel.DisplayName = core.StringPtr("testString") createRoleOptionsModel.Actions = []string{"testString"} - createRoleOptionsModel.Name = core.StringPtr("testString") + createRoleOptionsModel.Name = core.StringPtr("Developer") createRoleOptionsModel.AccountID = core.StringPtr("testString") - createRoleOptionsModel.ServiceName = core.StringPtr("testString") + createRoleOptionsModel.ServiceName = core.StringPtr("iam-groups") createRoleOptionsModel.Description = core.StringPtr("testString") - createRoleOptionsModel.AcceptLanguage = core.StringPtr("testString") + createRoleOptionsModel.AcceptLanguage = core.StringPtr("default") createRoleOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) @@ -2143,11 +2313,11 @@ var _ = Describe(`IamPolicyManagementV1`, func() { createRoleOptionsModel := new(iampolicymanagementv1.CreateRoleOptions) createRoleOptionsModel.DisplayName = core.StringPtr("testString") createRoleOptionsModel.Actions = []string{"testString"} - createRoleOptionsModel.Name = core.StringPtr("testString") + createRoleOptionsModel.Name = core.StringPtr("Developer") createRoleOptionsModel.AccountID = core.StringPtr("testString") - createRoleOptionsModel.ServiceName = core.StringPtr("testString") + createRoleOptionsModel.ServiceName = core.StringPtr("iam-groups") createRoleOptionsModel.Description = core.StringPtr("testString") - createRoleOptionsModel.AcceptLanguage = core.StringPtr("testString") + createRoleOptionsModel.AcceptLanguage = core.StringPtr("default") createRoleOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := iamPolicyManagementService.SetServiceURL("") @@ -2169,10 +2339,50 @@ var _ = Describe(`IamPolicyManagementV1`, 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 CreateRole successfully`, func() { + iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamPolicyManagementService).ToNot(BeNil()) + + // Construct an instance of the CreateRoleOptions model + createRoleOptionsModel := new(iampolicymanagementv1.CreateRoleOptions) + createRoleOptionsModel.DisplayName = core.StringPtr("testString") + createRoleOptionsModel.Actions = []string{"testString"} + createRoleOptionsModel.Name = core.StringPtr("Developer") + createRoleOptionsModel.AccountID = core.StringPtr("testString") + createRoleOptionsModel.ServiceName = core.StringPtr("iam-groups") + createRoleOptionsModel.Description = core.StringPtr("testString") + createRoleOptionsModel.AcceptLanguage = core.StringPtr("default") + createRoleOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamPolicyManagementService.CreateRole(createRoleOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) }) Describe(`UpdateRole(updateRoleOptions *UpdateRoleOptions) - Operation response error`, func() { updateRolePath := "/v2/roles/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() @@ -2221,7 +2431,6 @@ var _ = Describe(`IamPolicyManagementV1`, func() { }) }) }) - Describe(`UpdateRole(updateRoleOptions *UpdateRoleOptions)`, func() { updateRolePath := "/v2/roles/testString" Context(`Using mock server endpoint with timeout`, func() { @@ -2257,7 +2466,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"id": "ID", "display_name": "DisplayName", "description": "Description", "actions": ["Actions"], "crn": "CRN", "name": "Name", "account_id": "AccountID", "service_name": "ServiceName", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "href": "Href"}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "display_name": "DisplayName", "description": "Description", "actions": ["Actions"], "crn": "CRN", "name": "Developer", "account_id": "AccountID", "service_name": "iam-groups", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "href": "Href"}`) })) }) It(`Invoke UpdateRole successfully with retries`, func() { @@ -2333,7 +2542,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"id": "ID", "display_name": "DisplayName", "description": "Description", "actions": ["Actions"], "crn": "CRN", "name": "Name", "account_id": "AccountID", "service_name": "ServiceName", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "href": "Href"}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "display_name": "DisplayName", "description": "Description", "actions": ["Actions"], "crn": "CRN", "name": "Developer", "account_id": "AccountID", "service_name": "iam-groups", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "href": "Href"}`) })) }) It(`Invoke UpdateRole successfully`, func() { @@ -2402,10 +2611,48 @@ var _ = Describe(`IamPolicyManagementV1`, 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 UpdateRole successfully`, func() { + iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamPolicyManagementService).ToNot(BeNil()) + + // Construct an instance of the UpdateRoleOptions model + updateRoleOptionsModel := new(iampolicymanagementv1.UpdateRoleOptions) + updateRoleOptionsModel.RoleID = core.StringPtr("testString") + updateRoleOptionsModel.IfMatch = core.StringPtr("testString") + updateRoleOptionsModel.DisplayName = core.StringPtr("testString") + updateRoleOptionsModel.Description = core.StringPtr("testString") + updateRoleOptionsModel.Actions = []string{"testString"} + updateRoleOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamPolicyManagementService.UpdateRole(updateRoleOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) }) Describe(`GetRole(getRoleOptions *GetRoleOptions) - Operation response error`, func() { getRolePath := "/v2/roles/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() @@ -2448,7 +2695,6 @@ var _ = Describe(`IamPolicyManagementV1`, func() { }) }) }) - Describe(`GetRole(getRoleOptions *GetRoleOptions)`, func() { getRolePath := "/v2/roles/testString" Context(`Using mock server endpoint with timeout`, func() { @@ -2466,7 +2712,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"id": "ID", "display_name": "DisplayName", "description": "Description", "actions": ["Actions"], "crn": "CRN", "name": "Name", "account_id": "AccountID", "service_name": "ServiceName", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "href": "Href"}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "display_name": "DisplayName", "description": "Description", "actions": ["Actions"], "crn": "CRN", "name": "Developer", "account_id": "AccountID", "service_name": "iam-groups", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "href": "Href"}`) })) }) It(`Invoke GetRole successfully with retries`, func() { @@ -2520,7 +2766,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"id": "ID", "display_name": "DisplayName", "description": "Description", "actions": ["Actions"], "crn": "CRN", "name": "Name", "account_id": "AccountID", "service_name": "ServiceName", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "href": "Href"}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "display_name": "DisplayName", "description": "Description", "actions": ["Actions"], "crn": "CRN", "name": "Developer", "account_id": "AccountID", "service_name": "iam-groups", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "href": "Href"}`) })) }) It(`Invoke GetRole successfully`, func() { @@ -2581,8 +2827,41 @@ var _ = Describe(`IamPolicyManagementV1`, 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 GetRole successfully`, func() { + iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(iamPolicyManagementService).ToNot(BeNil()) + + // Construct an instance of the GetRoleOptions model + getRoleOptionsModel := new(iampolicymanagementv1.GetRoleOptions) + getRoleOptionsModel.RoleID = core.StringPtr("testString") + getRoleOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := iamPolicyManagementService.GetRole(getRoleOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) Describe(`DeleteRole(deleteRoleOptions *DeleteRoleOptions)`, func() { deleteRolePath := "/v2/roles/testString" Context(`Using mock server endpoint`, func() { @@ -2717,7 +2996,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { createPolicyOptionsModel.SetRoles([]iampolicymanagementv1.PolicyRole{*policyRoleModel}) createPolicyOptionsModel.SetResources([]iampolicymanagementv1.PolicyResource{*policyResourceModel}) createPolicyOptionsModel.SetDescription("testString") - createPolicyOptionsModel.SetAcceptLanguage("testString") + createPolicyOptionsModel.SetAcceptLanguage("default") createPolicyOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(createPolicyOptionsModel).ToNot(BeNil()) Expect(createPolicyOptionsModel.Type).To(Equal(core.StringPtr("testString"))) @@ -2725,33 +3004,33 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(createPolicyOptionsModel.Roles).To(Equal([]iampolicymanagementv1.PolicyRole{*policyRoleModel})) Expect(createPolicyOptionsModel.Resources).To(Equal([]iampolicymanagementv1.PolicyResource{*policyResourceModel})) Expect(createPolicyOptionsModel.Description).To(Equal(core.StringPtr("testString"))) - Expect(createPolicyOptionsModel.AcceptLanguage).To(Equal(core.StringPtr("testString"))) + Expect(createPolicyOptionsModel.AcceptLanguage).To(Equal(core.StringPtr("default"))) Expect(createPolicyOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) It(`Invoke NewCreateRoleOptions successfully`, func() { // Construct an instance of the CreateRoleOptions model createRoleOptionsDisplayName := "testString" createRoleOptionsActions := []string{"testString"} - createRoleOptionsName := "testString" + createRoleOptionsName := "Developer" createRoleOptionsAccountID := "testString" - createRoleOptionsServiceName := "testString" + createRoleOptionsServiceName := "iam-groups" createRoleOptionsModel := iamPolicyManagementService.NewCreateRoleOptions(createRoleOptionsDisplayName, createRoleOptionsActions, createRoleOptionsName, createRoleOptionsAccountID, createRoleOptionsServiceName) createRoleOptionsModel.SetDisplayName("testString") createRoleOptionsModel.SetActions([]string{"testString"}) - createRoleOptionsModel.SetName("testString") + createRoleOptionsModel.SetName("Developer") createRoleOptionsModel.SetAccountID("testString") - createRoleOptionsModel.SetServiceName("testString") + createRoleOptionsModel.SetServiceName("iam-groups") createRoleOptionsModel.SetDescription("testString") - createRoleOptionsModel.SetAcceptLanguage("testString") + createRoleOptionsModel.SetAcceptLanguage("default") createRoleOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(createRoleOptionsModel).ToNot(BeNil()) Expect(createRoleOptionsModel.DisplayName).To(Equal(core.StringPtr("testString"))) Expect(createRoleOptionsModel.Actions).To(Equal([]string{"testString"})) - Expect(createRoleOptionsModel.Name).To(Equal(core.StringPtr("testString"))) + Expect(createRoleOptionsModel.Name).To(Equal(core.StringPtr("Developer"))) Expect(createRoleOptionsModel.AccountID).To(Equal(core.StringPtr("testString"))) - Expect(createRoleOptionsModel.ServiceName).To(Equal(core.StringPtr("testString"))) + Expect(createRoleOptionsModel.ServiceName).To(Equal(core.StringPtr("iam-groups"))) Expect(createRoleOptionsModel.Description).To(Equal(core.StringPtr("testString"))) - Expect(createRoleOptionsModel.AcceptLanguage).To(Equal(core.StringPtr("testString"))) + Expect(createRoleOptionsModel.AcceptLanguage).To(Equal(core.StringPtr("default"))) Expect(createRoleOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) It(`Invoke NewDeletePolicyOptions successfully`, func() { @@ -2799,42 +3078,46 @@ var _ = Describe(`IamPolicyManagementV1`, func() { accountID := "testString" listPoliciesOptionsModel := iamPolicyManagementService.NewListPoliciesOptions(accountID) listPoliciesOptionsModel.SetAccountID("testString") - listPoliciesOptionsModel.SetAcceptLanguage("testString") + listPoliciesOptionsModel.SetAcceptLanguage("default") listPoliciesOptionsModel.SetIamID("testString") listPoliciesOptionsModel.SetAccessGroupID("testString") - listPoliciesOptionsModel.SetType("testString") - listPoliciesOptionsModel.SetServiceType("testString") + listPoliciesOptionsModel.SetType("access") + listPoliciesOptionsModel.SetServiceType("service") listPoliciesOptionsModel.SetTagName("testString") listPoliciesOptionsModel.SetTagValue("testString") - listPoliciesOptionsModel.SetSort("testString") - listPoliciesOptionsModel.SetFormat("testString") - listPoliciesOptionsModel.SetState("testString") + listPoliciesOptionsModel.SetSort("id") + listPoliciesOptionsModel.SetFormat("include_last_permit") + listPoliciesOptionsModel.SetState("active") listPoliciesOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(listPoliciesOptionsModel).ToNot(BeNil()) Expect(listPoliciesOptionsModel.AccountID).To(Equal(core.StringPtr("testString"))) - Expect(listPoliciesOptionsModel.AcceptLanguage).To(Equal(core.StringPtr("testString"))) + Expect(listPoliciesOptionsModel.AcceptLanguage).To(Equal(core.StringPtr("default"))) Expect(listPoliciesOptionsModel.IamID).To(Equal(core.StringPtr("testString"))) Expect(listPoliciesOptionsModel.AccessGroupID).To(Equal(core.StringPtr("testString"))) - Expect(listPoliciesOptionsModel.Type).To(Equal(core.StringPtr("testString"))) - Expect(listPoliciesOptionsModel.ServiceType).To(Equal(core.StringPtr("testString"))) + Expect(listPoliciesOptionsModel.Type).To(Equal(core.StringPtr("access"))) + Expect(listPoliciesOptionsModel.ServiceType).To(Equal(core.StringPtr("service"))) Expect(listPoliciesOptionsModel.TagName).To(Equal(core.StringPtr("testString"))) Expect(listPoliciesOptionsModel.TagValue).To(Equal(core.StringPtr("testString"))) - Expect(listPoliciesOptionsModel.Sort).To(Equal(core.StringPtr("testString"))) - Expect(listPoliciesOptionsModel.Format).To(Equal(core.StringPtr("testString"))) - Expect(listPoliciesOptionsModel.State).To(Equal(core.StringPtr("testString"))) + Expect(listPoliciesOptionsModel.Sort).To(Equal(core.StringPtr("id"))) + Expect(listPoliciesOptionsModel.Format).To(Equal(core.StringPtr("include_last_permit"))) + Expect(listPoliciesOptionsModel.State).To(Equal(core.StringPtr("active"))) Expect(listPoliciesOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) It(`Invoke NewListRolesOptions successfully`, func() { // Construct an instance of the ListRolesOptions model listRolesOptionsModel := iamPolicyManagementService.NewListRolesOptions() - listRolesOptionsModel.SetAcceptLanguage("testString") + listRolesOptionsModel.SetAcceptLanguage("default") listRolesOptionsModel.SetAccountID("testString") - listRolesOptionsModel.SetServiceName("testString") + listRolesOptionsModel.SetServiceName("iam-groups") + listRolesOptionsModel.SetSourceServiceName("iam-groups") + listRolesOptionsModel.SetPolicyType("authorization") listRolesOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(listRolesOptionsModel).ToNot(BeNil()) - Expect(listRolesOptionsModel.AcceptLanguage).To(Equal(core.StringPtr("testString"))) + Expect(listRolesOptionsModel.AcceptLanguage).To(Equal(core.StringPtr("default"))) Expect(listRolesOptionsModel.AccountID).To(Equal(core.StringPtr("testString"))) - Expect(listRolesOptionsModel.ServiceName).To(Equal(core.StringPtr("testString"))) + Expect(listRolesOptionsModel.ServiceName).To(Equal(core.StringPtr("iam-groups"))) + Expect(listRolesOptionsModel.SourceServiceName).To(Equal(core.StringPtr("iam-groups"))) + Expect(listRolesOptionsModel.PolicyType).To(Equal(core.StringPtr("authorization"))) Expect(listRolesOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) It(`Invoke NewPatchPolicyOptions successfully`, func() { @@ -2844,12 +3127,12 @@ var _ = Describe(`IamPolicyManagementV1`, func() { patchPolicyOptionsModel := iamPolicyManagementService.NewPatchPolicyOptions(policyID, ifMatch) patchPolicyOptionsModel.SetPolicyID("testString") patchPolicyOptionsModel.SetIfMatch("testString") - patchPolicyOptionsModel.SetState("testString") + patchPolicyOptionsModel.SetState("active") patchPolicyOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(patchPolicyOptionsModel).ToNot(BeNil()) Expect(patchPolicyOptionsModel.PolicyID).To(Equal(core.StringPtr("testString"))) Expect(patchPolicyOptionsModel.IfMatch).To(Equal(core.StringPtr("testString"))) - Expect(patchPolicyOptionsModel.State).To(Equal(core.StringPtr("testString"))) + Expect(patchPolicyOptionsModel.State).To(Equal(core.StringPtr("active"))) Expect(patchPolicyOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) It(`Invoke NewUpdatePolicyOptions successfully`, func() { @@ -2948,29 +3231,29 @@ var _ = Describe(`IamPolicyManagementV1`, func() { }) It(`Invoke NewPolicyRole successfully`, func() { roleID := "testString" - model, err := iamPolicyManagementService.NewPolicyRole(roleID) - Expect(model).ToNot(BeNil()) + _model, err := iamPolicyManagementService.NewPolicyRole(roleID) + Expect(_model).ToNot(BeNil()) Expect(err).To(BeNil()) }) It(`Invoke NewResourceAttribute successfully`, func() { name := "testString" value := "testString" - model, err := iamPolicyManagementService.NewResourceAttribute(name, value) - Expect(model).ToNot(BeNil()) + _model, err := iamPolicyManagementService.NewResourceAttribute(name, value) + Expect(_model).ToNot(BeNil()) Expect(err).To(BeNil()) }) It(`Invoke NewResourceTag successfully`, func() { name := "testString" value := "testString" - model, err := iamPolicyManagementService.NewResourceTag(name, value) - Expect(model).ToNot(BeNil()) + _model, err := iamPolicyManagementService.NewResourceTag(name, value) + Expect(_model).ToNot(BeNil()) Expect(err).To(BeNil()) }) It(`Invoke NewSubjectAttribute successfully`, func() { name := "testString" value := "testString" - model, err := iamPolicyManagementService.NewSubjectAttribute(name, value) - Expect(model).ToNot(BeNil()) + _model, err := iamPolicyManagementService.NewSubjectAttribute(name, value) + Expect(_model).ToNot(BeNil()) Expect(err).To(BeNil()) }) }) @@ -2989,11 +3272,11 @@ var _ = Describe(`IamPolicyManagementV1`, 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()) }) }) @@ -3018,13 +3301,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 }