diff --git a/iampolicymanagementv1/iam_policy_management_v1.go b/iampolicymanagementv1/iam_policy_management_v1.go index 76c51c1b..79ed2db0 100644 --- a/iampolicymanagementv1/iam_policy_management_v1.go +++ b/iampolicymanagementv1/iam_policy_management_v1.go @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2022. + * (C) Copyright IBM Corp. 2023. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ */ /* - * IBM OpenAPI SDK Code Generator Version: 3.61.0-1667892a-20221109-194550 + * IBM OpenAPI SDK Code Generator Version: 3.62.0-a2a22f95-20221115-162524 */ // Package iampolicymanagementv1 : Operations and models for the IamPolicyManagementV1 service @@ -165,7 +165,9 @@ func (iamPolicyManagement *IamPolicyManagementV1) DisableRetries() { // filter by attribute values. This can be done through query parameters. Currently, only the following attributes are // supported: account_id, iam_id, access_group_id, type, service_type, sort, format and state. account_id is a required // query parameter. Only policies that have the specified attributes and that the caller has read access to are -// returned. If the caller does not have read access to any policies an empty array is returned. +// returned. If the caller does not have read access to any policies an empty array is returned. If a policy was created +// using the new beta v2/policies API, then the caller will see placeholder information, e.g., "unsupported version" for +// iam_id, and a valid v2/policies href. The caller should use this href to view the policy. func (iamPolicyManagement *IamPolicyManagementV1) ListPolicies(listPoliciesOptions *ListPoliciesOptions) (result *PolicyList, response *core.DetailedResponse, err error) { return iamPolicyManagement.ListPoliciesWithContext(context.Background(), listPoliciesOptions) } @@ -372,7 +374,7 @@ func (iamPolicyManagement *IamPolicyManagementV1) CreatePolicyWithContext(ctx co return } -// UpdatePolicy : Update a policy +// ReplacePolicy : Update a policy // Update a policy to grant access between a subject and a resource. A policy administrator might want to update an // existing policy. The policy type cannot be changed (You cannot change an access policy to an authorization policy). // @@ -408,23 +410,23 @@ func (iamPolicyManagement *IamPolicyManagementV1) CreatePolicyWithContext(ctx co // 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) +func (iamPolicyManagement *IamPolicyManagementV1) ReplacePolicy(replacePolicyOptions *ReplacePolicyOptions) (result *Policy, response *core.DetailedResponse, err error) { + return iamPolicyManagement.ReplacePolicyWithContext(context.Background(), replacePolicyOptions) } -// UpdatePolicyWithContext is an alternate form of the UpdatePolicy method which supports a Context parameter -func (iamPolicyManagement *IamPolicyManagementV1) UpdatePolicyWithContext(ctx context.Context, updatePolicyOptions *UpdatePolicyOptions) (result *Policy, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(updatePolicyOptions, "updatePolicyOptions cannot be nil") +// ReplacePolicyWithContext is an alternate form of the ReplacePolicy method which supports a Context parameter +func (iamPolicyManagement *IamPolicyManagementV1) ReplacePolicyWithContext(ctx context.Context, replacePolicyOptions *ReplacePolicyOptions) (result *Policy, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(replacePolicyOptions, "replacePolicyOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(updatePolicyOptions, "updatePolicyOptions") + err = core.ValidateStruct(replacePolicyOptions, "replacePolicyOptions") if err != nil { return } pathParamsMap := map[string]string{ - "policy_id": *updatePolicyOptions.PolicyID, + "policy_id": *replacePolicyOptions.PolicyID, } builder := core.NewRequestBuilder(core.PUT) @@ -435,35 +437,35 @@ func (iamPolicyManagement *IamPolicyManagementV1) UpdatePolicyWithContext(ctx co return } - for headerName, headerValue := range updatePolicyOptions.Headers { + for headerName, headerValue := range replacePolicyOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("iam_policy_management", "V1", "UpdatePolicy") + sdkHeaders := common.GetSdkHeaders("iam_policy_management", "V1", "ReplacePolicy") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") builder.AddHeader("Content-Type", "application/json") - if updatePolicyOptions.IfMatch != nil { - builder.AddHeader("If-Match", fmt.Sprint(*updatePolicyOptions.IfMatch)) + if replacePolicyOptions.IfMatch != nil { + builder.AddHeader("If-Match", fmt.Sprint(*replacePolicyOptions.IfMatch)) } body := make(map[string]interface{}) - if updatePolicyOptions.Type != nil { - body["type"] = updatePolicyOptions.Type + if replacePolicyOptions.Type != nil { + body["type"] = replacePolicyOptions.Type } - if updatePolicyOptions.Subjects != nil { - body["subjects"] = updatePolicyOptions.Subjects + if replacePolicyOptions.Subjects != nil { + body["subjects"] = replacePolicyOptions.Subjects } - if updatePolicyOptions.Roles != nil { - body["roles"] = updatePolicyOptions.Roles + if replacePolicyOptions.Roles != nil { + body["roles"] = replacePolicyOptions.Roles } - if updatePolicyOptions.Resources != nil { - body["resources"] = updatePolicyOptions.Resources + if replacePolicyOptions.Resources != nil { + body["resources"] = replacePolicyOptions.Resources } - if updatePolicyOptions.Description != nil { - body["description"] = updatePolicyOptions.Description + if replacePolicyOptions.Description != nil { + body["description"] = replacePolicyOptions.Description } _, err = builder.SetBodyContentJSON(body) if err != nil { @@ -600,26 +602,26 @@ func (iamPolicyManagement *IamPolicyManagementV1) DeletePolicyWithContext(ctx co return } -// PatchPolicy : Restore a deleted policy by ID +// UpdatePolicyState : Restore a deleted policy by ID // Restore a policy that has recently been deleted. A policy administrator might want to restore a deleted policy. To // restore a policy, use **`"state": "active"`** in the body. -func (iamPolicyManagement *IamPolicyManagementV1) PatchPolicy(patchPolicyOptions *PatchPolicyOptions) (result *Policy, response *core.DetailedResponse, err error) { - return iamPolicyManagement.PatchPolicyWithContext(context.Background(), patchPolicyOptions) +func (iamPolicyManagement *IamPolicyManagementV1) UpdatePolicyState(updatePolicyStateOptions *UpdatePolicyStateOptions) (result *Policy, response *core.DetailedResponse, err error) { + return iamPolicyManagement.UpdatePolicyStateWithContext(context.Background(), updatePolicyStateOptions) } -// PatchPolicyWithContext is an alternate form of the PatchPolicy method which supports a Context parameter -func (iamPolicyManagement *IamPolicyManagementV1) PatchPolicyWithContext(ctx context.Context, patchPolicyOptions *PatchPolicyOptions) (result *Policy, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(patchPolicyOptions, "patchPolicyOptions cannot be nil") +// UpdatePolicyStateWithContext is an alternate form of the UpdatePolicyState method which supports a Context parameter +func (iamPolicyManagement *IamPolicyManagementV1) UpdatePolicyStateWithContext(ctx context.Context, updatePolicyStateOptions *UpdatePolicyStateOptions) (result *Policy, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(updatePolicyStateOptions, "updatePolicyStateOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(patchPolicyOptions, "patchPolicyOptions") + err = core.ValidateStruct(updatePolicyStateOptions, "updatePolicyStateOptions") if err != nil { return } pathParamsMap := map[string]string{ - "policy_id": *patchPolicyOptions.PolicyID, + "policy_id": *updatePolicyStateOptions.PolicyID, } builder := core.NewRequestBuilder(core.PATCH) @@ -630,23 +632,23 @@ func (iamPolicyManagement *IamPolicyManagementV1) PatchPolicyWithContext(ctx con return } - for headerName, headerValue := range patchPolicyOptions.Headers { + for headerName, headerValue := range updatePolicyStateOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("iam_policy_management", "V1", "PatchPolicy") + sdkHeaders := common.GetSdkHeaders("iam_policy_management", "V1", "UpdatePolicyState") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") builder.AddHeader("Content-Type", "application/json") - if patchPolicyOptions.IfMatch != nil { - builder.AddHeader("If-Match", fmt.Sprint(*patchPolicyOptions.IfMatch)) + if updatePolicyStateOptions.IfMatch != nil { + builder.AddHeader("If-Match", fmt.Sprint(*updatePolicyStateOptions.IfMatch)) } body := make(map[string]interface{}) - if patchPolicyOptions.State != nil { - body["state"] = patchPolicyOptions.State + if updatePolicyStateOptions.State != nil { + body["state"] = updatePolicyStateOptions.State } _, err = builder.SetBodyContentJSON(body) if err != nil { @@ -832,26 +834,26 @@ func (iamPolicyManagement *IamPolicyManagementV1) CreateRoleWithContext(ctx cont return } -// UpdateRole : Update a role +// ReplaceRole : Update a role // Update a custom role. A role administrator might want to update an existing role by updating the display name, // description, or the actions that are mapped to the role. The name, account_id, and service_name can't be changed. -func (iamPolicyManagement *IamPolicyManagementV1) UpdateRole(updateRoleOptions *UpdateRoleOptions) (result *CustomRole, response *core.DetailedResponse, err error) { - return iamPolicyManagement.UpdateRoleWithContext(context.Background(), updateRoleOptions) +func (iamPolicyManagement *IamPolicyManagementV1) ReplaceRole(replaceRoleOptions *ReplaceRoleOptions) (result *CustomRole, response *core.DetailedResponse, err error) { + return iamPolicyManagement.ReplaceRoleWithContext(context.Background(), replaceRoleOptions) } -// UpdateRoleWithContext is an alternate form of the UpdateRole method which supports a Context parameter -func (iamPolicyManagement *IamPolicyManagementV1) UpdateRoleWithContext(ctx context.Context, updateRoleOptions *UpdateRoleOptions) (result *CustomRole, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(updateRoleOptions, "updateRoleOptions cannot be nil") +// ReplaceRoleWithContext is an alternate form of the ReplaceRole method which supports a Context parameter +func (iamPolicyManagement *IamPolicyManagementV1) ReplaceRoleWithContext(ctx context.Context, replaceRoleOptions *ReplaceRoleOptions) (result *CustomRole, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(replaceRoleOptions, "replaceRoleOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(updateRoleOptions, "updateRoleOptions") + err = core.ValidateStruct(replaceRoleOptions, "replaceRoleOptions") if err != nil { return } pathParamsMap := map[string]string{ - "role_id": *updateRoleOptions.RoleID, + "role_id": *replaceRoleOptions.RoleID, } builder := core.NewRequestBuilder(core.PUT) @@ -862,29 +864,29 @@ func (iamPolicyManagement *IamPolicyManagementV1) UpdateRoleWithContext(ctx cont return } - for headerName, headerValue := range updateRoleOptions.Headers { + for headerName, headerValue := range replaceRoleOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("iam_policy_management", "V1", "UpdateRole") + sdkHeaders := common.GetSdkHeaders("iam_policy_management", "V1", "ReplaceRole") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") builder.AddHeader("Content-Type", "application/json") - if updateRoleOptions.IfMatch != nil { - builder.AddHeader("If-Match", fmt.Sprint(*updateRoleOptions.IfMatch)) + if replaceRoleOptions.IfMatch != nil { + builder.AddHeader("If-Match", fmt.Sprint(*replaceRoleOptions.IfMatch)) } body := make(map[string]interface{}) - if updateRoleOptions.DisplayName != nil { - body["display_name"] = updateRoleOptions.DisplayName + if replaceRoleOptions.DisplayName != nil { + body["display_name"] = replaceRoleOptions.DisplayName } - if updateRoleOptions.Description != nil { - body["description"] = updateRoleOptions.Description + if replaceRoleOptions.Actions != nil { + body["actions"] = replaceRoleOptions.Actions } - if updateRoleOptions.Actions != nil { - body["actions"] = updateRoleOptions.Actions + if replaceRoleOptions.Description != nil { + body["description"] = replaceRoleOptions.Description } _, err = builder.SetBodyContentJSON(body) if err != nil { @@ -1020,23 +1022,23 @@ func (iamPolicyManagement *IamPolicyManagementV1) DeleteRoleWithContext(ctx cont return } -// V2ListPolicies : Get policies by attributes +// ListV2Policies : Get policies by attributes // Get policies and filter by attributes. While managing policies, you may want to retrieve policies in the account and // filter by attribute values. This can be done through query parameters. Currently, only the following attributes are // supported: account_id, iam_id, access_group_id, type, service_type, sort, format and state. account_id is a required // query parameter. Only policies that have the specified attributes and that the caller has read access to are // returned. If the caller does not have read access to any policies an empty array is returned. -func (iamPolicyManagement *IamPolicyManagementV1) V2ListPolicies(v2ListPoliciesOptions *V2ListPoliciesOptions) (result *V2PolicyList, response *core.DetailedResponse, err error) { - return iamPolicyManagement.V2ListPoliciesWithContext(context.Background(), v2ListPoliciesOptions) +func (iamPolicyManagement *IamPolicyManagementV1) ListV2Policies(listV2PoliciesOptions *ListV2PoliciesOptions) (result *V2PolicyCollection, response *core.DetailedResponse, err error) { + return iamPolicyManagement.ListV2PoliciesWithContext(context.Background(), listV2PoliciesOptions) } -// V2ListPoliciesWithContext is an alternate form of the V2ListPolicies method which supports a Context parameter -func (iamPolicyManagement *IamPolicyManagementV1) V2ListPoliciesWithContext(ctx context.Context, v2ListPoliciesOptions *V2ListPoliciesOptions) (result *V2PolicyList, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(v2ListPoliciesOptions, "v2ListPoliciesOptions cannot be nil") +// ListV2PoliciesWithContext is an alternate form of the ListV2Policies method which supports a Context parameter +func (iamPolicyManagement *IamPolicyManagementV1) ListV2PoliciesWithContext(ctx context.Context, listV2PoliciesOptions *ListV2PoliciesOptions) (result *V2PolicyCollection, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(listV2PoliciesOptions, "listV2PoliciesOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(v2ListPoliciesOptions, "v2ListPoliciesOptions") + err = core.ValidateStruct(listV2PoliciesOptions, "listV2PoliciesOptions") if err != nil { return } @@ -1049,43 +1051,43 @@ func (iamPolicyManagement *IamPolicyManagementV1) V2ListPoliciesWithContext(ctx return } - for headerName, headerValue := range v2ListPoliciesOptions.Headers { + for headerName, headerValue := range listV2PoliciesOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("iam_policy_management", "V1", "V2ListPolicies") + sdkHeaders := common.GetSdkHeaders("iam_policy_management", "V1", "ListV2Policies") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") - if v2ListPoliciesOptions.AcceptLanguage != nil { - builder.AddHeader("Accept-Language", fmt.Sprint(*v2ListPoliciesOptions.AcceptLanguage)) + if listV2PoliciesOptions.AcceptLanguage != nil { + builder.AddHeader("Accept-Language", fmt.Sprint(*listV2PoliciesOptions.AcceptLanguage)) } - builder.AddQuery("account_id", fmt.Sprint(*v2ListPoliciesOptions.AccountID)) - if v2ListPoliciesOptions.IamID != nil { - builder.AddQuery("iam_id", fmt.Sprint(*v2ListPoliciesOptions.IamID)) + builder.AddQuery("account_id", fmt.Sprint(*listV2PoliciesOptions.AccountID)) + if listV2PoliciesOptions.IamID != nil { + builder.AddQuery("iam_id", fmt.Sprint(*listV2PoliciesOptions.IamID)) } - if v2ListPoliciesOptions.AccessGroupID != nil { - builder.AddQuery("access_group_id", fmt.Sprint(*v2ListPoliciesOptions.AccessGroupID)) + if listV2PoliciesOptions.AccessGroupID != nil { + builder.AddQuery("access_group_id", fmt.Sprint(*listV2PoliciesOptions.AccessGroupID)) } - if v2ListPoliciesOptions.Type != nil { - builder.AddQuery("type", fmt.Sprint(*v2ListPoliciesOptions.Type)) + if listV2PoliciesOptions.Type != nil { + builder.AddQuery("type", fmt.Sprint(*listV2PoliciesOptions.Type)) } - if v2ListPoliciesOptions.ServiceType != nil { - builder.AddQuery("service_type", fmt.Sprint(*v2ListPoliciesOptions.ServiceType)) + if listV2PoliciesOptions.ServiceType != nil { + builder.AddQuery("service_type", fmt.Sprint(*listV2PoliciesOptions.ServiceType)) } - if v2ListPoliciesOptions.ServiceName != nil { - builder.AddQuery("service_name", fmt.Sprint(*v2ListPoliciesOptions.ServiceName)) + if listV2PoliciesOptions.ServiceName != nil { + builder.AddQuery("service_name", fmt.Sprint(*listV2PoliciesOptions.ServiceName)) } - if v2ListPoliciesOptions.ServiceGroupID != nil { - builder.AddQuery("service_group_id", fmt.Sprint(*v2ListPoliciesOptions.ServiceGroupID)) + if listV2PoliciesOptions.ServiceGroupID != nil { + builder.AddQuery("service_group_id", fmt.Sprint(*listV2PoliciesOptions.ServiceGroupID)) } - if v2ListPoliciesOptions.Format != nil { - builder.AddQuery("format", fmt.Sprint(*v2ListPoliciesOptions.Format)) + if listV2PoliciesOptions.Format != nil { + builder.AddQuery("format", fmt.Sprint(*listV2PoliciesOptions.Format)) } - if v2ListPoliciesOptions.State != nil { - builder.AddQuery("state", fmt.Sprint(*v2ListPoliciesOptions.State)) + if listV2PoliciesOptions.State != nil { + builder.AddQuery("state", fmt.Sprint(*listV2PoliciesOptions.State)) } request, err := builder.Build() @@ -1099,7 +1101,7 @@ func (iamPolicyManagement *IamPolicyManagementV1) V2ListPoliciesWithContext(ctx return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalV2PolicyList) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalV2PolicyCollection) if err != nil { return } @@ -1109,7 +1111,7 @@ func (iamPolicyManagement *IamPolicyManagementV1) V2ListPoliciesWithContext(ctx return } -// V2CreatePolicy : Create a policy +// CreateV2Policy : Create a policy // Creates a policy to grant access between a subject and a resource. Currently, there is one type of a v2/policy: // **access**. A policy administrator might want to create an access policy which grants access to a user, service-id, // or an access group. @@ -1119,21 +1121,23 @@ func (iamPolicyManagement *IamPolicyManagementV1) V2ListPoliciesWithContext(ctx // To create an access policy, use **`"type": "access"`** in the body. The possible subject attributes are **`iam_id`** // and **`access_group_id`**. Use the **`iam_id`** subject attribute for assigning access for a user or service-id. Use // the **`access_group_id`** subject attribute for assigning access for an access group. The roles must be a subset of a -// service's or the platform's supported roles. The resource attributes must be a subset of a service's or the -// platform's supported attributes. The policy resource must include either the **`serviceType`**, **`serviceName`**, -// **`resourceGroupId`** or **`service_group_id`** attribute and the **`accountId`** attribute.` The rule field can -// either specify single **`key`**, **`value`**, and **`operator`** or be set of **`conditions`** with a combination -// **`operator`**. The possible combination operator are **`and`** and **`or`**. The rule field has a maximum of 2 -// levels of nested **`conditions`**. The operator for a rule can be used to specify a time based restriction (e.g., -// access only during business hours, during the Monday-Friday work week). For example, a policy can grant access -// Monday-Friday, 9:00am-5:00pm using the following rule: +// service's or the platform's supported roles. For more information, see [IAM roles and +// actions](https://cloud.ibm.com/docs/account?topic=account-iam-service-roles-actions). The resource attributes must be +// a subset of a service's or the platform's supported attributes. Caller should check with service, e.g., +// [VPC](https://cloud.ibm.com/docs/vpc?topic=vpc-resource-attributes), to view supported attributes. The policy +// resource must include either the **`serviceType`**, **`serviceName`**, **`resourceGroupId`** or +// **`service_group_id`** attribute and the **`accountId`** attribute.` The rule field can either specify single +// **`key`**, **`value`**, and **`operator`** or be set of **`conditions`** with a combination **`operator`**. The +// possible combination operator are **`and`** and **`or`**. The operator for a rule can be used to specify a time-based +// condition (e.g., access only during business hours, during the Monday-Friday work week). For example, a policy can +// grant access Monday-Friday, 9:00am-5:00pm using the following rule: // ```json // "rule": { // "operator": "and", // "conditions": [{ // "key": "{{environment.attributes.day_of_week}}", // "operator": "dayOfWeekAnyOf", -// "value": [1, 2, 3, 4, 5] +// "value": ["1+00:00", "2+00:00", "3+00:00", "4+00:00", "5+00:00"] // }, // "key": "{{environment.attributes.current_time}}", // "operator": "timeGreaterThanOrEquals", @@ -1147,15 +1151,19 @@ func (iamPolicyManagement *IamPolicyManagementV1) V2ListPoliciesWithContext(ctx // ``` Rules and conditions allow the following operators with **`key`**, **`value`** : // ``` // 'timeLessThan', 'timeLessThanOrEquals', 'timeGreaterThan', 'timeGreaterThanOrEquals', -// 'dateLessThan', 'dateLessThanOrEquals', 'dateGreaterThan', 'dateGreaterThanOrEquals', // 'dateTimeLessThan', 'dateTimeLessThanOrEquals', 'dateTimeGreaterThan', 'dateTimeGreaterThanOrEquals', // 'dayOfWeekEquals', 'dayOfWeekAnyOf', -// 'monthEquals', 'monthAnyOf', -// 'dayOfMonthEquals', 'dayOfMonthAnyOf' -// ``` The pattern field can be coupled with a rule that matches the pattern. For the business hour rule example above, -// the **`pattern`** is **`"time-based-restrictions:weekly"`**. The IAM Services group (`IAM`) is a subset of account -// management services that includes the IAM platform services IAM Identity, IAM Access Management, IAM Users -// Management, IAM Groups, and future IAM services. If the subject is a locked service-id, the request will fail. +// ``` +// +// The pattern field that matches the rule is required when rule is provided. For the business hour rule example above, +// the **`pattern`** is **`"time-based-conditions:weekly"`**. For more information, see [Time-based conditions +// operators](https://cloud.ibm.com/docs/account?topic=account-iam-condition-properties&interface=ui#policy-condition-properties) +// and +// [Limiting access with time-based +// conditions](https://cloud.ibm.com/docs/account?topic=account-iam-time-based&interface=ui). The IAM Services group +// (`IAM`) is a subset of account management services that includes the IAM platform services IAM Identity, IAM Access +// Management, IAM Users Management, IAM Groups, and future IAM services. If the subject is a locked service-id, the +// request will fail. // // ### Attribute Operators // @@ -1167,17 +1175,17 @@ func (iamPolicyManagement *IamPolicyManagementV1) V2ListPoliciesWithContext(ctx // 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) V2CreatePolicy(v2CreatePolicyOptions *V2CreatePolicyOptions) (result *V2Policy, response *core.DetailedResponse, err error) { - return iamPolicyManagement.V2CreatePolicyWithContext(context.Background(), v2CreatePolicyOptions) +func (iamPolicyManagement *IamPolicyManagementV1) CreateV2Policy(createV2PolicyOptions *CreateV2PolicyOptions) (result *V2Policy, response *core.DetailedResponse, err error) { + return iamPolicyManagement.CreateV2PolicyWithContext(context.Background(), createV2PolicyOptions) } -// V2CreatePolicyWithContext is an alternate form of the V2CreatePolicy method which supports a Context parameter -func (iamPolicyManagement *IamPolicyManagementV1) V2CreatePolicyWithContext(ctx context.Context, v2CreatePolicyOptions *V2CreatePolicyOptions) (result *V2Policy, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(v2CreatePolicyOptions, "v2CreatePolicyOptions cannot be nil") +// CreateV2PolicyWithContext is an alternate form of the CreateV2Policy method which supports a Context parameter +func (iamPolicyManagement *IamPolicyManagementV1) CreateV2PolicyWithContext(ctx context.Context, createV2PolicyOptions *CreateV2PolicyOptions) (result *V2Policy, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(createV2PolicyOptions, "createV2PolicyOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(v2CreatePolicyOptions, "v2CreatePolicyOptions") + err = core.ValidateStruct(createV2PolicyOptions, "createV2PolicyOptions") if err != nil { return } @@ -1190,41 +1198,41 @@ func (iamPolicyManagement *IamPolicyManagementV1) V2CreatePolicyWithContext(ctx return } - for headerName, headerValue := range v2CreatePolicyOptions.Headers { + for headerName, headerValue := range createV2PolicyOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("iam_policy_management", "V1", "V2CreatePolicy") + sdkHeaders := common.GetSdkHeaders("iam_policy_management", "V1", "CreateV2Policy") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") builder.AddHeader("Content-Type", "application/json") - if v2CreatePolicyOptions.AcceptLanguage != nil { - builder.AddHeader("Accept-Language", fmt.Sprint(*v2CreatePolicyOptions.AcceptLanguage)) + if createV2PolicyOptions.AcceptLanguage != nil { + builder.AddHeader("Accept-Language", fmt.Sprint(*createV2PolicyOptions.AcceptLanguage)) } body := make(map[string]interface{}) - if v2CreatePolicyOptions.Type != nil { - body["type"] = v2CreatePolicyOptions.Type + if createV2PolicyOptions.Control != nil { + body["control"] = createV2PolicyOptions.Control } - if v2CreatePolicyOptions.Control != nil { - body["control"] = v2CreatePolicyOptions.Control + if createV2PolicyOptions.Type != nil { + body["type"] = createV2PolicyOptions.Type } - if v2CreatePolicyOptions.Description != nil { - body["description"] = v2CreatePolicyOptions.Description + if createV2PolicyOptions.Description != nil { + body["description"] = createV2PolicyOptions.Description } - if v2CreatePolicyOptions.Subject != nil { - body["subject"] = v2CreatePolicyOptions.Subject + if createV2PolicyOptions.Subject != nil { + body["subject"] = createV2PolicyOptions.Subject } - if v2CreatePolicyOptions.Resource != nil { - body["resource"] = v2CreatePolicyOptions.Resource + if createV2PolicyOptions.Resource != nil { + body["resource"] = createV2PolicyOptions.Resource } - if v2CreatePolicyOptions.Pattern != nil { - body["pattern"] = v2CreatePolicyOptions.Pattern + if createV2PolicyOptions.Pattern != nil { + body["pattern"] = createV2PolicyOptions.Pattern } - if v2CreatePolicyOptions.Rule != nil { - body["rule"] = v2CreatePolicyOptions.Rule + if createV2PolicyOptions.Rule != nil { + body["rule"] = createV2PolicyOptions.Rule } _, err = builder.SetBodyContentJSON(body) if err != nil { @@ -1252,7 +1260,7 @@ func (iamPolicyManagement *IamPolicyManagementV1) V2CreatePolicyWithContext(ctx return } -// V2UpdatePolicy : Update a policy +// ReplaceV2Policy : Update a policy // Update a policy to grant access between a subject and a resource. A policy administrator might want to update an // existing policy. // @@ -1261,21 +1269,23 @@ func (iamPolicyManagement *IamPolicyManagementV1) V2CreatePolicyWithContext(ctx // To update an access policy, use **`"type": "access"`** in the body. The possible subject attributes are **`iam_id`** // and **`access_group_id`**. Use the **`iam_id`** subject attribute for assigning access for a user or service-id. Use // the **`access_group_id`** subject attribute for assigning access for an access group. The roles must be a subset of a -// service's or the platform's supported roles. The resource attributes must be a subset of a service's or the -// platform's supported attributes. The policy resource must include either the **`serviceType`**, **`serviceName`**, -// or **`resourceGroupId`** attribute and the **`accountId`** attribute.` The rule field can either specify single -// **`key`**, **`value`**, and **`operator`** or be set of **`conditions`** with a combination **`operator`**. The -// possible combination operator are **`and`** and **`or`**. The rule field has a maximum of 2 levels of nested -// **`conditions`**. The operator for a rule can be used to specify a time based restriction (e.g., access only during -// business hours, during the Monday-Friday work week). For example, a policy can grant access Monday-Friday, -// 9:00am-5:00pm using the following rule: +// service's or the platform's supported roles. For more information, see [IAM roles and +// actions](https://cloud.ibm.com/docs/account?topic=account-iam-service-roles-actions). The resource attributes must be +// a subset of a service's or the platform's supported attributes. Caller should check with service, e.g., +// [VPC](https://cloud.ibm.com/docs/vpc?topic=vpc-resource-attributes), to view supported attributes. The policy +// resource must include either the **`serviceType`**, **`serviceName`**, or **`resourceGroupId`** attribute and the +// **`accountId`** attribute.` The rule field can either specify single **`key`**, **`value`**, and **`operator`** or be +// set of **`conditions`** with a combination **`operator`**. The possible combination operator are **`and`** and +// **`or`**. The operator for a rule can be used to specify a time-based condition (e.g., access only during business +// hours, during the Monday-Friday work week). For example, a policy can grant access Monday-Friday, 9:00am-5:00pm using +// the following rule: // ```json // "rule": { // "operator": "and", // "conditions": [{ // "key": "{{environment.attributes.day_of_week}}", // "operator": "dayOfWeekAnyOf", -// "value": [1, 2, 3, 4, 5] +// "value": ["1+00:00", "2+00:00", "3+00:00", "4+00:00", "5+00:00"] // }, // "key": "{{environment.attributes.current_time}}", // "operator": "timeGreaterThanOrEquals", @@ -1289,14 +1299,14 @@ func (iamPolicyManagement *IamPolicyManagementV1) V2CreatePolicyWithContext(ctx // ``` Rules and conditions allow the following operators with **`key`**, **`value`** : // ``` // 'timeLessThan', 'timeLessThanOrEquals', 'timeGreaterThan', 'timeGreaterThanOrEquals', -// 'dateLessThan', 'dateLessThanOrEquals', 'dateGreaterThan', 'dateGreaterThanOrEquals', // 'dateTimeLessThan', 'dateTimeLessThanOrEquals', 'dateTimeGreaterThan', 'dateTimeGreaterThanOrEquals', // 'dayOfWeekEquals', 'dayOfWeekAnyOf', -// 'monthEquals', 'monthAnyOf', -// 'dayOfMonthEquals', 'dayOfMonthAnyOf' -// ``` The pattern field can be coupled with a rule that matches the pattern. For the business hour rule example above, -// the **`pattern`** is **`"time-based-restrictions:weekly"`**. If the subject is a locked service-id, the request will -// fail. +// ``` The pattern field that matches the rule is required when rule is provided. For the business hour rule example +// above, the **`pattern`** is **`"time-based-conditions:weekly"`**. For more information, see [Time-based conditions +// operators](https://cloud.ibm.com/docs/account?topic=account-iam-condition-properties&interface=ui#policy-condition-properties) +// and +// [Limiting access with time-based +// conditions](https://cloud.ibm.com/docs/account?topic=account-iam-time-based&interface=ui). // // ### Attribute Operators // @@ -1308,68 +1318,68 @@ func (iamPolicyManagement *IamPolicyManagementV1) V2CreatePolicyWithContext(ctx // 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) V2UpdatePolicy(v2UpdatePolicyOptions *V2UpdatePolicyOptions) (result *V2Policy, response *core.DetailedResponse, err error) { - return iamPolicyManagement.V2UpdatePolicyWithContext(context.Background(), v2UpdatePolicyOptions) +func (iamPolicyManagement *IamPolicyManagementV1) ReplaceV2Policy(replaceV2PolicyOptions *ReplaceV2PolicyOptions) (result *V2Policy, response *core.DetailedResponse, err error) { + return iamPolicyManagement.ReplaceV2PolicyWithContext(context.Background(), replaceV2PolicyOptions) } -// V2UpdatePolicyWithContext is an alternate form of the V2UpdatePolicy method which supports a Context parameter -func (iamPolicyManagement *IamPolicyManagementV1) V2UpdatePolicyWithContext(ctx context.Context, v2UpdatePolicyOptions *V2UpdatePolicyOptions) (result *V2Policy, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(v2UpdatePolicyOptions, "v2UpdatePolicyOptions cannot be nil") +// ReplaceV2PolicyWithContext is an alternate form of the ReplaceV2Policy method which supports a Context parameter +func (iamPolicyManagement *IamPolicyManagementV1) ReplaceV2PolicyWithContext(ctx context.Context, replaceV2PolicyOptions *ReplaceV2PolicyOptions) (result *V2Policy, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(replaceV2PolicyOptions, "replaceV2PolicyOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(v2UpdatePolicyOptions, "v2UpdatePolicyOptions") + err = core.ValidateStruct(replaceV2PolicyOptions, "replaceV2PolicyOptions") if err != nil { return } pathParamsMap := map[string]string{ - "policy_id": *v2UpdatePolicyOptions.PolicyID, + "id": *replaceV2PolicyOptions.ID, } builder := core.NewRequestBuilder(core.PUT) builder = builder.WithContext(ctx) builder.EnableGzipCompression = iamPolicyManagement.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(iamPolicyManagement.Service.Options.URL, `/v2/policies/{policy_id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(iamPolicyManagement.Service.Options.URL, `/v2/policies/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range v2UpdatePolicyOptions.Headers { + for headerName, headerValue := range replaceV2PolicyOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("iam_policy_management", "V1", "V2UpdatePolicy") + sdkHeaders := common.GetSdkHeaders("iam_policy_management", "V1", "ReplaceV2Policy") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") builder.AddHeader("Content-Type", "application/json") - if v2UpdatePolicyOptions.IfMatch != nil { - builder.AddHeader("If-Match", fmt.Sprint(*v2UpdatePolicyOptions.IfMatch)) + if replaceV2PolicyOptions.IfMatch != nil { + builder.AddHeader("If-Match", fmt.Sprint(*replaceV2PolicyOptions.IfMatch)) } body := make(map[string]interface{}) - if v2UpdatePolicyOptions.Type != nil { - body["type"] = v2UpdatePolicyOptions.Type + if replaceV2PolicyOptions.Control != nil { + body["control"] = replaceV2PolicyOptions.Control } - if v2UpdatePolicyOptions.Control != nil { - body["control"] = v2UpdatePolicyOptions.Control + if replaceV2PolicyOptions.Type != nil { + body["type"] = replaceV2PolicyOptions.Type } - if v2UpdatePolicyOptions.Description != nil { - body["description"] = v2UpdatePolicyOptions.Description + if replaceV2PolicyOptions.Description != nil { + body["description"] = replaceV2PolicyOptions.Description } - if v2UpdatePolicyOptions.Subject != nil { - body["subject"] = v2UpdatePolicyOptions.Subject + if replaceV2PolicyOptions.Subject != nil { + body["subject"] = replaceV2PolicyOptions.Subject } - if v2UpdatePolicyOptions.Resource != nil { - body["resource"] = v2UpdatePolicyOptions.Resource + if replaceV2PolicyOptions.Resource != nil { + body["resource"] = replaceV2PolicyOptions.Resource } - if v2UpdatePolicyOptions.Pattern != nil { - body["pattern"] = v2UpdatePolicyOptions.Pattern + if replaceV2PolicyOptions.Pattern != nil { + body["pattern"] = replaceV2PolicyOptions.Pattern } - if v2UpdatePolicyOptions.Rule != nil { - body["rule"] = v2UpdatePolicyOptions.Rule + if replaceV2PolicyOptions.Rule != nil { + body["rule"] = replaceV2PolicyOptions.Rule } _, err = builder.SetBodyContentJSON(body) if err != nil { @@ -1397,40 +1407,40 @@ func (iamPolicyManagement *IamPolicyManagementV1) V2UpdatePolicyWithContext(ctx return } -// V2GetPolicy : Retrieve a policy by ID +// GetV2Policy : Retrieve a policy by ID // Retrieve a policy by providing a policy ID. -func (iamPolicyManagement *IamPolicyManagementV1) V2GetPolicy(v2GetPolicyOptions *V2GetPolicyOptions) (result *Policy, response *core.DetailedResponse, err error) { - return iamPolicyManagement.V2GetPolicyWithContext(context.Background(), v2GetPolicyOptions) +func (iamPolicyManagement *IamPolicyManagementV1) GetV2Policy(getV2PolicyOptions *GetV2PolicyOptions) (result *V2Policy, response *core.DetailedResponse, err error) { + return iamPolicyManagement.GetV2PolicyWithContext(context.Background(), getV2PolicyOptions) } -// V2GetPolicyWithContext is an alternate form of the V2GetPolicy method which supports a Context parameter -func (iamPolicyManagement *IamPolicyManagementV1) V2GetPolicyWithContext(ctx context.Context, v2GetPolicyOptions *V2GetPolicyOptions) (result *Policy, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(v2GetPolicyOptions, "v2GetPolicyOptions cannot be nil") +// GetV2PolicyWithContext is an alternate form of the GetV2Policy method which supports a Context parameter +func (iamPolicyManagement *IamPolicyManagementV1) GetV2PolicyWithContext(ctx context.Context, getV2PolicyOptions *GetV2PolicyOptions) (result *V2Policy, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getV2PolicyOptions, "getV2PolicyOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(v2GetPolicyOptions, "v2GetPolicyOptions") + err = core.ValidateStruct(getV2PolicyOptions, "getV2PolicyOptions") if err != nil { return } pathParamsMap := map[string]string{ - "policy_id": *v2GetPolicyOptions.PolicyID, + "id": *getV2PolicyOptions.ID, } builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = iamPolicyManagement.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(iamPolicyManagement.Service.Options.URL, `/v2/policies/{policy_id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(iamPolicyManagement.Service.Options.URL, `/v2/policies/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range v2GetPolicyOptions.Headers { + for headerName, headerValue := range getV2PolicyOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("iam_policy_management", "V1", "V2GetPolicy") + sdkHeaders := common.GetSdkHeaders("iam_policy_management", "V1", "GetV2Policy") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -1447,7 +1457,7 @@ func (iamPolicyManagement *IamPolicyManagementV1) V2GetPolicyWithContext(ctx con return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalPolicy) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalV2Policy) if err != nil { return } @@ -1457,41 +1467,41 @@ func (iamPolicyManagement *IamPolicyManagementV1) V2GetPolicyWithContext(ctx con return } -// V2DeletePolicy : Delete a policy by ID +// DeleteV2Policy : Delete a policy by ID // Delete a policy by providing a policy ID. A policy cannot be deleted if the subject ID contains a locked service ID. // If the subject of the policy is a locked service-id, the request will fail. -func (iamPolicyManagement *IamPolicyManagementV1) V2DeletePolicy(v2DeletePolicyOptions *V2DeletePolicyOptions) (response *core.DetailedResponse, err error) { - return iamPolicyManagement.V2DeletePolicyWithContext(context.Background(), v2DeletePolicyOptions) +func (iamPolicyManagement *IamPolicyManagementV1) DeleteV2Policy(deleteV2PolicyOptions *DeleteV2PolicyOptions) (response *core.DetailedResponse, err error) { + return iamPolicyManagement.DeleteV2PolicyWithContext(context.Background(), deleteV2PolicyOptions) } -// V2DeletePolicyWithContext is an alternate form of the V2DeletePolicy method which supports a Context parameter -func (iamPolicyManagement *IamPolicyManagementV1) V2DeletePolicyWithContext(ctx context.Context, v2DeletePolicyOptions *V2DeletePolicyOptions) (response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(v2DeletePolicyOptions, "v2DeletePolicyOptions cannot be nil") +// DeleteV2PolicyWithContext is an alternate form of the DeleteV2Policy method which supports a Context parameter +func (iamPolicyManagement *IamPolicyManagementV1) DeleteV2PolicyWithContext(ctx context.Context, deleteV2PolicyOptions *DeleteV2PolicyOptions) (response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(deleteV2PolicyOptions, "deleteV2PolicyOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(v2DeletePolicyOptions, "v2DeletePolicyOptions") + err = core.ValidateStruct(deleteV2PolicyOptions, "deleteV2PolicyOptions") if err != nil { return } pathParamsMap := map[string]string{ - "policy_id": *v2DeletePolicyOptions.PolicyID, + "id": *deleteV2PolicyOptions.ID, } builder := core.NewRequestBuilder(core.DELETE) builder = builder.WithContext(ctx) builder.EnableGzipCompression = iamPolicyManagement.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(iamPolicyManagement.Service.Options.URL, `/v2/policies/{policy_id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(iamPolicyManagement.Service.Options.URL, `/v2/policies/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range v2DeletePolicyOptions.Headers { + for headerName, headerValue := range deleteV2PolicyOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("iam_policy_management", "V1", "V2DeletePolicy") + sdkHeaders := common.GetSdkHeaders("iam_policy_management", "V1", "DeleteV2Policy") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -1506,6 +1516,59 @@ func (iamPolicyManagement *IamPolicyManagementV1) V2DeletePolicyWithContext(ctx return } +// Control : Specifies the type of access granted by the policy. +type Control struct { + // Permission granted by the policy. + Grant *V2PolicyGrant `json:"grant" validate:"required"` +} + +// NewControl : Instantiate Control (Generic Model Constructor) +func (*IamPolicyManagementV1) NewControl(grant *V2PolicyGrant) (_model *Control, err error) { + _model = &Control{ + Grant: grant, + } + err = core.ValidateStruct(_model, "required parameters") + return +} + +// UnmarshalControl unmarshals an instance of Control from the specified map of raw messages. +func UnmarshalControl(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(Control) + err = core.UnmarshalModel(m, "grant", &obj.Grant, UnmarshalV2PolicyGrant) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// ControlResponse : ControlResponse struct +// Models which "extend" this model: +// - ControlResponseControl +// - ControlResponseControlWithTranslatedRoles +type ControlResponse struct { + // Permission granted by the policy. + Grant *V2PolicyGrant `json:"grant,omitempty"` +} +func (*ControlResponse) isaControlResponse() bool { + return true +} + +type ControlResponseIntf interface { + isaControlResponse() bool +} + +// UnmarshalControlResponse unmarshals an instance of ControlResponse from the specified map of raw messages. +func UnmarshalControlResponse(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(ControlResponse) + err = core.UnmarshalModel(m, "grant", &obj.Grant, UnmarshalV2PolicyGrant) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + // CreatePolicyOptions : The CreatePolicy options. type CreatePolicyOptions struct { // The policy type; either 'access' or 'authorization'. @@ -1691,6 +1754,117 @@ func (options *CreateRoleOptions) SetHeaders(param map[string]string) *CreateRol return options } +// CreateV2PolicyOptions : The CreateV2Policy options. +type CreateV2PolicyOptions struct { + // Specifies the type of access granted by the policy. + Control *Control `json:"control" validate:"required"` + + // The policy type; either 'access' or 'authorization'. + Type *string `json:"type" validate:"required"` + + // Allows the customer to use their own words to record the purpose/context related to a policy. + Description *string `json:"description,omitempty"` + + // The subject attributes for whom the policy grants access. + Subject *V2PolicySubject `json:"subject,omitempty"` + + // The resource attributes to which the policy grants access. + Resource *V2PolicyResource `json:"resource,omitempty"` + + // Indicates pattern of rule, either 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or + // 'time-based-conditions:weekly:custom-hours'. + Pattern *string `json:"pattern,omitempty"` + + // Additional access conditions associated with the policy. + Rule V2PolicyRuleIntf `json:"rule,omitempty"` + + // 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 +} + +// Constants associated with the CreateV2PolicyOptions.Type property. +// The policy type; either 'access' or 'authorization'. +const ( + CreateV2PolicyOptionsTypeAccessConst = "access" + CreateV2PolicyOptionsTypeAuthorizationConst = "authorization" +) + +// NewCreateV2PolicyOptions : Instantiate CreateV2PolicyOptions +func (*IamPolicyManagementV1) NewCreateV2PolicyOptions(control *Control, typeVar string) *CreateV2PolicyOptions { + return &CreateV2PolicyOptions{ + Control: control, + Type: core.StringPtr(typeVar), + } +} + +// SetControl : Allow user to set Control +func (_options *CreateV2PolicyOptions) SetControl(control *Control) *CreateV2PolicyOptions { + _options.Control = control + return _options +} + +// SetType : Allow user to set Type +func (_options *CreateV2PolicyOptions) SetType(typeVar string) *CreateV2PolicyOptions { + _options.Type = core.StringPtr(typeVar) + return _options +} + +// SetDescription : Allow user to set Description +func (_options *CreateV2PolicyOptions) SetDescription(description string) *CreateV2PolicyOptions { + _options.Description = core.StringPtr(description) + return _options +} + +// SetSubject : Allow user to set Subject +func (_options *CreateV2PolicyOptions) SetSubject(subject *V2PolicySubject) *CreateV2PolicyOptions { + _options.Subject = subject + return _options +} + +// SetResource : Allow user to set Resource +func (_options *CreateV2PolicyOptions) SetResource(resource *V2PolicyResource) *CreateV2PolicyOptions { + _options.Resource = resource + return _options +} + +// SetPattern : Allow user to set Pattern +func (_options *CreateV2PolicyOptions) SetPattern(pattern string) *CreateV2PolicyOptions { + _options.Pattern = core.StringPtr(pattern) + return _options +} + +// SetRule : Allow user to set Rule +func (_options *CreateV2PolicyOptions) SetRule(rule V2PolicyRuleIntf) *CreateV2PolicyOptions { + _options.Rule = rule + return _options +} + +// SetAcceptLanguage : Allow user to set AcceptLanguage +func (_options *CreateV2PolicyOptions) SetAcceptLanguage(acceptLanguage string) *CreateV2PolicyOptions { + _options.AcceptLanguage = core.StringPtr(acceptLanguage) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *CreateV2PolicyOptions) SetHeaders(param map[string]string) *CreateV2PolicyOptions { + options.Headers = param + return options +} + // DeletePolicyOptions : The DeletePolicy options. type DeletePolicyOptions struct { // The policy ID. @@ -1747,6 +1921,34 @@ func (options *DeleteRoleOptions) SetHeaders(param map[string]string) *DeleteRol return options } +// DeleteV2PolicyOptions : The DeleteV2Policy options. +type DeleteV2PolicyOptions struct { + // The policy ID. + ID *string `json:"id" validate:"required,ne="` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewDeleteV2PolicyOptions : Instantiate DeleteV2PolicyOptions +func (*IamPolicyManagementV1) NewDeleteV2PolicyOptions(id string) *DeleteV2PolicyOptions { + return &DeleteV2PolicyOptions{ + ID: core.StringPtr(id), + } +} + +// SetID : Allow user to set ID +func (_options *DeleteV2PolicyOptions) SetID(id string) *DeleteV2PolicyOptions { + _options.ID = core.StringPtr(id) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *DeleteV2PolicyOptions) SetHeaders(param map[string]string) *DeleteV2PolicyOptions { + options.Headers = param + return options +} + // GetPolicyOptions : The GetPolicy options. type GetPolicyOptions struct { // The policy ID. @@ -1803,6 +2005,51 @@ func (options *GetRoleOptions) SetHeaders(param map[string]string) *GetRoleOptio return options } +// GetV2PolicyOptions : The GetV2Policy options. +type GetV2PolicyOptions struct { + // The policy ID. + ID *string `json:"id" validate:"required,ne="` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewGetV2PolicyOptions : Instantiate GetV2PolicyOptions +func (*IamPolicyManagementV1) NewGetV2PolicyOptions(id string) *GetV2PolicyOptions { + return &GetV2PolicyOptions{ + ID: core.StringPtr(id), + } +} + +// SetID : Allow user to set ID +func (_options *GetV2PolicyOptions) SetID(id string) *GetV2PolicyOptions { + _options.ID = core.StringPtr(id) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *GetV2PolicyOptions) SetHeaders(param map[string]string) *GetV2PolicyOptions { + options.Headers = param + return options +} + +// GrantWithTranslatedRoles : Permission granted by the policy with translated roles and additional role information. +type GrantWithTranslatedRoles struct { + // A set of roles granted by the policy. + Roles []RoleInDisplayFormat `json:"roles" validate:"required"` +} + +// UnmarshalGrantWithTranslatedRoles unmarshals an instance of GrantWithTranslatedRoles from the specified map of raw messages. +func UnmarshalGrantWithTranslatedRoles(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(GrantWithTranslatedRoles) + err = core.UnmarshalModel(m, "roles", &obj.Roles, UnmarshalRoleInDisplayFormat) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + // ListPoliciesOptions : The ListPolicies options. type ListPoliciesOptions struct { // The account GUID in which the policies belong to. @@ -2058,63 +2305,208 @@ func (options *ListRolesOptions) SetHeaders(param map[string]string) *ListRolesO return options } -// PatchPolicyOptions : The PatchPolicy options. -type PatchPolicyOptions struct { - // The policy ID. - PolicyID *string `json:"policy_id" validate:"required,ne="` +// ListV2PoliciesOptions : The ListV2Policies options. +type ListV2PoliciesOptions struct { + // The account GUID in which the policies belong to. + AccountID *string `json:"account_id" validate:"required"` - // 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 `json:"If-Match" 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"` - // The policy state. + // 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"` + + // Optional type of service. + ServiceType *string `json:"service_type,omitempty"` + + // Optional name of service. + ServiceName *string `json:"service_name,omitempty"` + + // Optional ID of service group. + ServiceGroupID *string `json:"service_group_id,omitempty"` + + // 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 and translations for all relevant + // fields. + Format *string `json:"format,omitempty"` + + // The state of the policy. + // * `active` - returns active policies + // * `deleted` - returns non-active policies. 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. +// Constants associated with the ListV2PoliciesOptions.Type property. +// Optional type of policy. const ( - PatchPolicyOptionsStateActiveConst = "active" - PatchPolicyOptionsStateDeletedConst = "deleted" + ListV2PoliciesOptionsTypeAccessConst = "access" + ListV2PoliciesOptionsTypeAuthorizationConst = "authorization" ) -// NewPatchPolicyOptions : Instantiate PatchPolicyOptions -func (*IamPolicyManagementV1) NewPatchPolicyOptions(policyID string, ifMatch string) *PatchPolicyOptions { - return &PatchPolicyOptions{ - PolicyID: core.StringPtr(policyID), - IfMatch: core.StringPtr(ifMatch), +// Constants associated with the ListV2PoliciesOptions.ServiceType property. +// Optional type of service. +const ( + ListV2PoliciesOptionsServiceTypePlatformServiceConst = "platform_service" + ListV2PoliciesOptionsServiceTypeServiceConst = "service" +) + +// Constants associated with the ListV2PoliciesOptions.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 and translations for all relevant +// fields. +const ( + ListV2PoliciesOptionsFormatDisplayConst = "display" + ListV2PoliciesOptionsFormatIncludeLastPermitConst = "include_last_permit" +) + +// Constants associated with the ListV2PoliciesOptions.State property. +// The state of the policy. +// * `active` - returns active policies +// * `deleted` - returns non-active policies. +const ( + ListV2PoliciesOptionsStateActiveConst = "active" + ListV2PoliciesOptionsStateDeletedConst = "deleted" +) + +// NewListV2PoliciesOptions : Instantiate ListV2PoliciesOptions +func (*IamPolicyManagementV1) NewListV2PoliciesOptions(accountID string) *ListV2PoliciesOptions { + return &ListV2PoliciesOptions{ + AccountID: core.StringPtr(accountID), } } -// SetPolicyID : Allow user to set PolicyID -func (_options *PatchPolicyOptions) SetPolicyID(policyID string) *PatchPolicyOptions { - _options.PolicyID = core.StringPtr(policyID) +// SetAccountID : Allow user to set AccountID +func (_options *ListV2PoliciesOptions) SetAccountID(accountID string) *ListV2PoliciesOptions { + _options.AccountID = core.StringPtr(accountID) return _options } -// SetIfMatch : Allow user to set IfMatch -func (_options *PatchPolicyOptions) SetIfMatch(ifMatch string) *PatchPolicyOptions { - _options.IfMatch = core.StringPtr(ifMatch) +// SetAcceptLanguage : Allow user to set AcceptLanguage +func (_options *ListV2PoliciesOptions) SetAcceptLanguage(acceptLanguage string) *ListV2PoliciesOptions { + _options.AcceptLanguage = core.StringPtr(acceptLanguage) return _options } -// SetState : Allow user to set State -func (_options *PatchPolicyOptions) SetState(state string) *PatchPolicyOptions { - _options.State = core.StringPtr(state) +// SetIamID : Allow user to set IamID +func (_options *ListV2PoliciesOptions) SetIamID(iamID string) *ListV2PoliciesOptions { + _options.IamID = core.StringPtr(iamID) return _options } -// SetHeaders : Allow user to set Headers -func (options *PatchPolicyOptions) SetHeaders(param map[string]string) *PatchPolicyOptions { +// SetAccessGroupID : Allow user to set AccessGroupID +func (_options *ListV2PoliciesOptions) SetAccessGroupID(accessGroupID string) *ListV2PoliciesOptions { + _options.AccessGroupID = core.StringPtr(accessGroupID) + return _options +} + +// SetType : Allow user to set Type +func (_options *ListV2PoliciesOptions) SetType(typeVar string) *ListV2PoliciesOptions { + _options.Type = core.StringPtr(typeVar) + return _options +} + +// SetServiceType : Allow user to set ServiceType +func (_options *ListV2PoliciesOptions) SetServiceType(serviceType string) *ListV2PoliciesOptions { + _options.ServiceType = core.StringPtr(serviceType) + return _options +} + +// SetServiceName : Allow user to set ServiceName +func (_options *ListV2PoliciesOptions) SetServiceName(serviceName string) *ListV2PoliciesOptions { + _options.ServiceName = core.StringPtr(serviceName) + return _options +} + +// SetServiceGroupID : Allow user to set ServiceGroupID +func (_options *ListV2PoliciesOptions) SetServiceGroupID(serviceGroupID string) *ListV2PoliciesOptions { + _options.ServiceGroupID = core.StringPtr(serviceGroupID) + return _options +} + +// SetFormat : Allow user to set Format +func (_options *ListV2PoliciesOptions) SetFormat(format string) *ListV2PoliciesOptions { + _options.Format = core.StringPtr(format) + return _options +} + +// SetState : Allow user to set State +func (_options *ListV2PoliciesOptions) SetState(state string) *ListV2PoliciesOptions { + _options.State = core.StringPtr(state) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *ListV2PoliciesOptions) SetHeaders(param map[string]string) *ListV2PoliciesOptions { options.Headers = param return options } -// UpdatePolicyOptions : The UpdatePolicy options. -type UpdatePolicyOptions struct { +// PolicyRole : A role associated with a policy. +type PolicyRole struct { + // 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. + DisplayName *string `json:"display_name,omitempty"` + + // The description of the role. + Description *string `json:"description,omitempty"` +} + +// NewPolicyRole : Instantiate PolicyRole (Generic Model Constructor) +func (*IamPolicyManagementV1) NewPolicyRole(roleID string) (_model *PolicyRole, err error) { + _model = &PolicyRole{ + RoleID: core.StringPtr(roleID), + } + err = core.ValidateStruct(_model, "required parameters") + return +} + +// UnmarshalPolicyRole unmarshals an instance of PolicyRole from the specified map of raw messages. +func UnmarshalPolicyRole(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(PolicyRole) + err = core.UnmarshalPrimitive(m, "role_id", &obj.RoleID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "display_name", &obj.DisplayName) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "description", &obj.Description) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// ReplacePolicyOptions : The ReplacePolicy options. +type ReplacePolicyOptions struct { // The policy ID. PolicyID *string `json:"policy_id" validate:"required,ne="` @@ -2141,9 +2533,9 @@ type UpdatePolicyOptions struct { Headers map[string]string } -// NewUpdatePolicyOptions : Instantiate UpdatePolicyOptions -func (*IamPolicyManagementV1) NewUpdatePolicyOptions(policyID string, ifMatch string, typeVar string, subjects []PolicySubject, roles []PolicyRole, resources []PolicyResource) *UpdatePolicyOptions { - return &UpdatePolicyOptions{ +// NewReplacePolicyOptions : Instantiate ReplacePolicyOptions +func (*IamPolicyManagementV1) NewReplacePolicyOptions(policyID string, ifMatch string, typeVar string, subjects []PolicySubject, roles []PolicyRole, resources []PolicyResource) *ReplacePolicyOptions { + return &ReplacePolicyOptions{ PolicyID: core.StringPtr(policyID), IfMatch: core.StringPtr(ifMatch), Type: core.StringPtr(typeVar), @@ -2154,55 +2546,55 @@ func (*IamPolicyManagementV1) NewUpdatePolicyOptions(policyID string, ifMatch st } // SetPolicyID : Allow user to set PolicyID -func (_options *UpdatePolicyOptions) SetPolicyID(policyID string) *UpdatePolicyOptions { +func (_options *ReplacePolicyOptions) SetPolicyID(policyID string) *ReplacePolicyOptions { _options.PolicyID = core.StringPtr(policyID) return _options } // SetIfMatch : Allow user to set IfMatch -func (_options *UpdatePolicyOptions) SetIfMatch(ifMatch string) *UpdatePolicyOptions { +func (_options *ReplacePolicyOptions) SetIfMatch(ifMatch string) *ReplacePolicyOptions { _options.IfMatch = core.StringPtr(ifMatch) return _options } // SetType : Allow user to set Type -func (_options *UpdatePolicyOptions) SetType(typeVar string) *UpdatePolicyOptions { +func (_options *ReplacePolicyOptions) SetType(typeVar string) *ReplacePolicyOptions { _options.Type = core.StringPtr(typeVar) return _options } // SetSubjects : Allow user to set Subjects -func (_options *UpdatePolicyOptions) SetSubjects(subjects []PolicySubject) *UpdatePolicyOptions { +func (_options *ReplacePolicyOptions) SetSubjects(subjects []PolicySubject) *ReplacePolicyOptions { _options.Subjects = subjects return _options } // SetRoles : Allow user to set Roles -func (_options *UpdatePolicyOptions) SetRoles(roles []PolicyRole) *UpdatePolicyOptions { +func (_options *ReplacePolicyOptions) SetRoles(roles []PolicyRole) *ReplacePolicyOptions { _options.Roles = roles return _options } // SetResources : Allow user to set Resources -func (_options *UpdatePolicyOptions) SetResources(resources []PolicyResource) *UpdatePolicyOptions { +func (_options *ReplacePolicyOptions) SetResources(resources []PolicyResource) *ReplacePolicyOptions { _options.Resources = resources return _options } // SetDescription : Allow user to set Description -func (_options *UpdatePolicyOptions) SetDescription(description string) *UpdatePolicyOptions { +func (_options *ReplacePolicyOptions) SetDescription(description string) *ReplacePolicyOptions { _options.Description = core.StringPtr(description) return _options } // SetHeaders : Allow user to set Headers -func (options *UpdatePolicyOptions) SetHeaders(param map[string]string) *UpdatePolicyOptions { +func (options *ReplacePolicyOptions) SetHeaders(param map[string]string) *ReplacePolicyOptions { options.Headers = param return options } -// UpdateRoleOptions : The UpdateRole options. -type UpdateRoleOptions struct { +// ReplaceRoleOptions : The ReplaceRole options. +type ReplaceRoleOptions struct { // The role ID. RoleID *string `json:"role_id" validate:"required,ne="` @@ -2211,401 +2603,618 @@ type UpdateRoleOptions struct { IfMatch *string `json:"If-Match" validate:"required"` // The display name of the role that is shown in the console. - DisplayName *string `json:"display_name,omitempty"` - - // The description of the role. - Description *string `json:"description,omitempty"` + DisplayName *string `json:"display_name" 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,omitempty"` + Actions []string `json:"actions" validate:"required"` + + // The description of the role. + Description *string `json:"description,omitempty"` // Allows users to set headers on API requests Headers map[string]string } -// NewUpdateRoleOptions : Instantiate UpdateRoleOptions -func (*IamPolicyManagementV1) NewUpdateRoleOptions(roleID string, ifMatch string) *UpdateRoleOptions { - return &UpdateRoleOptions{ +// NewReplaceRoleOptions : Instantiate ReplaceRoleOptions +func (*IamPolicyManagementV1) NewReplaceRoleOptions(roleID string, ifMatch string, displayName string, actions []string) *ReplaceRoleOptions { + return &ReplaceRoleOptions{ RoleID: core.StringPtr(roleID), IfMatch: core.StringPtr(ifMatch), + DisplayName: core.StringPtr(displayName), + Actions: actions, } } // SetRoleID : Allow user to set RoleID -func (_options *UpdateRoleOptions) SetRoleID(roleID string) *UpdateRoleOptions { +func (_options *ReplaceRoleOptions) SetRoleID(roleID string) *ReplaceRoleOptions { _options.RoleID = core.StringPtr(roleID) return _options } // SetIfMatch : Allow user to set IfMatch -func (_options *UpdateRoleOptions) SetIfMatch(ifMatch string) *UpdateRoleOptions { +func (_options *ReplaceRoleOptions) SetIfMatch(ifMatch string) *ReplaceRoleOptions { _options.IfMatch = core.StringPtr(ifMatch) return _options } // SetDisplayName : Allow user to set DisplayName -func (_options *UpdateRoleOptions) SetDisplayName(displayName string) *UpdateRoleOptions { +func (_options *ReplaceRoleOptions) SetDisplayName(displayName string) *ReplaceRoleOptions { _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) +// SetActions : Allow user to set Actions +func (_options *ReplaceRoleOptions) SetActions(actions []string) *ReplaceRoleOptions { + _options.Actions = actions return _options } -// SetActions : Allow user to set Actions -func (_options *UpdateRoleOptions) SetActions(actions []string) *UpdateRoleOptions { - _options.Actions = actions +// SetDescription : Allow user to set Description +func (_options *ReplaceRoleOptions) SetDescription(description string) *ReplaceRoleOptions { + _options.Description = core.StringPtr(description) return _options } // SetHeaders : Allow user to set Headers -func (options *UpdateRoleOptions) SetHeaders(param map[string]string) *UpdateRoleOptions { +func (options *ReplaceRoleOptions) SetHeaders(param map[string]string) *ReplaceRoleOptions { options.Headers = param return options } -// V2CreatePolicyOptions : The V2CreatePolicy options. -type V2CreatePolicyOptions struct { - // The policy type; either 'access' or 'authorization'. - Type *string `json:"type" validate:"required"` +// ReplaceV2PolicyOptions : The ReplaceV2Policy options. +type ReplaceV2PolicyOptions struct { + // The policy ID. + ID *string `json:"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 /v2/policies/{id} API and looking at the ETag response header. + IfMatch *string `json:"If-Match" validate:"required"` // Specifies the type of access granted by the policy. - Control *V2PolicyBaseControl `json:"control" validate:"required"` + Control *Control `json:"control" validate:"required"` - // Customer-defined description. + // The policy type; either 'access' or 'authorization'. + Type *string `json:"type" validate:"required"` + + // Allows the customer to use their own words to record the purpose/context related to a policy. Description *string `json:"description,omitempty"` - // The subject attributes associated with a policy. - Subject *V2PolicyBaseSubject `json:"subject,omitempty"` + // The subject attributes for whom the policy grants access. + Subject *V2PolicySubject `json:"subject,omitempty"` - // The resource attributes associated with a policy. - Resource *V2PolicyBaseResource `json:"resource,omitempty"` + // The resource attributes to which the policy grants access. + Resource *V2PolicyResource `json:"resource,omitempty"` - // Indicates pattern of rule. + // Indicates pattern of rule, either 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or + // 'time-based-conditions:weekly:custom-hours'. Pattern *string `json:"pattern,omitempty"` - // Additional access conditions associated with a policy. - Rule V2PolicyBaseRuleIntf `json:"rule,omitempty"` - - // 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"` + // Additional access conditions associated with the policy. + Rule V2PolicyRuleIntf `json:"rule,omitempty"` // Allows users to set headers on API requests Headers map[string]string } -// NewV2CreatePolicyOptions : Instantiate V2CreatePolicyOptions -func (*IamPolicyManagementV1) NewV2CreatePolicyOptions(typeVar string, control *V2PolicyBaseControl) *V2CreatePolicyOptions { - return &V2CreatePolicyOptions{ - Type: core.StringPtr(typeVar), +// Constants associated with the ReplaceV2PolicyOptions.Type property. +// The policy type; either 'access' or 'authorization'. +const ( + ReplaceV2PolicyOptionsTypeAccessConst = "access" + ReplaceV2PolicyOptionsTypeAuthorizationConst = "authorization" +) + +// NewReplaceV2PolicyOptions : Instantiate ReplaceV2PolicyOptions +func (*IamPolicyManagementV1) NewReplaceV2PolicyOptions(id string, ifMatch string, control *Control, typeVar string) *ReplaceV2PolicyOptions { + return &ReplaceV2PolicyOptions{ + ID: core.StringPtr(id), + IfMatch: core.StringPtr(ifMatch), Control: control, + Type: core.StringPtr(typeVar), } } -// SetType : Allow user to set Type -func (_options *V2CreatePolicyOptions) SetType(typeVar string) *V2CreatePolicyOptions { - _options.Type = core.StringPtr(typeVar) +// SetID : Allow user to set ID +func (_options *ReplaceV2PolicyOptions) SetID(id string) *ReplaceV2PolicyOptions { + _options.ID = core.StringPtr(id) + return _options +} + +// SetIfMatch : Allow user to set IfMatch +func (_options *ReplaceV2PolicyOptions) SetIfMatch(ifMatch string) *ReplaceV2PolicyOptions { + _options.IfMatch = core.StringPtr(ifMatch) return _options } // SetControl : Allow user to set Control -func (_options *V2CreatePolicyOptions) SetControl(control *V2PolicyBaseControl) *V2CreatePolicyOptions { +func (_options *ReplaceV2PolicyOptions) SetControl(control *Control) *ReplaceV2PolicyOptions { _options.Control = control return _options } +// SetType : Allow user to set Type +func (_options *ReplaceV2PolicyOptions) SetType(typeVar string) *ReplaceV2PolicyOptions { + _options.Type = core.StringPtr(typeVar) + return _options +} + // SetDescription : Allow user to set Description -func (_options *V2CreatePolicyOptions) SetDescription(description string) *V2CreatePolicyOptions { +func (_options *ReplaceV2PolicyOptions) SetDescription(description string) *ReplaceV2PolicyOptions { _options.Description = core.StringPtr(description) return _options } // SetSubject : Allow user to set Subject -func (_options *V2CreatePolicyOptions) SetSubject(subject *V2PolicyBaseSubject) *V2CreatePolicyOptions { +func (_options *ReplaceV2PolicyOptions) SetSubject(subject *V2PolicySubject) *ReplaceV2PolicyOptions { _options.Subject = subject return _options } // SetResource : Allow user to set Resource -func (_options *V2CreatePolicyOptions) SetResource(resource *V2PolicyBaseResource) *V2CreatePolicyOptions { +func (_options *ReplaceV2PolicyOptions) SetResource(resource *V2PolicyResource) *ReplaceV2PolicyOptions { _options.Resource = resource return _options } // SetPattern : Allow user to set Pattern -func (_options *V2CreatePolicyOptions) SetPattern(pattern string) *V2CreatePolicyOptions { +func (_options *ReplaceV2PolicyOptions) SetPattern(pattern string) *ReplaceV2PolicyOptions { _options.Pattern = core.StringPtr(pattern) return _options } // SetRule : Allow user to set Rule -func (_options *V2CreatePolicyOptions) SetRule(rule V2PolicyBaseRuleIntf) *V2CreatePolicyOptions { +func (_options *ReplaceV2PolicyOptions) SetRule(rule V2PolicyRuleIntf) *ReplaceV2PolicyOptions { _options.Rule = rule return _options } -// SetAcceptLanguage : Allow user to set AcceptLanguage -func (_options *V2CreatePolicyOptions) SetAcceptLanguage(acceptLanguage string) *V2CreatePolicyOptions { - _options.AcceptLanguage = core.StringPtr(acceptLanguage) - return _options -} - // SetHeaders : Allow user to set Headers -func (options *V2CreatePolicyOptions) SetHeaders(param map[string]string) *V2CreatePolicyOptions { +func (options *ReplaceV2PolicyOptions) SetHeaders(param map[string]string) *ReplaceV2PolicyOptions { options.Headers = param return options } -// V2DeletePolicyOptions : The V2DeletePolicy options. -type V2DeletePolicyOptions struct { - // The policy ID. - PolicyID *string `json:"policy_id" validate:"required,ne="` +// RoleAction : An action that can be performed by the policy subject when assigned role. +type RoleAction struct { + // Unique identifier for action with structure service.resource.action e.g., cbr.rule.read. + ID *string `json:"id" validate:"required"` - // Allows users to set headers on API requests - Headers map[string]string + // Service defined display name for action. + DisplayName *string `json:"display_name" validate:"required"` + + // Service defined description for action. + Description *string `json:"description" validate:"required"` } -// NewV2DeletePolicyOptions : Instantiate V2DeletePolicyOptions -func (*IamPolicyManagementV1) NewV2DeletePolicyOptions(policyID string) *V2DeletePolicyOptions { - return &V2DeletePolicyOptions{ - PolicyID: core.StringPtr(policyID), +// UnmarshalRoleAction unmarshals an instance of RoleAction from the specified map of raw messages. +func UnmarshalRoleAction(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(RoleAction) + err = core.UnmarshalPrimitive(m, "id", &obj.ID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "display_name", &obj.DisplayName) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "description", &obj.Description) + if err != nil { + return } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return } -// SetPolicyID : Allow user to set PolicyID -func (_options *V2DeletePolicyOptions) SetPolicyID(policyID string) *V2DeletePolicyOptions { - _options.PolicyID = core.StringPtr(policyID) - return _options +// RoleInDisplayFormat : A role associated with a policy with additional information (display_name, description, actions) when +// `format=display`. +type RoleInDisplayFormat struct { + // 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 service defined (or user defined if a custom role) display name of the role. + DisplayName *string `json:"display_name,omitempty"` + + // The service defined (or user defined if a custom role) description of the role. + Description *string `json:"description,omitempty"` + + // 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 []RoleAction `json:"actions" validate:"required"` } -// SetHeaders : Allow user to set Headers -func (options *V2DeletePolicyOptions) SetHeaders(param map[string]string) *V2DeletePolicyOptions { - options.Headers = param - return options +// UnmarshalRoleInDisplayFormat unmarshals an instance of RoleInDisplayFormat from the specified map of raw messages. +func UnmarshalRoleInDisplayFormat(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(RoleInDisplayFormat) + err = core.UnmarshalPrimitive(m, "role_id", &obj.RoleID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "display_name", &obj.DisplayName) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "description", &obj.Description) + if err != nil { + return + } + err = core.UnmarshalModel(m, "actions", &obj.Actions, UnmarshalRoleAction) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// RuleAttribute : Rule that specifies additional access granted (e.g., time-based condition). +type RuleAttribute struct { + // The name of an attribute. + Key *string `json:"key" validate:"required"` + + // The operator of an attribute. + Operator *string `json:"operator" validate:"required"` + + // The value of an rule or resource attribute; can be boolean or string for resource attribute. Can be a string or an + // array of strings (e.g., array of days to permit access) for rule attribute. + Value interface{} `json:"value" validate:"required"` +} + +// Constants associated with the RuleAttribute.Operator property. +// The operator of an attribute. +const ( + RuleAttributeOperatorDatetimegreaterthanConst = "dateTimeGreaterThan" + RuleAttributeOperatorDatetimegreaterthanorequalsConst = "dateTimeGreaterThanOrEquals" + RuleAttributeOperatorDatetimelessthanConst = "dateTimeLessThan" + RuleAttributeOperatorDatetimelessthanorequalsConst = "dateTimeLessThanOrEquals" + RuleAttributeOperatorDayofweekanyofConst = "dayOfWeekAnyOf" + RuleAttributeOperatorDayofweekequalsConst = "dayOfWeekEquals" + RuleAttributeOperatorTimegreaterthanConst = "timeGreaterThan" + RuleAttributeOperatorTimegreaterthanorequalsConst = "timeGreaterThanOrEquals" + RuleAttributeOperatorTimelessthanConst = "timeLessThan" + RuleAttributeOperatorTimelessthanorequalsConst = "timeLessThanOrEquals" +) + +// NewRuleAttribute : Instantiate RuleAttribute (Generic Model Constructor) +func (*IamPolicyManagementV1) NewRuleAttribute(key string, operator string, value interface{}) (_model *RuleAttribute, err error) { + _model = &RuleAttribute{ + Key: core.StringPtr(key), + Operator: core.StringPtr(operator), + Value: value, + } + err = core.ValidateStruct(_model, "required parameters") + return +} + +// UnmarshalRuleAttribute unmarshals an instance of RuleAttribute from the specified map of raw messages. +func UnmarshalRuleAttribute(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(RuleAttribute) + err = core.UnmarshalPrimitive(m, "key", &obj.Key) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "operator", &obj.Operator) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "value", &obj.Value) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return } -// V2GetPolicyOptions : The V2GetPolicy options. -type V2GetPolicyOptions struct { +// UpdatePolicyStateOptions : The UpdatePolicyState options. +type UpdatePolicyStateOptions struct { // The policy ID. 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 `json:"If-Match" validate:"required"` + + // The policy state. + State *string `json:"state,omitempty"` + // Allows users to set headers on API requests Headers map[string]string } -// NewV2GetPolicyOptions : Instantiate V2GetPolicyOptions -func (*IamPolicyManagementV1) NewV2GetPolicyOptions(policyID string) *V2GetPolicyOptions { - return &V2GetPolicyOptions{ +// Constants associated with the UpdatePolicyStateOptions.State property. +// The policy state. +const ( + UpdatePolicyStateOptionsStateActiveConst = "active" + UpdatePolicyStateOptionsStateDeletedConst = "deleted" +) + +// NewUpdatePolicyStateOptions : Instantiate UpdatePolicyStateOptions +func (*IamPolicyManagementV1) NewUpdatePolicyStateOptions(policyID string, ifMatch string) *UpdatePolicyStateOptions { + return &UpdatePolicyStateOptions{ PolicyID: core.StringPtr(policyID), + IfMatch: core.StringPtr(ifMatch), } } // SetPolicyID : Allow user to set PolicyID -func (_options *V2GetPolicyOptions) SetPolicyID(policyID string) *V2GetPolicyOptions { +func (_options *UpdatePolicyStateOptions) SetPolicyID(policyID string) *UpdatePolicyStateOptions { _options.PolicyID = core.StringPtr(policyID) return _options } +// SetIfMatch : Allow user to set IfMatch +func (_options *UpdatePolicyStateOptions) SetIfMatch(ifMatch string) *UpdatePolicyStateOptions { + _options.IfMatch = core.StringPtr(ifMatch) + return _options +} + +// SetState : Allow user to set State +func (_options *UpdatePolicyStateOptions) SetState(state string) *UpdatePolicyStateOptions { + _options.State = core.StringPtr(state) + return _options +} + // SetHeaders : Allow user to set Headers -func (options *V2GetPolicyOptions) SetHeaders(param map[string]string) *V2GetPolicyOptions { +func (options *UpdatePolicyStateOptions) SetHeaders(param map[string]string) *UpdatePolicyStateOptions { options.Headers = param return options } -// V2ListPoliciesOptions : The V2ListPolicies options. -type V2ListPoliciesOptions struct { - // The account GUID in which the policies belong to. - 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"` +// V2Policy : The core set of properties associated with the policy. +type V2Policy struct { + // The policy type; either 'access' or 'authorization'. + Type *string `json:"type" validate:"required"` - // Optional IAM ID used to identify the subject. - IamID *string `json:"iam_id,omitempty"` + // Allows the customer to use their own words to record the purpose/context related to a policy. + Description *string `json:"description,omitempty"` - // Optional access group id. - AccessGroupID *string `json:"access_group_id,omitempty"` + // The subject attributes for whom the policy grants access. + Subject *V2PolicySubject `json:"subject,omitempty"` - // Optional type of policy. - Type *string `json:"type,omitempty"` + // The resource attributes to which the policy grants access. + Resource *V2PolicyResource `json:"resource,omitempty"` - // Optional type of service. - ServiceType *string `json:"service_type,omitempty"` + // Indicates pattern of rule, either 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or + // 'time-based-conditions:weekly:custom-hours'. + Pattern *string `json:"pattern,omitempty"` - // Optional name of service. - ServiceName *string `json:"service_name,omitempty"` + // Additional access conditions associated with the policy. + Rule V2PolicyRuleIntf `json:"rule,omitempty"` - // Optional ID of service group. - ServiceGroupID *string `json:"service_group_id,omitempty"` + // The policy ID. + ID *string `json:"id,omitempty"` - // 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 and translations for all relevant - // fields. - Format *string `json:"format,omitempty"` + // The href URL that links to the policies API by policy ID. + Href *string `json:"href,omitempty"` - // The state of the policy. - // * `active` - returns active policies - // * `deleted` - returns non-active policies. - State *string `json:"state,omitempty"` + Control ControlResponseIntf `json:"control" validate:"required"` - // Allows users to set headers on API requests - Headers map[string]string -} + // The UTC timestamp when the policy was created. + CreatedAt *strfmt.DateTime `json:"created_at,omitempty"` -// Constants associated with the V2ListPoliciesOptions.Type property. -// Optional type of policy. -const ( - V2ListPoliciesOptionsTypeAccessConst = "access" - V2ListPoliciesOptionsTypeAuthorizationConst = "authorization" -) + // The iam ID of the entity that created the policy. + CreatedByID *string `json:"created_by_id,omitempty"` -// Constants associated with the V2ListPoliciesOptions.ServiceType property. -// Optional type of service. -const ( - V2ListPoliciesOptionsServiceTypePlatformServiceConst = "platform_service" - V2ListPoliciesOptionsServiceTypeServiceConst = "service" -) + // The UTC timestamp when the policy was last modified. + LastModifiedAt *strfmt.DateTime `json:"last_modified_at,omitempty"` -// Constants associated with the V2ListPoliciesOptions.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 and translations for all relevant -// fields. + // The iam ID of the entity that last modified the policy. + LastModifiedByID *string `json:"last_modified_by_id,omitempty"` + + // The policy state, either 'deleted' or 'active'. + State *string `json:"state" validate:"required"` + + // The optional last permit time of policy, when passing query parameter format=include_last_permit. + LastPermitAt *string `json:"last_permit_at,omitempty"` + + // The optional count of times that policy has provided a permit, when passing query parameter + // format=include_last_permit. + LastPermitFrequency *int64 `json:"last_permit_frequency,omitempty"` +} + +// Constants associated with the V2Policy.Type property. +// The policy type; either 'access' or 'authorization'. const ( - V2ListPoliciesOptionsFormatDisplayConst = "display" - V2ListPoliciesOptionsFormatIncludeLastPermitConst = "include_last_permit" + V2PolicyTypeAccessConst = "access" + V2PolicyTypeAuthorizationConst = "authorization" ) -// Constants associated with the V2ListPoliciesOptions.State property. -// The state of the policy. -// * `active` - returns active policies -// * `deleted` - returns non-active policies. +// Constants associated with the V2Policy.State property. +// The policy state, either 'deleted' or 'active'. const ( - V2ListPoliciesOptionsStateActiveConst = "active" - V2ListPoliciesOptionsStateDeletedConst = "deleted" + V2PolicyStateActiveConst = "active" + V2PolicyStateDeletedConst = "deleted" ) -// NewV2ListPoliciesOptions : Instantiate V2ListPoliciesOptions -func (*IamPolicyManagementV1) NewV2ListPoliciesOptions(accountID string) *V2ListPoliciesOptions { - return &V2ListPoliciesOptions{ - AccountID: core.StringPtr(accountID), +// UnmarshalV2Policy unmarshals an instance of V2Policy from the specified map of raw messages. +func UnmarshalV2Policy(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(V2Policy) + err = core.UnmarshalPrimitive(m, "type", &obj.Type) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "description", &obj.Description) + if err != nil { + return + } + err = core.UnmarshalModel(m, "subject", &obj.Subject, UnmarshalV2PolicySubject) + if err != nil { + return + } + err = core.UnmarshalModel(m, "resource", &obj.Resource, UnmarshalV2PolicyResource) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "pattern", &obj.Pattern) + if err != nil { + return + } + err = core.UnmarshalModel(m, "rule", &obj.Rule, UnmarshalV2PolicyRule) + if err != nil { + return } + err = core.UnmarshalPrimitive(m, "id", &obj.ID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "href", &obj.Href) + if err != nil { + return + } + err = core.UnmarshalModel(m, "control", &obj.Control, UnmarshalControlResponse) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "created_at", &obj.CreatedAt) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "created_by_id", &obj.CreatedByID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "last_modified_at", &obj.LastModifiedAt) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "last_modified_by_id", &obj.LastModifiedByID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "state", &obj.State) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "last_permit_at", &obj.LastPermitAt) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "last_permit_frequency", &obj.LastPermitFrequency) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return } -// SetAccountID : Allow user to set AccountID -func (_options *V2ListPoliciesOptions) SetAccountID(accountID string) *V2ListPoliciesOptions { - _options.AccountID = core.StringPtr(accountID) - return _options +// V2PolicyCollection : A collection of policies. +type V2PolicyCollection struct { + // List of policies. + Policies []V2Policy `json:"policies,omitempty"` } -// SetAcceptLanguage : Allow user to set AcceptLanguage -func (_options *V2ListPoliciesOptions) SetAcceptLanguage(acceptLanguage string) *V2ListPoliciesOptions { - _options.AcceptLanguage = core.StringPtr(acceptLanguage) - return _options +// UnmarshalV2PolicyCollection unmarshals an instance of V2PolicyCollection from the specified map of raw messages. +func UnmarshalV2PolicyCollection(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(V2PolicyCollection) + err = core.UnmarshalModel(m, "policies", &obj.Policies, UnmarshalV2Policy) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return } -// SetIamID : Allow user to set IamID -func (_options *V2ListPoliciesOptions) SetIamID(iamID string) *V2ListPoliciesOptions { - _options.IamID = core.StringPtr(iamID) - return _options +// V2PolicyGrant : Permission granted by the policy. +type V2PolicyGrant struct { + // A set of role cloud resource names (CRNs) granted by the policy. + Roles []PolicyRole `json:"roles" validate:"required"` } -// SetAccessGroupID : Allow user to set AccessGroupID -func (_options *V2ListPoliciesOptions) SetAccessGroupID(accessGroupID string) *V2ListPoliciesOptions { - _options.AccessGroupID = core.StringPtr(accessGroupID) - return _options +// NewV2PolicyGrant : Instantiate V2PolicyGrant (Generic Model Constructor) +func (*IamPolicyManagementV1) NewV2PolicyGrant(roles []PolicyRole) (_model *V2PolicyGrant, err error) { + _model = &V2PolicyGrant{ + Roles: roles, + } + err = core.ValidateStruct(_model, "required parameters") + return } -// SetType : Allow user to set Type -func (_options *V2ListPoliciesOptions) SetType(typeVar string) *V2ListPoliciesOptions { - _options.Type = core.StringPtr(typeVar) - return _options +// UnmarshalV2PolicyGrant unmarshals an instance of V2PolicyGrant from the specified map of raw messages. +func UnmarshalV2PolicyGrant(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(V2PolicyGrant) + err = core.UnmarshalModel(m, "roles", &obj.Roles, UnmarshalPolicyRole) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return } -// SetServiceType : Allow user to set ServiceType -func (_options *V2ListPoliciesOptions) SetServiceType(serviceType string) *V2ListPoliciesOptions { - _options.ServiceType = core.StringPtr(serviceType) - return _options -} +// V2PolicyResource : The resource attributes to which the policy grants access. +type V2PolicyResource struct { + // List of resource attributes to which the policy grants access. + Attributes []V2PolicyResourceAttribute `json:"attributes" validate:"required"` -// SetServiceName : Allow user to set ServiceName -func (_options *V2ListPoliciesOptions) SetServiceName(serviceName string) *V2ListPoliciesOptions { - _options.ServiceName = core.StringPtr(serviceName) - return _options + // Optional list of resource tags to which the policy grants access. + Tags []V2PolicyResourceTag `json:"tags,omitempty"` } -// SetServiceGroupID : Allow user to set ServiceGroupID -func (_options *V2ListPoliciesOptions) SetServiceGroupID(serviceGroupID string) *V2ListPoliciesOptions { - _options.ServiceGroupID = core.StringPtr(serviceGroupID) - return _options +// NewV2PolicyResource : Instantiate V2PolicyResource (Generic Model Constructor) +func (*IamPolicyManagementV1) NewV2PolicyResource(attributes []V2PolicyResourceAttribute) (_model *V2PolicyResource, err error) { + _model = &V2PolicyResource{ + Attributes: attributes, + } + err = core.ValidateStruct(_model, "required parameters") + return } -// SetFormat : Allow user to set Format -func (_options *V2ListPoliciesOptions) SetFormat(format string) *V2ListPoliciesOptions { - _options.Format = core.StringPtr(format) - return _options +// UnmarshalV2PolicyResource unmarshals an instance of V2PolicyResource from the specified map of raw messages. +func UnmarshalV2PolicyResource(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(V2PolicyResource) + err = core.UnmarshalModel(m, "attributes", &obj.Attributes, UnmarshalV2PolicyResourceAttribute) + if err != nil { + return + } + err = core.UnmarshalModel(m, "tags", &obj.Tags, UnmarshalV2PolicyResourceTag) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return } -// SetState : Allow user to set State -func (_options *V2ListPoliciesOptions) SetState(state string) *V2ListPoliciesOptions { - _options.State = core.StringPtr(state) - return _options -} +// V2PolicyResourceAttribute : Resource attribute to which the policy grants access. +type V2PolicyResourceAttribute struct { + // The name of a resource attribute. + Key *string `json:"key" validate:"required"` -// SetHeaders : Allow user to set Headers -func (options *V2ListPoliciesOptions) SetHeaders(param map[string]string) *V2ListPoliciesOptions { - options.Headers = param - return options -} + // The operator of an attribute. + Operator *string `json:"operator" validate:"required"` -// V2PolicyBaseControl : Specifies the type of access granted by the policy. -type V2PolicyBaseControl struct { - // Permission granted by the policy. - Grant *V2PolicyBaseControlGrant `json:"grant" validate:"required"` + // The value of an rule or resource attribute; can be boolean or string for resource attribute. Can be a string or an + // array of strings (e.g., array of days to permit access) for rule attribute. + Value interface{} `json:"value" validate:"required"` } -// NewV2PolicyBaseControl : Instantiate V2PolicyBaseControl (Generic Model Constructor) -func (*IamPolicyManagementV1) NewV2PolicyBaseControl(grant *V2PolicyBaseControlGrant) (_model *V2PolicyBaseControl, err error) { - _model = &V2PolicyBaseControl{ - Grant: grant, +// Constants associated with the V2PolicyResourceAttribute.Operator property. +// The operator of an attribute. +const ( + V2PolicyResourceAttributeOperatorStringequalsConst = "stringEquals" + V2PolicyResourceAttributeOperatorStringexistsConst = "stringExists" + V2PolicyResourceAttributeOperatorStringmatchConst = "stringMatch" +) + +// NewV2PolicyResourceAttribute : Instantiate V2PolicyResourceAttribute (Generic Model Constructor) +func (*IamPolicyManagementV1) NewV2PolicyResourceAttribute(key string, operator string, value interface{}) (_model *V2PolicyResourceAttribute, err error) { + _model = &V2PolicyResourceAttribute{ + Key: core.StringPtr(key), + Operator: core.StringPtr(operator), + Value: value, } err = core.ValidateStruct(_model, "required parameters") return } -// UnmarshalV2PolicyBaseControl unmarshals an instance of V2PolicyBaseControl from the specified map of raw messages. -func UnmarshalV2PolicyBaseControl(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(V2PolicyBaseControl) - err = core.UnmarshalModel(m, "grant", &obj.Grant, UnmarshalV2PolicyBaseControlGrant) +// UnmarshalV2PolicyResourceAttribute unmarshals an instance of V2PolicyResourceAttribute from the specified map of raw messages. +func UnmarshalV2PolicyResourceAttribute(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(V2PolicyResourceAttribute) + err = core.UnmarshalPrimitive(m, "key", &obj.Key) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "operator", &obj.Operator) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "value", &obj.Value) if err != nil { return } @@ -2613,42 +3222,48 @@ func UnmarshalV2PolicyBaseControl(m map[string]json.RawMessage, result interface return } -// V2PolicyBaseControlGrant : Permission granted by the policy. -type V2PolicyBaseControlGrant struct { - // A set of role cloud resource names (CRNs) granted by the policy. - Roles []PolicyRole `json:"roles" validate:"required"` +// V2PolicyResourceTag : A tag associated with a resource. +type V2PolicyResourceTag struct { + // The name of an access management tag. + Key *string `json:"key" validate:"required"` + + // The value of an access management tag. + Value *string `json:"value" validate:"required"` + + // The operator of an access management tag. + Operator *string `json:"operator" validate:"required"` } -// NewV2PolicyBaseControlGrant : Instantiate V2PolicyBaseControlGrant (Generic Model Constructor) -func (*IamPolicyManagementV1) NewV2PolicyBaseControlGrant(roles []PolicyRole) (_model *V2PolicyBaseControlGrant, err error) { - _model = &V2PolicyBaseControlGrant{ - Roles: roles, +// Constants associated with the V2PolicyResourceTag.Operator property. +// The operator of an access management tag. +const ( + V2PolicyResourceTagOperatorStringequalsConst = "stringEquals" + V2PolicyResourceTagOperatorStringmatchConst = "stringMatch" +) + +// NewV2PolicyResourceTag : Instantiate V2PolicyResourceTag (Generic Model Constructor) +func (*IamPolicyManagementV1) NewV2PolicyResourceTag(key string, value string, operator string) (_model *V2PolicyResourceTag, err error) { + _model = &V2PolicyResourceTag{ + Key: core.StringPtr(key), + Value: core.StringPtr(value), + Operator: core.StringPtr(operator), } err = core.ValidateStruct(_model, "required parameters") return } -// UnmarshalV2PolicyBaseControlGrant unmarshals an instance of V2PolicyBaseControlGrant from the specified map of raw messages. -func UnmarshalV2PolicyBaseControlGrant(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(V2PolicyBaseControlGrant) - err = core.UnmarshalModel(m, "roles", &obj.Roles, UnmarshalPolicyRole) +// UnmarshalV2PolicyResourceTag unmarshals an instance of V2PolicyResourceTag from the specified map of raw messages. +func UnmarshalV2PolicyResourceTag(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(V2PolicyResourceTag) + err = core.UnmarshalPrimitive(m, "key", &obj.Key) if err != nil { return } - reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) - return -} - -// V2PolicyBaseResource : The resource attributes associated with a policy. -type V2PolicyBaseResource struct { - // List of resource attributes associated with policy/. - Attributes []V2PolicyAttribute `json:"attributes,omitempty"` -} - -// UnmarshalV2PolicyBaseResource unmarshals an instance of V2PolicyBaseResource from the specified map of raw messages. -func UnmarshalV2PolicyBaseResource(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(V2PolicyBaseResource) - err = core.UnmarshalModel(m, "attributes", &obj.Attributes, UnmarshalV2PolicyAttribute) + err = core.UnmarshalPrimitive(m, "value", &obj.Value) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "operator", &obj.Operator) if err != nil { return } @@ -2656,34 +3271,51 @@ func UnmarshalV2PolicyBaseResource(m map[string]json.RawMessage, result interfac return } -// V2PolicyBaseRule : Additional access conditions associated with a policy. +// V2PolicyRule : Additional access conditions associated with the policy. // Models which "extend" this model: -// - V2PolicyBaseRuleV2PolicyAttribute -// - V2PolicyBaseRuleV2RuleWithConditions -type V2PolicyBaseRule struct { +// - V2PolicyRuleRuleAttribute +// - V2PolicyRuleRuleWithConditions +type V2PolicyRule struct { // The name of an attribute. Key *string `json:"key,omitempty"` // The operator of an attribute. Operator *string `json:"operator,omitempty"` - // The value of an attribute; can be array, boolean, string, or integer. + // The value of an rule or resource attribute; can be boolean or string for resource attribute. Can be a string or an + // array of strings (e.g., array of days to permit access) for rule attribute. Value interface{} `json:"value,omitempty"` - // List of conditions to associated with a policy. Note that conditions can be nested up to 2 levels. - Conditions []V2PolicyAttribute `json:"conditions,omitempty"` + // List of conditions associated with a policy, e.g., time-based-conditions that grant access over a certain time + // period. + Conditions []RuleAttribute `json:"conditions,omitempty"` } -func (*V2PolicyBaseRule) isaV2PolicyBaseRule() bool { + +// Constants associated with the V2PolicyRule.Operator property. +// The operator of an attribute. +const ( + V2PolicyRuleOperatorDatetimegreaterthanConst = "dateTimeGreaterThan" + V2PolicyRuleOperatorDatetimegreaterthanorequalsConst = "dateTimeGreaterThanOrEquals" + V2PolicyRuleOperatorDatetimelessthanConst = "dateTimeLessThan" + V2PolicyRuleOperatorDatetimelessthanorequalsConst = "dateTimeLessThanOrEquals" + V2PolicyRuleOperatorDayofweekanyofConst = "dayOfWeekAnyOf" + V2PolicyRuleOperatorDayofweekequalsConst = "dayOfWeekEquals" + V2PolicyRuleOperatorTimegreaterthanConst = "timeGreaterThan" + V2PolicyRuleOperatorTimegreaterthanorequalsConst = "timeGreaterThanOrEquals" + V2PolicyRuleOperatorTimelessthanConst = "timeLessThan" + V2PolicyRuleOperatorTimelessthanorequalsConst = "timeLessThanOrEquals" +) +func (*V2PolicyRule) isaV2PolicyRule() bool { return true } -type V2PolicyBaseRuleIntf interface { - isaV2PolicyBaseRule() bool +type V2PolicyRuleIntf interface { + isaV2PolicyRule() bool } -// UnmarshalV2PolicyBaseRule unmarshals an instance of V2PolicyBaseRule from the specified map of raw messages. -func UnmarshalV2PolicyBaseRule(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(V2PolicyBaseRule) +// UnmarshalV2PolicyRule unmarshals an instance of V2PolicyRule from the specified map of raw messages. +func UnmarshalV2PolicyRule(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(V2PolicyRule) err = core.UnmarshalPrimitive(m, "key", &obj.Key) if err != nil { return @@ -2696,133 +3328,86 @@ func UnmarshalV2PolicyBaseRule(m map[string]json.RawMessage, result interface{}) if err != nil { return } - err = core.UnmarshalModel(m, "conditions", &obj.Conditions, UnmarshalV2PolicyAttribute) - if err != nil { - return - } - reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) - return -} - -// V2PolicyBaseSubject : The subject attributes associated with a policy. -type V2PolicyBaseSubject struct { - // List of subject attributes associated with policy/. - Attributes []V2PolicyAttribute `json:"attributes,omitempty"` -} - -// UnmarshalV2PolicyBaseSubject unmarshals an instance of V2PolicyBaseSubject from the specified map of raw messages. -func UnmarshalV2PolicyBaseSubject(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(V2PolicyBaseSubject) - err = core.UnmarshalModel(m, "attributes", &obj.Attributes, UnmarshalV2PolicyAttribute) + err = core.UnmarshalModel(m, "conditions", &obj.Conditions, UnmarshalRuleAttribute) if err != nil { return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) - return -} - -// V2UpdatePolicyOptions : The V2UpdatePolicy options. -type V2UpdatePolicyOptions struct { - // The policy ID. - 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 `json:"If-Match" validate:"required"` - - // The policy type; either 'access' or 'authorization'. - Type *string `json:"type" validate:"required"` - - // Specifies the type of access granted by the policy. - Control *V2PolicyBaseControl `json:"control" validate:"required"` - - // Customer-defined description. - Description *string `json:"description,omitempty"` - - // The subject attributes associated with a policy. - Subject *V2PolicyBaseSubject `json:"subject,omitempty"` - - // The resource attributes associated with a policy. - Resource *V2PolicyBaseResource `json:"resource,omitempty"` - - // Indicates pattern of rule. - Pattern *string `json:"pattern,omitempty"` - - // Additional access conditions associated with a policy. - Rule V2PolicyBaseRuleIntf `json:"rule,omitempty"` - - // Allows users to set headers on API requests - Headers map[string]string -} - -// NewV2UpdatePolicyOptions : Instantiate V2UpdatePolicyOptions -func (*IamPolicyManagementV1) NewV2UpdatePolicyOptions(policyID string, ifMatch string, typeVar string, control *V2PolicyBaseControl) *V2UpdatePolicyOptions { - return &V2UpdatePolicyOptions{ - PolicyID: core.StringPtr(policyID), - IfMatch: core.StringPtr(ifMatch), - Type: core.StringPtr(typeVar), - Control: control, - } -} - -// SetPolicyID : Allow user to set PolicyID -func (_options *V2UpdatePolicyOptions) SetPolicyID(policyID string) *V2UpdatePolicyOptions { - _options.PolicyID = core.StringPtr(policyID) - return _options -} - -// SetIfMatch : Allow user to set IfMatch -func (_options *V2UpdatePolicyOptions) SetIfMatch(ifMatch string) *V2UpdatePolicyOptions { - _options.IfMatch = core.StringPtr(ifMatch) - return _options -} - -// SetType : Allow user to set Type -func (_options *V2UpdatePolicyOptions) SetType(typeVar string) *V2UpdatePolicyOptions { - _options.Type = core.StringPtr(typeVar) - return _options + return } -// SetControl : Allow user to set Control -func (_options *V2UpdatePolicyOptions) SetControl(control *V2PolicyBaseControl) *V2UpdatePolicyOptions { - _options.Control = control - return _options +// V2PolicySubject : The subject attributes for whom the policy grants access. +type V2PolicySubject struct { + // List of subject attributes associated with policy/. + Attributes []V2PolicySubjectAttribute `json:"attributes" validate:"required"` } -// SetDescription : Allow user to set Description -func (_options *V2UpdatePolicyOptions) SetDescription(description string) *V2UpdatePolicyOptions { - _options.Description = core.StringPtr(description) - return _options +// NewV2PolicySubject : Instantiate V2PolicySubject (Generic Model Constructor) +func (*IamPolicyManagementV1) NewV2PolicySubject(attributes []V2PolicySubjectAttribute) (_model *V2PolicySubject, err error) { + _model = &V2PolicySubject{ + Attributes: attributes, + } + err = core.ValidateStruct(_model, "required parameters") + return } -// SetSubject : Allow user to set Subject -func (_options *V2UpdatePolicyOptions) SetSubject(subject *V2PolicyBaseSubject) *V2UpdatePolicyOptions { - _options.Subject = subject - return _options +// UnmarshalV2PolicySubject unmarshals an instance of V2PolicySubject from the specified map of raw messages. +func UnmarshalV2PolicySubject(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(V2PolicySubject) + err = core.UnmarshalModel(m, "attributes", &obj.Attributes, UnmarshalV2PolicySubjectAttribute) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return } -// SetResource : Allow user to set Resource -func (_options *V2UpdatePolicyOptions) SetResource(resource *V2PolicyBaseResource) *V2UpdatePolicyOptions { - _options.Resource = resource - return _options -} +// V2PolicySubjectAttribute : Subject attribute for whom the policy grants access. +type V2PolicySubjectAttribute struct { + // The name of a subject attribute, e.g., iam_id, access_group_id. + Key *string `json:"key" validate:"required"` -// SetPattern : Allow user to set Pattern -func (_options *V2UpdatePolicyOptions) SetPattern(pattern string) *V2UpdatePolicyOptions { - _options.Pattern = core.StringPtr(pattern) - return _options + // The operator of an attribute. + Operator *string `json:"operator" validate:"required"` + + // The value of the ID of the subject, e.g., service ID, access group ID, IAM ID. + Value *string `json:"value" validate:"required"` } -// SetRule : Allow user to set Rule -func (_options *V2UpdatePolicyOptions) SetRule(rule V2PolicyBaseRuleIntf) *V2UpdatePolicyOptions { - _options.Rule = rule - return _options +// Constants associated with the V2PolicySubjectAttribute.Operator property. +// The operator of an attribute. +const ( + V2PolicySubjectAttributeOperatorStringequalsConst = "stringEquals" +) + +// NewV2PolicySubjectAttribute : Instantiate V2PolicySubjectAttribute (Generic Model Constructor) +func (*IamPolicyManagementV1) NewV2PolicySubjectAttribute(key string, operator string, value string) (_model *V2PolicySubjectAttribute, err error) { + _model = &V2PolicySubjectAttribute{ + Key: core.StringPtr(key), + Operator: core.StringPtr(operator), + Value: core.StringPtr(value), + } + err = core.ValidateStruct(_model, "required parameters") + return } -// SetHeaders : Allow user to set Headers -func (options *V2UpdatePolicyOptions) SetHeaders(param map[string]string) *V2UpdatePolicyOptions { - options.Headers = param - return options +// UnmarshalV2PolicySubjectAttribute unmarshals an instance of V2PolicySubjectAttribute from the specified map of raw messages. +func UnmarshalV2PolicySubjectAttribute(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(V2PolicySubjectAttribute) + err = core.UnmarshalPrimitive(m, "key", &obj.Key) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "operator", &obj.Operator) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "value", &obj.Value) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return } // CustomRole : An additional set of properties associated with a role. @@ -2831,27 +3416,27 @@ type CustomRole struct { ID *string `json:"id,omitempty"` // The display name of the role that is shown in the console. - DisplayName *string `json:"display_name,omitempty"` + DisplayName *string `json:"display_name" validate:"required"` // The description of the role. Description *string `json:"description,omitempty"` // 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"` + Actions []string `json:"actions" validate:"required"` // 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. - Name *string `json:"name,omitempty"` + Name *string `json:"name" validate:"required"` // The account GUID. - AccountID *string `json:"account_id,omitempty"` + AccountID *string `json:"account_id" validate:"required"` // The service name. - ServiceName *string `json:"service_name,omitempty"` + ServiceName *string `json:"service_name" validate:"required"` // The UTC timestamp when the role was created. CreatedAt *strfmt.DateTime `json:"created_at,omitempty"` @@ -2934,19 +3519,19 @@ type Policy struct { ID *string `json:"id,omitempty"` // The policy type; either 'access' or 'authorization'. - Type *string `json:"type,omitempty"` + Type *string `json:"type" validate:"required"` // Customer-defined description. Description *string `json:"description,omitempty"` // The subjects associated with a policy. - Subjects []PolicySubject `json:"subjects,omitempty"` + Subjects []PolicySubject `json:"subjects" validate:"required"` // A set of role cloud resource names (CRNs) granted by the policy. - Roles []PolicyRole `json:"roles,omitempty"` + Roles []PolicyRole `json:"roles" validate:"required"` // The resources associated with a policy. - Resources []PolicyResource `json:"resources,omitempty"` + Resources []PolicyResource `json:"resources" validate:"required"` // The href link back to the policy. Href *string `json:"href,omitempty"` @@ -3070,46 +3655,6 @@ func UnmarshalPolicyResource(m map[string]json.RawMessage, result interface{}) ( return } -// PolicyRole : A role associated with a policy. -type PolicyRole struct { - // 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. - DisplayName *string `json:"display_name,omitempty"` - - // The description of the role. - Description *string `json:"description,omitempty"` -} - -// NewPolicyRole : Instantiate PolicyRole (Generic Model Constructor) -func (*IamPolicyManagementV1) NewPolicyRole(roleID string) (_model *PolicyRole, err error) { - _model = &PolicyRole{ - RoleID: core.StringPtr(roleID), - } - err = core.ValidateStruct(_model, "required parameters") - return -} - -// UnmarshalPolicyRole unmarshals an instance of PolicyRole from the specified map of raw messages. -func UnmarshalPolicyRole(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(PolicyRole) - err = core.UnmarshalPrimitive(m, "role_id", &obj.RoleID) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "display_name", &obj.DisplayName) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "description", &obj.Description) - if err != nil { - return - } - reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) - return -} - // PolicySubject : The subject attribute values that must match in order for this policy to apply in a permission decision. type PolicySubject struct { // List of subject attributes. @@ -3212,20 +3757,30 @@ func UnmarshalResourceTag(m map[string]json.RawMessage, result interface{}) (err // Role : A role resource. type Role struct { // The display name of the role that is shown in the console. - DisplayName *string `json:"display_name,omitempty"` + DisplayName *string `json:"display_name" validate:"required"` // The description of the role. Description *string `json:"description,omitempty"` // 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"` + Actions []string `json:"actions" validate:"required"` // The role Cloud Resource Name (CRN). Example CRN: // 'crn:v1:ibmcloud:public:iam-access-management::a/exampleAccountId::customRole:ExampleRoleName'. CRN *string `json:"crn,omitempty"` } +// NewRole : Instantiate Role (Generic Model Constructor) +func (*IamPolicyManagementV1) NewRole(displayName string, actions []string) (_model *Role, err error) { + _model = &Role{ + DisplayName: core.StringPtr(displayName), + Actions: actions, + } + err = core.ValidateStruct(_model, "required parameters") + return +} + // UnmarshalRole unmarshals an instance of Role from the specified map of raw messages. func UnmarshalRole(m map[string]json.RawMessage, result interface{}) (err error) { obj := new(Role) @@ -3314,114 +3869,21 @@ func UnmarshalSubjectAttribute(m map[string]json.RawMessage, result interface{}) return } -// V2Policy : The core set of properties associated with a policy. -type V2Policy struct { - // The policy ID. - ID *string `json:"id,omitempty"` - - // The policy type; either 'access' or 'authorization'. - Type *string `json:"type" validate:"required"` - - // Customer-defined description. - Description *string `json:"description,omitempty"` - - // The subject attributes associated with a policy. - Subject *V2PolicyBaseSubject `json:"subject,omitempty"` - - // Specifies the type of access granted by the policy. - Control *V2PolicyBaseControl `json:"control" validate:"required"` - - // The resource attributes associated with a policy. - Resource *V2PolicyBaseResource `json:"resource,omitempty"` - - // Indicates pattern of rule. - Pattern *string `json:"pattern,omitempty"` - - // Additional access conditions associated with a policy. - Rule V2PolicyBaseRuleIntf `json:"rule,omitempty"` - - // The href link back to the policy. - Href *string `json:"href,omitempty"` - - // The UTC timestamp when the policy was created. - CreatedAt *strfmt.DateTime `json:"created_at,omitempty"` - - // The iam ID of the entity that created the policy. - CreatedByID *string `json:"created_by_id,omitempty"` - - // The UTC timestamp when the policy was last modified. - LastModifiedAt *strfmt.DateTime `json:"last_modified_at,omitempty"` - - // The iam ID of the entity that last modified the policy. - LastModifiedByID *string `json:"last_modified_by_id,omitempty"` - - // The policy state. - State *string `json:"state,omitempty"` +// ControlResponseControl : Specifies the type of access granted by the policy. +// This model "extends" ControlResponse +type ControlResponseControl struct { + // Permission granted by the policy. + Grant *V2PolicyGrant `json:"grant" validate:"required"` } -// Constants associated with the V2Policy.State property. -// The policy state. -const ( - V2PolicyStateActiveConst = "active" - V2PolicyStateDeletedConst = "deleted" -) +func (*ControlResponseControl) isaControlResponse() bool { + return true +} -// UnmarshalV2Policy unmarshals an instance of V2Policy from the specified map of raw messages. -func UnmarshalV2Policy(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(V2Policy) - err = core.UnmarshalPrimitive(m, "id", &obj.ID) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "type", &obj.Type) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "description", &obj.Description) - if err != nil { - return - } - err = core.UnmarshalModel(m, "subject", &obj.Subject, UnmarshalV2PolicyBaseSubject) - if err != nil { - return - } - err = core.UnmarshalModel(m, "control", &obj.Control, UnmarshalV2PolicyBaseControl) - if err != nil { - return - } - err = core.UnmarshalModel(m, "resource", &obj.Resource, UnmarshalV2PolicyBaseResource) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "pattern", &obj.Pattern) - if err != nil { - return - } - err = core.UnmarshalModel(m, "rule", &obj.Rule, UnmarshalV2PolicyBaseRule) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "href", &obj.Href) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "created_at", &obj.CreatedAt) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "created_by_id", &obj.CreatedByID) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "last_modified_at", &obj.LastModifiedAt) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "last_modified_by_id", &obj.LastModifiedByID) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "state", &obj.State) +// UnmarshalControlResponseControl unmarshals an instance of ControlResponseControl from the specified map of raw messages. +func UnmarshalControlResponseControl(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(ControlResponseControl) + err = core.UnmarshalModel(m, "grant", &obj.Grant, UnmarshalV2PolicyGrant) if err != nil { return } @@ -3429,58 +3891,21 @@ func UnmarshalV2Policy(m map[string]json.RawMessage, result interface{}) (err er return } -// V2PolicyAttribute : Resource/subject attribute associated with policy attributes. -type V2PolicyAttribute struct { - // The name of an attribute. - Key *string `json:"key" validate:"required"` - - // The operator of an attribute. - Operator *string `json:"operator" validate:"required"` - - // The value of an attribute; can be array, boolean, string, or integer. - Value interface{} `json:"value" validate:"required"` -} - -// NewV2PolicyAttribute : Instantiate V2PolicyAttribute (Generic Model Constructor) -func (*IamPolicyManagementV1) NewV2PolicyAttribute(key string, operator string, value interface{}) (_model *V2PolicyAttribute, err error) { - _model = &V2PolicyAttribute{ - Key: core.StringPtr(key), - Operator: core.StringPtr(operator), - Value: value, - } - err = core.ValidateStruct(_model, "required parameters") - return -} - -// UnmarshalV2PolicyAttribute unmarshals an instance of V2PolicyAttribute from the specified map of raw messages. -func UnmarshalV2PolicyAttribute(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(V2PolicyAttribute) - err = core.UnmarshalPrimitive(m, "key", &obj.Key) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "operator", &obj.Operator) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "value", &obj.Value) - if err != nil { - return - } - reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) - return +// ControlResponseControlWithTranslatedRoles : Specifies the type of access granted by the policy with additional role information. +// This model "extends" ControlResponse +type ControlResponseControlWithTranslatedRoles struct { + // Permission granted by the policy with translated roles and additional role information. + Grant *GrantWithTranslatedRoles `json:"grant" validate:"required"` } -// V2PolicyList : A collection of policies. -type V2PolicyList struct { - // List of policies. - Policies []V2Policy `json:"policies,omitempty"` +func (*ControlResponseControlWithTranslatedRoles) isaControlResponse() bool { + return true } -// UnmarshalV2PolicyList unmarshals an instance of V2PolicyList from the specified map of raw messages. -func UnmarshalV2PolicyList(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(V2PolicyList) - err = core.UnmarshalModel(m, "policies", &obj.Policies, UnmarshalV2Policy) +// UnmarshalControlResponseControlWithTranslatedRoles unmarshals an instance of ControlResponseControlWithTranslatedRoles from the specified map of raw messages. +func UnmarshalControlResponseControlWithTranslatedRoles(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(ControlResponseControlWithTranslatedRoles) + err = core.UnmarshalModel(m, "grant", &obj.Grant, UnmarshalGrantWithTranslatedRoles) if err != nil { return } @@ -3488,22 +3913,38 @@ func UnmarshalV2PolicyList(m map[string]json.RawMessage, result interface{}) (er return } -// V2PolicyBaseRuleV2PolicyAttribute : Resource/subject attribute associated with policy attributes. -// This model "extends" V2PolicyBaseRule -type V2PolicyBaseRuleV2PolicyAttribute struct { +// V2PolicyRuleRuleAttribute : Rule that specifies additional access granted (e.g., time-based condition). +// This model "extends" V2PolicyRule +type V2PolicyRuleRuleAttribute struct { // The name of an attribute. Key *string `json:"key" validate:"required"` // The operator of an attribute. Operator *string `json:"operator" validate:"required"` - // The value of an attribute; can be array, boolean, string, or integer. + // The value of an rule or resource attribute; can be boolean or string for resource attribute. Can be a string or an + // array of strings (e.g., array of days to permit access) for rule attribute. Value interface{} `json:"value" validate:"required"` } -// NewV2PolicyBaseRuleV2PolicyAttribute : Instantiate V2PolicyBaseRuleV2PolicyAttribute (Generic Model Constructor) -func (*IamPolicyManagementV1) NewV2PolicyBaseRuleV2PolicyAttribute(key string, operator string, value interface{}) (_model *V2PolicyBaseRuleV2PolicyAttribute, err error) { - _model = &V2PolicyBaseRuleV2PolicyAttribute{ +// Constants associated with the V2PolicyRuleRuleAttribute.Operator property. +// The operator of an attribute. +const ( + V2PolicyRuleRuleAttributeOperatorDatetimegreaterthanConst = "dateTimeGreaterThan" + V2PolicyRuleRuleAttributeOperatorDatetimegreaterthanorequalsConst = "dateTimeGreaterThanOrEquals" + V2PolicyRuleRuleAttributeOperatorDatetimelessthanConst = "dateTimeLessThan" + V2PolicyRuleRuleAttributeOperatorDatetimelessthanorequalsConst = "dateTimeLessThanOrEquals" + V2PolicyRuleRuleAttributeOperatorDayofweekanyofConst = "dayOfWeekAnyOf" + V2PolicyRuleRuleAttributeOperatorDayofweekequalsConst = "dayOfWeekEquals" + V2PolicyRuleRuleAttributeOperatorTimegreaterthanConst = "timeGreaterThan" + V2PolicyRuleRuleAttributeOperatorTimegreaterthanorequalsConst = "timeGreaterThanOrEquals" + V2PolicyRuleRuleAttributeOperatorTimelessthanConst = "timeLessThan" + V2PolicyRuleRuleAttributeOperatorTimelessthanorequalsConst = "timeLessThanOrEquals" +) + +// NewV2PolicyRuleRuleAttribute : Instantiate V2PolicyRuleRuleAttribute (Generic Model Constructor) +func (*IamPolicyManagementV1) NewV2PolicyRuleRuleAttribute(key string, operator string, value interface{}) (_model *V2PolicyRuleRuleAttribute, err error) { + _model = &V2PolicyRuleRuleAttribute{ Key: core.StringPtr(key), Operator: core.StringPtr(operator), Value: value, @@ -3512,13 +3953,13 @@ func (*IamPolicyManagementV1) NewV2PolicyBaseRuleV2PolicyAttribute(key string, o return } -func (*V2PolicyBaseRuleV2PolicyAttribute) isaV2PolicyBaseRule() bool { +func (*V2PolicyRuleRuleAttribute) isaV2PolicyRule() bool { return true } -// UnmarshalV2PolicyBaseRuleV2PolicyAttribute unmarshals an instance of V2PolicyBaseRuleV2PolicyAttribute from the specified map of raw messages. -func UnmarshalV2PolicyBaseRuleV2PolicyAttribute(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(V2PolicyBaseRuleV2PolicyAttribute) +// UnmarshalV2PolicyRuleRuleAttribute unmarshals an instance of V2PolicyRuleRuleAttribute from the specified map of raw messages. +func UnmarshalV2PolicyRuleRuleAttribute(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(V2PolicyRuleRuleAttribute) err = core.UnmarshalPrimitive(m, "key", &obj.Key) if err != nil { return @@ -3535,26 +3976,27 @@ func UnmarshalV2PolicyBaseRuleV2PolicyAttribute(m map[string]json.RawMessage, re return } -// V2PolicyBaseRuleV2RuleWithConditions : Policy rule that has 2 to 10 conditions. -// This model "extends" V2PolicyBaseRule -type V2PolicyBaseRuleV2RuleWithConditions struct { +// V2PolicyRuleRuleWithConditions : Rule that specifies additional access granted (e.g., time-based condition) accross multiple conditions. +// This model "extends" V2PolicyRule +type V2PolicyRuleRuleWithConditions struct { // Operator to evalute conditions. Operator *string `json:"operator" validate:"required"` - // List of conditions to associated with a policy. Note that conditions can be nested up to 2 levels. - Conditions []V2PolicyAttribute `json:"conditions" validate:"required"` + // List of conditions associated with a policy, e.g., time-based-conditions that grant access over a certain time + // period. + Conditions []RuleAttribute `json:"conditions" validate:"required"` } -// Constants associated with the V2PolicyBaseRuleV2RuleWithConditions.Operator property. +// Constants associated with the V2PolicyRuleRuleWithConditions.Operator property. // Operator to evalute conditions. const ( - V2PolicyBaseRuleV2RuleWithConditionsOperatorAndConst = "and" - V2PolicyBaseRuleV2RuleWithConditionsOperatorOrConst = "or" + V2PolicyRuleRuleWithConditionsOperatorAndConst = "and" + V2PolicyRuleRuleWithConditionsOperatorOrConst = "or" ) -// NewV2PolicyBaseRuleV2RuleWithConditions : Instantiate V2PolicyBaseRuleV2RuleWithConditions (Generic Model Constructor) -func (*IamPolicyManagementV1) NewV2PolicyBaseRuleV2RuleWithConditions(operator string, conditions []V2PolicyAttribute) (_model *V2PolicyBaseRuleV2RuleWithConditions, err error) { - _model = &V2PolicyBaseRuleV2RuleWithConditions{ +// NewV2PolicyRuleRuleWithConditions : Instantiate V2PolicyRuleRuleWithConditions (Generic Model Constructor) +func (*IamPolicyManagementV1) NewV2PolicyRuleRuleWithConditions(operator string, conditions []RuleAttribute) (_model *V2PolicyRuleRuleWithConditions, err error) { + _model = &V2PolicyRuleRuleWithConditions{ Operator: core.StringPtr(operator), Conditions: conditions, } @@ -3562,18 +4004,18 @@ func (*IamPolicyManagementV1) NewV2PolicyBaseRuleV2RuleWithConditions(operator s return } -func (*V2PolicyBaseRuleV2RuleWithConditions) isaV2PolicyBaseRule() bool { +func (*V2PolicyRuleRuleWithConditions) isaV2PolicyRule() bool { return true } -// UnmarshalV2PolicyBaseRuleV2RuleWithConditions unmarshals an instance of V2PolicyBaseRuleV2RuleWithConditions from the specified map of raw messages. -func UnmarshalV2PolicyBaseRuleV2RuleWithConditions(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(V2PolicyBaseRuleV2RuleWithConditions) +// UnmarshalV2PolicyRuleRuleWithConditions unmarshals an instance of V2PolicyRuleRuleWithConditions from the specified map of raw messages. +func UnmarshalV2PolicyRuleRuleWithConditions(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(V2PolicyRuleRuleWithConditions) err = core.UnmarshalPrimitive(m, "operator", &obj.Operator) if err != nil { return } - err = core.UnmarshalModel(m, "conditions", &obj.Conditions, UnmarshalV2PolicyAttribute) + err = core.UnmarshalModel(m, "conditions", &obj.Conditions, UnmarshalRuleAttribute) if err != nil { return } diff --git a/iampolicymanagementv1/iam_policy_management_v1_examples_test.go b/iampolicymanagementv1/iam_policy_management_v1_examples_test.go index 870945e6..3ca0debd 100644 --- a/iampolicymanagementv1/iam_policy_management_v1_examples_test.go +++ b/iampolicymanagementv1/iam_policy_management_v1_examples_test.go @@ -198,9 +198,9 @@ var _ = Describe(`IamPolicyManagementV1 Examples Tests`, func() { examplePolicyETag = response.GetHeaders().Get("ETag") }) - It(`UpdatePolicy request example`, func() { - fmt.Println("\nUpdatePolicy() result:") - // begin-update_policy + It(`ReplacePolicy request example`, func() { + fmt.Println("\nReplacePolicy() result:") + // begin-replace_policy subjectAttribute := &iampolicymanagementv1.SubjectAttribute{ Name: core.StringPtr("iam_id"), @@ -233,7 +233,7 @@ var _ = Describe(`IamPolicyManagementV1 Examples Tests`, func() { RoleID: core.StringPtr("crn:v1:bluemix:public:iam::::role:Editor"), } - options := iamPolicyManagementService.NewUpdatePolicyOptions( + options := iamPolicyManagementService.NewReplacePolicyOptions( examplePolicyID, examplePolicyETag, "access", @@ -242,14 +242,14 @@ var _ = Describe(`IamPolicyManagementV1 Examples Tests`, func() { []iampolicymanagementv1.PolicyResource{*policyResources}, ) - policy, response, err := iamPolicyManagementService.UpdatePolicy(options) + policy, response, err := iamPolicyManagementService.ReplacePolicy(options) if err != nil { panic(err) } b, _ := json.MarshalIndent(policy, "", " ") fmt.Println(string(b)) - // end-update_policy + // end-replace_policy Expect(err).To(BeNil()) Expect(response.StatusCode).To(Equal(200)) @@ -257,25 +257,25 @@ var _ = Describe(`IamPolicyManagementV1 Examples Tests`, func() { examplePolicyETag = response.GetHeaders().Get("ETag") }) - It(`PatchPolicy request example`, func() { - fmt.Println("\nPatchPolicy() result:") - // begin-patch_policy + It(`UpdatePolicy request example`, func() { + fmt.Println("\nUpdatePolicyState() result:") + // begin-update_policy_state - options := iamPolicyManagementService.NewPatchPolicyOptions( + options := iamPolicyManagementService.NewUpdatePolicyStateOptions( examplePolicyID, examplePolicyETag, ) options.SetState("active") - policy, response, err := iamPolicyManagementService.PatchPolicy(options) + policy, response, err := iamPolicyManagementService.UpdatePolicyState(options) if err != nil { panic(err) } b, _ := json.MarshalIndent(policy, "", " ") fmt.Println(string(b)) - // end-patch_policy + // end-update_policy_state Expect(err).To(BeNil()) Expect(response.StatusCode).To(Equal(200)) @@ -324,57 +324,85 @@ var _ = Describe(`IamPolicyManagementV1 Examples Tests`, func() { Expect(response.StatusCode).To(Equal(204)) }) - It(`V2CreatePolicy request example`, func() { - fmt.Println("\nCreatePolicy() result:") - // begin-v2_create_policy + It(`CreateV2Policy request example`, func() { + fmt.Println("\nCreateV2Policy() result:") + // begin-create_v2_policy - subjectAttribute := &iampolicymanagementv1.V2PolicyAttribute{ + subjectAttribute := &iampolicymanagementv1.V2PolicySubjectAttribute{ Key: core.StringPtr("iam_id"), Operator: core.StringPtr("stringEquals"), Value: &exampleUserID, } - policySubject := &iampolicymanagementv1.V2PolicyBaseSubject{ - Attributes: []iampolicymanagementv1.V2PolicyAttribute{*subjectAttribute}, + policySubject := &iampolicymanagementv1.V2PolicySubject{ + Attributes: []iampolicymanagementv1.V2PolicySubjectAttribute{*subjectAttribute}, } policyRole := &iampolicymanagementv1.PolicyRole{ RoleID: core.StringPtr("crn:v1:bluemix:public:iam::::role:Viewer"), } - v2PolicyGrant := &iampolicymanagementv1.V2PolicyBaseControlGrant{ + v2PolicyGrant := &iampolicymanagementv1.V2PolicyGrant{ Roles: []iampolicymanagementv1.PolicyRole{*policyRole}, } - v2PolicyControl := &iampolicymanagementv1.V2PolicyBaseControl{ + v2PolicyControl := &iampolicymanagementv1.Control{ Grant: v2PolicyGrant, } - accountIDResourceAttribute := &iampolicymanagementv1.V2PolicyAttribute{ + accountIDResourceAttribute := &iampolicymanagementv1.V2PolicyResourceAttribute{ Key: core.StringPtr("accountId"), Operator: core.StringPtr("stringEquals"), Value: core.StringPtr(exampleAccountID), } - serviceNameResourceAttribute := &iampolicymanagementv1.V2PolicyAttribute{ + serviceNameResourceAttribute := &iampolicymanagementv1.V2PolicyResourceAttribute{ Key: core.StringPtr("serviceType"), Operator: core.StringPtr("stringEquals"), Value: core.StringPtr("service"), } - policyResource := &iampolicymanagementv1.V2PolicyBaseResource{ - Attributes: []iampolicymanagementv1.V2PolicyAttribute{ + policyResourceTag := &iampolicymanagementv1.V2PolicyResourceTag{ + Key: core.StringPtr("project"), + Value: core.StringPtr("prototype"), + Operator: core.StringPtr("stringEquals"), + } + policyResource := &iampolicymanagementv1.V2PolicyResource{ + Attributes: []iampolicymanagementv1.V2PolicyResourceAttribute{ *accountIDResourceAttribute, *serviceNameResourceAttribute}, + Tags: []iampolicymanagementv1.V2PolicyResourceTag{*policyResourceTag}, + } + weeklyConditionAttribute := &iampolicymanagementv1.RuleAttribute{ + Key: core.StringPtr("{{environment.attributes.day_of_week}}"), + Operator: core.StringPtr("dayOfWeekAnyOf"), + Value: []string{"1+00:00","2+00:00","3+00:00","4+00:00","5+00:00"}, + } + startConditionAttribute := &iampolicymanagementv1.RuleAttribute{ + Key: core.StringPtr("{{environment.attributes.current_time}}"), + Operator: core.StringPtr("timeGreaterThanOrEquals"), + Value: core.StringPtr("09:00:00+00:00"), + } + endConditionAttribute := &iampolicymanagementv1.RuleAttribute{ + Key: core.StringPtr("{{environment.attributes.current_time}}"), + Operator: core.StringPtr("timeLessThanOrEquals"), + Value: core.StringPtr("17:00:00+00:00"), + } + policyRule := &iampolicymanagementv1.V2PolicyRule{ + Operator: core.StringPtr("and"), + Conditions: []iampolicymanagementv1.RuleAttribute{ + *weeklyConditionAttribute, *startConditionAttribute, *endConditionAttribute}, } - options := iamPolicyManagementService.NewV2CreatePolicyOptions( - "access", + options := iamPolicyManagementService.NewCreateV2PolicyOptions( v2PolicyControl, + "access", ) options.SetSubject(policySubject) options.SetResource(policyResource) + options.SetRule(policyRule) + options.SetPattern(*core.StringPtr("time-based-conditions:weekly:custom-hours")) - policy, response, err := iamPolicyManagementService.V2CreatePolicy(options) + policy, response, err := iamPolicyManagementService.CreateV2Policy(options) if err != nil { panic(err) } b, _ := json.MarshalIndent(policy, "", " ") fmt.Println(string(b)) - // end-create_policy + // end-create_v2_policy Expect(err).To(BeNil()) Expect(response.StatusCode).To(Equal(201)) @@ -382,22 +410,22 @@ var _ = Describe(`IamPolicyManagementV1 Examples Tests`, func() { examplePolicyID = *policy.ID }) - It(`V2GetPolicy request example`, func() { - fmt.Println("\nGetPolicy() result:") - // begin-get_policy + It(`GetV2Policy request example`, func() { + fmt.Println("\nGetV2Policy() result:") + // begin-get_v2_policy - options := iamPolicyManagementService.NewV2GetPolicyOptions( + options := iamPolicyManagementService.NewGetV2PolicyOptions( examplePolicyID, ) - policy, response, err := iamPolicyManagementService.V2GetPolicy(options) + policy, response, err := iamPolicyManagementService.GetV2Policy(options) if err != nil { panic(err) } b, _ := json.MarshalIndent(policy, "", " ") fmt.Println(string(b)) - // end-get_policy + // end-get_v2_policy Expect(err).To(BeNil()) Expect(response.StatusCode).To(Equal(200)) @@ -405,60 +433,60 @@ var _ = Describe(`IamPolicyManagementV1 Examples Tests`, func() { examplePolicyETag = response.GetHeaders().Get("ETag") }) - It(`V2UpdatePolicy request example`, func() { - fmt.Println("\nUpdatePolicy() result:") - // begin-update_policy + It(`ReplaceV2Policy request example`, func() { + fmt.Println("\nReplaceV2Policy() result:") + // begin-replace_v2_policy - subjectAttribute := &iampolicymanagementv1.V2PolicyAttribute{ + subjectAttribute := &iampolicymanagementv1.V2PolicySubjectAttribute{ Key: core.StringPtr("iam_id"), Operator: core.StringPtr("stringEquals"), Value: &exampleUserID, } - policySubject := &iampolicymanagementv1.V2PolicyBaseSubject{ - Attributes: []iampolicymanagementv1.V2PolicyAttribute{*subjectAttribute}, + policySubject := &iampolicymanagementv1.V2PolicySubject{ + Attributes: []iampolicymanagementv1.V2PolicySubjectAttribute{*subjectAttribute}, } updatedPolicyRole := &iampolicymanagementv1.PolicyRole{ RoleID: core.StringPtr("crn:v1:bluemix:public:iam::::role:Editor"), } - v2PolicyGrant := &iampolicymanagementv1.V2PolicyBaseControlGrant{ + v2PolicyGrant := &iampolicymanagementv1.V2PolicyGrant{ Roles: []iampolicymanagementv1.PolicyRole{*updatedPolicyRole}, } - v2PolicyControl := &iampolicymanagementv1.V2PolicyBaseControl{ + v2PolicyControl := &iampolicymanagementv1.Control{ Grant: v2PolicyGrant, } - accountIDResourceAttribute := &iampolicymanagementv1.V2PolicyAttribute{ + accountIDResourceAttribute := &iampolicymanagementv1.V2PolicyResourceAttribute{ Key: core.StringPtr("accountId"), Operator: core.StringPtr("stringEquals"), Value: core.StringPtr(exampleAccountID), } - serviceNameResourceAttribute := &iampolicymanagementv1.V2PolicyAttribute{ + serviceNameResourceAttribute := &iampolicymanagementv1.V2PolicyResourceAttribute{ Key: core.StringPtr("serviceType"), Operator: core.StringPtr("stringEquals"), Value: core.StringPtr("service"), } - policyResource := &iampolicymanagementv1.V2PolicyBaseResource{ - Attributes: []iampolicymanagementv1.V2PolicyAttribute{ + policyResource := &iampolicymanagementv1.V2PolicyResource{ + Attributes: []iampolicymanagementv1.V2PolicyResourceAttribute{ *accountIDResourceAttribute, *serviceNameResourceAttribute}, } - options := iamPolicyManagementService.NewV2UpdatePolicyOptions( + options := iamPolicyManagementService.NewReplaceV2PolicyOptions( examplePolicyID, examplePolicyETag, - "access", v2PolicyControl, + "access", ) options.SetSubject(policySubject) options.SetResource(policyResource) - policy, response, err := iamPolicyManagementService.V2UpdatePolicy(options) + policy, response, err := iamPolicyManagementService.ReplaceV2Policy(options) if err != nil { panic(err) } b, _ := json.MarshalIndent(policy, "", " ") fmt.Println(string(b)) - // end-update_policy + // end-replace_v2_policy Expect(err).To(BeNil()) Expect(response.StatusCode).To(Equal(200)) @@ -466,44 +494,44 @@ var _ = Describe(`IamPolicyManagementV1 Examples Tests`, func() { examplePolicyETag = response.GetHeaders().Get("ETag") }) - It(`V2ListPolicies request example`, func() { - fmt.Println("\nListPolicies() result:") - // begin-list_policies + It(`ListV2Policies request example`, func() { + fmt.Println("\nListV2Policies() result:") + // begin-list_v2_policies - options := iamPolicyManagementService.NewV2ListPoliciesOptions( + options := iamPolicyManagementService.NewListV2PoliciesOptions( exampleAccountID, ) options.SetIamID(exampleUserID) options.SetFormat("include_last_permit") - policyList, response, err := iamPolicyManagementService.V2ListPolicies(options) + policyList, response, err := iamPolicyManagementService.ListV2Policies(options) if err != nil { panic(err) } b, _ := json.MarshalIndent(policyList, "", " ") fmt.Println(string(b)) - // end-list_policies + // end-list_v2_policies Expect(err).To(BeNil()) Expect(response.StatusCode).To(Equal(200)) Expect(policyList).ToNot(BeNil()) }) - It(`V2DeletePolicy request example`, func() { - // begin-delete_policy + It(`DeleteV2Policy request example`, func() { + // begin-delete_v2_policy - options := iamPolicyManagementService.NewV2DeletePolicyOptions( + options := iamPolicyManagementService.NewDeleteV2PolicyOptions( examplePolicyID, ) - response, err := iamPolicyManagementService.V2DeletePolicy(options) + response, err := iamPolicyManagementService.DeleteV2Policy(options) if err != nil { panic(err) } - // end-delete_policy - fmt.Printf("\nDeletePolicy() response status code: %d\n", response.StatusCode) + // end-delete_delete_v2_policypolicy + fmt.Printf("\nDeleteV2Policy() response status code: %d\n", response.StatusCode) Expect(err).To(BeNil()) Expect(response.StatusCode).To(Equal(204)) @@ -559,26 +587,27 @@ var _ = Describe(`IamPolicyManagementV1 Examples Tests`, func() { exampleCustomRoleETag = response.Headers.Get("ETag") }) - It(`UpdateRole request example`, func() { - fmt.Println("\nUpdateRole() result:") - // begin-update_role + It(`ReplaceRole request example`, func() { + fmt.Println("\nReplaceRole() result:") + // begin-replace_role updatedRoleActions := []string{"iam-groups.groups.read", "iam-groups.groups.list"} - options := iamPolicyManagementService.NewUpdateRoleOptions( + options := iamPolicyManagementService.NewReplaceRoleOptions( exampleCustomRoleID, exampleCustomRoleETag, + "ExampleRoleIAMGroups", + updatedRoleActions, ) - options.SetActions(updatedRoleActions) - customRole, response, err := iamPolicyManagementService.UpdateRole(options) + customRole, response, err := iamPolicyManagementService.ReplaceRole(options) if err != nil { panic(err) } b, _ := json.MarshalIndent(customRole, "", " ") fmt.Println(string(b)) - // end-update_role + // end-replace_role Expect(err).To(BeNil()) Expect(response.StatusCode).To(Equal(200)) diff --git a/iampolicymanagementv1/iam_policy_management_v1_integration_test.go b/iampolicymanagementv1/iam_policy_management_v1_integration_test.go index 57535d98..ec1335a9 100644 --- a/iampolicymanagementv1/iam_policy_management_v1_integration_test.go +++ b/iampolicymanagementv1/iam_policy_management_v1_integration_test.go @@ -48,7 +48,7 @@ var _ = Describe("IAM Policy Management - Integration Tests", func() { testAccountID string etagHeader string = "ETag" testPolicyETag string = "" - testV2PolicyETag string = "" + testV2PolicyETag string = "" testPolicyId string = "" testV2PolicyId string = "" testUserId string = "IBMid-GoSDK" + strconv.Itoa(rand.Intn(100000)) @@ -220,7 +220,7 @@ var _ = Describe("IAM Policy Management - Integration Tests", func() { policySubject.Attributes = []iampolicymanagementv1.SubjectAttribute{*subjectAttribute} // Construct an instance of the CreatePolicyOptions model - options := new(iampolicymanagementv1.UpdatePolicyOptions) + options := new(iampolicymanagementv1.ReplacePolicyOptions) options.PolicyID = core.StringPtr(testPolicyId) options.IfMatch = core.StringPtr(testPolicyETag) options.Type = core.StringPtr("access") @@ -228,11 +228,11 @@ var _ = Describe("IAM Policy Management - Integration Tests", func() { options.Roles = []iampolicymanagementv1.PolicyRole{*policyRole} options.Resources = []iampolicymanagementv1.PolicyResource{*policyResource} - policy, detailedResponse, err := service.UpdatePolicy(options) + policy, detailedResponse, err := service.ReplacePolicy(options) Expect(err).To(BeNil()) Expect(detailedResponse.StatusCode).To(Equal(200)) Expect(policy).ToNot(BeNil()) - fmt.Fprintf(GinkgoWriter, "UpdatePolicy() result:\n%s\n", common.ToJSON(policy)) + fmt.Fprintf(GinkgoWriter, "ReplacePolicy() result:\n%s\n", common.ToJSON(policy)) Expect(*policy.ID).To(Equal(testPolicyId)) Expect(policy.Type).To(Equal(options.Type)) Expect(policy.Subjects).To(Equal(options.Subjects)) @@ -251,17 +251,17 @@ var _ = Describe("IAM Policy Management - Integration Tests", func() { Expect(testPolicyId).To(Not(BeNil())) Expect(testPolicyETag).To(Not(BeNil())) - // Construct an instance of the PatchPolicyOptions model - options := new(iampolicymanagementv1.PatchPolicyOptions) + // Construct an instance of the UpdatePolicyStateOptions model + options := new(iampolicymanagementv1.UpdatePolicyStateOptions) options.PolicyID = &testPolicyId options.IfMatch = core.StringPtr(testPolicyETag) options.State = core.StringPtr("active") - policy, detailedResponse, err := service.PatchPolicy(options) + policy, detailedResponse, err := service.UpdatePolicyState(options) Expect(err).To(BeNil()) Expect(detailedResponse.StatusCode).To(Equal(200)) Expect(policy).ToNot(BeNil()) - fmt.Fprintf(GinkgoWriter, "PatchPolicy() result:\n%s\n", common.ToJSON(policy)) + fmt.Fprintf(GinkgoWriter, "UpdatePolicyState() result:\n%s\n", common.ToJSON(policy)) Expect(*policy.ID).To(Equal(testPolicyId)) Expect(policy.State).To(Equal(options.State)) @@ -299,78 +299,87 @@ var _ = Describe("IAM Policy Management - Integration Tests", func() { shouldSkipTest() // Construct an instance of the ResourceAttribute model - accountIdResourceAttribute := new(iampolicymanagementv1.V2PolicyAttribute) + accountIdResourceAttribute := new(iampolicymanagementv1.V2PolicyResourceAttribute) accountIdResourceAttribute.Key = core.StringPtr("accountId") accountIdResourceAttribute.Value = core.StringPtr(testAccountID) accountIdResourceAttribute.Operator = core.StringPtr("stringEquals") - serviceNameResourceAttribute := new(iampolicymanagementv1.V2PolicyAttribute) + serviceNameResourceAttribute := new(iampolicymanagementv1.V2PolicyResourceAttribute) serviceNameResourceAttribute.Key = core.StringPtr("serviceType") serviceNameResourceAttribute.Value = core.StringPtr("service") serviceNameResourceAttribute.Operator = core.StringPtr("stringEquals") + + policyResourceTag := new(iampolicymanagementv1.V2PolicyResourceTag) + policyResourceTag.Key = core.StringPtr("project") + policyResourceTag.Value = core.StringPtr("prototype") + policyResourceTag.Operator = core.StringPtr("stringEquals") + // Construct an instance of the SubjectAttribute model - subjectAttribute := new(iampolicymanagementv1.V2PolicyAttribute) + subjectAttribute := new(iampolicymanagementv1.V2PolicySubjectAttribute) subjectAttribute.Key = core.StringPtr("iam_id") subjectAttribute.Operator = core.StringPtr("stringEquals") subjectAttribute.Value = core.StringPtr(testUserId) - - // Construct an instance of the V2PolicyBaseResource model - policyResource := new(iampolicymanagementv1.V2PolicyBaseResource) - policyResource.Attributes = []iampolicymanagementv1.V2PolicyAttribute{*accountIdResourceAttribute, *serviceNameResourceAttribute} + + // Construct an instance of the V2PolicyResource model + policyResource := new(iampolicymanagementv1.V2PolicyResource) + policyResource.Attributes = []iampolicymanagementv1.V2PolicyResourceAttribute{*accountIdResourceAttribute, *serviceNameResourceAttribute} + policyResource.Tags = []iampolicymanagementv1.V2PolicyResourceTag{*policyResourceTag} // Construct an instance of the PolicyRole model policyRole := new(iampolicymanagementv1.PolicyRole) policyRole.RoleID = core.StringPtr(testViewerRoleCrn) // Construct an instance of the PolicySubject model - policySubject := new(iampolicymanagementv1.V2PolicyBaseSubject) - policySubject.Attributes = []iampolicymanagementv1.V2PolicyAttribute{*subjectAttribute} + policySubject := new(iampolicymanagementv1.V2PolicySubject) + policySubject.Attributes = []iampolicymanagementv1.V2PolicySubjectAttribute{*subjectAttribute} // Contruct and instance of PolicyControl model - policyControl := new(iampolicymanagementv1.V2PolicyBaseControl) - controlGrant := new(iampolicymanagementv1.V2PolicyBaseControlGrant) - controlGrant.Roles = []iampolicymanagementv1.PolicyRole{*policyRole} - policyControl.Grant = controlGrant + control := new(iampolicymanagementv1.Control) + grant := new(iampolicymanagementv1.V2PolicyGrant) + grant.Roles = []iampolicymanagementv1.PolicyRole{*policyRole} + control.Grant = grant // Construct an instance of Policy Rule Attribute - weeklyConditionAttribute := new(iampolicymanagementv1.V2PolicyAttribute) + weeklyConditionAttribute := new(iampolicymanagementv1.RuleAttribute) weeklyConditionAttribute.Key = core.StringPtr("{{environment.attributes.day_of_week}}") weeklyConditionAttribute.Operator = core.StringPtr("dayOfWeekAnyOf") - weeklyConditionAttribute.Value = []int{1, 2, 3, 4, 5} + weeklyConditionAttribute.Value = []string{"1+00:00","2+00:00","3+00:00","4+00:00","5+00:00"} - startConditionAttribute := new(iampolicymanagementv1.V2PolicyAttribute) + startConditionAttribute := new(iampolicymanagementv1.RuleAttribute) startConditionAttribute.Key = core.StringPtr("{{environment.attributes.current_time}}") startConditionAttribute.Operator = core.StringPtr("timeGreaterThanOrEquals") startConditionAttribute.Value = core.StringPtr("09:00:00+00:00") - endConditionAttribute := new(iampolicymanagementv1.V2PolicyAttribute) + endConditionAttribute := new(iampolicymanagementv1.RuleAttribute) endConditionAttribute.Key = core.StringPtr("{{environment.attributes.current_time}}") endConditionAttribute.Operator = core.StringPtr("timeLessThanOrEquals") endConditionAttribute.Value = core.StringPtr("17:00:00+00:00") - policyRule := new(iampolicymanagementv1.V2PolicyBaseRule) + policyRule := new(iampolicymanagementv1.V2PolicyRule) policyRule.Operator = core.StringPtr("and") - policyRule.Conditions = []iampolicymanagementv1.V2PolicyAttribute{*weeklyConditionAttribute, *startConditionAttribute, *endConditionAttribute} + policyRule.Conditions = []iampolicymanagementv1.RuleAttribute{*weeklyConditionAttribute, *startConditionAttribute, *endConditionAttribute} - // Construct an instance of the V2CreatePolicyOptions model - options := new(iampolicymanagementv1.V2CreatePolicyOptions) + // Construct an instance of the CreateV2PolicyOptions model + options := new(iampolicymanagementv1.CreateV2PolicyOptions) options.Type = core.StringPtr("access") options.Subject = policySubject - options.Control = policyControl + options.Control = control options.Resource = policyResource - options.Pattern = core.StringPtr("time-based-restrictions:weekly") + options.Pattern = core.StringPtr("time-based-conditions:weekly:custom-hours") options.Rule = policyRule options.AcceptLanguage = core.StringPtr("en") - policy, detailedResponse, err := service.V2CreatePolicy(options) + policy, detailedResponse, err := service.CreateV2Policy(options) + controlResponse := new(iampolicymanagementv1.ControlResponse) + controlResponse.Grant = grant Expect(err).To(BeNil()) Expect(detailedResponse.StatusCode).To(Equal(201)) Expect(policy).ToNot(BeNil()) - fmt.Fprintf(GinkgoWriter, "CreatePolicy() result:\n%s\n", common.ToJSON(policy)) + fmt.Fprintf(GinkgoWriter, "CreateV2Policy() result:\n%s\n", common.ToJSON(policy)) Expect(policy.Type).To(Equal(options.Type)) - Expect(policy.Subject.Attributes[0].Value).To(Equal(testUserId)) - Expect(policy.Control.Grant.Roles[0].RoleID).To(Equal(options.Control.Grant.Roles[0].RoleID)) + Expect(policy.Subject.Attributes[0].Value).To(Equal(&testUserId)) + Expect(policy.Control).To(Equal(controlResponse)) Expect(policy.Resource.Attributes[0].Value).To(Equal(testAccountID)) testV2PolicyId = *policy.ID @@ -383,12 +392,12 @@ var _ = Describe("IAM Policy Management - Integration Tests", func() { shouldSkipTest() Expect(testPolicyId).To(Not(BeNil())) - options := service.NewV2GetPolicyOptions(testV2PolicyId) - policy, detailedResponse, err := service.V2GetPolicy(options) + options := service.NewGetV2PolicyOptions(testV2PolicyId) + policy, detailedResponse, err := service.GetV2Policy(options) Expect(err).To(BeNil()) Expect(detailedResponse.StatusCode).To(Equal(200)) Expect(policy).ToNot(BeNil()) - fmt.Fprintf(GinkgoWriter, "GetPolicy() result:\n%s\n", common.ToJSON(policy)) + fmt.Fprintf(GinkgoWriter, "GetV2Policy() result:\n%s\n", common.ToJSON(policy)) Expect(*policy.ID).To(Equal(testV2PolicyId)) testV2PolicyETag = detailedResponse.GetHeaders().Get(etagHeader) @@ -403,80 +412,82 @@ var _ = Describe("IAM Policy Management - Integration Tests", func() { Expect(testV2PolicyETag).To(Not(BeNil())) // Construct an instance of the ResourceAttribute model - accountIdResourceAttribute := new(iampolicymanagementv1.V2PolicyAttribute) + accountIdResourceAttribute := new(iampolicymanagementv1.V2PolicyResourceAttribute) accountIdResourceAttribute.Key = core.StringPtr("accountId") accountIdResourceAttribute.Value = core.StringPtr(testAccountID) accountIdResourceAttribute.Operator = core.StringPtr("stringEquals") - serviceNameResourceAttribute := new(iampolicymanagementv1.V2PolicyAttribute) + serviceNameResourceAttribute := new(iampolicymanagementv1.V2PolicyResourceAttribute) serviceNameResourceAttribute.Key = core.StringPtr("serviceType") serviceNameResourceAttribute.Value = core.StringPtr("service") serviceNameResourceAttribute.Operator = core.StringPtr("stringEquals") // Construct an instance of the SubjectAttribute model - subjectAttribute := new(iampolicymanagementv1.V2PolicyAttribute) + subjectAttribute := new(iampolicymanagementv1.V2PolicySubjectAttribute) subjectAttribute.Key = core.StringPtr("iam_id") subjectAttribute.Operator = core.StringPtr("stringEquals") subjectAttribute.Value = core.StringPtr(testUserId) // Construct an instance of the V2PolicyBaseResource model - policyResource := new(iampolicymanagementv1.V2PolicyBaseResource) - policyResource.Attributes = []iampolicymanagementv1.V2PolicyAttribute{*accountIdResourceAttribute, *serviceNameResourceAttribute} + policyResource := new(iampolicymanagementv1.V2PolicyResource) + policyResource.Attributes = []iampolicymanagementv1.V2PolicyResourceAttribute{*accountIdResourceAttribute, *serviceNameResourceAttribute} // Construct an instance of the PolicyRole model policyRole := new(iampolicymanagementv1.PolicyRole) policyRole.RoleID = core.StringPtr(testViewerRoleCrn) // Construct an instance of the PolicySubject model - policySubject := new(iampolicymanagementv1.V2PolicyBaseSubject) - policySubject.Attributes = []iampolicymanagementv1.V2PolicyAttribute{*subjectAttribute} + policySubject := new(iampolicymanagementv1.V2PolicySubject) + policySubject.Attributes = []iampolicymanagementv1.V2PolicySubjectAttribute{*subjectAttribute} // Contruct and instance of PolicyControl model - policyControl := new(iampolicymanagementv1.V2PolicyBaseControl) - controlGrant := new(iampolicymanagementv1.V2PolicyBaseControlGrant) - controlGrant.Roles = []iampolicymanagementv1.PolicyRole{*policyRole} - policyControl.Grant = controlGrant + control := new(iampolicymanagementv1.Control) + grant := new(iampolicymanagementv1.V2PolicyGrant) + grant.Roles = []iampolicymanagementv1.PolicyRole{*policyRole} + control.Grant = grant // Construct an instance of Policy Rule Attribute - weeklyConditionAttribute := new(iampolicymanagementv1.V2PolicyAttribute) + weeklyConditionAttribute := new(iampolicymanagementv1.RuleAttribute) weeklyConditionAttribute.Key = core.StringPtr("{{environment.attributes.day_of_week}}") weeklyConditionAttribute.Operator = core.StringPtr("dayOfWeekAnyOf") - weeklyConditionAttribute.Value = []int{1, 2, 3, 4, 5} + weeklyConditionAttribute.Value = []string{"1+00:00","2+00:00","3+00:00","4+00:00","5+00:00"} - startConditionAttribute := new(iampolicymanagementv1.V2PolicyAttribute) + startConditionAttribute := new(iampolicymanagementv1.RuleAttribute) startConditionAttribute.Key = core.StringPtr("{{environment.attributes.current_time}}") startConditionAttribute.Operator = core.StringPtr("timeGreaterThanOrEquals") startConditionAttribute.Value = core.StringPtr("09:00:00+00:00") - endConditionAttribute := new(iampolicymanagementv1.V2PolicyAttribute) + endConditionAttribute := new(iampolicymanagementv1.RuleAttribute) endConditionAttribute.Key = core.StringPtr("{{environment.attributes.current_time}}") endConditionAttribute.Operator = core.StringPtr("timeLessThanOrEquals") endConditionAttribute.Value = core.StringPtr("17:00:00+00:00") - policyRule := new(iampolicymanagementv1.V2PolicyBaseRule) + policyRule := new(iampolicymanagementv1.V2PolicyRule) policyRule.Operator = core.StringPtr("and") - policyRule.Conditions = []iampolicymanagementv1.V2PolicyAttribute{*weeklyConditionAttribute, *startConditionAttribute, *endConditionAttribute} + policyRule.Conditions = []iampolicymanagementv1.RuleAttribute{*weeklyConditionAttribute, *startConditionAttribute, *endConditionAttribute} - // Construct an instance of the UpdatePolicyOptions model - options := new(iampolicymanagementv1.V2UpdatePolicyOptions) - options.PolicyID = core.StringPtr(testV2PolicyId) + // Construct an instance of the ReplaceV2PolicyOptions model + options := new(iampolicymanagementv1.ReplaceV2PolicyOptions) + options.ID = core.StringPtr(testV2PolicyId) options.IfMatch = core.StringPtr(testV2PolicyETag) options.Type = core.StringPtr("access") options.Subject = policySubject - options.Control = policyControl + options.Control = control options.Resource = policyResource - options.Pattern = core.StringPtr("time-based-restrictions:weekly") + options.Pattern = core.StringPtr("time-based-conditions:weekly:custom-hours") options.Rule = policyRule - policy, detailedResponse, err := service.V2UpdatePolicy(options) + policy, detailedResponse, err := service.ReplaceV2Policy(options) + controlResponse := new(iampolicymanagementv1.ControlResponse) + controlResponse.Grant = grant Expect(err).To(BeNil()) Expect(detailedResponse.StatusCode).To(Equal(200)) Expect(policy).ToNot(BeNil()) - fmt.Fprintf(GinkgoWriter, "UpdatePolicy() result:\n%s\n", common.ToJSON(policy)) + fmt.Fprintf(GinkgoWriter, "ReplaceV2Policy() result:\n%s\n", common.ToJSON(policy)) Expect(*policy.ID).To(Equal(testV2PolicyId)) Expect(policy.Type).To(Equal(options.Type)) - Expect(policy.Subject.Attributes[0].Value).To(Equal(testUserId)) - Expect(policy.Control.Grant.Roles[0].RoleID).To(Equal(options.Control.Grant.Roles[0].RoleID)) + Expect(policy.Subject.Attributes[0].Value).To(Equal(&testUserId)) + Expect(policy.Control).To(Equal(controlResponse)) Expect(policy.Resource.Attributes[0].Value).To(Equal(testAccountID)) newV2PolicyEtag := detailedResponse.GetHeaders().Get(etagHeader) @@ -491,13 +502,13 @@ var _ = Describe("IAM Policy Management - Integration Tests", func() { shouldSkipTest() Expect(testV2PolicyId).To(Not(BeNil())) - options := service.NewV2ListPoliciesOptions(testAccountID) + options := service.NewListV2PoliciesOptions(testAccountID) options.SetIamID(testUserId) - result, detailedResponse, err := service.V2ListPolicies(options) + result, detailedResponse, err := service.ListV2Policies(options) Expect(err).To(BeNil()) Expect(detailedResponse.StatusCode).To(Equal(200)) Expect(result).ToNot(BeNil()) - fmt.Fprintf(GinkgoWriter, "ListPolicies() result:\n%s\n", common.ToJSON(result)) + fmt.Fprintf(GinkgoWriter, "ListV2Policies() result:\n%s\n", common.ToJSON(result)) // confirm the test policy is present testPolicyPresent := false @@ -555,15 +566,19 @@ var _ = Describe("IAM Policy Management - Integration Tests", func() { Expect(testCustomRoleId).To(Not(BeNil())) Expect(testPolicyETag).To(Not(BeNil())) - options := service.NewUpdateRoleOptions( + actions := []string{"iam-groups.groups.read"} + options := service.NewReplaceRoleOptions( testCustomRoleId, - testCustomRoleETag) + testCustomRoleETag, + testCustomRoleName, + actions, + ) options.SetDescription("GO SDK test role udpated") options.SetDisplayName("GO SDK test role udpated") - result, detailedResponse, err := service.UpdateRole(options) + result, detailedResponse, err := service.ReplaceRole(options) Expect(err).To(BeNil()) Expect(result).ToNot(BeNil()) - fmt.Fprintf(GinkgoWriter, "UpdateRole() result:\n%s\n", common.ToJSON(result)) + fmt.Fprintf(GinkgoWriter, "ReplaceRole() result:\n%s\n", common.ToJSON(result)) Expect(detailedResponse.StatusCode).To(Equal(200)) Expect(*result.ID).To(Equal(testCustomRoleId)) @@ -621,8 +636,8 @@ var _ = Describe("IAM Policy Management - Integration Tests", func() { fiveMinutesAgo := time.Now().Add(-(time.Duration(5) * time.Minute)) if strings.Contains(*policy.Href, "v2/policies") { if *policy.ID == testV2PolicyId || createdAt.Before(fiveMinutesAgo) { - options := service.NewV2DeletePolicyOptions(*policy.ID) - detailedResponse, err := service.V2DeletePolicy(options) + options := service.NewDeleteV2PolicyOptions(*policy.ID) + detailedResponse, err := service.DeleteV2Policy(options) Expect(err).To(BeNil()) Expect(detailedResponse.StatusCode).To(Equal(204)) } diff --git a/iampolicymanagementv1/iam_policy_management_v1_suite_test.go b/iampolicymanagementv1/iam_policy_management_v1_suite_test.go index 9f797781..fa66a974 100644 --- a/iampolicymanagementv1/iam_policy_management_v1_suite_test.go +++ b/iampolicymanagementv1/iam_policy_management_v1_suite_test.go @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2022. + * (C) Copyright IBM Corp. 2023. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/iampolicymanagementv1/iam_policy_management_v1_test.go b/iampolicymanagementv1/iam_policy_management_v1_test.go index f7944716..81c69fe5 100644 --- a/iampolicymanagementv1/iam_policy_management_v1_test.go +++ b/iampolicymanagementv1/iam_policy_management_v1_test.go @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2022. + * (C) Copyright IBM Corp. 2023. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -886,15 +886,15 @@ var _ = Describe(`IamPolicyManagementV1`, func() { }) }) }) - Describe(`UpdatePolicy(updatePolicyOptions *UpdatePolicyOptions) - Operation response error`, func() { - updatePolicyPath := "/v1/policies/testString" + Describe(`ReplacePolicy(replacePolicyOptions *ReplacePolicyOptions) - Operation response error`, func() { + replacePolicyPath := "/v1/policies/testString" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(updatePolicyPath)) + Expect(req.URL.EscapedPath()).To(Equal(replacePolicyPath)) Expect(req.Method).To(Equal("PUT")) Expect(req.Header["If-Match"]).ToNot(BeNil()) Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) @@ -903,7 +903,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke UpdatePolicy with error: Operation response processing error`, func() { + It(`Invoke ReplacePolicy with error: Operation response processing error`, func() { iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -941,25 +941,25 @@ var _ = Describe(`IamPolicyManagementV1`, func() { 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"} + // Construct an instance of the ReplacePolicyOptions model + replacePolicyOptionsModel := new(iampolicymanagementv1.ReplacePolicyOptions) + replacePolicyOptionsModel.PolicyID = core.StringPtr("testString") + replacePolicyOptionsModel.IfMatch = core.StringPtr("testString") + replacePolicyOptionsModel.Type = core.StringPtr("testString") + replacePolicyOptionsModel.Subjects = []iampolicymanagementv1.PolicySubject{*policySubjectModel} + replacePolicyOptionsModel.Roles = []iampolicymanagementv1.PolicyRole{*policyRoleModel} + replacePolicyOptionsModel.Resources = []iampolicymanagementv1.PolicyResource{*policyResourceModel} + replacePolicyOptionsModel.Description = core.StringPtr("testString") + replacePolicyOptionsModel.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.UpdatePolicy(updatePolicyOptionsModel) + result, response, operationErr := iamPolicyManagementService.ReplacePolicy(replacePolicyOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again iamPolicyManagementService.EnableRetries(0, 0) - result, response, operationErr = iamPolicyManagementService.UpdatePolicy(updatePolicyOptionsModel) + result, response, operationErr = iamPolicyManagementService.ReplacePolicy(replacePolicyOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -969,15 +969,15 @@ var _ = Describe(`IamPolicyManagementV1`, func() { }) }) }) - Describe(`UpdatePolicy(updatePolicyOptions *UpdatePolicyOptions)`, func() { - updatePolicyPath := "/v1/policies/testString" + Describe(`ReplacePolicy(replacePolicyOptions *ReplacePolicyOptions)`, func() { + replacePolicyPath := "/v1/policies/testString" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(updatePolicyPath)) + Expect(req.URL.EscapedPath()).To(Equal(replacePolicyPath)) Expect(req.Method).To(Equal("PUT")) // For gzip-disabled operation, verify Content-Encoding is not set. @@ -1007,7 +1007,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { 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() { + It(`Invoke ReplacePolicy successfully with retries`, func() { iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -1046,27 +1046,27 @@ var _ = Describe(`IamPolicyManagementV1`, func() { 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"} + // Construct an instance of the ReplacePolicyOptions model + replacePolicyOptionsModel := new(iampolicymanagementv1.ReplacePolicyOptions) + replacePolicyOptionsModel.PolicyID = core.StringPtr("testString") + replacePolicyOptionsModel.IfMatch = core.StringPtr("testString") + replacePolicyOptionsModel.Type = core.StringPtr("testString") + replacePolicyOptionsModel.Subjects = []iampolicymanagementv1.PolicySubject{*policySubjectModel} + replacePolicyOptionsModel.Roles = []iampolicymanagementv1.PolicyRole{*policyRoleModel} + replacePolicyOptionsModel.Resources = []iampolicymanagementv1.PolicyResource{*policyResourceModel} + replacePolicyOptionsModel.Description = core.StringPtr("testString") + replacePolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := iamPolicyManagementService.UpdatePolicyWithContext(ctx, updatePolicyOptionsModel) + _, _, operationErr := iamPolicyManagementService.ReplacePolicyWithContext(ctx, replacePolicyOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again iamPolicyManagementService.DisableRetries() - result, response, operationErr := iamPolicyManagementService.UpdatePolicy(updatePolicyOptionsModel) + result, response, operationErr := iamPolicyManagementService.ReplacePolicy(replacePolicyOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -1074,7 +1074,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = iamPolicyManagementService.UpdatePolicyWithContext(ctx, updatePolicyOptionsModel) + _, _, operationErr = iamPolicyManagementService.ReplacePolicyWithContext(ctx, replacePolicyOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -1088,7 +1088,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(updatePolicyPath)) + Expect(req.URL.EscapedPath()).To(Equal(replacePolicyPath)) Expect(req.Method).To(Equal("PUT")) // For gzip-disabled operation, verify Content-Encoding is not set. @@ -1115,7 +1115,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { 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() { + It(`Invoke ReplacePolicy successfully`, func() { iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -1124,7 +1124,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(iamPolicyManagementService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := iamPolicyManagementService.UpdatePolicy(nil) + result, response, operationErr := iamPolicyManagementService.ReplacePolicy(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -1159,25 +1159,25 @@ var _ = Describe(`IamPolicyManagementV1`, func() { 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"} + // Construct an instance of the ReplacePolicyOptions model + replacePolicyOptionsModel := new(iampolicymanagementv1.ReplacePolicyOptions) + replacePolicyOptionsModel.PolicyID = core.StringPtr("testString") + replacePolicyOptionsModel.IfMatch = core.StringPtr("testString") + replacePolicyOptionsModel.Type = core.StringPtr("testString") + replacePolicyOptionsModel.Subjects = []iampolicymanagementv1.PolicySubject{*policySubjectModel} + replacePolicyOptionsModel.Roles = []iampolicymanagementv1.PolicyRole{*policyRoleModel} + replacePolicyOptionsModel.Resources = []iampolicymanagementv1.PolicyResource{*policyResourceModel} + replacePolicyOptionsModel.Description = core.StringPtr("testString") + replacePolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = iamPolicyManagementService.UpdatePolicy(updatePolicyOptionsModel) + result, response, operationErr = iamPolicyManagementService.ReplacePolicy(replacePolicyOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke UpdatePolicy with error: Operation validation and request error`, func() { + It(`Invoke ReplacePolicy with error: Operation validation and request error`, func() { iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -1215,28 +1215,28 @@ var _ = Describe(`IamPolicyManagementV1`, func() { 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"} + // Construct an instance of the ReplacePolicyOptions model + replacePolicyOptionsModel := new(iampolicymanagementv1.ReplacePolicyOptions) + replacePolicyOptionsModel.PolicyID = core.StringPtr("testString") + replacePolicyOptionsModel.IfMatch = core.StringPtr("testString") + replacePolicyOptionsModel.Type = core.StringPtr("testString") + replacePolicyOptionsModel.Subjects = []iampolicymanagementv1.PolicySubject{*policySubjectModel} + replacePolicyOptionsModel.Roles = []iampolicymanagementv1.PolicyRole{*policyRoleModel} + replacePolicyOptionsModel.Resources = []iampolicymanagementv1.PolicyResource{*policyResourceModel} + replacePolicyOptionsModel.Description = core.StringPtr("testString") + replacePolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := iamPolicyManagementService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := iamPolicyManagementService.UpdatePolicy(updatePolicyOptionsModel) + result, response, operationErr := iamPolicyManagementService.ReplacePolicy(replacePolicyOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct a second instance of the UpdatePolicyOptions model with no property values - updatePolicyOptionsModelNew := new(iampolicymanagementv1.UpdatePolicyOptions) + // Construct a second instance of the ReplacePolicyOptions model with no property values + replacePolicyOptionsModelNew := new(iampolicymanagementv1.ReplacePolicyOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = iamPolicyManagementService.UpdatePolicy(updatePolicyOptionsModelNew) + result, response, operationErr = iamPolicyManagementService.ReplacePolicy(replacePolicyOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -1254,7 +1254,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke UpdatePolicy successfully`, func() { + It(`Invoke ReplacePolicy successfully`, func() { iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -1292,19 +1292,19 @@ var _ = Describe(`IamPolicyManagementV1`, func() { 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"} + // Construct an instance of the ReplacePolicyOptions model + replacePolicyOptionsModel := new(iampolicymanagementv1.ReplacePolicyOptions) + replacePolicyOptionsModel.PolicyID = core.StringPtr("testString") + replacePolicyOptionsModel.IfMatch = core.StringPtr("testString") + replacePolicyOptionsModel.Type = core.StringPtr("testString") + replacePolicyOptionsModel.Subjects = []iampolicymanagementv1.PolicySubject{*policySubjectModel} + replacePolicyOptionsModel.Roles = []iampolicymanagementv1.PolicyRole{*policyRoleModel} + replacePolicyOptionsModel.Resources = []iampolicymanagementv1.PolicyResource{*policyResourceModel} + replacePolicyOptionsModel.Description = core.StringPtr("testString") + replacePolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := iamPolicyManagementService.UpdatePolicy(updatePolicyOptionsModel) + result, response, operationErr := iamPolicyManagementService.ReplacePolicy(replacePolicyOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -1596,15 +1596,15 @@ var _ = Describe(`IamPolicyManagementV1`, func() { }) }) }) - Describe(`PatchPolicy(patchPolicyOptions *PatchPolicyOptions) - Operation response error`, func() { - patchPolicyPath := "/v1/policies/testString" + Describe(`UpdatePolicyState(updatePolicyStateOptions *UpdatePolicyStateOptions) - Operation response error`, func() { + updatePolicyStatePath := "/v1/policies/testString" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(patchPolicyPath)) + Expect(req.URL.EscapedPath()).To(Equal(updatePolicyStatePath)) Expect(req.Method).To(Equal("PATCH")) Expect(req.Header["If-Match"]).ToNot(BeNil()) Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) @@ -1613,7 +1613,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke PatchPolicy with error: Operation response processing error`, func() { + It(`Invoke UpdatePolicyState with error: Operation response processing error`, func() { iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -1621,21 +1621,21 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(serviceErr).To(BeNil()) Expect(iamPolicyManagementService).ToNot(BeNil()) - // 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"} + // Construct an instance of the UpdatePolicyStateOptions model + updatePolicyStateOptionsModel := new(iampolicymanagementv1.UpdatePolicyStateOptions) + updatePolicyStateOptionsModel.PolicyID = core.StringPtr("testString") + updatePolicyStateOptionsModel.IfMatch = core.StringPtr("testString") + updatePolicyStateOptionsModel.State = core.StringPtr("active") + updatePolicyStateOptionsModel.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) + result, response, operationErr := iamPolicyManagementService.UpdatePolicyState(updatePolicyStateOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again iamPolicyManagementService.EnableRetries(0, 0) - result, response, operationErr = iamPolicyManagementService.PatchPolicy(patchPolicyOptionsModel) + result, response, operationErr = iamPolicyManagementService.UpdatePolicyState(updatePolicyStateOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -1645,15 +1645,15 @@ var _ = Describe(`IamPolicyManagementV1`, func() { }) }) }) - Describe(`PatchPolicy(patchPolicyOptions *PatchPolicyOptions)`, func() { - patchPolicyPath := "/v1/policies/testString" + Describe(`UpdatePolicyState(updatePolicyStateOptions *UpdatePolicyStateOptions)`, func() { + updatePolicyStatePath := "/v1/policies/testString" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(patchPolicyPath)) + Expect(req.URL.EscapedPath()).To(Equal(updatePolicyStatePath)) Expect(req.Method).To(Equal("PATCH")) // For gzip-disabled operation, verify Content-Encoding is not set. @@ -1683,7 +1683,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { 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() { + It(`Invoke UpdatePolicyState successfully with retries`, func() { iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -1692,23 +1692,23 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(iamPolicyManagementService).ToNot(BeNil()) iamPolicyManagementService.EnableRetries(0, 0) - // 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"} + // Construct an instance of the UpdatePolicyStateOptions model + updatePolicyStateOptionsModel := new(iampolicymanagementv1.UpdatePolicyStateOptions) + updatePolicyStateOptionsModel.PolicyID = core.StringPtr("testString") + updatePolicyStateOptionsModel.IfMatch = core.StringPtr("testString") + updatePolicyStateOptionsModel.State = core.StringPtr("active") + updatePolicyStateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := iamPolicyManagementService.PatchPolicyWithContext(ctx, patchPolicyOptionsModel) + _, _, operationErr := iamPolicyManagementService.UpdatePolicyStateWithContext(ctx, updatePolicyStateOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again iamPolicyManagementService.DisableRetries() - result, response, operationErr := iamPolicyManagementService.PatchPolicy(patchPolicyOptionsModel) + result, response, operationErr := iamPolicyManagementService.UpdatePolicyState(updatePolicyStateOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -1716,7 +1716,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = iamPolicyManagementService.PatchPolicyWithContext(ctx, patchPolicyOptionsModel) + _, _, operationErr = iamPolicyManagementService.UpdatePolicyStateWithContext(ctx, updatePolicyStateOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -1730,7 +1730,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(patchPolicyPath)) + Expect(req.URL.EscapedPath()).To(Equal(updatePolicyStatePath)) Expect(req.Method).To(Equal("PATCH")) // For gzip-disabled operation, verify Content-Encoding is not set. @@ -1757,7 +1757,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { 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() { + It(`Invoke UpdatePolicyState successfully`, func() { iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -1766,26 +1766,26 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(iamPolicyManagementService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := iamPolicyManagementService.PatchPolicy(nil) + result, response, operationErr := iamPolicyManagementService.UpdatePolicyState(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // 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"} + // Construct an instance of the UpdatePolicyStateOptions model + updatePolicyStateOptionsModel := new(iampolicymanagementv1.UpdatePolicyStateOptions) + updatePolicyStateOptionsModel.PolicyID = core.StringPtr("testString") + updatePolicyStateOptionsModel.IfMatch = core.StringPtr("testString") + updatePolicyStateOptionsModel.State = core.StringPtr("active") + updatePolicyStateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = iamPolicyManagementService.PatchPolicy(patchPolicyOptionsModel) + result, response, operationErr = iamPolicyManagementService.UpdatePolicyState(updatePolicyStateOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke PatchPolicy with error: Operation validation and request error`, func() { + It(`Invoke UpdatePolicyState with error: Operation validation and request error`, func() { iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -1793,24 +1793,24 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(serviceErr).To(BeNil()) Expect(iamPolicyManagementService).ToNot(BeNil()) - // 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"} + // Construct an instance of the UpdatePolicyStateOptions model + updatePolicyStateOptionsModel := new(iampolicymanagementv1.UpdatePolicyStateOptions) + updatePolicyStateOptionsModel.PolicyID = core.StringPtr("testString") + updatePolicyStateOptionsModel.IfMatch = core.StringPtr("testString") + updatePolicyStateOptionsModel.State = core.StringPtr("active") + updatePolicyStateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := iamPolicyManagementService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := iamPolicyManagementService.PatchPolicy(patchPolicyOptionsModel) + result, response, operationErr := iamPolicyManagementService.UpdatePolicyState(updatePolicyStateOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct a second instance of the PatchPolicyOptions model with no property values - patchPolicyOptionsModelNew := new(iampolicymanagementv1.PatchPolicyOptions) + // Construct a second instance of the UpdatePolicyStateOptions model with no property values + updatePolicyStateOptionsModelNew := new(iampolicymanagementv1.UpdatePolicyStateOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = iamPolicyManagementService.PatchPolicy(patchPolicyOptionsModelNew) + result, response, operationErr = iamPolicyManagementService.UpdatePolicyState(updatePolicyStateOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -1828,7 +1828,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke PatchPolicy successfully`, func() { + It(`Invoke UpdatePolicyState successfully`, func() { iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -1836,15 +1836,15 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(serviceErr).To(BeNil()) Expect(iamPolicyManagementService).ToNot(BeNil()) - // 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"} + // Construct an instance of the UpdatePolicyStateOptions model + updatePolicyStateOptionsModel := new(iampolicymanagementv1.UpdatePolicyStateOptions) + updatePolicyStateOptionsModel.PolicyID = core.StringPtr("testString") + updatePolicyStateOptionsModel.IfMatch = core.StringPtr("testString") + updatePolicyStateOptionsModel.State = core.StringPtr("active") + updatePolicyStateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := iamPolicyManagementService.PatchPolicy(patchPolicyOptionsModel) + result, response, operationErr := iamPolicyManagementService.UpdatePolicyState(updatePolicyStateOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -2379,15 +2379,15 @@ var _ = Describe(`IamPolicyManagementV1`, func() { }) }) }) - Describe(`UpdateRole(updateRoleOptions *UpdateRoleOptions) - Operation response error`, func() { - updateRolePath := "/v2/roles/testString" + Describe(`ReplaceRole(replaceRoleOptions *ReplaceRoleOptions) - Operation response error`, func() { + replaceRolePath := "/v2/roles/testString" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(updateRolePath)) + Expect(req.URL.EscapedPath()).To(Equal(replaceRolePath)) Expect(req.Method).To(Equal("PUT")) Expect(req.Header["If-Match"]).ToNot(BeNil()) Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) @@ -2396,7 +2396,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke UpdateRole with error: Operation response processing error`, func() { + It(`Invoke ReplaceRole with error: Operation response processing error`, func() { iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -2404,23 +2404,23 @@ var _ = Describe(`IamPolicyManagementV1`, func() { 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"} + // Construct an instance of the ReplaceRoleOptions model + replaceRoleOptionsModel := new(iampolicymanagementv1.ReplaceRoleOptions) + replaceRoleOptionsModel.RoleID = core.StringPtr("testString") + replaceRoleOptionsModel.IfMatch = core.StringPtr("testString") + replaceRoleOptionsModel.DisplayName = core.StringPtr("testString") + replaceRoleOptionsModel.Actions = []string{"testString"} + replaceRoleOptionsModel.Description = core.StringPtr("testString") + replaceRoleOptionsModel.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.UpdateRole(updateRoleOptionsModel) + result, response, operationErr := iamPolicyManagementService.ReplaceRole(replaceRoleOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again iamPolicyManagementService.EnableRetries(0, 0) - result, response, operationErr = iamPolicyManagementService.UpdateRole(updateRoleOptionsModel) + result, response, operationErr = iamPolicyManagementService.ReplaceRole(replaceRoleOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -2430,15 +2430,15 @@ var _ = Describe(`IamPolicyManagementV1`, func() { }) }) }) - Describe(`UpdateRole(updateRoleOptions *UpdateRoleOptions)`, func() { - updateRolePath := "/v2/roles/testString" + Describe(`ReplaceRole(replaceRoleOptions *ReplaceRoleOptions)`, func() { + replaceRolePath := "/v2/roles/testString" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(updateRolePath)) + Expect(req.URL.EscapedPath()).To(Equal(replaceRolePath)) Expect(req.Method).To(Equal("PUT")) // For gzip-disabled operation, verify Content-Encoding is not set. @@ -2468,7 +2468,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { 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() { + It(`Invoke ReplaceRole successfully with retries`, func() { iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -2477,25 +2477,25 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(iamPolicyManagementService).ToNot(BeNil()) iamPolicyManagementService.EnableRetries(0, 0) - // 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"} + // Construct an instance of the ReplaceRoleOptions model + replaceRoleOptionsModel := new(iampolicymanagementv1.ReplaceRoleOptions) + replaceRoleOptionsModel.RoleID = core.StringPtr("testString") + replaceRoleOptionsModel.IfMatch = core.StringPtr("testString") + replaceRoleOptionsModel.DisplayName = core.StringPtr("testString") + replaceRoleOptionsModel.Actions = []string{"testString"} + replaceRoleOptionsModel.Description = core.StringPtr("testString") + replaceRoleOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := iamPolicyManagementService.UpdateRoleWithContext(ctx, updateRoleOptionsModel) + _, _, operationErr := iamPolicyManagementService.ReplaceRoleWithContext(ctx, replaceRoleOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again iamPolicyManagementService.DisableRetries() - result, response, operationErr := iamPolicyManagementService.UpdateRole(updateRoleOptionsModel) + result, response, operationErr := iamPolicyManagementService.ReplaceRole(replaceRoleOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -2503,7 +2503,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = iamPolicyManagementService.UpdateRoleWithContext(ctx, updateRoleOptionsModel) + _, _, operationErr = iamPolicyManagementService.ReplaceRoleWithContext(ctx, replaceRoleOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -2517,7 +2517,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(updateRolePath)) + Expect(req.URL.EscapedPath()).To(Equal(replaceRolePath)) Expect(req.Method).To(Equal("PUT")) // For gzip-disabled operation, verify Content-Encoding is not set. @@ -2544,7 +2544,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { 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() { + It(`Invoke ReplaceRole successfully`, func() { iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -2553,28 +2553,28 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(iamPolicyManagementService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := iamPolicyManagementService.UpdateRole(nil) + result, response, operationErr := iamPolicyManagementService.ReplaceRole(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(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"} + // Construct an instance of the ReplaceRoleOptions model + replaceRoleOptionsModel := new(iampolicymanagementv1.ReplaceRoleOptions) + replaceRoleOptionsModel.RoleID = core.StringPtr("testString") + replaceRoleOptionsModel.IfMatch = core.StringPtr("testString") + replaceRoleOptionsModel.DisplayName = core.StringPtr("testString") + replaceRoleOptionsModel.Actions = []string{"testString"} + replaceRoleOptionsModel.Description = core.StringPtr("testString") + replaceRoleOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = iamPolicyManagementService.UpdateRole(updateRoleOptionsModel) + result, response, operationErr = iamPolicyManagementService.ReplaceRole(replaceRoleOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke UpdateRole with error: Operation validation and request error`, func() { + It(`Invoke ReplaceRole with error: Operation validation and request error`, func() { iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -2582,26 +2582,26 @@ var _ = Describe(`IamPolicyManagementV1`, func() { 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"} + // Construct an instance of the ReplaceRoleOptions model + replaceRoleOptionsModel := new(iampolicymanagementv1.ReplaceRoleOptions) + replaceRoleOptionsModel.RoleID = core.StringPtr("testString") + replaceRoleOptionsModel.IfMatch = core.StringPtr("testString") + replaceRoleOptionsModel.DisplayName = core.StringPtr("testString") + replaceRoleOptionsModel.Actions = []string{"testString"} + replaceRoleOptionsModel.Description = core.StringPtr("testString") + replaceRoleOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := iamPolicyManagementService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := iamPolicyManagementService.UpdateRole(updateRoleOptionsModel) + result, response, operationErr := iamPolicyManagementService.ReplaceRole(replaceRoleOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct a second instance of the UpdateRoleOptions model with no property values - updateRoleOptionsModelNew := new(iampolicymanagementv1.UpdateRoleOptions) + // Construct a second instance of the ReplaceRoleOptions model with no property values + replaceRoleOptionsModelNew := new(iampolicymanagementv1.ReplaceRoleOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = iamPolicyManagementService.UpdateRole(updateRoleOptionsModelNew) + result, response, operationErr = iamPolicyManagementService.ReplaceRole(replaceRoleOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -2619,7 +2619,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke UpdateRole successfully`, func() { + It(`Invoke ReplaceRole successfully`, func() { iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -2627,17 +2627,17 @@ var _ = Describe(`IamPolicyManagementV1`, func() { 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"} + // Construct an instance of the ReplaceRoleOptions model + replaceRoleOptionsModel := new(iampolicymanagementv1.ReplaceRoleOptions) + replaceRoleOptionsModel.RoleID = core.StringPtr("testString") + replaceRoleOptionsModel.IfMatch = core.StringPtr("testString") + replaceRoleOptionsModel.DisplayName = core.StringPtr("testString") + replaceRoleOptionsModel.Actions = []string{"testString"} + replaceRoleOptionsModel.Description = core.StringPtr("testString") + replaceRoleOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := iamPolicyManagementService.UpdateRole(updateRoleOptionsModel) + result, response, operationErr := iamPolicyManagementService.ReplaceRole(replaceRoleOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -2929,15 +2929,15 @@ var _ = Describe(`IamPolicyManagementV1`, func() { }) }) }) - Describe(`V2ListPolicies(v2ListPoliciesOptions *V2ListPoliciesOptions) - Operation response error`, func() { - v2ListPoliciesPath := "/v2/policies" + Describe(`ListV2Policies(listV2PoliciesOptions *ListV2PoliciesOptions) - Operation response error`, func() { + listV2PoliciesPath := "/v2/policies" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(v2ListPoliciesPath)) + Expect(req.URL.EscapedPath()).To(Equal(listV2PoliciesPath)) Expect(req.Method).To(Equal("GET")) Expect(req.Header["Accept-Language"]).ToNot(BeNil()) Expect(req.Header["Accept-Language"][0]).To(Equal(fmt.Sprintf("%v", "default"))) @@ -2955,7 +2955,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke V2ListPolicies with error: Operation response processing error`, func() { + It(`Invoke ListV2Policies with error: Operation response processing error`, func() { iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -2963,28 +2963,28 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(serviceErr).To(BeNil()) Expect(iamPolicyManagementService).ToNot(BeNil()) - // Construct an instance of the V2ListPoliciesOptions model - v2ListPoliciesOptionsModel := new(iampolicymanagementv1.V2ListPoliciesOptions) - v2ListPoliciesOptionsModel.AccountID = core.StringPtr("testString") - v2ListPoliciesOptionsModel.AcceptLanguage = core.StringPtr("default") - v2ListPoliciesOptionsModel.IamID = core.StringPtr("testString") - v2ListPoliciesOptionsModel.AccessGroupID = core.StringPtr("testString") - v2ListPoliciesOptionsModel.Type = core.StringPtr("access") - v2ListPoliciesOptionsModel.ServiceType = core.StringPtr("service") - v2ListPoliciesOptionsModel.ServiceName = core.StringPtr("testString") - v2ListPoliciesOptionsModel.ServiceGroupID = core.StringPtr("testString") - v2ListPoliciesOptionsModel.Format = core.StringPtr("include_last_permit") - v2ListPoliciesOptionsModel.State = core.StringPtr("active") - v2ListPoliciesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListV2PoliciesOptions model + listV2PoliciesOptionsModel := new(iampolicymanagementv1.ListV2PoliciesOptions) + listV2PoliciesOptionsModel.AccountID = core.StringPtr("testString") + listV2PoliciesOptionsModel.AcceptLanguage = core.StringPtr("default") + listV2PoliciesOptionsModel.IamID = core.StringPtr("testString") + listV2PoliciesOptionsModel.AccessGroupID = core.StringPtr("testString") + listV2PoliciesOptionsModel.Type = core.StringPtr("access") + listV2PoliciesOptionsModel.ServiceType = core.StringPtr("service") + listV2PoliciesOptionsModel.ServiceName = core.StringPtr("testString") + listV2PoliciesOptionsModel.ServiceGroupID = core.StringPtr("testString") + listV2PoliciesOptionsModel.Format = core.StringPtr("include_last_permit") + listV2PoliciesOptionsModel.State = core.StringPtr("active") + listV2PoliciesOptionsModel.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.V2ListPolicies(v2ListPoliciesOptionsModel) + result, response, operationErr := iamPolicyManagementService.ListV2Policies(listV2PoliciesOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again iamPolicyManagementService.EnableRetries(0, 0) - result, response, operationErr = iamPolicyManagementService.V2ListPolicies(v2ListPoliciesOptionsModel) + result, response, operationErr = iamPolicyManagementService.ListV2Policies(listV2PoliciesOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -2994,15 +2994,15 @@ var _ = Describe(`IamPolicyManagementV1`, func() { }) }) }) - Describe(`V2ListPolicies(v2ListPoliciesOptions *V2ListPoliciesOptions)`, func() { - v2ListPoliciesPath := "/v2/policies" + Describe(`ListV2Policies(listV2PoliciesOptions *ListV2PoliciesOptions)`, func() { + listV2PoliciesPath := "/v2/policies" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(v2ListPoliciesPath)) + Expect(req.URL.EscapedPath()).To(Equal(listV2PoliciesPath)) Expect(req.Method).To(Equal("GET")) Expect(req.Header["Accept-Language"]).ToNot(BeNil()) @@ -3022,10 +3022,10 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"policies": [{"id": "ID", "type": "Type", "description": "Description", "subject": {"attributes": [{"key": "Key", "operator": "Operator", "value": "anyValue"}]}, "control": {"grant": {"roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}]}}, "resource": {"attributes": [{"key": "Key", "operator": "Operator", "value": "anyValue"}]}, "pattern": "Pattern", "rule": {"key": "Key", "operator": "Operator", "value": "anyValue"}, "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"}]}`) + fmt.Fprintf(res, "%s", `{"policies": [{"type": "access", "description": "Description", "subject": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "Value"}]}, "resource": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "Key", "value": "Value", "operator": "stringEquals"}]}, "pattern": "Pattern", "rule": {"key": "Key", "operator": "timeLessThan", "value": "anyValue"}, "id": "ID", "href": "Href", "control": {"grant": {"roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}]}}, "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", "last_permit_at": "LastPermitAt", "last_permit_frequency": 19}]}`) })) }) - It(`Invoke V2ListPolicies successfully with retries`, func() { + It(`Invoke ListV2Policies successfully with retries`, func() { iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -3034,30 +3034,30 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(iamPolicyManagementService).ToNot(BeNil()) iamPolicyManagementService.EnableRetries(0, 0) - // Construct an instance of the V2ListPoliciesOptions model - v2ListPoliciesOptionsModel := new(iampolicymanagementv1.V2ListPoliciesOptions) - v2ListPoliciesOptionsModel.AccountID = core.StringPtr("testString") - v2ListPoliciesOptionsModel.AcceptLanguage = core.StringPtr("default") - v2ListPoliciesOptionsModel.IamID = core.StringPtr("testString") - v2ListPoliciesOptionsModel.AccessGroupID = core.StringPtr("testString") - v2ListPoliciesOptionsModel.Type = core.StringPtr("access") - v2ListPoliciesOptionsModel.ServiceType = core.StringPtr("service") - v2ListPoliciesOptionsModel.ServiceName = core.StringPtr("testString") - v2ListPoliciesOptionsModel.ServiceGroupID = core.StringPtr("testString") - v2ListPoliciesOptionsModel.Format = core.StringPtr("include_last_permit") - v2ListPoliciesOptionsModel.State = core.StringPtr("active") - v2ListPoliciesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListV2PoliciesOptions model + listV2PoliciesOptionsModel := new(iampolicymanagementv1.ListV2PoliciesOptions) + listV2PoliciesOptionsModel.AccountID = core.StringPtr("testString") + listV2PoliciesOptionsModel.AcceptLanguage = core.StringPtr("default") + listV2PoliciesOptionsModel.IamID = core.StringPtr("testString") + listV2PoliciesOptionsModel.AccessGroupID = core.StringPtr("testString") + listV2PoliciesOptionsModel.Type = core.StringPtr("access") + listV2PoliciesOptionsModel.ServiceType = core.StringPtr("service") + listV2PoliciesOptionsModel.ServiceName = core.StringPtr("testString") + listV2PoliciesOptionsModel.ServiceGroupID = core.StringPtr("testString") + listV2PoliciesOptionsModel.Format = core.StringPtr("include_last_permit") + listV2PoliciesOptionsModel.State = core.StringPtr("active") + listV2PoliciesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := iamPolicyManagementService.V2ListPoliciesWithContext(ctx, v2ListPoliciesOptionsModel) + _, _, operationErr := iamPolicyManagementService.ListV2PoliciesWithContext(ctx, listV2PoliciesOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again iamPolicyManagementService.DisableRetries() - result, response, operationErr := iamPolicyManagementService.V2ListPolicies(v2ListPoliciesOptionsModel) + result, response, operationErr := iamPolicyManagementService.ListV2Policies(listV2PoliciesOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -3065,7 +3065,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = iamPolicyManagementService.V2ListPoliciesWithContext(ctx, v2ListPoliciesOptionsModel) + _, _, operationErr = iamPolicyManagementService.ListV2PoliciesWithContext(ctx, listV2PoliciesOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -3079,7 +3079,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(v2ListPoliciesPath)) + Expect(req.URL.EscapedPath()).To(Equal(listV2PoliciesPath)) Expect(req.Method).To(Equal("GET")) Expect(req.Header["Accept-Language"]).ToNot(BeNil()) @@ -3096,10 +3096,10 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"policies": [{"id": "ID", "type": "Type", "description": "Description", "subject": {"attributes": [{"key": "Key", "operator": "Operator", "value": "anyValue"}]}, "control": {"grant": {"roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}]}}, "resource": {"attributes": [{"key": "Key", "operator": "Operator", "value": "anyValue"}]}, "pattern": "Pattern", "rule": {"key": "Key", "operator": "Operator", "value": "anyValue"}, "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"}]}`) + fmt.Fprintf(res, "%s", `{"policies": [{"type": "access", "description": "Description", "subject": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "Value"}]}, "resource": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "Key", "value": "Value", "operator": "stringEquals"}]}, "pattern": "Pattern", "rule": {"key": "Key", "operator": "timeLessThan", "value": "anyValue"}, "id": "ID", "href": "Href", "control": {"grant": {"roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}]}}, "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", "last_permit_at": "LastPermitAt", "last_permit_frequency": 19}]}`) })) }) - It(`Invoke V2ListPolicies successfully`, func() { + It(`Invoke ListV2Policies successfully`, func() { iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -3108,33 +3108,33 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(iamPolicyManagementService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := iamPolicyManagementService.V2ListPolicies(nil) + result, response, operationErr := iamPolicyManagementService.ListV2Policies(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the V2ListPoliciesOptions model - v2ListPoliciesOptionsModel := new(iampolicymanagementv1.V2ListPoliciesOptions) - v2ListPoliciesOptionsModel.AccountID = core.StringPtr("testString") - v2ListPoliciesOptionsModel.AcceptLanguage = core.StringPtr("default") - v2ListPoliciesOptionsModel.IamID = core.StringPtr("testString") - v2ListPoliciesOptionsModel.AccessGroupID = core.StringPtr("testString") - v2ListPoliciesOptionsModel.Type = core.StringPtr("access") - v2ListPoliciesOptionsModel.ServiceType = core.StringPtr("service") - v2ListPoliciesOptionsModel.ServiceName = core.StringPtr("testString") - v2ListPoliciesOptionsModel.ServiceGroupID = core.StringPtr("testString") - v2ListPoliciesOptionsModel.Format = core.StringPtr("include_last_permit") - v2ListPoliciesOptionsModel.State = core.StringPtr("active") - v2ListPoliciesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListV2PoliciesOptions model + listV2PoliciesOptionsModel := new(iampolicymanagementv1.ListV2PoliciesOptions) + listV2PoliciesOptionsModel.AccountID = core.StringPtr("testString") + listV2PoliciesOptionsModel.AcceptLanguage = core.StringPtr("default") + listV2PoliciesOptionsModel.IamID = core.StringPtr("testString") + listV2PoliciesOptionsModel.AccessGroupID = core.StringPtr("testString") + listV2PoliciesOptionsModel.Type = core.StringPtr("access") + listV2PoliciesOptionsModel.ServiceType = core.StringPtr("service") + listV2PoliciesOptionsModel.ServiceName = core.StringPtr("testString") + listV2PoliciesOptionsModel.ServiceGroupID = core.StringPtr("testString") + listV2PoliciesOptionsModel.Format = core.StringPtr("include_last_permit") + listV2PoliciesOptionsModel.State = core.StringPtr("active") + listV2PoliciesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = iamPolicyManagementService.V2ListPolicies(v2ListPoliciesOptionsModel) + result, response, operationErr = iamPolicyManagementService.ListV2Policies(listV2PoliciesOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke V2ListPolicies with error: Operation validation and request error`, func() { + It(`Invoke ListV2Policies with error: Operation validation and request error`, func() { iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -3142,31 +3142,31 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(serviceErr).To(BeNil()) Expect(iamPolicyManagementService).ToNot(BeNil()) - // Construct an instance of the V2ListPoliciesOptions model - v2ListPoliciesOptionsModel := new(iampolicymanagementv1.V2ListPoliciesOptions) - v2ListPoliciesOptionsModel.AccountID = core.StringPtr("testString") - v2ListPoliciesOptionsModel.AcceptLanguage = core.StringPtr("default") - v2ListPoliciesOptionsModel.IamID = core.StringPtr("testString") - v2ListPoliciesOptionsModel.AccessGroupID = core.StringPtr("testString") - v2ListPoliciesOptionsModel.Type = core.StringPtr("access") - v2ListPoliciesOptionsModel.ServiceType = core.StringPtr("service") - v2ListPoliciesOptionsModel.ServiceName = core.StringPtr("testString") - v2ListPoliciesOptionsModel.ServiceGroupID = core.StringPtr("testString") - v2ListPoliciesOptionsModel.Format = core.StringPtr("include_last_permit") - v2ListPoliciesOptionsModel.State = core.StringPtr("active") - v2ListPoliciesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListV2PoliciesOptions model + listV2PoliciesOptionsModel := new(iampolicymanagementv1.ListV2PoliciesOptions) + listV2PoliciesOptionsModel.AccountID = core.StringPtr("testString") + listV2PoliciesOptionsModel.AcceptLanguage = core.StringPtr("default") + listV2PoliciesOptionsModel.IamID = core.StringPtr("testString") + listV2PoliciesOptionsModel.AccessGroupID = core.StringPtr("testString") + listV2PoliciesOptionsModel.Type = core.StringPtr("access") + listV2PoliciesOptionsModel.ServiceType = core.StringPtr("service") + listV2PoliciesOptionsModel.ServiceName = core.StringPtr("testString") + listV2PoliciesOptionsModel.ServiceGroupID = core.StringPtr("testString") + listV2PoliciesOptionsModel.Format = core.StringPtr("include_last_permit") + listV2PoliciesOptionsModel.State = core.StringPtr("active") + listV2PoliciesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := iamPolicyManagementService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := iamPolicyManagementService.V2ListPolicies(v2ListPoliciesOptionsModel) + result, response, operationErr := iamPolicyManagementService.ListV2Policies(listV2PoliciesOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct a second instance of the V2ListPoliciesOptions model with no property values - v2ListPoliciesOptionsModelNew := new(iampolicymanagementv1.V2ListPoliciesOptions) + // Construct a second instance of the ListV2PoliciesOptions model with no property values + listV2PoliciesOptionsModelNew := new(iampolicymanagementv1.ListV2PoliciesOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = iamPolicyManagementService.V2ListPolicies(v2ListPoliciesOptionsModelNew) + result, response, operationErr = iamPolicyManagementService.ListV2Policies(listV2PoliciesOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -3184,7 +3184,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke V2ListPolicies successfully`, func() { + It(`Invoke ListV2Policies successfully`, func() { iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -3192,22 +3192,22 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(serviceErr).To(BeNil()) Expect(iamPolicyManagementService).ToNot(BeNil()) - // Construct an instance of the V2ListPoliciesOptions model - v2ListPoliciesOptionsModel := new(iampolicymanagementv1.V2ListPoliciesOptions) - v2ListPoliciesOptionsModel.AccountID = core.StringPtr("testString") - v2ListPoliciesOptionsModel.AcceptLanguage = core.StringPtr("default") - v2ListPoliciesOptionsModel.IamID = core.StringPtr("testString") - v2ListPoliciesOptionsModel.AccessGroupID = core.StringPtr("testString") - v2ListPoliciesOptionsModel.Type = core.StringPtr("access") - v2ListPoliciesOptionsModel.ServiceType = core.StringPtr("service") - v2ListPoliciesOptionsModel.ServiceName = core.StringPtr("testString") - v2ListPoliciesOptionsModel.ServiceGroupID = core.StringPtr("testString") - v2ListPoliciesOptionsModel.Format = core.StringPtr("include_last_permit") - v2ListPoliciesOptionsModel.State = core.StringPtr("active") - v2ListPoliciesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListV2PoliciesOptions model + listV2PoliciesOptionsModel := new(iampolicymanagementv1.ListV2PoliciesOptions) + listV2PoliciesOptionsModel.AccountID = core.StringPtr("testString") + listV2PoliciesOptionsModel.AcceptLanguage = core.StringPtr("default") + listV2PoliciesOptionsModel.IamID = core.StringPtr("testString") + listV2PoliciesOptionsModel.AccessGroupID = core.StringPtr("testString") + listV2PoliciesOptionsModel.Type = core.StringPtr("access") + listV2PoliciesOptionsModel.ServiceType = core.StringPtr("service") + listV2PoliciesOptionsModel.ServiceName = core.StringPtr("testString") + listV2PoliciesOptionsModel.ServiceGroupID = core.StringPtr("testString") + listV2PoliciesOptionsModel.Format = core.StringPtr("include_last_permit") + listV2PoliciesOptionsModel.State = core.StringPtr("active") + listV2PoliciesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := iamPolicyManagementService.V2ListPolicies(v2ListPoliciesOptionsModel) + result, response, operationErr := iamPolicyManagementService.ListV2Policies(listV2PoliciesOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -3219,15 +3219,15 @@ var _ = Describe(`IamPolicyManagementV1`, func() { }) }) }) - Describe(`V2CreatePolicy(v2CreatePolicyOptions *V2CreatePolicyOptions) - Operation response error`, func() { - v2CreatePolicyPath := "/v2/policies" + Describe(`CreateV2Policy(createV2PolicyOptions *CreateV2PolicyOptions) - Operation response error`, func() { + createV2PolicyPath := "/v2/policies" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(v2CreatePolicyPath)) + Expect(req.URL.EscapedPath()).To(Equal(createV2PolicyPath)) Expect(req.Method).To(Equal("POST")) Expect(req.Header["Accept-Language"]).ToNot(BeNil()) Expect(req.Header["Accept-Language"][0]).To(Equal(fmt.Sprintf("%v", "default"))) @@ -3236,7 +3236,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke V2CreatePolicy with error: Operation response processing error`, func() { + It(`Invoke CreateV2Policy with error: Operation response processing error`, func() { iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -3248,54 +3248,67 @@ var _ = Describe(`IamPolicyManagementV1`, func() { policyRoleModel := new(iampolicymanagementv1.PolicyRole) policyRoleModel.RoleID = core.StringPtr("testString") - // Construct an instance of the V2PolicyBaseControlGrant model - v2PolicyBaseControlGrantModel := new(iampolicymanagementv1.V2PolicyBaseControlGrant) - v2PolicyBaseControlGrantModel.Roles = []iampolicymanagementv1.PolicyRole{*policyRoleModel} - - // Construct an instance of the V2PolicyBaseControl model - v2PolicyBaseControlModel := new(iampolicymanagementv1.V2PolicyBaseControl) - v2PolicyBaseControlModel.Grant = v2PolicyBaseControlGrantModel - - // Construct an instance of the V2PolicyAttribute model - v2PolicyAttributeModel := new(iampolicymanagementv1.V2PolicyAttribute) - v2PolicyAttributeModel.Key = core.StringPtr("testString") - v2PolicyAttributeModel.Operator = core.StringPtr("testString") - v2PolicyAttributeModel.Value = core.StringPtr("testString") - - // Construct an instance of the V2PolicyBaseSubject model - v2PolicyBaseSubjectModel := new(iampolicymanagementv1.V2PolicyBaseSubject) - v2PolicyBaseSubjectModel.Attributes = []iampolicymanagementv1.V2PolicyAttribute{*v2PolicyAttributeModel} - - // Construct an instance of the V2PolicyBaseResource model - v2PolicyBaseResourceModel := new(iampolicymanagementv1.V2PolicyBaseResource) - v2PolicyBaseResourceModel.Attributes = []iampolicymanagementv1.V2PolicyAttribute{*v2PolicyAttributeModel} - - // Construct an instance of the V2PolicyBaseRuleV2PolicyAttribute model - v2PolicyBaseRuleModel := new(iampolicymanagementv1.V2PolicyBaseRuleV2PolicyAttribute) - v2PolicyBaseRuleModel.Key = core.StringPtr("testString") - v2PolicyBaseRuleModel.Operator = core.StringPtr("testString") - v2PolicyBaseRuleModel.Value = core.StringPtr("testString") - - // Construct an instance of the V2CreatePolicyOptions model - v2CreatePolicyOptionsModel := new(iampolicymanagementv1.V2CreatePolicyOptions) - v2CreatePolicyOptionsModel.Type = core.StringPtr("testString") - v2CreatePolicyOptionsModel.Control = v2PolicyBaseControlModel - v2CreatePolicyOptionsModel.Description = core.StringPtr("testString") - v2CreatePolicyOptionsModel.Subject = v2PolicyBaseSubjectModel - v2CreatePolicyOptionsModel.Resource = v2PolicyBaseResourceModel - v2CreatePolicyOptionsModel.Pattern = core.StringPtr("testString") - v2CreatePolicyOptionsModel.Rule = v2PolicyBaseRuleModel - v2CreatePolicyOptionsModel.AcceptLanguage = core.StringPtr("default") - v2CreatePolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the V2PolicyGrant model + v2PolicyGrantModel := new(iampolicymanagementv1.V2PolicyGrant) + v2PolicyGrantModel.Roles = []iampolicymanagementv1.PolicyRole{*policyRoleModel} + + // Construct an instance of the Control model + controlModel := new(iampolicymanagementv1.Control) + controlModel.Grant = v2PolicyGrantModel + + // Construct an instance of the V2PolicySubjectAttribute model + v2PolicySubjectAttributeModel := new(iampolicymanagementv1.V2PolicySubjectAttribute) + v2PolicySubjectAttributeModel.Key = core.StringPtr("testString") + v2PolicySubjectAttributeModel.Operator = core.StringPtr("stringEquals") + v2PolicySubjectAttributeModel.Value = core.StringPtr("testString") + + // Construct an instance of the V2PolicySubject model + v2PolicySubjectModel := new(iampolicymanagementv1.V2PolicySubject) + v2PolicySubjectModel.Attributes = []iampolicymanagementv1.V2PolicySubjectAttribute{*v2PolicySubjectAttributeModel} + + // Construct an instance of the V2PolicyResourceAttribute model + v2PolicyResourceAttributeModel := new(iampolicymanagementv1.V2PolicyResourceAttribute) + v2PolicyResourceAttributeModel.Key = core.StringPtr("testString") + v2PolicyResourceAttributeModel.Operator = core.StringPtr("stringEquals") + v2PolicyResourceAttributeModel.Value = core.StringPtr("testString") + + // Construct an instance of the V2PolicyResourceTag model + v2PolicyResourceTagModel := new(iampolicymanagementv1.V2PolicyResourceTag) + v2PolicyResourceTagModel.Key = core.StringPtr("testString") + v2PolicyResourceTagModel.Value = core.StringPtr("testString") + v2PolicyResourceTagModel.Operator = core.StringPtr("stringEquals") + + // Construct an instance of the V2PolicyResource model + v2PolicyResourceModel := new(iampolicymanagementv1.V2PolicyResource) + v2PolicyResourceModel.Attributes = []iampolicymanagementv1.V2PolicyResourceAttribute{*v2PolicyResourceAttributeModel} + v2PolicyResourceModel.Tags = []iampolicymanagementv1.V2PolicyResourceTag{*v2PolicyResourceTagModel} + + // Construct an instance of the V2PolicyRuleRuleAttribute model + v2PolicyRuleModel := new(iampolicymanagementv1.V2PolicyRuleRuleAttribute) + v2PolicyRuleModel.Key = core.StringPtr("testString") + v2PolicyRuleModel.Operator = core.StringPtr("timeLessThan") + v2PolicyRuleModel.Value = core.StringPtr("testString") + + // Construct an instance of the CreateV2PolicyOptions model + createV2PolicyOptionsModel := new(iampolicymanagementv1.CreateV2PolicyOptions) + createV2PolicyOptionsModel.Control = controlModel + createV2PolicyOptionsModel.Type = core.StringPtr("access") + createV2PolicyOptionsModel.Description = core.StringPtr("testString") + createV2PolicyOptionsModel.Subject = v2PolicySubjectModel + createV2PolicyOptionsModel.Resource = v2PolicyResourceModel + createV2PolicyOptionsModel.Pattern = core.StringPtr("testString") + createV2PolicyOptionsModel.Rule = v2PolicyRuleModel + createV2PolicyOptionsModel.AcceptLanguage = core.StringPtr("default") + createV2PolicyOptionsModel.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.V2CreatePolicy(v2CreatePolicyOptionsModel) + result, response, operationErr := iamPolicyManagementService.CreateV2Policy(createV2PolicyOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again iamPolicyManagementService.EnableRetries(0, 0) - result, response, operationErr = iamPolicyManagementService.V2CreatePolicy(v2CreatePolicyOptionsModel) + result, response, operationErr = iamPolicyManagementService.CreateV2Policy(createV2PolicyOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -3305,15 +3318,15 @@ var _ = Describe(`IamPolicyManagementV1`, func() { }) }) }) - Describe(`V2CreatePolicy(v2CreatePolicyOptions *V2CreatePolicyOptions)`, func() { - v2CreatePolicyPath := "/v2/policies" + Describe(`CreateV2Policy(createV2PolicyOptions *CreateV2PolicyOptions)`, func() { + createV2PolicyPath := "/v2/policies" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(v2CreatePolicyPath)) + Expect(req.URL.EscapedPath()).To(Equal(createV2PolicyPath)) Expect(req.Method).To(Equal("POST")) // For gzip-disabled operation, verify Content-Encoding is not set. @@ -3340,10 +3353,10 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subject": {"attributes": [{"key": "Key", "operator": "Operator", "value": "anyValue"}]}, "control": {"grant": {"roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}]}}, "resource": {"attributes": [{"key": "Key", "operator": "Operator", "value": "anyValue"}]}, "pattern": "Pattern", "rule": {"key": "Key", "operator": "Operator", "value": "anyValue"}, "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"}`) + fmt.Fprintf(res, "%s", `{"type": "access", "description": "Description", "subject": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "Value"}]}, "resource": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "Key", "value": "Value", "operator": "stringEquals"}]}, "pattern": "Pattern", "rule": {"key": "Key", "operator": "timeLessThan", "value": "anyValue"}, "id": "ID", "href": "Href", "control": {"grant": {"roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}]}}, "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", "last_permit_at": "LastPermitAt", "last_permit_frequency": 19}`) })) }) - It(`Invoke V2CreatePolicy successfully with retries`, func() { + It(`Invoke CreateV2Policy successfully with retries`, func() { iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -3356,56 +3369,69 @@ var _ = Describe(`IamPolicyManagementV1`, func() { policyRoleModel := new(iampolicymanagementv1.PolicyRole) policyRoleModel.RoleID = core.StringPtr("testString") - // Construct an instance of the V2PolicyBaseControlGrant model - v2PolicyBaseControlGrantModel := new(iampolicymanagementv1.V2PolicyBaseControlGrant) - v2PolicyBaseControlGrantModel.Roles = []iampolicymanagementv1.PolicyRole{*policyRoleModel} - - // Construct an instance of the V2PolicyBaseControl model - v2PolicyBaseControlModel := new(iampolicymanagementv1.V2PolicyBaseControl) - v2PolicyBaseControlModel.Grant = v2PolicyBaseControlGrantModel - - // Construct an instance of the V2PolicyAttribute model - v2PolicyAttributeModel := new(iampolicymanagementv1.V2PolicyAttribute) - v2PolicyAttributeModel.Key = core.StringPtr("testString") - v2PolicyAttributeModel.Operator = core.StringPtr("testString") - v2PolicyAttributeModel.Value = core.StringPtr("testString") - - // Construct an instance of the V2PolicyBaseSubject model - v2PolicyBaseSubjectModel := new(iampolicymanagementv1.V2PolicyBaseSubject) - v2PolicyBaseSubjectModel.Attributes = []iampolicymanagementv1.V2PolicyAttribute{*v2PolicyAttributeModel} - - // Construct an instance of the V2PolicyBaseResource model - v2PolicyBaseResourceModel := new(iampolicymanagementv1.V2PolicyBaseResource) - v2PolicyBaseResourceModel.Attributes = []iampolicymanagementv1.V2PolicyAttribute{*v2PolicyAttributeModel} - - // Construct an instance of the V2PolicyBaseRuleV2PolicyAttribute model - v2PolicyBaseRuleModel := new(iampolicymanagementv1.V2PolicyBaseRuleV2PolicyAttribute) - v2PolicyBaseRuleModel.Key = core.StringPtr("testString") - v2PolicyBaseRuleModel.Operator = core.StringPtr("testString") - v2PolicyBaseRuleModel.Value = core.StringPtr("testString") - - // Construct an instance of the V2CreatePolicyOptions model - v2CreatePolicyOptionsModel := new(iampolicymanagementv1.V2CreatePolicyOptions) - v2CreatePolicyOptionsModel.Type = core.StringPtr("testString") - v2CreatePolicyOptionsModel.Control = v2PolicyBaseControlModel - v2CreatePolicyOptionsModel.Description = core.StringPtr("testString") - v2CreatePolicyOptionsModel.Subject = v2PolicyBaseSubjectModel - v2CreatePolicyOptionsModel.Resource = v2PolicyBaseResourceModel - v2CreatePolicyOptionsModel.Pattern = core.StringPtr("testString") - v2CreatePolicyOptionsModel.Rule = v2PolicyBaseRuleModel - v2CreatePolicyOptionsModel.AcceptLanguage = core.StringPtr("default") - v2CreatePolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the V2PolicyGrant model + v2PolicyGrantModel := new(iampolicymanagementv1.V2PolicyGrant) + v2PolicyGrantModel.Roles = []iampolicymanagementv1.PolicyRole{*policyRoleModel} + + // Construct an instance of the Control model + controlModel := new(iampolicymanagementv1.Control) + controlModel.Grant = v2PolicyGrantModel + + // Construct an instance of the V2PolicySubjectAttribute model + v2PolicySubjectAttributeModel := new(iampolicymanagementv1.V2PolicySubjectAttribute) + v2PolicySubjectAttributeModel.Key = core.StringPtr("testString") + v2PolicySubjectAttributeModel.Operator = core.StringPtr("stringEquals") + v2PolicySubjectAttributeModel.Value = core.StringPtr("testString") + + // Construct an instance of the V2PolicySubject model + v2PolicySubjectModel := new(iampolicymanagementv1.V2PolicySubject) + v2PolicySubjectModel.Attributes = []iampolicymanagementv1.V2PolicySubjectAttribute{*v2PolicySubjectAttributeModel} + + // Construct an instance of the V2PolicyResourceAttribute model + v2PolicyResourceAttributeModel := new(iampolicymanagementv1.V2PolicyResourceAttribute) + v2PolicyResourceAttributeModel.Key = core.StringPtr("testString") + v2PolicyResourceAttributeModel.Operator = core.StringPtr("stringEquals") + v2PolicyResourceAttributeModel.Value = core.StringPtr("testString") + + // Construct an instance of the V2PolicyResourceTag model + v2PolicyResourceTagModel := new(iampolicymanagementv1.V2PolicyResourceTag) + v2PolicyResourceTagModel.Key = core.StringPtr("testString") + v2PolicyResourceTagModel.Value = core.StringPtr("testString") + v2PolicyResourceTagModel.Operator = core.StringPtr("stringEquals") + + // Construct an instance of the V2PolicyResource model + v2PolicyResourceModel := new(iampolicymanagementv1.V2PolicyResource) + v2PolicyResourceModel.Attributes = []iampolicymanagementv1.V2PolicyResourceAttribute{*v2PolicyResourceAttributeModel} + v2PolicyResourceModel.Tags = []iampolicymanagementv1.V2PolicyResourceTag{*v2PolicyResourceTagModel} + + // Construct an instance of the V2PolicyRuleRuleAttribute model + v2PolicyRuleModel := new(iampolicymanagementv1.V2PolicyRuleRuleAttribute) + v2PolicyRuleModel.Key = core.StringPtr("testString") + v2PolicyRuleModel.Operator = core.StringPtr("timeLessThan") + v2PolicyRuleModel.Value = core.StringPtr("testString") + + // Construct an instance of the CreateV2PolicyOptions model + createV2PolicyOptionsModel := new(iampolicymanagementv1.CreateV2PolicyOptions) + createV2PolicyOptionsModel.Control = controlModel + createV2PolicyOptionsModel.Type = core.StringPtr("access") + createV2PolicyOptionsModel.Description = core.StringPtr("testString") + createV2PolicyOptionsModel.Subject = v2PolicySubjectModel + createV2PolicyOptionsModel.Resource = v2PolicyResourceModel + createV2PolicyOptionsModel.Pattern = core.StringPtr("testString") + createV2PolicyOptionsModel.Rule = v2PolicyRuleModel + createV2PolicyOptionsModel.AcceptLanguage = core.StringPtr("default") + createV2PolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := iamPolicyManagementService.V2CreatePolicyWithContext(ctx, v2CreatePolicyOptionsModel) + _, _, operationErr := iamPolicyManagementService.CreateV2PolicyWithContext(ctx, createV2PolicyOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again iamPolicyManagementService.DisableRetries() - result, response, operationErr := iamPolicyManagementService.V2CreatePolicy(v2CreatePolicyOptionsModel) + result, response, operationErr := iamPolicyManagementService.CreateV2Policy(createV2PolicyOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -3413,7 +3439,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = iamPolicyManagementService.V2CreatePolicyWithContext(ctx, v2CreatePolicyOptionsModel) + _, _, operationErr = iamPolicyManagementService.CreateV2PolicyWithContext(ctx, createV2PolicyOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -3427,7 +3453,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(v2CreatePolicyPath)) + Expect(req.URL.EscapedPath()).To(Equal(createV2PolicyPath)) Expect(req.Method).To(Equal("POST")) // For gzip-disabled operation, verify Content-Encoding is not set. @@ -3451,10 +3477,10 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subject": {"attributes": [{"key": "Key", "operator": "Operator", "value": "anyValue"}]}, "control": {"grant": {"roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}]}}, "resource": {"attributes": [{"key": "Key", "operator": "Operator", "value": "anyValue"}]}, "pattern": "Pattern", "rule": {"key": "Key", "operator": "Operator", "value": "anyValue"}, "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"}`) + fmt.Fprintf(res, "%s", `{"type": "access", "description": "Description", "subject": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "Value"}]}, "resource": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "Key", "value": "Value", "operator": "stringEquals"}]}, "pattern": "Pattern", "rule": {"key": "Key", "operator": "timeLessThan", "value": "anyValue"}, "id": "ID", "href": "Href", "control": {"grant": {"roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}]}}, "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", "last_permit_at": "LastPermitAt", "last_permit_frequency": 19}`) })) }) - It(`Invoke V2CreatePolicy successfully`, func() { + It(`Invoke CreateV2Policy successfully`, func() { iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -3463,7 +3489,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(iamPolicyManagementService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := iamPolicyManagementService.V2CreatePolicy(nil) + result, response, operationErr := iamPolicyManagementService.CreateV2Policy(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -3472,54 +3498,67 @@ var _ = Describe(`IamPolicyManagementV1`, func() { policyRoleModel := new(iampolicymanagementv1.PolicyRole) policyRoleModel.RoleID = core.StringPtr("testString") - // Construct an instance of the V2PolicyBaseControlGrant model - v2PolicyBaseControlGrantModel := new(iampolicymanagementv1.V2PolicyBaseControlGrant) - v2PolicyBaseControlGrantModel.Roles = []iampolicymanagementv1.PolicyRole{*policyRoleModel} - - // Construct an instance of the V2PolicyBaseControl model - v2PolicyBaseControlModel := new(iampolicymanagementv1.V2PolicyBaseControl) - v2PolicyBaseControlModel.Grant = v2PolicyBaseControlGrantModel - - // Construct an instance of the V2PolicyAttribute model - v2PolicyAttributeModel := new(iampolicymanagementv1.V2PolicyAttribute) - v2PolicyAttributeModel.Key = core.StringPtr("testString") - v2PolicyAttributeModel.Operator = core.StringPtr("testString") - v2PolicyAttributeModel.Value = core.StringPtr("testString") - - // Construct an instance of the V2PolicyBaseSubject model - v2PolicyBaseSubjectModel := new(iampolicymanagementv1.V2PolicyBaseSubject) - v2PolicyBaseSubjectModel.Attributes = []iampolicymanagementv1.V2PolicyAttribute{*v2PolicyAttributeModel} - - // Construct an instance of the V2PolicyBaseResource model - v2PolicyBaseResourceModel := new(iampolicymanagementv1.V2PolicyBaseResource) - v2PolicyBaseResourceModel.Attributes = []iampolicymanagementv1.V2PolicyAttribute{*v2PolicyAttributeModel} - - // Construct an instance of the V2PolicyBaseRuleV2PolicyAttribute model - v2PolicyBaseRuleModel := new(iampolicymanagementv1.V2PolicyBaseRuleV2PolicyAttribute) - v2PolicyBaseRuleModel.Key = core.StringPtr("testString") - v2PolicyBaseRuleModel.Operator = core.StringPtr("testString") - v2PolicyBaseRuleModel.Value = core.StringPtr("testString") - - // Construct an instance of the V2CreatePolicyOptions model - v2CreatePolicyOptionsModel := new(iampolicymanagementv1.V2CreatePolicyOptions) - v2CreatePolicyOptionsModel.Type = core.StringPtr("testString") - v2CreatePolicyOptionsModel.Control = v2PolicyBaseControlModel - v2CreatePolicyOptionsModel.Description = core.StringPtr("testString") - v2CreatePolicyOptionsModel.Subject = v2PolicyBaseSubjectModel - v2CreatePolicyOptionsModel.Resource = v2PolicyBaseResourceModel - v2CreatePolicyOptionsModel.Pattern = core.StringPtr("testString") - v2CreatePolicyOptionsModel.Rule = v2PolicyBaseRuleModel - v2CreatePolicyOptionsModel.AcceptLanguage = core.StringPtr("default") - v2CreatePolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the V2PolicyGrant model + v2PolicyGrantModel := new(iampolicymanagementv1.V2PolicyGrant) + v2PolicyGrantModel.Roles = []iampolicymanagementv1.PolicyRole{*policyRoleModel} + + // Construct an instance of the Control model + controlModel := new(iampolicymanagementv1.Control) + controlModel.Grant = v2PolicyGrantModel + + // Construct an instance of the V2PolicySubjectAttribute model + v2PolicySubjectAttributeModel := new(iampolicymanagementv1.V2PolicySubjectAttribute) + v2PolicySubjectAttributeModel.Key = core.StringPtr("testString") + v2PolicySubjectAttributeModel.Operator = core.StringPtr("stringEquals") + v2PolicySubjectAttributeModel.Value = core.StringPtr("testString") + + // Construct an instance of the V2PolicySubject model + v2PolicySubjectModel := new(iampolicymanagementv1.V2PolicySubject) + v2PolicySubjectModel.Attributes = []iampolicymanagementv1.V2PolicySubjectAttribute{*v2PolicySubjectAttributeModel} + + // Construct an instance of the V2PolicyResourceAttribute model + v2PolicyResourceAttributeModel := new(iampolicymanagementv1.V2PolicyResourceAttribute) + v2PolicyResourceAttributeModel.Key = core.StringPtr("testString") + v2PolicyResourceAttributeModel.Operator = core.StringPtr("stringEquals") + v2PolicyResourceAttributeModel.Value = core.StringPtr("testString") + + // Construct an instance of the V2PolicyResourceTag model + v2PolicyResourceTagModel := new(iampolicymanagementv1.V2PolicyResourceTag) + v2PolicyResourceTagModel.Key = core.StringPtr("testString") + v2PolicyResourceTagModel.Value = core.StringPtr("testString") + v2PolicyResourceTagModel.Operator = core.StringPtr("stringEquals") + + // Construct an instance of the V2PolicyResource model + v2PolicyResourceModel := new(iampolicymanagementv1.V2PolicyResource) + v2PolicyResourceModel.Attributes = []iampolicymanagementv1.V2PolicyResourceAttribute{*v2PolicyResourceAttributeModel} + v2PolicyResourceModel.Tags = []iampolicymanagementv1.V2PolicyResourceTag{*v2PolicyResourceTagModel} + + // Construct an instance of the V2PolicyRuleRuleAttribute model + v2PolicyRuleModel := new(iampolicymanagementv1.V2PolicyRuleRuleAttribute) + v2PolicyRuleModel.Key = core.StringPtr("testString") + v2PolicyRuleModel.Operator = core.StringPtr("timeLessThan") + v2PolicyRuleModel.Value = core.StringPtr("testString") + + // Construct an instance of the CreateV2PolicyOptions model + createV2PolicyOptionsModel := new(iampolicymanagementv1.CreateV2PolicyOptions) + createV2PolicyOptionsModel.Control = controlModel + createV2PolicyOptionsModel.Type = core.StringPtr("access") + createV2PolicyOptionsModel.Description = core.StringPtr("testString") + createV2PolicyOptionsModel.Subject = v2PolicySubjectModel + createV2PolicyOptionsModel.Resource = v2PolicyResourceModel + createV2PolicyOptionsModel.Pattern = core.StringPtr("testString") + createV2PolicyOptionsModel.Rule = v2PolicyRuleModel + createV2PolicyOptionsModel.AcceptLanguage = core.StringPtr("default") + createV2PolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = iamPolicyManagementService.V2CreatePolicy(v2CreatePolicyOptionsModel) + result, response, operationErr = iamPolicyManagementService.CreateV2Policy(createV2PolicyOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke V2CreatePolicy with error: Operation validation and request error`, func() { + It(`Invoke CreateV2Policy with error: Operation validation and request error`, func() { iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -3531,57 +3570,70 @@ var _ = Describe(`IamPolicyManagementV1`, func() { policyRoleModel := new(iampolicymanagementv1.PolicyRole) policyRoleModel.RoleID = core.StringPtr("testString") - // Construct an instance of the V2PolicyBaseControlGrant model - v2PolicyBaseControlGrantModel := new(iampolicymanagementv1.V2PolicyBaseControlGrant) - v2PolicyBaseControlGrantModel.Roles = []iampolicymanagementv1.PolicyRole{*policyRoleModel} - - // Construct an instance of the V2PolicyBaseControl model - v2PolicyBaseControlModel := new(iampolicymanagementv1.V2PolicyBaseControl) - v2PolicyBaseControlModel.Grant = v2PolicyBaseControlGrantModel - - // Construct an instance of the V2PolicyAttribute model - v2PolicyAttributeModel := new(iampolicymanagementv1.V2PolicyAttribute) - v2PolicyAttributeModel.Key = core.StringPtr("testString") - v2PolicyAttributeModel.Operator = core.StringPtr("testString") - v2PolicyAttributeModel.Value = core.StringPtr("testString") - - // Construct an instance of the V2PolicyBaseSubject model - v2PolicyBaseSubjectModel := new(iampolicymanagementv1.V2PolicyBaseSubject) - v2PolicyBaseSubjectModel.Attributes = []iampolicymanagementv1.V2PolicyAttribute{*v2PolicyAttributeModel} - - // Construct an instance of the V2PolicyBaseResource model - v2PolicyBaseResourceModel := new(iampolicymanagementv1.V2PolicyBaseResource) - v2PolicyBaseResourceModel.Attributes = []iampolicymanagementv1.V2PolicyAttribute{*v2PolicyAttributeModel} - - // Construct an instance of the V2PolicyBaseRuleV2PolicyAttribute model - v2PolicyBaseRuleModel := new(iampolicymanagementv1.V2PolicyBaseRuleV2PolicyAttribute) - v2PolicyBaseRuleModel.Key = core.StringPtr("testString") - v2PolicyBaseRuleModel.Operator = core.StringPtr("testString") - v2PolicyBaseRuleModel.Value = core.StringPtr("testString") - - // Construct an instance of the V2CreatePolicyOptions model - v2CreatePolicyOptionsModel := new(iampolicymanagementv1.V2CreatePolicyOptions) - v2CreatePolicyOptionsModel.Type = core.StringPtr("testString") - v2CreatePolicyOptionsModel.Control = v2PolicyBaseControlModel - v2CreatePolicyOptionsModel.Description = core.StringPtr("testString") - v2CreatePolicyOptionsModel.Subject = v2PolicyBaseSubjectModel - v2CreatePolicyOptionsModel.Resource = v2PolicyBaseResourceModel - v2CreatePolicyOptionsModel.Pattern = core.StringPtr("testString") - v2CreatePolicyOptionsModel.Rule = v2PolicyBaseRuleModel - v2CreatePolicyOptionsModel.AcceptLanguage = core.StringPtr("default") - v2CreatePolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the V2PolicyGrant model + v2PolicyGrantModel := new(iampolicymanagementv1.V2PolicyGrant) + v2PolicyGrantModel.Roles = []iampolicymanagementv1.PolicyRole{*policyRoleModel} + + // Construct an instance of the Control model + controlModel := new(iampolicymanagementv1.Control) + controlModel.Grant = v2PolicyGrantModel + + // Construct an instance of the V2PolicySubjectAttribute model + v2PolicySubjectAttributeModel := new(iampolicymanagementv1.V2PolicySubjectAttribute) + v2PolicySubjectAttributeModel.Key = core.StringPtr("testString") + v2PolicySubjectAttributeModel.Operator = core.StringPtr("stringEquals") + v2PolicySubjectAttributeModel.Value = core.StringPtr("testString") + + // Construct an instance of the V2PolicySubject model + v2PolicySubjectModel := new(iampolicymanagementv1.V2PolicySubject) + v2PolicySubjectModel.Attributes = []iampolicymanagementv1.V2PolicySubjectAttribute{*v2PolicySubjectAttributeModel} + + // Construct an instance of the V2PolicyResourceAttribute model + v2PolicyResourceAttributeModel := new(iampolicymanagementv1.V2PolicyResourceAttribute) + v2PolicyResourceAttributeModel.Key = core.StringPtr("testString") + v2PolicyResourceAttributeModel.Operator = core.StringPtr("stringEquals") + v2PolicyResourceAttributeModel.Value = core.StringPtr("testString") + + // Construct an instance of the V2PolicyResourceTag model + v2PolicyResourceTagModel := new(iampolicymanagementv1.V2PolicyResourceTag) + v2PolicyResourceTagModel.Key = core.StringPtr("testString") + v2PolicyResourceTagModel.Value = core.StringPtr("testString") + v2PolicyResourceTagModel.Operator = core.StringPtr("stringEquals") + + // Construct an instance of the V2PolicyResource model + v2PolicyResourceModel := new(iampolicymanagementv1.V2PolicyResource) + v2PolicyResourceModel.Attributes = []iampolicymanagementv1.V2PolicyResourceAttribute{*v2PolicyResourceAttributeModel} + v2PolicyResourceModel.Tags = []iampolicymanagementv1.V2PolicyResourceTag{*v2PolicyResourceTagModel} + + // Construct an instance of the V2PolicyRuleRuleAttribute model + v2PolicyRuleModel := new(iampolicymanagementv1.V2PolicyRuleRuleAttribute) + v2PolicyRuleModel.Key = core.StringPtr("testString") + v2PolicyRuleModel.Operator = core.StringPtr("timeLessThan") + v2PolicyRuleModel.Value = core.StringPtr("testString") + + // Construct an instance of the CreateV2PolicyOptions model + createV2PolicyOptionsModel := new(iampolicymanagementv1.CreateV2PolicyOptions) + createV2PolicyOptionsModel.Control = controlModel + createV2PolicyOptionsModel.Type = core.StringPtr("access") + createV2PolicyOptionsModel.Description = core.StringPtr("testString") + createV2PolicyOptionsModel.Subject = v2PolicySubjectModel + createV2PolicyOptionsModel.Resource = v2PolicyResourceModel + createV2PolicyOptionsModel.Pattern = core.StringPtr("testString") + createV2PolicyOptionsModel.Rule = v2PolicyRuleModel + createV2PolicyOptionsModel.AcceptLanguage = core.StringPtr("default") + createV2PolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := iamPolicyManagementService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := iamPolicyManagementService.V2CreatePolicy(v2CreatePolicyOptionsModel) + result, response, operationErr := iamPolicyManagementService.CreateV2Policy(createV2PolicyOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct a second instance of the V2CreatePolicyOptions model with no property values - v2CreatePolicyOptionsModelNew := new(iampolicymanagementv1.V2CreatePolicyOptions) + // Construct a second instance of the CreateV2PolicyOptions model with no property values + createV2PolicyOptionsModelNew := new(iampolicymanagementv1.CreateV2PolicyOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = iamPolicyManagementService.V2CreatePolicy(v2CreatePolicyOptionsModelNew) + result, response, operationErr = iamPolicyManagementService.CreateV2Policy(createV2PolicyOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -3599,7 +3651,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { res.WriteHeader(201) })) }) - It(`Invoke V2CreatePolicy successfully`, func() { + It(`Invoke CreateV2Policy successfully`, func() { iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -3611,48 +3663,61 @@ var _ = Describe(`IamPolicyManagementV1`, func() { policyRoleModel := new(iampolicymanagementv1.PolicyRole) policyRoleModel.RoleID = core.StringPtr("testString") - // Construct an instance of the V2PolicyBaseControlGrant model - v2PolicyBaseControlGrantModel := new(iampolicymanagementv1.V2PolicyBaseControlGrant) - v2PolicyBaseControlGrantModel.Roles = []iampolicymanagementv1.PolicyRole{*policyRoleModel} - - // Construct an instance of the V2PolicyBaseControl model - v2PolicyBaseControlModel := new(iampolicymanagementv1.V2PolicyBaseControl) - v2PolicyBaseControlModel.Grant = v2PolicyBaseControlGrantModel - - // Construct an instance of the V2PolicyAttribute model - v2PolicyAttributeModel := new(iampolicymanagementv1.V2PolicyAttribute) - v2PolicyAttributeModel.Key = core.StringPtr("testString") - v2PolicyAttributeModel.Operator = core.StringPtr("testString") - v2PolicyAttributeModel.Value = core.StringPtr("testString") - - // Construct an instance of the V2PolicyBaseSubject model - v2PolicyBaseSubjectModel := new(iampolicymanagementv1.V2PolicyBaseSubject) - v2PolicyBaseSubjectModel.Attributes = []iampolicymanagementv1.V2PolicyAttribute{*v2PolicyAttributeModel} - - // Construct an instance of the V2PolicyBaseResource model - v2PolicyBaseResourceModel := new(iampolicymanagementv1.V2PolicyBaseResource) - v2PolicyBaseResourceModel.Attributes = []iampolicymanagementv1.V2PolicyAttribute{*v2PolicyAttributeModel} - - // Construct an instance of the V2PolicyBaseRuleV2PolicyAttribute model - v2PolicyBaseRuleModel := new(iampolicymanagementv1.V2PolicyBaseRuleV2PolicyAttribute) - v2PolicyBaseRuleModel.Key = core.StringPtr("testString") - v2PolicyBaseRuleModel.Operator = core.StringPtr("testString") - v2PolicyBaseRuleModel.Value = core.StringPtr("testString") - - // Construct an instance of the V2CreatePolicyOptions model - v2CreatePolicyOptionsModel := new(iampolicymanagementv1.V2CreatePolicyOptions) - v2CreatePolicyOptionsModel.Type = core.StringPtr("testString") - v2CreatePolicyOptionsModel.Control = v2PolicyBaseControlModel - v2CreatePolicyOptionsModel.Description = core.StringPtr("testString") - v2CreatePolicyOptionsModel.Subject = v2PolicyBaseSubjectModel - v2CreatePolicyOptionsModel.Resource = v2PolicyBaseResourceModel - v2CreatePolicyOptionsModel.Pattern = core.StringPtr("testString") - v2CreatePolicyOptionsModel.Rule = v2PolicyBaseRuleModel - v2CreatePolicyOptionsModel.AcceptLanguage = core.StringPtr("default") - v2CreatePolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the V2PolicyGrant model + v2PolicyGrantModel := new(iampolicymanagementv1.V2PolicyGrant) + v2PolicyGrantModel.Roles = []iampolicymanagementv1.PolicyRole{*policyRoleModel} + + // Construct an instance of the Control model + controlModel := new(iampolicymanagementv1.Control) + controlModel.Grant = v2PolicyGrantModel + + // Construct an instance of the V2PolicySubjectAttribute model + v2PolicySubjectAttributeModel := new(iampolicymanagementv1.V2PolicySubjectAttribute) + v2PolicySubjectAttributeModel.Key = core.StringPtr("testString") + v2PolicySubjectAttributeModel.Operator = core.StringPtr("stringEquals") + v2PolicySubjectAttributeModel.Value = core.StringPtr("testString") + + // Construct an instance of the V2PolicySubject model + v2PolicySubjectModel := new(iampolicymanagementv1.V2PolicySubject) + v2PolicySubjectModel.Attributes = []iampolicymanagementv1.V2PolicySubjectAttribute{*v2PolicySubjectAttributeModel} + + // Construct an instance of the V2PolicyResourceAttribute model + v2PolicyResourceAttributeModel := new(iampolicymanagementv1.V2PolicyResourceAttribute) + v2PolicyResourceAttributeModel.Key = core.StringPtr("testString") + v2PolicyResourceAttributeModel.Operator = core.StringPtr("stringEquals") + v2PolicyResourceAttributeModel.Value = core.StringPtr("testString") + + // Construct an instance of the V2PolicyResourceTag model + v2PolicyResourceTagModel := new(iampolicymanagementv1.V2PolicyResourceTag) + v2PolicyResourceTagModel.Key = core.StringPtr("testString") + v2PolicyResourceTagModel.Value = core.StringPtr("testString") + v2PolicyResourceTagModel.Operator = core.StringPtr("stringEquals") + + // Construct an instance of the V2PolicyResource model + v2PolicyResourceModel := new(iampolicymanagementv1.V2PolicyResource) + v2PolicyResourceModel.Attributes = []iampolicymanagementv1.V2PolicyResourceAttribute{*v2PolicyResourceAttributeModel} + v2PolicyResourceModel.Tags = []iampolicymanagementv1.V2PolicyResourceTag{*v2PolicyResourceTagModel} + + // Construct an instance of the V2PolicyRuleRuleAttribute model + v2PolicyRuleModel := new(iampolicymanagementv1.V2PolicyRuleRuleAttribute) + v2PolicyRuleModel.Key = core.StringPtr("testString") + v2PolicyRuleModel.Operator = core.StringPtr("timeLessThan") + v2PolicyRuleModel.Value = core.StringPtr("testString") + + // Construct an instance of the CreateV2PolicyOptions model + createV2PolicyOptionsModel := new(iampolicymanagementv1.CreateV2PolicyOptions) + createV2PolicyOptionsModel.Control = controlModel + createV2PolicyOptionsModel.Type = core.StringPtr("access") + createV2PolicyOptionsModel.Description = core.StringPtr("testString") + createV2PolicyOptionsModel.Subject = v2PolicySubjectModel + createV2PolicyOptionsModel.Resource = v2PolicyResourceModel + createV2PolicyOptionsModel.Pattern = core.StringPtr("testString") + createV2PolicyOptionsModel.Rule = v2PolicyRuleModel + createV2PolicyOptionsModel.AcceptLanguage = core.StringPtr("default") + createV2PolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := iamPolicyManagementService.V2CreatePolicy(v2CreatePolicyOptionsModel) + result, response, operationErr := iamPolicyManagementService.CreateV2Policy(createV2PolicyOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -3664,15 +3729,15 @@ var _ = Describe(`IamPolicyManagementV1`, func() { }) }) }) - Describe(`V2UpdatePolicy(v2UpdatePolicyOptions *V2UpdatePolicyOptions) - Operation response error`, func() { - v2UpdatePolicyPath := "/v2/policies/testString" + Describe(`ReplaceV2Policy(replaceV2PolicyOptions *ReplaceV2PolicyOptions) - Operation response error`, func() { + replaceV2PolicyPath := "/v2/policies/testString" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(v2UpdatePolicyPath)) + Expect(req.URL.EscapedPath()).To(Equal(replaceV2PolicyPath)) Expect(req.Method).To(Equal("PUT")) Expect(req.Header["If-Match"]).ToNot(BeNil()) Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) @@ -3681,7 +3746,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke V2UpdatePolicy with error: Operation response processing error`, func() { + It(`Invoke ReplaceV2Policy with error: Operation response processing error`, func() { iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -3693,55 +3758,68 @@ var _ = Describe(`IamPolicyManagementV1`, func() { policyRoleModel := new(iampolicymanagementv1.PolicyRole) policyRoleModel.RoleID = core.StringPtr("testString") - // Construct an instance of the V2PolicyBaseControlGrant model - v2PolicyBaseControlGrantModel := new(iampolicymanagementv1.V2PolicyBaseControlGrant) - v2PolicyBaseControlGrantModel.Roles = []iampolicymanagementv1.PolicyRole{*policyRoleModel} - - // Construct an instance of the V2PolicyBaseControl model - v2PolicyBaseControlModel := new(iampolicymanagementv1.V2PolicyBaseControl) - v2PolicyBaseControlModel.Grant = v2PolicyBaseControlGrantModel - - // Construct an instance of the V2PolicyAttribute model - v2PolicyAttributeModel := new(iampolicymanagementv1.V2PolicyAttribute) - v2PolicyAttributeModel.Key = core.StringPtr("testString") - v2PolicyAttributeModel.Operator = core.StringPtr("testString") - v2PolicyAttributeModel.Value = core.StringPtr("testString") - - // Construct an instance of the V2PolicyBaseSubject model - v2PolicyBaseSubjectModel := new(iampolicymanagementv1.V2PolicyBaseSubject) - v2PolicyBaseSubjectModel.Attributes = []iampolicymanagementv1.V2PolicyAttribute{*v2PolicyAttributeModel} - - // Construct an instance of the V2PolicyBaseResource model - v2PolicyBaseResourceModel := new(iampolicymanagementv1.V2PolicyBaseResource) - v2PolicyBaseResourceModel.Attributes = []iampolicymanagementv1.V2PolicyAttribute{*v2PolicyAttributeModel} - - // Construct an instance of the V2PolicyBaseRuleV2PolicyAttribute model - v2PolicyBaseRuleModel := new(iampolicymanagementv1.V2PolicyBaseRuleV2PolicyAttribute) - v2PolicyBaseRuleModel.Key = core.StringPtr("testString") - v2PolicyBaseRuleModel.Operator = core.StringPtr("testString") - v2PolicyBaseRuleModel.Value = core.StringPtr("testString") - - // Construct an instance of the V2UpdatePolicyOptions model - v2UpdatePolicyOptionsModel := new(iampolicymanagementv1.V2UpdatePolicyOptions) - v2UpdatePolicyOptionsModel.PolicyID = core.StringPtr("testString") - v2UpdatePolicyOptionsModel.IfMatch = core.StringPtr("testString") - v2UpdatePolicyOptionsModel.Type = core.StringPtr("testString") - v2UpdatePolicyOptionsModel.Control = v2PolicyBaseControlModel - v2UpdatePolicyOptionsModel.Description = core.StringPtr("testString") - v2UpdatePolicyOptionsModel.Subject = v2PolicyBaseSubjectModel - v2UpdatePolicyOptionsModel.Resource = v2PolicyBaseResourceModel - v2UpdatePolicyOptionsModel.Pattern = core.StringPtr("testString") - v2UpdatePolicyOptionsModel.Rule = v2PolicyBaseRuleModel - v2UpdatePolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the V2PolicyGrant model + v2PolicyGrantModel := new(iampolicymanagementv1.V2PolicyGrant) + v2PolicyGrantModel.Roles = []iampolicymanagementv1.PolicyRole{*policyRoleModel} + + // Construct an instance of the Control model + controlModel := new(iampolicymanagementv1.Control) + controlModel.Grant = v2PolicyGrantModel + + // Construct an instance of the V2PolicySubjectAttribute model + v2PolicySubjectAttributeModel := new(iampolicymanagementv1.V2PolicySubjectAttribute) + v2PolicySubjectAttributeModel.Key = core.StringPtr("testString") + v2PolicySubjectAttributeModel.Operator = core.StringPtr("stringEquals") + v2PolicySubjectAttributeModel.Value = core.StringPtr("testString") + + // Construct an instance of the V2PolicySubject model + v2PolicySubjectModel := new(iampolicymanagementv1.V2PolicySubject) + v2PolicySubjectModel.Attributes = []iampolicymanagementv1.V2PolicySubjectAttribute{*v2PolicySubjectAttributeModel} + + // Construct an instance of the V2PolicyResourceAttribute model + v2PolicyResourceAttributeModel := new(iampolicymanagementv1.V2PolicyResourceAttribute) + v2PolicyResourceAttributeModel.Key = core.StringPtr("testString") + v2PolicyResourceAttributeModel.Operator = core.StringPtr("stringEquals") + v2PolicyResourceAttributeModel.Value = core.StringPtr("testString") + + // Construct an instance of the V2PolicyResourceTag model + v2PolicyResourceTagModel := new(iampolicymanagementv1.V2PolicyResourceTag) + v2PolicyResourceTagModel.Key = core.StringPtr("testString") + v2PolicyResourceTagModel.Value = core.StringPtr("testString") + v2PolicyResourceTagModel.Operator = core.StringPtr("stringEquals") + + // Construct an instance of the V2PolicyResource model + v2PolicyResourceModel := new(iampolicymanagementv1.V2PolicyResource) + v2PolicyResourceModel.Attributes = []iampolicymanagementv1.V2PolicyResourceAttribute{*v2PolicyResourceAttributeModel} + v2PolicyResourceModel.Tags = []iampolicymanagementv1.V2PolicyResourceTag{*v2PolicyResourceTagModel} + + // Construct an instance of the V2PolicyRuleRuleAttribute model + v2PolicyRuleModel := new(iampolicymanagementv1.V2PolicyRuleRuleAttribute) + v2PolicyRuleModel.Key = core.StringPtr("testString") + v2PolicyRuleModel.Operator = core.StringPtr("timeLessThan") + v2PolicyRuleModel.Value = core.StringPtr("testString") + + // Construct an instance of the ReplaceV2PolicyOptions model + replaceV2PolicyOptionsModel := new(iampolicymanagementv1.ReplaceV2PolicyOptions) + replaceV2PolicyOptionsModel.ID = core.StringPtr("testString") + replaceV2PolicyOptionsModel.IfMatch = core.StringPtr("testString") + replaceV2PolicyOptionsModel.Control = controlModel + replaceV2PolicyOptionsModel.Type = core.StringPtr("access") + replaceV2PolicyOptionsModel.Description = core.StringPtr("testString") + replaceV2PolicyOptionsModel.Subject = v2PolicySubjectModel + replaceV2PolicyOptionsModel.Resource = v2PolicyResourceModel + replaceV2PolicyOptionsModel.Pattern = core.StringPtr("testString") + replaceV2PolicyOptionsModel.Rule = v2PolicyRuleModel + replaceV2PolicyOptionsModel.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.V2UpdatePolicy(v2UpdatePolicyOptionsModel) + result, response, operationErr := iamPolicyManagementService.ReplaceV2Policy(replaceV2PolicyOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again iamPolicyManagementService.EnableRetries(0, 0) - result, response, operationErr = iamPolicyManagementService.V2UpdatePolicy(v2UpdatePolicyOptionsModel) + result, response, operationErr = iamPolicyManagementService.ReplaceV2Policy(replaceV2PolicyOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -3751,15 +3829,15 @@ var _ = Describe(`IamPolicyManagementV1`, func() { }) }) }) - Describe(`V2UpdatePolicy(v2UpdatePolicyOptions *V2UpdatePolicyOptions)`, func() { - v2UpdatePolicyPath := "/v2/policies/testString" + Describe(`ReplaceV2Policy(replaceV2PolicyOptions *ReplaceV2PolicyOptions)`, func() { + replaceV2PolicyPath := "/v2/policies/testString" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(v2UpdatePolicyPath)) + Expect(req.URL.EscapedPath()).To(Equal(replaceV2PolicyPath)) Expect(req.Method).To(Equal("PUT")) // For gzip-disabled operation, verify Content-Encoding is not set. @@ -3786,10 +3864,10 @@ 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", "subject": {"attributes": [{"key": "Key", "operator": "Operator", "value": "anyValue"}]}, "control": {"grant": {"roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}]}}, "resource": {"attributes": [{"key": "Key", "operator": "Operator", "value": "anyValue"}]}, "pattern": "Pattern", "rule": {"key": "Key", "operator": "Operator", "value": "anyValue"}, "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"}`) + fmt.Fprintf(res, "%s", `{"type": "access", "description": "Description", "subject": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "Value"}]}, "resource": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "Key", "value": "Value", "operator": "stringEquals"}]}, "pattern": "Pattern", "rule": {"key": "Key", "operator": "timeLessThan", "value": "anyValue"}, "id": "ID", "href": "Href", "control": {"grant": {"roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}]}}, "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", "last_permit_at": "LastPermitAt", "last_permit_frequency": 19}`) })) }) - It(`Invoke V2UpdatePolicy successfully with retries`, func() { + It(`Invoke ReplaceV2Policy successfully with retries`, func() { iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -3802,57 +3880,70 @@ var _ = Describe(`IamPolicyManagementV1`, func() { policyRoleModel := new(iampolicymanagementv1.PolicyRole) policyRoleModel.RoleID = core.StringPtr("testString") - // Construct an instance of the V2PolicyBaseControlGrant model - v2PolicyBaseControlGrantModel := new(iampolicymanagementv1.V2PolicyBaseControlGrant) - v2PolicyBaseControlGrantModel.Roles = []iampolicymanagementv1.PolicyRole{*policyRoleModel} - - // Construct an instance of the V2PolicyBaseControl model - v2PolicyBaseControlModel := new(iampolicymanagementv1.V2PolicyBaseControl) - v2PolicyBaseControlModel.Grant = v2PolicyBaseControlGrantModel - - // Construct an instance of the V2PolicyAttribute model - v2PolicyAttributeModel := new(iampolicymanagementv1.V2PolicyAttribute) - v2PolicyAttributeModel.Key = core.StringPtr("testString") - v2PolicyAttributeModel.Operator = core.StringPtr("testString") - v2PolicyAttributeModel.Value = core.StringPtr("testString") - - // Construct an instance of the V2PolicyBaseSubject model - v2PolicyBaseSubjectModel := new(iampolicymanagementv1.V2PolicyBaseSubject) - v2PolicyBaseSubjectModel.Attributes = []iampolicymanagementv1.V2PolicyAttribute{*v2PolicyAttributeModel} - - // Construct an instance of the V2PolicyBaseResource model - v2PolicyBaseResourceModel := new(iampolicymanagementv1.V2PolicyBaseResource) - v2PolicyBaseResourceModel.Attributes = []iampolicymanagementv1.V2PolicyAttribute{*v2PolicyAttributeModel} - - // Construct an instance of the V2PolicyBaseRuleV2PolicyAttribute model - v2PolicyBaseRuleModel := new(iampolicymanagementv1.V2PolicyBaseRuleV2PolicyAttribute) - v2PolicyBaseRuleModel.Key = core.StringPtr("testString") - v2PolicyBaseRuleModel.Operator = core.StringPtr("testString") - v2PolicyBaseRuleModel.Value = core.StringPtr("testString") - - // Construct an instance of the V2UpdatePolicyOptions model - v2UpdatePolicyOptionsModel := new(iampolicymanagementv1.V2UpdatePolicyOptions) - v2UpdatePolicyOptionsModel.PolicyID = core.StringPtr("testString") - v2UpdatePolicyOptionsModel.IfMatch = core.StringPtr("testString") - v2UpdatePolicyOptionsModel.Type = core.StringPtr("testString") - v2UpdatePolicyOptionsModel.Control = v2PolicyBaseControlModel - v2UpdatePolicyOptionsModel.Description = core.StringPtr("testString") - v2UpdatePolicyOptionsModel.Subject = v2PolicyBaseSubjectModel - v2UpdatePolicyOptionsModel.Resource = v2PolicyBaseResourceModel - v2UpdatePolicyOptionsModel.Pattern = core.StringPtr("testString") - v2UpdatePolicyOptionsModel.Rule = v2PolicyBaseRuleModel - v2UpdatePolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the V2PolicyGrant model + v2PolicyGrantModel := new(iampolicymanagementv1.V2PolicyGrant) + v2PolicyGrantModel.Roles = []iampolicymanagementv1.PolicyRole{*policyRoleModel} + + // Construct an instance of the Control model + controlModel := new(iampolicymanagementv1.Control) + controlModel.Grant = v2PolicyGrantModel + + // Construct an instance of the V2PolicySubjectAttribute model + v2PolicySubjectAttributeModel := new(iampolicymanagementv1.V2PolicySubjectAttribute) + v2PolicySubjectAttributeModel.Key = core.StringPtr("testString") + v2PolicySubjectAttributeModel.Operator = core.StringPtr("stringEquals") + v2PolicySubjectAttributeModel.Value = core.StringPtr("testString") + + // Construct an instance of the V2PolicySubject model + v2PolicySubjectModel := new(iampolicymanagementv1.V2PolicySubject) + v2PolicySubjectModel.Attributes = []iampolicymanagementv1.V2PolicySubjectAttribute{*v2PolicySubjectAttributeModel} + + // Construct an instance of the V2PolicyResourceAttribute model + v2PolicyResourceAttributeModel := new(iampolicymanagementv1.V2PolicyResourceAttribute) + v2PolicyResourceAttributeModel.Key = core.StringPtr("testString") + v2PolicyResourceAttributeModel.Operator = core.StringPtr("stringEquals") + v2PolicyResourceAttributeModel.Value = core.StringPtr("testString") + + // Construct an instance of the V2PolicyResourceTag model + v2PolicyResourceTagModel := new(iampolicymanagementv1.V2PolicyResourceTag) + v2PolicyResourceTagModel.Key = core.StringPtr("testString") + v2PolicyResourceTagModel.Value = core.StringPtr("testString") + v2PolicyResourceTagModel.Operator = core.StringPtr("stringEquals") + + // Construct an instance of the V2PolicyResource model + v2PolicyResourceModel := new(iampolicymanagementv1.V2PolicyResource) + v2PolicyResourceModel.Attributes = []iampolicymanagementv1.V2PolicyResourceAttribute{*v2PolicyResourceAttributeModel} + v2PolicyResourceModel.Tags = []iampolicymanagementv1.V2PolicyResourceTag{*v2PolicyResourceTagModel} + + // Construct an instance of the V2PolicyRuleRuleAttribute model + v2PolicyRuleModel := new(iampolicymanagementv1.V2PolicyRuleRuleAttribute) + v2PolicyRuleModel.Key = core.StringPtr("testString") + v2PolicyRuleModel.Operator = core.StringPtr("timeLessThan") + v2PolicyRuleModel.Value = core.StringPtr("testString") + + // Construct an instance of the ReplaceV2PolicyOptions model + replaceV2PolicyOptionsModel := new(iampolicymanagementv1.ReplaceV2PolicyOptions) + replaceV2PolicyOptionsModel.ID = core.StringPtr("testString") + replaceV2PolicyOptionsModel.IfMatch = core.StringPtr("testString") + replaceV2PolicyOptionsModel.Control = controlModel + replaceV2PolicyOptionsModel.Type = core.StringPtr("access") + replaceV2PolicyOptionsModel.Description = core.StringPtr("testString") + replaceV2PolicyOptionsModel.Subject = v2PolicySubjectModel + replaceV2PolicyOptionsModel.Resource = v2PolicyResourceModel + replaceV2PolicyOptionsModel.Pattern = core.StringPtr("testString") + replaceV2PolicyOptionsModel.Rule = v2PolicyRuleModel + replaceV2PolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := iamPolicyManagementService.V2UpdatePolicyWithContext(ctx, v2UpdatePolicyOptionsModel) + _, _, operationErr := iamPolicyManagementService.ReplaceV2PolicyWithContext(ctx, replaceV2PolicyOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again iamPolicyManagementService.DisableRetries() - result, response, operationErr := iamPolicyManagementService.V2UpdatePolicy(v2UpdatePolicyOptionsModel) + result, response, operationErr := iamPolicyManagementService.ReplaceV2Policy(replaceV2PolicyOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -3860,7 +3951,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = iamPolicyManagementService.V2UpdatePolicyWithContext(ctx, v2UpdatePolicyOptionsModel) + _, _, operationErr = iamPolicyManagementService.ReplaceV2PolicyWithContext(ctx, replaceV2PolicyOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -3874,7 +3965,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(v2UpdatePolicyPath)) + Expect(req.URL.EscapedPath()).To(Equal(replaceV2PolicyPath)) Expect(req.Method).To(Equal("PUT")) // For gzip-disabled operation, verify Content-Encoding is not set. @@ -3898,10 +3989,10 @@ 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", "subject": {"attributes": [{"key": "Key", "operator": "Operator", "value": "anyValue"}]}, "control": {"grant": {"roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}]}}, "resource": {"attributes": [{"key": "Key", "operator": "Operator", "value": "anyValue"}]}, "pattern": "Pattern", "rule": {"key": "Key", "operator": "Operator", "value": "anyValue"}, "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"}`) + fmt.Fprintf(res, "%s", `{"type": "access", "description": "Description", "subject": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "Value"}]}, "resource": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "Key", "value": "Value", "operator": "stringEquals"}]}, "pattern": "Pattern", "rule": {"key": "Key", "operator": "timeLessThan", "value": "anyValue"}, "id": "ID", "href": "Href", "control": {"grant": {"roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}]}}, "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", "last_permit_at": "LastPermitAt", "last_permit_frequency": 19}`) })) }) - It(`Invoke V2UpdatePolicy successfully`, func() { + It(`Invoke ReplaceV2Policy successfully`, func() { iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -3910,7 +4001,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(iamPolicyManagementService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := iamPolicyManagementService.V2UpdatePolicy(nil) + result, response, operationErr := iamPolicyManagementService.ReplaceV2Policy(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -3919,55 +4010,68 @@ var _ = Describe(`IamPolicyManagementV1`, func() { policyRoleModel := new(iampolicymanagementv1.PolicyRole) policyRoleModel.RoleID = core.StringPtr("testString") - // Construct an instance of the V2PolicyBaseControlGrant model - v2PolicyBaseControlGrantModel := new(iampolicymanagementv1.V2PolicyBaseControlGrant) - v2PolicyBaseControlGrantModel.Roles = []iampolicymanagementv1.PolicyRole{*policyRoleModel} - - // Construct an instance of the V2PolicyBaseControl model - v2PolicyBaseControlModel := new(iampolicymanagementv1.V2PolicyBaseControl) - v2PolicyBaseControlModel.Grant = v2PolicyBaseControlGrantModel - - // Construct an instance of the V2PolicyAttribute model - v2PolicyAttributeModel := new(iampolicymanagementv1.V2PolicyAttribute) - v2PolicyAttributeModel.Key = core.StringPtr("testString") - v2PolicyAttributeModel.Operator = core.StringPtr("testString") - v2PolicyAttributeModel.Value = core.StringPtr("testString") - - // Construct an instance of the V2PolicyBaseSubject model - v2PolicyBaseSubjectModel := new(iampolicymanagementv1.V2PolicyBaseSubject) - v2PolicyBaseSubjectModel.Attributes = []iampolicymanagementv1.V2PolicyAttribute{*v2PolicyAttributeModel} - - // Construct an instance of the V2PolicyBaseResource model - v2PolicyBaseResourceModel := new(iampolicymanagementv1.V2PolicyBaseResource) - v2PolicyBaseResourceModel.Attributes = []iampolicymanagementv1.V2PolicyAttribute{*v2PolicyAttributeModel} - - // Construct an instance of the V2PolicyBaseRuleV2PolicyAttribute model - v2PolicyBaseRuleModel := new(iampolicymanagementv1.V2PolicyBaseRuleV2PolicyAttribute) - v2PolicyBaseRuleModel.Key = core.StringPtr("testString") - v2PolicyBaseRuleModel.Operator = core.StringPtr("testString") - v2PolicyBaseRuleModel.Value = core.StringPtr("testString") - - // Construct an instance of the V2UpdatePolicyOptions model - v2UpdatePolicyOptionsModel := new(iampolicymanagementv1.V2UpdatePolicyOptions) - v2UpdatePolicyOptionsModel.PolicyID = core.StringPtr("testString") - v2UpdatePolicyOptionsModel.IfMatch = core.StringPtr("testString") - v2UpdatePolicyOptionsModel.Type = core.StringPtr("testString") - v2UpdatePolicyOptionsModel.Control = v2PolicyBaseControlModel - v2UpdatePolicyOptionsModel.Description = core.StringPtr("testString") - v2UpdatePolicyOptionsModel.Subject = v2PolicyBaseSubjectModel - v2UpdatePolicyOptionsModel.Resource = v2PolicyBaseResourceModel - v2UpdatePolicyOptionsModel.Pattern = core.StringPtr("testString") - v2UpdatePolicyOptionsModel.Rule = v2PolicyBaseRuleModel - v2UpdatePolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the V2PolicyGrant model + v2PolicyGrantModel := new(iampolicymanagementv1.V2PolicyGrant) + v2PolicyGrantModel.Roles = []iampolicymanagementv1.PolicyRole{*policyRoleModel} + + // Construct an instance of the Control model + controlModel := new(iampolicymanagementv1.Control) + controlModel.Grant = v2PolicyGrantModel + + // Construct an instance of the V2PolicySubjectAttribute model + v2PolicySubjectAttributeModel := new(iampolicymanagementv1.V2PolicySubjectAttribute) + v2PolicySubjectAttributeModel.Key = core.StringPtr("testString") + v2PolicySubjectAttributeModel.Operator = core.StringPtr("stringEquals") + v2PolicySubjectAttributeModel.Value = core.StringPtr("testString") + + // Construct an instance of the V2PolicySubject model + v2PolicySubjectModel := new(iampolicymanagementv1.V2PolicySubject) + v2PolicySubjectModel.Attributes = []iampolicymanagementv1.V2PolicySubjectAttribute{*v2PolicySubjectAttributeModel} + + // Construct an instance of the V2PolicyResourceAttribute model + v2PolicyResourceAttributeModel := new(iampolicymanagementv1.V2PolicyResourceAttribute) + v2PolicyResourceAttributeModel.Key = core.StringPtr("testString") + v2PolicyResourceAttributeModel.Operator = core.StringPtr("stringEquals") + v2PolicyResourceAttributeModel.Value = core.StringPtr("testString") + + // Construct an instance of the V2PolicyResourceTag model + v2PolicyResourceTagModel := new(iampolicymanagementv1.V2PolicyResourceTag) + v2PolicyResourceTagModel.Key = core.StringPtr("testString") + v2PolicyResourceTagModel.Value = core.StringPtr("testString") + v2PolicyResourceTagModel.Operator = core.StringPtr("stringEquals") + + // Construct an instance of the V2PolicyResource model + v2PolicyResourceModel := new(iampolicymanagementv1.V2PolicyResource) + v2PolicyResourceModel.Attributes = []iampolicymanagementv1.V2PolicyResourceAttribute{*v2PolicyResourceAttributeModel} + v2PolicyResourceModel.Tags = []iampolicymanagementv1.V2PolicyResourceTag{*v2PolicyResourceTagModel} + + // Construct an instance of the V2PolicyRuleRuleAttribute model + v2PolicyRuleModel := new(iampolicymanagementv1.V2PolicyRuleRuleAttribute) + v2PolicyRuleModel.Key = core.StringPtr("testString") + v2PolicyRuleModel.Operator = core.StringPtr("timeLessThan") + v2PolicyRuleModel.Value = core.StringPtr("testString") + + // Construct an instance of the ReplaceV2PolicyOptions model + replaceV2PolicyOptionsModel := new(iampolicymanagementv1.ReplaceV2PolicyOptions) + replaceV2PolicyOptionsModel.ID = core.StringPtr("testString") + replaceV2PolicyOptionsModel.IfMatch = core.StringPtr("testString") + replaceV2PolicyOptionsModel.Control = controlModel + replaceV2PolicyOptionsModel.Type = core.StringPtr("access") + replaceV2PolicyOptionsModel.Description = core.StringPtr("testString") + replaceV2PolicyOptionsModel.Subject = v2PolicySubjectModel + replaceV2PolicyOptionsModel.Resource = v2PolicyResourceModel + replaceV2PolicyOptionsModel.Pattern = core.StringPtr("testString") + replaceV2PolicyOptionsModel.Rule = v2PolicyRuleModel + replaceV2PolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = iamPolicyManagementService.V2UpdatePolicy(v2UpdatePolicyOptionsModel) + result, response, operationErr = iamPolicyManagementService.ReplaceV2Policy(replaceV2PolicyOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke V2UpdatePolicy with error: Operation validation and request error`, func() { + It(`Invoke ReplaceV2Policy with error: Operation validation and request error`, func() { iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -3979,58 +4083,71 @@ var _ = Describe(`IamPolicyManagementV1`, func() { policyRoleModel := new(iampolicymanagementv1.PolicyRole) policyRoleModel.RoleID = core.StringPtr("testString") - // Construct an instance of the V2PolicyBaseControlGrant model - v2PolicyBaseControlGrantModel := new(iampolicymanagementv1.V2PolicyBaseControlGrant) - v2PolicyBaseControlGrantModel.Roles = []iampolicymanagementv1.PolicyRole{*policyRoleModel} - - // Construct an instance of the V2PolicyBaseControl model - v2PolicyBaseControlModel := new(iampolicymanagementv1.V2PolicyBaseControl) - v2PolicyBaseControlModel.Grant = v2PolicyBaseControlGrantModel - - // Construct an instance of the V2PolicyAttribute model - v2PolicyAttributeModel := new(iampolicymanagementv1.V2PolicyAttribute) - v2PolicyAttributeModel.Key = core.StringPtr("testString") - v2PolicyAttributeModel.Operator = core.StringPtr("testString") - v2PolicyAttributeModel.Value = core.StringPtr("testString") - - // Construct an instance of the V2PolicyBaseSubject model - v2PolicyBaseSubjectModel := new(iampolicymanagementv1.V2PolicyBaseSubject) - v2PolicyBaseSubjectModel.Attributes = []iampolicymanagementv1.V2PolicyAttribute{*v2PolicyAttributeModel} - - // Construct an instance of the V2PolicyBaseResource model - v2PolicyBaseResourceModel := new(iampolicymanagementv1.V2PolicyBaseResource) - v2PolicyBaseResourceModel.Attributes = []iampolicymanagementv1.V2PolicyAttribute{*v2PolicyAttributeModel} - - // Construct an instance of the V2PolicyBaseRuleV2PolicyAttribute model - v2PolicyBaseRuleModel := new(iampolicymanagementv1.V2PolicyBaseRuleV2PolicyAttribute) - v2PolicyBaseRuleModel.Key = core.StringPtr("testString") - v2PolicyBaseRuleModel.Operator = core.StringPtr("testString") - v2PolicyBaseRuleModel.Value = core.StringPtr("testString") - - // Construct an instance of the V2UpdatePolicyOptions model - v2UpdatePolicyOptionsModel := new(iampolicymanagementv1.V2UpdatePolicyOptions) - v2UpdatePolicyOptionsModel.PolicyID = core.StringPtr("testString") - v2UpdatePolicyOptionsModel.IfMatch = core.StringPtr("testString") - v2UpdatePolicyOptionsModel.Type = core.StringPtr("testString") - v2UpdatePolicyOptionsModel.Control = v2PolicyBaseControlModel - v2UpdatePolicyOptionsModel.Description = core.StringPtr("testString") - v2UpdatePolicyOptionsModel.Subject = v2PolicyBaseSubjectModel - v2UpdatePolicyOptionsModel.Resource = v2PolicyBaseResourceModel - v2UpdatePolicyOptionsModel.Pattern = core.StringPtr("testString") - v2UpdatePolicyOptionsModel.Rule = v2PolicyBaseRuleModel - v2UpdatePolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the V2PolicyGrant model + v2PolicyGrantModel := new(iampolicymanagementv1.V2PolicyGrant) + v2PolicyGrantModel.Roles = []iampolicymanagementv1.PolicyRole{*policyRoleModel} + + // Construct an instance of the Control model + controlModel := new(iampolicymanagementv1.Control) + controlModel.Grant = v2PolicyGrantModel + + // Construct an instance of the V2PolicySubjectAttribute model + v2PolicySubjectAttributeModel := new(iampolicymanagementv1.V2PolicySubjectAttribute) + v2PolicySubjectAttributeModel.Key = core.StringPtr("testString") + v2PolicySubjectAttributeModel.Operator = core.StringPtr("stringEquals") + v2PolicySubjectAttributeModel.Value = core.StringPtr("testString") + + // Construct an instance of the V2PolicySubject model + v2PolicySubjectModel := new(iampolicymanagementv1.V2PolicySubject) + v2PolicySubjectModel.Attributes = []iampolicymanagementv1.V2PolicySubjectAttribute{*v2PolicySubjectAttributeModel} + + // Construct an instance of the V2PolicyResourceAttribute model + v2PolicyResourceAttributeModel := new(iampolicymanagementv1.V2PolicyResourceAttribute) + v2PolicyResourceAttributeModel.Key = core.StringPtr("testString") + v2PolicyResourceAttributeModel.Operator = core.StringPtr("stringEquals") + v2PolicyResourceAttributeModel.Value = core.StringPtr("testString") + + // Construct an instance of the V2PolicyResourceTag model + v2PolicyResourceTagModel := new(iampolicymanagementv1.V2PolicyResourceTag) + v2PolicyResourceTagModel.Key = core.StringPtr("testString") + v2PolicyResourceTagModel.Value = core.StringPtr("testString") + v2PolicyResourceTagModel.Operator = core.StringPtr("stringEquals") + + // Construct an instance of the V2PolicyResource model + v2PolicyResourceModel := new(iampolicymanagementv1.V2PolicyResource) + v2PolicyResourceModel.Attributes = []iampolicymanagementv1.V2PolicyResourceAttribute{*v2PolicyResourceAttributeModel} + v2PolicyResourceModel.Tags = []iampolicymanagementv1.V2PolicyResourceTag{*v2PolicyResourceTagModel} + + // Construct an instance of the V2PolicyRuleRuleAttribute model + v2PolicyRuleModel := new(iampolicymanagementv1.V2PolicyRuleRuleAttribute) + v2PolicyRuleModel.Key = core.StringPtr("testString") + v2PolicyRuleModel.Operator = core.StringPtr("timeLessThan") + v2PolicyRuleModel.Value = core.StringPtr("testString") + + // Construct an instance of the ReplaceV2PolicyOptions model + replaceV2PolicyOptionsModel := new(iampolicymanagementv1.ReplaceV2PolicyOptions) + replaceV2PolicyOptionsModel.ID = core.StringPtr("testString") + replaceV2PolicyOptionsModel.IfMatch = core.StringPtr("testString") + replaceV2PolicyOptionsModel.Control = controlModel + replaceV2PolicyOptionsModel.Type = core.StringPtr("access") + replaceV2PolicyOptionsModel.Description = core.StringPtr("testString") + replaceV2PolicyOptionsModel.Subject = v2PolicySubjectModel + replaceV2PolicyOptionsModel.Resource = v2PolicyResourceModel + replaceV2PolicyOptionsModel.Pattern = core.StringPtr("testString") + replaceV2PolicyOptionsModel.Rule = v2PolicyRuleModel + replaceV2PolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := iamPolicyManagementService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := iamPolicyManagementService.V2UpdatePolicy(v2UpdatePolicyOptionsModel) + result, response, operationErr := iamPolicyManagementService.ReplaceV2Policy(replaceV2PolicyOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct a second instance of the V2UpdatePolicyOptions model with no property values - v2UpdatePolicyOptionsModelNew := new(iampolicymanagementv1.V2UpdatePolicyOptions) + // Construct a second instance of the ReplaceV2PolicyOptions model with no property values + replaceV2PolicyOptionsModelNew := new(iampolicymanagementv1.ReplaceV2PolicyOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = iamPolicyManagementService.V2UpdatePolicy(v2UpdatePolicyOptionsModelNew) + result, response, operationErr = iamPolicyManagementService.ReplaceV2Policy(replaceV2PolicyOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -4048,7 +4165,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke V2UpdatePolicy successfully`, func() { + It(`Invoke ReplaceV2Policy successfully`, func() { iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -4060,49 +4177,62 @@ var _ = Describe(`IamPolicyManagementV1`, func() { policyRoleModel := new(iampolicymanagementv1.PolicyRole) policyRoleModel.RoleID = core.StringPtr("testString") - // Construct an instance of the V2PolicyBaseControlGrant model - v2PolicyBaseControlGrantModel := new(iampolicymanagementv1.V2PolicyBaseControlGrant) - v2PolicyBaseControlGrantModel.Roles = []iampolicymanagementv1.PolicyRole{*policyRoleModel} - - // Construct an instance of the V2PolicyBaseControl model - v2PolicyBaseControlModel := new(iampolicymanagementv1.V2PolicyBaseControl) - v2PolicyBaseControlModel.Grant = v2PolicyBaseControlGrantModel - - // Construct an instance of the V2PolicyAttribute model - v2PolicyAttributeModel := new(iampolicymanagementv1.V2PolicyAttribute) - v2PolicyAttributeModel.Key = core.StringPtr("testString") - v2PolicyAttributeModel.Operator = core.StringPtr("testString") - v2PolicyAttributeModel.Value = core.StringPtr("testString") - - // Construct an instance of the V2PolicyBaseSubject model - v2PolicyBaseSubjectModel := new(iampolicymanagementv1.V2PolicyBaseSubject) - v2PolicyBaseSubjectModel.Attributes = []iampolicymanagementv1.V2PolicyAttribute{*v2PolicyAttributeModel} - - // Construct an instance of the V2PolicyBaseResource model - v2PolicyBaseResourceModel := new(iampolicymanagementv1.V2PolicyBaseResource) - v2PolicyBaseResourceModel.Attributes = []iampolicymanagementv1.V2PolicyAttribute{*v2PolicyAttributeModel} - - // Construct an instance of the V2PolicyBaseRuleV2PolicyAttribute model - v2PolicyBaseRuleModel := new(iampolicymanagementv1.V2PolicyBaseRuleV2PolicyAttribute) - v2PolicyBaseRuleModel.Key = core.StringPtr("testString") - v2PolicyBaseRuleModel.Operator = core.StringPtr("testString") - v2PolicyBaseRuleModel.Value = core.StringPtr("testString") - - // Construct an instance of the V2UpdatePolicyOptions model - v2UpdatePolicyOptionsModel := new(iampolicymanagementv1.V2UpdatePolicyOptions) - v2UpdatePolicyOptionsModel.PolicyID = core.StringPtr("testString") - v2UpdatePolicyOptionsModel.IfMatch = core.StringPtr("testString") - v2UpdatePolicyOptionsModel.Type = core.StringPtr("testString") - v2UpdatePolicyOptionsModel.Control = v2PolicyBaseControlModel - v2UpdatePolicyOptionsModel.Description = core.StringPtr("testString") - v2UpdatePolicyOptionsModel.Subject = v2PolicyBaseSubjectModel - v2UpdatePolicyOptionsModel.Resource = v2PolicyBaseResourceModel - v2UpdatePolicyOptionsModel.Pattern = core.StringPtr("testString") - v2UpdatePolicyOptionsModel.Rule = v2PolicyBaseRuleModel - v2UpdatePolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the V2PolicyGrant model + v2PolicyGrantModel := new(iampolicymanagementv1.V2PolicyGrant) + v2PolicyGrantModel.Roles = []iampolicymanagementv1.PolicyRole{*policyRoleModel} + + // Construct an instance of the Control model + controlModel := new(iampolicymanagementv1.Control) + controlModel.Grant = v2PolicyGrantModel + + // Construct an instance of the V2PolicySubjectAttribute model + v2PolicySubjectAttributeModel := new(iampolicymanagementv1.V2PolicySubjectAttribute) + v2PolicySubjectAttributeModel.Key = core.StringPtr("testString") + v2PolicySubjectAttributeModel.Operator = core.StringPtr("stringEquals") + v2PolicySubjectAttributeModel.Value = core.StringPtr("testString") + + // Construct an instance of the V2PolicySubject model + v2PolicySubjectModel := new(iampolicymanagementv1.V2PolicySubject) + v2PolicySubjectModel.Attributes = []iampolicymanagementv1.V2PolicySubjectAttribute{*v2PolicySubjectAttributeModel} + + // Construct an instance of the V2PolicyResourceAttribute model + v2PolicyResourceAttributeModel := new(iampolicymanagementv1.V2PolicyResourceAttribute) + v2PolicyResourceAttributeModel.Key = core.StringPtr("testString") + v2PolicyResourceAttributeModel.Operator = core.StringPtr("stringEquals") + v2PolicyResourceAttributeModel.Value = core.StringPtr("testString") + + // Construct an instance of the V2PolicyResourceTag model + v2PolicyResourceTagModel := new(iampolicymanagementv1.V2PolicyResourceTag) + v2PolicyResourceTagModel.Key = core.StringPtr("testString") + v2PolicyResourceTagModel.Value = core.StringPtr("testString") + v2PolicyResourceTagModel.Operator = core.StringPtr("stringEquals") + + // Construct an instance of the V2PolicyResource model + v2PolicyResourceModel := new(iampolicymanagementv1.V2PolicyResource) + v2PolicyResourceModel.Attributes = []iampolicymanagementv1.V2PolicyResourceAttribute{*v2PolicyResourceAttributeModel} + v2PolicyResourceModel.Tags = []iampolicymanagementv1.V2PolicyResourceTag{*v2PolicyResourceTagModel} + + // Construct an instance of the V2PolicyRuleRuleAttribute model + v2PolicyRuleModel := new(iampolicymanagementv1.V2PolicyRuleRuleAttribute) + v2PolicyRuleModel.Key = core.StringPtr("testString") + v2PolicyRuleModel.Operator = core.StringPtr("timeLessThan") + v2PolicyRuleModel.Value = core.StringPtr("testString") + + // Construct an instance of the ReplaceV2PolicyOptions model + replaceV2PolicyOptionsModel := new(iampolicymanagementv1.ReplaceV2PolicyOptions) + replaceV2PolicyOptionsModel.ID = core.StringPtr("testString") + replaceV2PolicyOptionsModel.IfMatch = core.StringPtr("testString") + replaceV2PolicyOptionsModel.Control = controlModel + replaceV2PolicyOptionsModel.Type = core.StringPtr("access") + replaceV2PolicyOptionsModel.Description = core.StringPtr("testString") + replaceV2PolicyOptionsModel.Subject = v2PolicySubjectModel + replaceV2PolicyOptionsModel.Resource = v2PolicyResourceModel + replaceV2PolicyOptionsModel.Pattern = core.StringPtr("testString") + replaceV2PolicyOptionsModel.Rule = v2PolicyRuleModel + replaceV2PolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := iamPolicyManagementService.V2UpdatePolicy(v2UpdatePolicyOptionsModel) + result, response, operationErr := iamPolicyManagementService.ReplaceV2Policy(replaceV2PolicyOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -4114,22 +4244,22 @@ var _ = Describe(`IamPolicyManagementV1`, func() { }) }) }) - Describe(`V2GetPolicy(v2GetPolicyOptions *V2GetPolicyOptions) - Operation response error`, func() { - v2GetPolicyPath := "/v2/policies/testString" + Describe(`GetV2Policy(getV2PolicyOptions *GetV2PolicyOptions) - Operation response error`, func() { + getV2PolicyPath := "/v2/policies/testString" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(v2GetPolicyPath)) + Expect(req.URL.EscapedPath()).To(Equal(getV2PolicyPath)) Expect(req.Method).To(Equal("GET")) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke V2GetPolicy with error: Operation response processing error`, func() { + It(`Invoke GetV2Policy with error: Operation response processing error`, func() { iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -4137,19 +4267,19 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(serviceErr).To(BeNil()) Expect(iamPolicyManagementService).ToNot(BeNil()) - // Construct an instance of the V2GetPolicyOptions model - v2GetPolicyOptionsModel := new(iampolicymanagementv1.V2GetPolicyOptions) - v2GetPolicyOptionsModel.PolicyID = core.StringPtr("testString") - v2GetPolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetV2PolicyOptions model + getV2PolicyOptionsModel := new(iampolicymanagementv1.GetV2PolicyOptions) + getV2PolicyOptionsModel.ID = core.StringPtr("testString") + getV2PolicyOptionsModel.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.V2GetPolicy(v2GetPolicyOptionsModel) + result, response, operationErr := iamPolicyManagementService.GetV2Policy(getV2PolicyOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again iamPolicyManagementService.EnableRetries(0, 0) - result, response, operationErr = iamPolicyManagementService.V2GetPolicy(v2GetPolicyOptionsModel) + result, response, operationErr = iamPolicyManagementService.GetV2Policy(getV2PolicyOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -4159,15 +4289,15 @@ var _ = Describe(`IamPolicyManagementV1`, func() { }) }) }) - Describe(`V2GetPolicy(v2GetPolicyOptions *V2GetPolicyOptions)`, func() { - v2GetPolicyPath := "/v2/policies/testString" + Describe(`GetV2Policy(getV2PolicyOptions *GetV2PolicyOptions)`, func() { + getV2PolicyPath := "/v2/policies/testString" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(v2GetPolicyPath)) + Expect(req.URL.EscapedPath()).To(Equal(getV2PolicyPath)) Expect(req.Method).To(Equal("GET")) // Sleep a short time to support a timeout test @@ -4176,10 +4306,10 @@ 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": "active"}`) + fmt.Fprintf(res, "%s", `{"type": "access", "description": "Description", "subject": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "Value"}]}, "resource": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "Key", "value": "Value", "operator": "stringEquals"}]}, "pattern": "Pattern", "rule": {"key": "Key", "operator": "timeLessThan", "value": "anyValue"}, "id": "ID", "href": "Href", "control": {"grant": {"roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}]}}, "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", "last_permit_at": "LastPermitAt", "last_permit_frequency": 19}`) })) }) - It(`Invoke V2GetPolicy successfully with retries`, func() { + It(`Invoke GetV2Policy successfully with retries`, func() { iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -4188,21 +4318,21 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(iamPolicyManagementService).ToNot(BeNil()) iamPolicyManagementService.EnableRetries(0, 0) - // Construct an instance of the V2GetPolicyOptions model - v2GetPolicyOptionsModel := new(iampolicymanagementv1.V2GetPolicyOptions) - v2GetPolicyOptionsModel.PolicyID = core.StringPtr("testString") - v2GetPolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetV2PolicyOptions model + getV2PolicyOptionsModel := new(iampolicymanagementv1.GetV2PolicyOptions) + getV2PolicyOptionsModel.ID = core.StringPtr("testString") + getV2PolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := iamPolicyManagementService.V2GetPolicyWithContext(ctx, v2GetPolicyOptionsModel) + _, _, operationErr := iamPolicyManagementService.GetV2PolicyWithContext(ctx, getV2PolicyOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again iamPolicyManagementService.DisableRetries() - result, response, operationErr := iamPolicyManagementService.V2GetPolicy(v2GetPolicyOptionsModel) + result, response, operationErr := iamPolicyManagementService.GetV2Policy(getV2PolicyOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -4210,7 +4340,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = iamPolicyManagementService.V2GetPolicyWithContext(ctx, v2GetPolicyOptionsModel) + _, _, operationErr = iamPolicyManagementService.GetV2PolicyWithContext(ctx, getV2PolicyOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -4224,16 +4354,16 @@ var _ = Describe(`IamPolicyManagementV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(v2GetPolicyPath)) + Expect(req.URL.EscapedPath()).To(Equal(getV2PolicyPath)) Expect(req.Method).To(Equal("GET")) // 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": "active"}`) + fmt.Fprintf(res, "%s", `{"type": "access", "description": "Description", "subject": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "Value"}]}, "resource": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "Key", "value": "Value", "operator": "stringEquals"}]}, "pattern": "Pattern", "rule": {"key": "Key", "operator": "timeLessThan", "value": "anyValue"}, "id": "ID", "href": "Href", "control": {"grant": {"roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}]}}, "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", "last_permit_at": "LastPermitAt", "last_permit_frequency": 19}`) })) }) - It(`Invoke V2GetPolicy successfully`, func() { + It(`Invoke GetV2Policy successfully`, func() { iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -4242,24 +4372,24 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(iamPolicyManagementService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := iamPolicyManagementService.V2GetPolicy(nil) + result, response, operationErr := iamPolicyManagementService.GetV2Policy(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the V2GetPolicyOptions model - v2GetPolicyOptionsModel := new(iampolicymanagementv1.V2GetPolicyOptions) - v2GetPolicyOptionsModel.PolicyID = core.StringPtr("testString") - v2GetPolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetV2PolicyOptions model + getV2PolicyOptionsModel := new(iampolicymanagementv1.GetV2PolicyOptions) + getV2PolicyOptionsModel.ID = core.StringPtr("testString") + getV2PolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = iamPolicyManagementService.V2GetPolicy(v2GetPolicyOptionsModel) + result, response, operationErr = iamPolicyManagementService.GetV2Policy(getV2PolicyOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke V2GetPolicy with error: Operation validation and request error`, func() { + It(`Invoke GetV2Policy with error: Operation validation and request error`, func() { iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -4267,22 +4397,22 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(serviceErr).To(BeNil()) Expect(iamPolicyManagementService).ToNot(BeNil()) - // Construct an instance of the V2GetPolicyOptions model - v2GetPolicyOptionsModel := new(iampolicymanagementv1.V2GetPolicyOptions) - v2GetPolicyOptionsModel.PolicyID = core.StringPtr("testString") - v2GetPolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetV2PolicyOptions model + getV2PolicyOptionsModel := new(iampolicymanagementv1.GetV2PolicyOptions) + getV2PolicyOptionsModel.ID = core.StringPtr("testString") + getV2PolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := iamPolicyManagementService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := iamPolicyManagementService.V2GetPolicy(v2GetPolicyOptionsModel) + result, response, operationErr := iamPolicyManagementService.GetV2Policy(getV2PolicyOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct a second instance of the V2GetPolicyOptions model with no property values - v2GetPolicyOptionsModelNew := new(iampolicymanagementv1.V2GetPolicyOptions) + // Construct a second instance of the GetV2PolicyOptions model with no property values + getV2PolicyOptionsModelNew := new(iampolicymanagementv1.GetV2PolicyOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = iamPolicyManagementService.V2GetPolicy(v2GetPolicyOptionsModelNew) + result, response, operationErr = iamPolicyManagementService.GetV2Policy(getV2PolicyOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -4300,7 +4430,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke V2GetPolicy successfully`, func() { + It(`Invoke GetV2Policy successfully`, func() { iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -4308,13 +4438,13 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(serviceErr).To(BeNil()) Expect(iamPolicyManagementService).ToNot(BeNil()) - // Construct an instance of the V2GetPolicyOptions model - v2GetPolicyOptionsModel := new(iampolicymanagementv1.V2GetPolicyOptions) - v2GetPolicyOptionsModel.PolicyID = core.StringPtr("testString") - v2GetPolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetV2PolicyOptions model + getV2PolicyOptionsModel := new(iampolicymanagementv1.GetV2PolicyOptions) + getV2PolicyOptionsModel.ID = core.StringPtr("testString") + getV2PolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := iamPolicyManagementService.V2GetPolicy(v2GetPolicyOptionsModel) + result, response, operationErr := iamPolicyManagementService.GetV2Policy(getV2PolicyOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -4326,21 +4456,21 @@ var _ = Describe(`IamPolicyManagementV1`, func() { }) }) }) - Describe(`V2DeletePolicy(v2DeletePolicyOptions *V2DeletePolicyOptions)`, func() { - v2DeletePolicyPath := "/v2/policies/testString" + Describe(`DeleteV2Policy(deleteV2PolicyOptions *DeleteV2PolicyOptions)`, func() { + deleteV2PolicyPath := "/v2/policies/testString" Context(`Using mock server endpoint`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(v2DeletePolicyPath)) + Expect(req.URL.EscapedPath()).To(Equal(deleteV2PolicyPath)) Expect(req.Method).To(Equal("DELETE")) res.WriteHeader(204) })) }) - It(`Invoke V2DeletePolicy successfully`, func() { + It(`Invoke DeleteV2Policy successfully`, func() { iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -4349,21 +4479,21 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(iamPolicyManagementService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - response, operationErr := iamPolicyManagementService.V2DeletePolicy(nil) + response, operationErr := iamPolicyManagementService.DeleteV2Policy(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) - // Construct an instance of the V2DeletePolicyOptions model - v2DeletePolicyOptionsModel := new(iampolicymanagementv1.V2DeletePolicyOptions) - v2DeletePolicyOptionsModel.PolicyID = core.StringPtr("testString") - v2DeletePolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the DeleteV2PolicyOptions model + deleteV2PolicyOptionsModel := new(iampolicymanagementv1.DeleteV2PolicyOptions) + deleteV2PolicyOptionsModel.ID = core.StringPtr("testString") + deleteV2PolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - response, operationErr = iamPolicyManagementService.V2DeletePolicy(v2DeletePolicyOptionsModel) + response, operationErr = iamPolicyManagementService.DeleteV2Policy(deleteV2PolicyOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) }) - It(`Invoke V2DeletePolicy with error: Operation validation and request error`, func() { + It(`Invoke DeleteV2Policy with error: Operation validation and request error`, func() { iamPolicyManagementService, serviceErr := iampolicymanagementv1.NewIamPolicyManagementV1(&iampolicymanagementv1.IamPolicyManagementV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -4371,21 +4501,21 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(serviceErr).To(BeNil()) Expect(iamPolicyManagementService).ToNot(BeNil()) - // Construct an instance of the V2DeletePolicyOptions model - v2DeletePolicyOptionsModel := new(iampolicymanagementv1.V2DeletePolicyOptions) - v2DeletePolicyOptionsModel.PolicyID = core.StringPtr("testString") - v2DeletePolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the DeleteV2PolicyOptions model + deleteV2PolicyOptionsModel := new(iampolicymanagementv1.DeleteV2PolicyOptions) + deleteV2PolicyOptionsModel.ID = core.StringPtr("testString") + deleteV2PolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := iamPolicyManagementService.SetServiceURL("") Expect(err).To(BeNil()) - response, operationErr := iamPolicyManagementService.V2DeletePolicy(v2DeletePolicyOptionsModel) + response, operationErr := iamPolicyManagementService.DeleteV2Policy(deleteV2PolicyOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) - // Construct a second instance of the V2DeletePolicyOptions model with no property values - v2DeletePolicyOptionsModelNew := new(iampolicymanagementv1.V2DeletePolicyOptions) + // Construct a second instance of the DeleteV2PolicyOptions model with no property values + deleteV2PolicyOptionsModelNew := new(iampolicymanagementv1.DeleteV2PolicyOptions) // Invoke operation with invalid model (negative test) - response, operationErr = iamPolicyManagementService.V2DeletePolicy(v2DeletePolicyOptionsModelNew) + response, operationErr = iamPolicyManagementService.DeleteV2Policy(deleteV2PolicyOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) }) @@ -4400,6 +4530,11 @@ var _ = Describe(`IamPolicyManagementV1`, func() { URL: "http://iampolicymanagementv1modelgenerator.com", Authenticator: &core.NoAuthAuthenticator{}, }) + It(`Invoke NewControl successfully`, func() { + var grant *iampolicymanagementv1.V2PolicyGrant = nil + _, err := iamPolicyManagementService.NewControl(grant) + Expect(err).ToNot(BeNil()) + }) It(`Invoke NewCreatePolicyOptions successfully`, func() { // Construct an instance of the SubjectAttribute model subjectAttributeModel := new(iampolicymanagementv1.SubjectAttribute) @@ -4497,6 +4632,103 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(createRoleOptionsModel.AcceptLanguage).To(Equal(core.StringPtr("default"))) Expect(createRoleOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewCreateV2PolicyOptions successfully`, func() { + // Construct an instance of the PolicyRole model + policyRoleModel := new(iampolicymanagementv1.PolicyRole) + Expect(policyRoleModel).ToNot(BeNil()) + policyRoleModel.RoleID = core.StringPtr("testString") + Expect(policyRoleModel.RoleID).To(Equal(core.StringPtr("testString"))) + + // Construct an instance of the V2PolicyGrant model + v2PolicyGrantModel := new(iampolicymanagementv1.V2PolicyGrant) + Expect(v2PolicyGrantModel).ToNot(BeNil()) + v2PolicyGrantModel.Roles = []iampolicymanagementv1.PolicyRole{*policyRoleModel} + Expect(v2PolicyGrantModel.Roles).To(Equal([]iampolicymanagementv1.PolicyRole{*policyRoleModel})) + + // Construct an instance of the Control model + controlModel := new(iampolicymanagementv1.Control) + Expect(controlModel).ToNot(BeNil()) + controlModel.Grant = v2PolicyGrantModel + Expect(controlModel.Grant).To(Equal(v2PolicyGrantModel)) + + // Construct an instance of the V2PolicySubjectAttribute model + v2PolicySubjectAttributeModel := new(iampolicymanagementv1.V2PolicySubjectAttribute) + Expect(v2PolicySubjectAttributeModel).ToNot(BeNil()) + v2PolicySubjectAttributeModel.Key = core.StringPtr("testString") + v2PolicySubjectAttributeModel.Operator = core.StringPtr("stringEquals") + v2PolicySubjectAttributeModel.Value = core.StringPtr("testString") + Expect(v2PolicySubjectAttributeModel.Key).To(Equal(core.StringPtr("testString"))) + Expect(v2PolicySubjectAttributeModel.Operator).To(Equal(core.StringPtr("stringEquals"))) + Expect(v2PolicySubjectAttributeModel.Value).To(Equal(core.StringPtr("testString"))) + + // Construct an instance of the V2PolicySubject model + v2PolicySubjectModel := new(iampolicymanagementv1.V2PolicySubject) + Expect(v2PolicySubjectModel).ToNot(BeNil()) + v2PolicySubjectModel.Attributes = []iampolicymanagementv1.V2PolicySubjectAttribute{*v2PolicySubjectAttributeModel} + Expect(v2PolicySubjectModel.Attributes).To(Equal([]iampolicymanagementv1.V2PolicySubjectAttribute{*v2PolicySubjectAttributeModel})) + + // Construct an instance of the V2PolicyResourceAttribute model + v2PolicyResourceAttributeModel := new(iampolicymanagementv1.V2PolicyResourceAttribute) + Expect(v2PolicyResourceAttributeModel).ToNot(BeNil()) + v2PolicyResourceAttributeModel.Key = core.StringPtr("testString") + v2PolicyResourceAttributeModel.Operator = core.StringPtr("stringEquals") + v2PolicyResourceAttributeModel.Value = core.StringPtr("testString") + Expect(v2PolicyResourceAttributeModel.Key).To(Equal(core.StringPtr("testString"))) + Expect(v2PolicyResourceAttributeModel.Operator).To(Equal(core.StringPtr("stringEquals"))) + Expect(v2PolicyResourceAttributeModel.Value).To(Equal(core.StringPtr("testString"))) + + // Construct an instance of the V2PolicyResourceTag model + v2PolicyResourceTagModel := new(iampolicymanagementv1.V2PolicyResourceTag) + Expect(v2PolicyResourceTagModel).ToNot(BeNil()) + v2PolicyResourceTagModel.Key = core.StringPtr("testString") + v2PolicyResourceTagModel.Value = core.StringPtr("testString") + v2PolicyResourceTagModel.Operator = core.StringPtr("stringEquals") + Expect(v2PolicyResourceTagModel.Key).To(Equal(core.StringPtr("testString"))) + Expect(v2PolicyResourceTagModel.Value).To(Equal(core.StringPtr("testString"))) + Expect(v2PolicyResourceTagModel.Operator).To(Equal(core.StringPtr("stringEquals"))) + + // Construct an instance of the V2PolicyResource model + v2PolicyResourceModel := new(iampolicymanagementv1.V2PolicyResource) + Expect(v2PolicyResourceModel).ToNot(BeNil()) + v2PolicyResourceModel.Attributes = []iampolicymanagementv1.V2PolicyResourceAttribute{*v2PolicyResourceAttributeModel} + v2PolicyResourceModel.Tags = []iampolicymanagementv1.V2PolicyResourceTag{*v2PolicyResourceTagModel} + Expect(v2PolicyResourceModel.Attributes).To(Equal([]iampolicymanagementv1.V2PolicyResourceAttribute{*v2PolicyResourceAttributeModel})) + Expect(v2PolicyResourceModel.Tags).To(Equal([]iampolicymanagementv1.V2PolicyResourceTag{*v2PolicyResourceTagModel})) + + // Construct an instance of the V2PolicyRuleRuleAttribute model + v2PolicyRuleModel := new(iampolicymanagementv1.V2PolicyRuleRuleAttribute) + Expect(v2PolicyRuleModel).ToNot(BeNil()) + v2PolicyRuleModel.Key = core.StringPtr("testString") + v2PolicyRuleModel.Operator = core.StringPtr("timeLessThan") + v2PolicyRuleModel.Value = core.StringPtr("testString") + Expect(v2PolicyRuleModel.Key).To(Equal(core.StringPtr("testString"))) + Expect(v2PolicyRuleModel.Operator).To(Equal(core.StringPtr("timeLessThan"))) + Expect(v2PolicyRuleModel.Value).To(Equal(core.StringPtr("testString"))) + + // Construct an instance of the CreateV2PolicyOptions model + var createV2PolicyOptionsControl *iampolicymanagementv1.Control = nil + createV2PolicyOptionsType := "access" + createV2PolicyOptionsModel := iamPolicyManagementService.NewCreateV2PolicyOptions(createV2PolicyOptionsControl, createV2PolicyOptionsType) + createV2PolicyOptionsModel.SetControl(controlModel) + createV2PolicyOptionsModel.SetType("access") + createV2PolicyOptionsModel.SetDescription("testString") + createV2PolicyOptionsModel.SetSubject(v2PolicySubjectModel) + createV2PolicyOptionsModel.SetResource(v2PolicyResourceModel) + createV2PolicyOptionsModel.SetPattern("testString") + createV2PolicyOptionsModel.SetRule(v2PolicyRuleModel) + createV2PolicyOptionsModel.SetAcceptLanguage("default") + createV2PolicyOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(createV2PolicyOptionsModel).ToNot(BeNil()) + Expect(createV2PolicyOptionsModel.Control).To(Equal(controlModel)) + Expect(createV2PolicyOptionsModel.Type).To(Equal(core.StringPtr("access"))) + Expect(createV2PolicyOptionsModel.Description).To(Equal(core.StringPtr("testString"))) + Expect(createV2PolicyOptionsModel.Subject).To(Equal(v2PolicySubjectModel)) + Expect(createV2PolicyOptionsModel.Resource).To(Equal(v2PolicyResourceModel)) + Expect(createV2PolicyOptionsModel.Pattern).To(Equal(core.StringPtr("testString"))) + Expect(createV2PolicyOptionsModel.Rule).To(Equal(v2PolicyRuleModel)) + Expect(createV2PolicyOptionsModel.AcceptLanguage).To(Equal(core.StringPtr("default"))) + Expect(createV2PolicyOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) It(`Invoke NewDeletePolicyOptions successfully`, func() { // Construct an instance of the DeletePolicyOptions model policyID := "testString" @@ -4517,6 +4749,16 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(deleteRoleOptionsModel.RoleID).To(Equal(core.StringPtr("testString"))) Expect(deleteRoleOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewDeleteV2PolicyOptions successfully`, func() { + // Construct an instance of the DeleteV2PolicyOptions model + id := "testString" + deleteV2PolicyOptionsModel := iamPolicyManagementService.NewDeleteV2PolicyOptions(id) + deleteV2PolicyOptionsModel.SetID("testString") + deleteV2PolicyOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(deleteV2PolicyOptionsModel).ToNot(BeNil()) + Expect(deleteV2PolicyOptionsModel.ID).To(Equal(core.StringPtr("testString"))) + Expect(deleteV2PolicyOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) It(`Invoke NewGetPolicyOptions successfully`, func() { // Construct an instance of the GetPolicyOptions model policyID := "testString" @@ -4537,6 +4779,16 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(getRoleOptionsModel.RoleID).To(Equal(core.StringPtr("testString"))) Expect(getRoleOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewGetV2PolicyOptions successfully`, func() { + // Construct an instance of the GetV2PolicyOptions model + id := "testString" + getV2PolicyOptionsModel := iamPolicyManagementService.NewGetV2PolicyOptions(id) + getV2PolicyOptionsModel.SetID("testString") + getV2PolicyOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(getV2PolicyOptionsModel).ToNot(BeNil()) + Expect(getV2PolicyOptionsModel.ID).To(Equal(core.StringPtr("testString"))) + Expect(getV2PolicyOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) It(`Invoke NewListPoliciesOptions successfully`, func() { // Construct an instance of the ListPoliciesOptions model accountID := "testString" @@ -4584,22 +4836,41 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(listRolesOptionsModel.PolicyType).To(Equal(core.StringPtr("authorization"))) Expect(listRolesOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) - It(`Invoke NewPatchPolicyOptions successfully`, func() { - // Construct an instance of the PatchPolicyOptions model - policyID := "testString" - ifMatch := "testString" - patchPolicyOptionsModel := iamPolicyManagementService.NewPatchPolicyOptions(policyID, ifMatch) - patchPolicyOptionsModel.SetPolicyID("testString") - patchPolicyOptionsModel.SetIfMatch("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("active"))) - Expect(patchPolicyOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) - }) - It(`Invoke NewUpdatePolicyOptions successfully`, func() { + It(`Invoke NewListV2PoliciesOptions successfully`, func() { + // Construct an instance of the ListV2PoliciesOptions model + accountID := "testString" + listV2PoliciesOptionsModel := iamPolicyManagementService.NewListV2PoliciesOptions(accountID) + listV2PoliciesOptionsModel.SetAccountID("testString") + listV2PoliciesOptionsModel.SetAcceptLanguage("default") + listV2PoliciesOptionsModel.SetIamID("testString") + listV2PoliciesOptionsModel.SetAccessGroupID("testString") + listV2PoliciesOptionsModel.SetType("access") + listV2PoliciesOptionsModel.SetServiceType("service") + listV2PoliciesOptionsModel.SetServiceName("testString") + listV2PoliciesOptionsModel.SetServiceGroupID("testString") + listV2PoliciesOptionsModel.SetFormat("include_last_permit") + listV2PoliciesOptionsModel.SetState("active") + listV2PoliciesOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(listV2PoliciesOptionsModel).ToNot(BeNil()) + Expect(listV2PoliciesOptionsModel.AccountID).To(Equal(core.StringPtr("testString"))) + Expect(listV2PoliciesOptionsModel.AcceptLanguage).To(Equal(core.StringPtr("default"))) + Expect(listV2PoliciesOptionsModel.IamID).To(Equal(core.StringPtr("testString"))) + Expect(listV2PoliciesOptionsModel.AccessGroupID).To(Equal(core.StringPtr("testString"))) + Expect(listV2PoliciesOptionsModel.Type).To(Equal(core.StringPtr("access"))) + Expect(listV2PoliciesOptionsModel.ServiceType).To(Equal(core.StringPtr("service"))) + Expect(listV2PoliciesOptionsModel.ServiceName).To(Equal(core.StringPtr("testString"))) + Expect(listV2PoliciesOptionsModel.ServiceGroupID).To(Equal(core.StringPtr("testString"))) + Expect(listV2PoliciesOptionsModel.Format).To(Equal(core.StringPtr("include_last_permit"))) + Expect(listV2PoliciesOptionsModel.State).To(Equal(core.StringPtr("active"))) + Expect(listV2PoliciesOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) + It(`Invoke NewPolicyRole successfully`, func() { + roleID := "testString" + _model, err := iamPolicyManagementService.NewPolicyRole(roleID) + Expect(_model).ToNot(BeNil()) + Expect(err).To(BeNil()) + }) + It(`Invoke NewReplacePolicyOptions successfully`, func() { // Construct an instance of the SubjectAttribute model subjectAttributeModel := new(iampolicymanagementv1.SubjectAttribute) Expect(subjectAttributeModel).ToNot(BeNil()) @@ -4648,267 +4919,216 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(policyResourceModel.Attributes).To(Equal([]iampolicymanagementv1.ResourceAttribute{*resourceAttributeModel})) Expect(policyResourceModel.Tags).To(Equal([]iampolicymanagementv1.ResourceTag{*resourceTagModel})) - // Construct an instance of the UpdatePolicyOptions model + // Construct an instance of the ReplacePolicyOptions model policyID := "testString" ifMatch := "testString" - updatePolicyOptionsType := "testString" - updatePolicyOptionsSubjects := []iampolicymanagementv1.PolicySubject{} - updatePolicyOptionsRoles := []iampolicymanagementv1.PolicyRole{} - updatePolicyOptionsResources := []iampolicymanagementv1.PolicyResource{} - updatePolicyOptionsModel := iamPolicyManagementService.NewUpdatePolicyOptions(policyID, ifMatch, updatePolicyOptionsType, updatePolicyOptionsSubjects, updatePolicyOptionsRoles, updatePolicyOptionsResources) - updatePolicyOptionsModel.SetPolicyID("testString") - updatePolicyOptionsModel.SetIfMatch("testString") - updatePolicyOptionsModel.SetType("testString") - updatePolicyOptionsModel.SetSubjects([]iampolicymanagementv1.PolicySubject{*policySubjectModel}) - updatePolicyOptionsModel.SetRoles([]iampolicymanagementv1.PolicyRole{*policyRoleModel}) - updatePolicyOptionsModel.SetResources([]iampolicymanagementv1.PolicyResource{*policyResourceModel}) - updatePolicyOptionsModel.SetDescription("testString") - updatePolicyOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) - Expect(updatePolicyOptionsModel).ToNot(BeNil()) - Expect(updatePolicyOptionsModel.PolicyID).To(Equal(core.StringPtr("testString"))) - Expect(updatePolicyOptionsModel.IfMatch).To(Equal(core.StringPtr("testString"))) - Expect(updatePolicyOptionsModel.Type).To(Equal(core.StringPtr("testString"))) - Expect(updatePolicyOptionsModel.Subjects).To(Equal([]iampolicymanagementv1.PolicySubject{*policySubjectModel})) - Expect(updatePolicyOptionsModel.Roles).To(Equal([]iampolicymanagementv1.PolicyRole{*policyRoleModel})) - Expect(updatePolicyOptionsModel.Resources).To(Equal([]iampolicymanagementv1.PolicyResource{*policyResourceModel})) - Expect(updatePolicyOptionsModel.Description).To(Equal(core.StringPtr("testString"))) - Expect(updatePolicyOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) - }) - It(`Invoke NewUpdateRoleOptions successfully`, func() { - // Construct an instance of the UpdateRoleOptions model + replacePolicyOptionsType := "testString" + replacePolicyOptionsSubjects := []iampolicymanagementv1.PolicySubject{} + replacePolicyOptionsRoles := []iampolicymanagementv1.PolicyRole{} + replacePolicyOptionsResources := []iampolicymanagementv1.PolicyResource{} + replacePolicyOptionsModel := iamPolicyManagementService.NewReplacePolicyOptions(policyID, ifMatch, replacePolicyOptionsType, replacePolicyOptionsSubjects, replacePolicyOptionsRoles, replacePolicyOptionsResources) + replacePolicyOptionsModel.SetPolicyID("testString") + replacePolicyOptionsModel.SetIfMatch("testString") + replacePolicyOptionsModel.SetType("testString") + replacePolicyOptionsModel.SetSubjects([]iampolicymanagementv1.PolicySubject{*policySubjectModel}) + replacePolicyOptionsModel.SetRoles([]iampolicymanagementv1.PolicyRole{*policyRoleModel}) + replacePolicyOptionsModel.SetResources([]iampolicymanagementv1.PolicyResource{*policyResourceModel}) + replacePolicyOptionsModel.SetDescription("testString") + replacePolicyOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(replacePolicyOptionsModel).ToNot(BeNil()) + Expect(replacePolicyOptionsModel.PolicyID).To(Equal(core.StringPtr("testString"))) + Expect(replacePolicyOptionsModel.IfMatch).To(Equal(core.StringPtr("testString"))) + Expect(replacePolicyOptionsModel.Type).To(Equal(core.StringPtr("testString"))) + Expect(replacePolicyOptionsModel.Subjects).To(Equal([]iampolicymanagementv1.PolicySubject{*policySubjectModel})) + Expect(replacePolicyOptionsModel.Roles).To(Equal([]iampolicymanagementv1.PolicyRole{*policyRoleModel})) + Expect(replacePolicyOptionsModel.Resources).To(Equal([]iampolicymanagementv1.PolicyResource{*policyResourceModel})) + Expect(replacePolicyOptionsModel.Description).To(Equal(core.StringPtr("testString"))) + Expect(replacePolicyOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) + It(`Invoke NewReplaceRoleOptions successfully`, func() { + // Construct an instance of the ReplaceRoleOptions model roleID := "testString" ifMatch := "testString" - updateRoleOptionsModel := iamPolicyManagementService.NewUpdateRoleOptions(roleID, ifMatch) - updateRoleOptionsModel.SetRoleID("testString") - updateRoleOptionsModel.SetIfMatch("testString") - updateRoleOptionsModel.SetDisplayName("testString") - updateRoleOptionsModel.SetDescription("testString") - updateRoleOptionsModel.SetActions([]string{"testString"}) - updateRoleOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) - Expect(updateRoleOptionsModel).ToNot(BeNil()) - Expect(updateRoleOptionsModel.RoleID).To(Equal(core.StringPtr("testString"))) - Expect(updateRoleOptionsModel.IfMatch).To(Equal(core.StringPtr("testString"))) - Expect(updateRoleOptionsModel.DisplayName).To(Equal(core.StringPtr("testString"))) - Expect(updateRoleOptionsModel.Description).To(Equal(core.StringPtr("testString"))) - Expect(updateRoleOptionsModel.Actions).To(Equal([]string{"testString"})) - Expect(updateRoleOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) - }) - It(`Invoke NewV2CreatePolicyOptions successfully`, func() { + replaceRoleOptionsDisplayName := "testString" + replaceRoleOptionsActions := []string{"testString"} + replaceRoleOptionsModel := iamPolicyManagementService.NewReplaceRoleOptions(roleID, ifMatch, replaceRoleOptionsDisplayName, replaceRoleOptionsActions) + replaceRoleOptionsModel.SetRoleID("testString") + replaceRoleOptionsModel.SetIfMatch("testString") + replaceRoleOptionsModel.SetDisplayName("testString") + replaceRoleOptionsModel.SetActions([]string{"testString"}) + replaceRoleOptionsModel.SetDescription("testString") + replaceRoleOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(replaceRoleOptionsModel).ToNot(BeNil()) + Expect(replaceRoleOptionsModel.RoleID).To(Equal(core.StringPtr("testString"))) + Expect(replaceRoleOptionsModel.IfMatch).To(Equal(core.StringPtr("testString"))) + Expect(replaceRoleOptionsModel.DisplayName).To(Equal(core.StringPtr("testString"))) + Expect(replaceRoleOptionsModel.Actions).To(Equal([]string{"testString"})) + Expect(replaceRoleOptionsModel.Description).To(Equal(core.StringPtr("testString"))) + Expect(replaceRoleOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) + It(`Invoke NewReplaceV2PolicyOptions successfully`, func() { // Construct an instance of the PolicyRole model policyRoleModel := new(iampolicymanagementv1.PolicyRole) Expect(policyRoleModel).ToNot(BeNil()) policyRoleModel.RoleID = core.StringPtr("testString") Expect(policyRoleModel.RoleID).To(Equal(core.StringPtr("testString"))) - // Construct an instance of the V2PolicyBaseControlGrant model - v2PolicyBaseControlGrantModel := new(iampolicymanagementv1.V2PolicyBaseControlGrant) - Expect(v2PolicyBaseControlGrantModel).ToNot(BeNil()) - v2PolicyBaseControlGrantModel.Roles = []iampolicymanagementv1.PolicyRole{*policyRoleModel} - Expect(v2PolicyBaseControlGrantModel.Roles).To(Equal([]iampolicymanagementv1.PolicyRole{*policyRoleModel})) - - // Construct an instance of the V2PolicyBaseControl model - v2PolicyBaseControlModel := new(iampolicymanagementv1.V2PolicyBaseControl) - Expect(v2PolicyBaseControlModel).ToNot(BeNil()) - v2PolicyBaseControlModel.Grant = v2PolicyBaseControlGrantModel - Expect(v2PolicyBaseControlModel.Grant).To(Equal(v2PolicyBaseControlGrantModel)) - - // Construct an instance of the V2PolicyAttribute model - v2PolicyAttributeModel := new(iampolicymanagementv1.V2PolicyAttribute) - Expect(v2PolicyAttributeModel).ToNot(BeNil()) - v2PolicyAttributeModel.Key = core.StringPtr("testString") - v2PolicyAttributeModel.Operator = core.StringPtr("testString") - v2PolicyAttributeModel.Value = core.StringPtr("testString") - Expect(v2PolicyAttributeModel.Key).To(Equal(core.StringPtr("testString"))) - Expect(v2PolicyAttributeModel.Operator).To(Equal(core.StringPtr("testString"))) - Expect(v2PolicyAttributeModel.Value).To(Equal(core.StringPtr("testString"))) - - // Construct an instance of the V2PolicyBaseSubject model - v2PolicyBaseSubjectModel := new(iampolicymanagementv1.V2PolicyBaseSubject) - Expect(v2PolicyBaseSubjectModel).ToNot(BeNil()) - v2PolicyBaseSubjectModel.Attributes = []iampolicymanagementv1.V2PolicyAttribute{*v2PolicyAttributeModel} - Expect(v2PolicyBaseSubjectModel.Attributes).To(Equal([]iampolicymanagementv1.V2PolicyAttribute{*v2PolicyAttributeModel})) - - // Construct an instance of the V2PolicyBaseResource model - v2PolicyBaseResourceModel := new(iampolicymanagementv1.V2PolicyBaseResource) - Expect(v2PolicyBaseResourceModel).ToNot(BeNil()) - v2PolicyBaseResourceModel.Attributes = []iampolicymanagementv1.V2PolicyAttribute{*v2PolicyAttributeModel} - Expect(v2PolicyBaseResourceModel.Attributes).To(Equal([]iampolicymanagementv1.V2PolicyAttribute{*v2PolicyAttributeModel})) - - // Construct an instance of the V2PolicyBaseRuleV2PolicyAttribute model - v2PolicyBaseRuleModel := new(iampolicymanagementv1.V2PolicyBaseRuleV2PolicyAttribute) - Expect(v2PolicyBaseRuleModel).ToNot(BeNil()) - v2PolicyBaseRuleModel.Key = core.StringPtr("testString") - v2PolicyBaseRuleModel.Operator = core.StringPtr("testString") - v2PolicyBaseRuleModel.Value = core.StringPtr("testString") - Expect(v2PolicyBaseRuleModel.Key).To(Equal(core.StringPtr("testString"))) - Expect(v2PolicyBaseRuleModel.Operator).To(Equal(core.StringPtr("testString"))) - Expect(v2PolicyBaseRuleModel.Value).To(Equal(core.StringPtr("testString"))) - - // Construct an instance of the V2CreatePolicyOptions model - v2CreatePolicyOptionsType := "testString" - var v2CreatePolicyOptionsControl *iampolicymanagementv1.V2PolicyBaseControl = nil - v2CreatePolicyOptionsModel := iamPolicyManagementService.NewV2CreatePolicyOptions(v2CreatePolicyOptionsType, v2CreatePolicyOptionsControl) - v2CreatePolicyOptionsModel.SetType("testString") - v2CreatePolicyOptionsModel.SetControl(v2PolicyBaseControlModel) - v2CreatePolicyOptionsModel.SetDescription("testString") - v2CreatePolicyOptionsModel.SetSubject(v2PolicyBaseSubjectModel) - v2CreatePolicyOptionsModel.SetResource(v2PolicyBaseResourceModel) - v2CreatePolicyOptionsModel.SetPattern("testString") - v2CreatePolicyOptionsModel.SetRule(v2PolicyBaseRuleModel) - v2CreatePolicyOptionsModel.SetAcceptLanguage("default") - v2CreatePolicyOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) - Expect(v2CreatePolicyOptionsModel).ToNot(BeNil()) - Expect(v2CreatePolicyOptionsModel.Type).To(Equal(core.StringPtr("testString"))) - Expect(v2CreatePolicyOptionsModel.Control).To(Equal(v2PolicyBaseControlModel)) - Expect(v2CreatePolicyOptionsModel.Description).To(Equal(core.StringPtr("testString"))) - Expect(v2CreatePolicyOptionsModel.Subject).To(Equal(v2PolicyBaseSubjectModel)) - Expect(v2CreatePolicyOptionsModel.Resource).To(Equal(v2PolicyBaseResourceModel)) - Expect(v2CreatePolicyOptionsModel.Pattern).To(Equal(core.StringPtr("testString"))) - Expect(v2CreatePolicyOptionsModel.Rule).To(Equal(v2PolicyBaseRuleModel)) - Expect(v2CreatePolicyOptionsModel.AcceptLanguage).To(Equal(core.StringPtr("default"))) - Expect(v2CreatePolicyOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) - }) - It(`Invoke NewV2DeletePolicyOptions successfully`, func() { - // Construct an instance of the V2DeletePolicyOptions model - policyID := "testString" - v2DeletePolicyOptionsModel := iamPolicyManagementService.NewV2DeletePolicyOptions(policyID) - v2DeletePolicyOptionsModel.SetPolicyID("testString") - v2DeletePolicyOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) - Expect(v2DeletePolicyOptionsModel).ToNot(BeNil()) - Expect(v2DeletePolicyOptionsModel.PolicyID).To(Equal(core.StringPtr("testString"))) - Expect(v2DeletePolicyOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) - }) - It(`Invoke NewV2GetPolicyOptions successfully`, func() { - // Construct an instance of the V2GetPolicyOptions model - policyID := "testString" - v2GetPolicyOptionsModel := iamPolicyManagementService.NewV2GetPolicyOptions(policyID) - v2GetPolicyOptionsModel.SetPolicyID("testString") - v2GetPolicyOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) - Expect(v2GetPolicyOptionsModel).ToNot(BeNil()) - Expect(v2GetPolicyOptionsModel.PolicyID).To(Equal(core.StringPtr("testString"))) - Expect(v2GetPolicyOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) - }) - It(`Invoke NewV2ListPoliciesOptions successfully`, func() { - // Construct an instance of the V2ListPoliciesOptions model - accountID := "testString" - v2ListPoliciesOptionsModel := iamPolicyManagementService.NewV2ListPoliciesOptions(accountID) - v2ListPoliciesOptionsModel.SetAccountID("testString") - v2ListPoliciesOptionsModel.SetAcceptLanguage("default") - v2ListPoliciesOptionsModel.SetIamID("testString") - v2ListPoliciesOptionsModel.SetAccessGroupID("testString") - v2ListPoliciesOptionsModel.SetType("access") - v2ListPoliciesOptionsModel.SetServiceType("service") - v2ListPoliciesOptionsModel.SetServiceName("testString") - v2ListPoliciesOptionsModel.SetServiceGroupID("testString") - v2ListPoliciesOptionsModel.SetFormat("include_last_permit") - v2ListPoliciesOptionsModel.SetState("active") - v2ListPoliciesOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) - Expect(v2ListPoliciesOptionsModel).ToNot(BeNil()) - Expect(v2ListPoliciesOptionsModel.AccountID).To(Equal(core.StringPtr("testString"))) - Expect(v2ListPoliciesOptionsModel.AcceptLanguage).To(Equal(core.StringPtr("default"))) - Expect(v2ListPoliciesOptionsModel.IamID).To(Equal(core.StringPtr("testString"))) - Expect(v2ListPoliciesOptionsModel.AccessGroupID).To(Equal(core.StringPtr("testString"))) - Expect(v2ListPoliciesOptionsModel.Type).To(Equal(core.StringPtr("access"))) - Expect(v2ListPoliciesOptionsModel.ServiceType).To(Equal(core.StringPtr("service"))) - Expect(v2ListPoliciesOptionsModel.ServiceName).To(Equal(core.StringPtr("testString"))) - Expect(v2ListPoliciesOptionsModel.ServiceGroupID).To(Equal(core.StringPtr("testString"))) - Expect(v2ListPoliciesOptionsModel.Format).To(Equal(core.StringPtr("include_last_permit"))) - Expect(v2ListPoliciesOptionsModel.State).To(Equal(core.StringPtr("active"))) - Expect(v2ListPoliciesOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) - }) - It(`Invoke NewV2PolicyBaseControl successfully`, func() { - var grant *iampolicymanagementv1.V2PolicyBaseControlGrant = nil - _, err := iamPolicyManagementService.NewV2PolicyBaseControl(grant) - Expect(err).ToNot(BeNil()) - }) - It(`Invoke NewV2PolicyBaseControlGrant successfully`, func() { - roles := []iampolicymanagementv1.PolicyRole{} - _model, err := iamPolicyManagementService.NewV2PolicyBaseControlGrant(roles) + // Construct an instance of the V2PolicyGrant model + v2PolicyGrantModel := new(iampolicymanagementv1.V2PolicyGrant) + Expect(v2PolicyGrantModel).ToNot(BeNil()) + v2PolicyGrantModel.Roles = []iampolicymanagementv1.PolicyRole{*policyRoleModel} + Expect(v2PolicyGrantModel.Roles).To(Equal([]iampolicymanagementv1.PolicyRole{*policyRoleModel})) + + // Construct an instance of the Control model + controlModel := new(iampolicymanagementv1.Control) + Expect(controlModel).ToNot(BeNil()) + controlModel.Grant = v2PolicyGrantModel + Expect(controlModel.Grant).To(Equal(v2PolicyGrantModel)) + + // Construct an instance of the V2PolicySubjectAttribute model + v2PolicySubjectAttributeModel := new(iampolicymanagementv1.V2PolicySubjectAttribute) + Expect(v2PolicySubjectAttributeModel).ToNot(BeNil()) + v2PolicySubjectAttributeModel.Key = core.StringPtr("testString") + v2PolicySubjectAttributeModel.Operator = core.StringPtr("stringEquals") + v2PolicySubjectAttributeModel.Value = core.StringPtr("testString") + Expect(v2PolicySubjectAttributeModel.Key).To(Equal(core.StringPtr("testString"))) + Expect(v2PolicySubjectAttributeModel.Operator).To(Equal(core.StringPtr("stringEquals"))) + Expect(v2PolicySubjectAttributeModel.Value).To(Equal(core.StringPtr("testString"))) + + // Construct an instance of the V2PolicySubject model + v2PolicySubjectModel := new(iampolicymanagementv1.V2PolicySubject) + Expect(v2PolicySubjectModel).ToNot(BeNil()) + v2PolicySubjectModel.Attributes = []iampolicymanagementv1.V2PolicySubjectAttribute{*v2PolicySubjectAttributeModel} + Expect(v2PolicySubjectModel.Attributes).To(Equal([]iampolicymanagementv1.V2PolicySubjectAttribute{*v2PolicySubjectAttributeModel})) + + // Construct an instance of the V2PolicyResourceAttribute model + v2PolicyResourceAttributeModel := new(iampolicymanagementv1.V2PolicyResourceAttribute) + Expect(v2PolicyResourceAttributeModel).ToNot(BeNil()) + v2PolicyResourceAttributeModel.Key = core.StringPtr("testString") + v2PolicyResourceAttributeModel.Operator = core.StringPtr("stringEquals") + v2PolicyResourceAttributeModel.Value = core.StringPtr("testString") + Expect(v2PolicyResourceAttributeModel.Key).To(Equal(core.StringPtr("testString"))) + Expect(v2PolicyResourceAttributeModel.Operator).To(Equal(core.StringPtr("stringEquals"))) + Expect(v2PolicyResourceAttributeModel.Value).To(Equal(core.StringPtr("testString"))) + + // Construct an instance of the V2PolicyResourceTag model + v2PolicyResourceTagModel := new(iampolicymanagementv1.V2PolicyResourceTag) + Expect(v2PolicyResourceTagModel).ToNot(BeNil()) + v2PolicyResourceTagModel.Key = core.StringPtr("testString") + v2PolicyResourceTagModel.Value = core.StringPtr("testString") + v2PolicyResourceTagModel.Operator = core.StringPtr("stringEquals") + Expect(v2PolicyResourceTagModel.Key).To(Equal(core.StringPtr("testString"))) + Expect(v2PolicyResourceTagModel.Value).To(Equal(core.StringPtr("testString"))) + Expect(v2PolicyResourceTagModel.Operator).To(Equal(core.StringPtr("stringEquals"))) + + // Construct an instance of the V2PolicyResource model + v2PolicyResourceModel := new(iampolicymanagementv1.V2PolicyResource) + Expect(v2PolicyResourceModel).ToNot(BeNil()) + v2PolicyResourceModel.Attributes = []iampolicymanagementv1.V2PolicyResourceAttribute{*v2PolicyResourceAttributeModel} + v2PolicyResourceModel.Tags = []iampolicymanagementv1.V2PolicyResourceTag{*v2PolicyResourceTagModel} + Expect(v2PolicyResourceModel.Attributes).To(Equal([]iampolicymanagementv1.V2PolicyResourceAttribute{*v2PolicyResourceAttributeModel})) + Expect(v2PolicyResourceModel.Tags).To(Equal([]iampolicymanagementv1.V2PolicyResourceTag{*v2PolicyResourceTagModel})) + + // Construct an instance of the V2PolicyRuleRuleAttribute model + v2PolicyRuleModel := new(iampolicymanagementv1.V2PolicyRuleRuleAttribute) + Expect(v2PolicyRuleModel).ToNot(BeNil()) + v2PolicyRuleModel.Key = core.StringPtr("testString") + v2PolicyRuleModel.Operator = core.StringPtr("timeLessThan") + v2PolicyRuleModel.Value = core.StringPtr("testString") + Expect(v2PolicyRuleModel.Key).To(Equal(core.StringPtr("testString"))) + Expect(v2PolicyRuleModel.Operator).To(Equal(core.StringPtr("timeLessThan"))) + Expect(v2PolicyRuleModel.Value).To(Equal(core.StringPtr("testString"))) + + // Construct an instance of the ReplaceV2PolicyOptions model + id := "testString" + ifMatch := "testString" + var replaceV2PolicyOptionsControl *iampolicymanagementv1.Control = nil + replaceV2PolicyOptionsType := "access" + replaceV2PolicyOptionsModel := iamPolicyManagementService.NewReplaceV2PolicyOptions(id, ifMatch, replaceV2PolicyOptionsControl, replaceV2PolicyOptionsType) + replaceV2PolicyOptionsModel.SetID("testString") + replaceV2PolicyOptionsModel.SetIfMatch("testString") + replaceV2PolicyOptionsModel.SetControl(controlModel) + replaceV2PolicyOptionsModel.SetType("access") + replaceV2PolicyOptionsModel.SetDescription("testString") + replaceV2PolicyOptionsModel.SetSubject(v2PolicySubjectModel) + replaceV2PolicyOptionsModel.SetResource(v2PolicyResourceModel) + replaceV2PolicyOptionsModel.SetPattern("testString") + replaceV2PolicyOptionsModel.SetRule(v2PolicyRuleModel) + replaceV2PolicyOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(replaceV2PolicyOptionsModel).ToNot(BeNil()) + Expect(replaceV2PolicyOptionsModel.ID).To(Equal(core.StringPtr("testString"))) + Expect(replaceV2PolicyOptionsModel.IfMatch).To(Equal(core.StringPtr("testString"))) + Expect(replaceV2PolicyOptionsModel.Control).To(Equal(controlModel)) + Expect(replaceV2PolicyOptionsModel.Type).To(Equal(core.StringPtr("access"))) + Expect(replaceV2PolicyOptionsModel.Description).To(Equal(core.StringPtr("testString"))) + Expect(replaceV2PolicyOptionsModel.Subject).To(Equal(v2PolicySubjectModel)) + Expect(replaceV2PolicyOptionsModel.Resource).To(Equal(v2PolicyResourceModel)) + Expect(replaceV2PolicyOptionsModel.Pattern).To(Equal(core.StringPtr("testString"))) + Expect(replaceV2PolicyOptionsModel.Rule).To(Equal(v2PolicyRuleModel)) + Expect(replaceV2PolicyOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) + It(`Invoke NewRuleAttribute successfully`, func() { + key := "testString" + operator := "timeLessThan" + value := core.StringPtr("testString") + _model, err := iamPolicyManagementService.NewRuleAttribute(key, operator, value) Expect(_model).ToNot(BeNil()) Expect(err).To(BeNil()) }) - It(`Invoke NewV2UpdatePolicyOptions successfully`, func() { - // Construct an instance of the PolicyRole model - policyRoleModel := new(iampolicymanagementv1.PolicyRole) - Expect(policyRoleModel).ToNot(BeNil()) - policyRoleModel.RoleID = core.StringPtr("testString") - Expect(policyRoleModel.RoleID).To(Equal(core.StringPtr("testString"))) - - // Construct an instance of the V2PolicyBaseControlGrant model - v2PolicyBaseControlGrantModel := new(iampolicymanagementv1.V2PolicyBaseControlGrant) - Expect(v2PolicyBaseControlGrantModel).ToNot(BeNil()) - v2PolicyBaseControlGrantModel.Roles = []iampolicymanagementv1.PolicyRole{*policyRoleModel} - Expect(v2PolicyBaseControlGrantModel.Roles).To(Equal([]iampolicymanagementv1.PolicyRole{*policyRoleModel})) - - // Construct an instance of the V2PolicyBaseControl model - v2PolicyBaseControlModel := new(iampolicymanagementv1.V2PolicyBaseControl) - Expect(v2PolicyBaseControlModel).ToNot(BeNil()) - v2PolicyBaseControlModel.Grant = v2PolicyBaseControlGrantModel - Expect(v2PolicyBaseControlModel.Grant).To(Equal(v2PolicyBaseControlGrantModel)) - - // Construct an instance of the V2PolicyAttribute model - v2PolicyAttributeModel := new(iampolicymanagementv1.V2PolicyAttribute) - Expect(v2PolicyAttributeModel).ToNot(BeNil()) - v2PolicyAttributeModel.Key = core.StringPtr("testString") - v2PolicyAttributeModel.Operator = core.StringPtr("testString") - v2PolicyAttributeModel.Value = core.StringPtr("testString") - Expect(v2PolicyAttributeModel.Key).To(Equal(core.StringPtr("testString"))) - Expect(v2PolicyAttributeModel.Operator).To(Equal(core.StringPtr("testString"))) - Expect(v2PolicyAttributeModel.Value).To(Equal(core.StringPtr("testString"))) - - // Construct an instance of the V2PolicyBaseSubject model - v2PolicyBaseSubjectModel := new(iampolicymanagementv1.V2PolicyBaseSubject) - Expect(v2PolicyBaseSubjectModel).ToNot(BeNil()) - v2PolicyBaseSubjectModel.Attributes = []iampolicymanagementv1.V2PolicyAttribute{*v2PolicyAttributeModel} - Expect(v2PolicyBaseSubjectModel.Attributes).To(Equal([]iampolicymanagementv1.V2PolicyAttribute{*v2PolicyAttributeModel})) - - // Construct an instance of the V2PolicyBaseResource model - v2PolicyBaseResourceModel := new(iampolicymanagementv1.V2PolicyBaseResource) - Expect(v2PolicyBaseResourceModel).ToNot(BeNil()) - v2PolicyBaseResourceModel.Attributes = []iampolicymanagementv1.V2PolicyAttribute{*v2PolicyAttributeModel} - Expect(v2PolicyBaseResourceModel.Attributes).To(Equal([]iampolicymanagementv1.V2PolicyAttribute{*v2PolicyAttributeModel})) - - // Construct an instance of the V2PolicyBaseRuleV2PolicyAttribute model - v2PolicyBaseRuleModel := new(iampolicymanagementv1.V2PolicyBaseRuleV2PolicyAttribute) - Expect(v2PolicyBaseRuleModel).ToNot(BeNil()) - v2PolicyBaseRuleModel.Key = core.StringPtr("testString") - v2PolicyBaseRuleModel.Operator = core.StringPtr("testString") - v2PolicyBaseRuleModel.Value = core.StringPtr("testString") - Expect(v2PolicyBaseRuleModel.Key).To(Equal(core.StringPtr("testString"))) - Expect(v2PolicyBaseRuleModel.Operator).To(Equal(core.StringPtr("testString"))) - Expect(v2PolicyBaseRuleModel.Value).To(Equal(core.StringPtr("testString"))) - - // Construct an instance of the V2UpdatePolicyOptions model + It(`Invoke NewUpdatePolicyStateOptions successfully`, func() { + // Construct an instance of the UpdatePolicyStateOptions model policyID := "testString" ifMatch := "testString" - v2UpdatePolicyOptionsType := "testString" - var v2UpdatePolicyOptionsControl *iampolicymanagementv1.V2PolicyBaseControl = nil - v2UpdatePolicyOptionsModel := iamPolicyManagementService.NewV2UpdatePolicyOptions(policyID, ifMatch, v2UpdatePolicyOptionsType, v2UpdatePolicyOptionsControl) - v2UpdatePolicyOptionsModel.SetPolicyID("testString") - v2UpdatePolicyOptionsModel.SetIfMatch("testString") - v2UpdatePolicyOptionsModel.SetType("testString") - v2UpdatePolicyOptionsModel.SetControl(v2PolicyBaseControlModel) - v2UpdatePolicyOptionsModel.SetDescription("testString") - v2UpdatePolicyOptionsModel.SetSubject(v2PolicyBaseSubjectModel) - v2UpdatePolicyOptionsModel.SetResource(v2PolicyBaseResourceModel) - v2UpdatePolicyOptionsModel.SetPattern("testString") - v2UpdatePolicyOptionsModel.SetRule(v2PolicyBaseRuleModel) - v2UpdatePolicyOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) - Expect(v2UpdatePolicyOptionsModel).ToNot(BeNil()) - Expect(v2UpdatePolicyOptionsModel.PolicyID).To(Equal(core.StringPtr("testString"))) - Expect(v2UpdatePolicyOptionsModel.IfMatch).To(Equal(core.StringPtr("testString"))) - Expect(v2UpdatePolicyOptionsModel.Type).To(Equal(core.StringPtr("testString"))) - Expect(v2UpdatePolicyOptionsModel.Control).To(Equal(v2PolicyBaseControlModel)) - Expect(v2UpdatePolicyOptionsModel.Description).To(Equal(core.StringPtr("testString"))) - Expect(v2UpdatePolicyOptionsModel.Subject).To(Equal(v2PolicyBaseSubjectModel)) - Expect(v2UpdatePolicyOptionsModel.Resource).To(Equal(v2PolicyBaseResourceModel)) - Expect(v2UpdatePolicyOptionsModel.Pattern).To(Equal(core.StringPtr("testString"))) - Expect(v2UpdatePolicyOptionsModel.Rule).To(Equal(v2PolicyBaseRuleModel)) - Expect(v2UpdatePolicyOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + updatePolicyStateOptionsModel := iamPolicyManagementService.NewUpdatePolicyStateOptions(policyID, ifMatch) + updatePolicyStateOptionsModel.SetPolicyID("testString") + updatePolicyStateOptionsModel.SetIfMatch("testString") + updatePolicyStateOptionsModel.SetState("active") + updatePolicyStateOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(updatePolicyStateOptionsModel).ToNot(BeNil()) + Expect(updatePolicyStateOptionsModel.PolicyID).To(Equal(core.StringPtr("testString"))) + Expect(updatePolicyStateOptionsModel.IfMatch).To(Equal(core.StringPtr("testString"))) + Expect(updatePolicyStateOptionsModel.State).To(Equal(core.StringPtr("active"))) + Expect(updatePolicyStateOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) + It(`Invoke NewV2PolicyGrant successfully`, func() { + roles := []iampolicymanagementv1.PolicyRole{} + _model, err := iamPolicyManagementService.NewV2PolicyGrant(roles) + Expect(_model).ToNot(BeNil()) + Expect(err).To(BeNil()) }) - It(`Invoke NewPolicyRole successfully`, func() { - roleID := "testString" - _model, err := iamPolicyManagementService.NewPolicyRole(roleID) + It(`Invoke NewV2PolicyResource successfully`, func() { + attributes := []iampolicymanagementv1.V2PolicyResourceAttribute{} + _model, err := iamPolicyManagementService.NewV2PolicyResource(attributes) + Expect(_model).ToNot(BeNil()) + Expect(err).To(BeNil()) + }) + It(`Invoke NewV2PolicyResourceAttribute successfully`, func() { + key := "testString" + operator := "stringEquals" + value := core.StringPtr("testString") + _model, err := iamPolicyManagementService.NewV2PolicyResourceAttribute(key, operator, value) + Expect(_model).ToNot(BeNil()) + Expect(err).To(BeNil()) + }) + It(`Invoke NewV2PolicyResourceTag successfully`, func() { + key := "testString" + value := "testString" + operator := "stringEquals" + _model, err := iamPolicyManagementService.NewV2PolicyResourceTag(key, value, operator) + Expect(_model).ToNot(BeNil()) + Expect(err).To(BeNil()) + }) + It(`Invoke NewV2PolicySubject successfully`, func() { + attributes := []iampolicymanagementv1.V2PolicySubjectAttribute{} + _model, err := iamPolicyManagementService.NewV2PolicySubject(attributes) + Expect(_model).ToNot(BeNil()) + Expect(err).To(BeNil()) + }) + It(`Invoke NewV2PolicySubjectAttribute successfully`, func() { + key := "testString" + operator := "stringEquals" + value := "testString" + _model, err := iamPolicyManagementService.NewV2PolicySubjectAttribute(key, operator, value) Expect(_model).ToNot(BeNil()) Expect(err).To(BeNil()) }) @@ -4926,6 +5146,13 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(_model).ToNot(BeNil()) Expect(err).To(BeNil()) }) + It(`Invoke NewRole successfully`, func() { + displayName := "testString" + actions := []string{"testString"} + _model, err := iamPolicyManagementService.NewRole(displayName, actions) + Expect(_model).ToNot(BeNil()) + Expect(err).To(BeNil()) + }) It(`Invoke NewSubjectAttribute successfully`, func() { name := "testString" value := "testString" @@ -4933,26 +5160,18 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(_model).ToNot(BeNil()) Expect(err).To(BeNil()) }) - It(`Invoke NewV2PolicyAttribute successfully`, func() { - key := "testString" - operator := "testString" - value := core.StringPtr("testString") - _model, err := iamPolicyManagementService.NewV2PolicyAttribute(key, operator, value) - Expect(_model).ToNot(BeNil()) - Expect(err).To(BeNil()) - }) - It(`Invoke NewV2PolicyBaseRuleV2PolicyAttribute successfully`, func() { + It(`Invoke NewV2PolicyRuleRuleAttribute successfully`, func() { key := "testString" - operator := "testString" + operator := "timeLessThan" value := core.StringPtr("testString") - _model, err := iamPolicyManagementService.NewV2PolicyBaseRuleV2PolicyAttribute(key, operator, value) + _model, err := iamPolicyManagementService.NewV2PolicyRuleRuleAttribute(key, operator, value) Expect(_model).ToNot(BeNil()) Expect(err).To(BeNil()) }) - It(`Invoke NewV2PolicyBaseRuleV2RuleWithConditions successfully`, func() { + It(`Invoke NewV2PolicyRuleRuleWithConditions successfully`, func() { operator := "and" - conditions := []iampolicymanagementv1.V2PolicyAttribute{} - _model, err := iamPolicyManagementService.NewV2PolicyBaseRuleV2RuleWithConditions(operator, conditions) + conditions := []iampolicymanagementv1.RuleAttribute{} + _model, err := iamPolicyManagementService.NewV2PolicyRuleRuleWithConditions(operator, conditions) Expect(_model).ToNot(BeNil()) Expect(err).To(BeNil()) })