From 542046f552aa1cbbdd744d5549f9357020840ff5 Mon Sep 17 00:00:00 2001 From: Rajesh <78408189+Rajesh-Pirati@users.noreply.github.com> Date: Mon, 28 Aug 2023 22:21:04 +0530 Subject: [PATCH] feat(IAM Policy Management): fix template metadata as part of policies (#274) Signed-off-by: Rajesh K Pirati --- .../iam_policy_management_v1.go | 439 ++++++++++++++---- .../iam_policy_management_v1_examples_test.go | 31 +- ...m_policy_management_v1_integration_test.go | 26 +- .../iam_policy_management_v1_test.go | 70 +-- 4 files changed, 452 insertions(+), 114 deletions(-) diff --git a/iampolicymanagementv1/iam_policy_management_v1.go b/iampolicymanagementv1/iam_policy_management_v1.go index eed7f91d..f86bcef0 100644 --- a/iampolicymanagementv1/iam_policy_management_v1.go +++ b/iampolicymanagementv1/iam_policy_management_v1.go @@ -15,7 +15,7 @@ */ /* - * IBM OpenAPI SDK Code Generator Version: 3.71.0-316eb5da-20230504-195406 + * IBM OpenAPI SDK Code Generator Version: 3.78.0-67aec9b7-20230818-174940 */ // Package iampolicymanagementv1 : Operations and models for the IamPolicyManagementV1 service @@ -497,12 +497,12 @@ func (iamPolicyManagement *IamPolicyManagementV1) ReplacePolicyWithContext(ctx c // GetPolicy : Retrieve a policy by ID // Retrieve a policy by providing a policy ID. -func (iamPolicyManagement *IamPolicyManagementV1) GetPolicy(getPolicyOptions *GetPolicyOptions) (result *Policy, response *core.DetailedResponse, err error) { +func (iamPolicyManagement *IamPolicyManagementV1) GetPolicy(getPolicyOptions *GetPolicyOptions) (result *PolicyTemplateMetaData, response *core.DetailedResponse, err error) { return iamPolicyManagement.GetPolicyWithContext(context.Background(), getPolicyOptions) } // GetPolicyWithContext is an alternate form of the GetPolicy method which supports a Context parameter -func (iamPolicyManagement *IamPolicyManagementV1) GetPolicyWithContext(ctx context.Context, getPolicyOptions *GetPolicyOptions) (result *Policy, response *core.DetailedResponse, err error) { +func (iamPolicyManagement *IamPolicyManagementV1) GetPolicyWithContext(ctx context.Context, getPolicyOptions *GetPolicyOptions) (result *PolicyTemplateMetaData, response *core.DetailedResponse, err error) { err = core.ValidateNotNil(getPolicyOptions, "getPolicyOptions cannot be nil") if err != nil { return @@ -545,7 +545,7 @@ func (iamPolicyManagement *IamPolicyManagementV1) GetPolicyWithContext(ctx conte return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalPolicy) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalPolicyTemplateMetaData) if err != nil { return } @@ -1413,12 +1413,12 @@ func (iamPolicyManagement *IamPolicyManagementV1) ReplaceV2PolicyWithContext(ctx // GetV2Policy : Retrieve a policy by ID // Retrieve a policy by providing a policy ID. -func (iamPolicyManagement *IamPolicyManagementV1) GetV2Policy(getV2PolicyOptions *GetV2PolicyOptions) (result *V2Policy, response *core.DetailedResponse, err error) { +func (iamPolicyManagement *IamPolicyManagementV1) GetV2Policy(getV2PolicyOptions *GetV2PolicyOptions) (result *V2PolicyTemplateMetaData, response *core.DetailedResponse, err error) { return iamPolicyManagement.GetV2PolicyWithContext(context.Background(), getV2PolicyOptions) } // 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) { +func (iamPolicyManagement *IamPolicyManagementV1) GetV2PolicyWithContext(ctx context.Context, getV2PolicyOptions *GetV2PolicyOptions) (result *V2PolicyTemplateMetaData, response *core.DetailedResponse, err error) { err = core.ValidateNotNil(getV2PolicyOptions, "getV2PolicyOptions cannot be nil") if err != nil { return @@ -1465,7 +1465,7 @@ func (iamPolicyManagement *IamPolicyManagementV1) GetV2PolicyWithContext(ctx con return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalV2Policy) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalV2PolicyTemplateMetaData) if err != nil { return } @@ -1826,6 +1826,9 @@ func (iamPolicyManagement *IamPolicyManagementV1) CreatePolicyTemplateVersionWit if createPolicyTemplateVersionOptions.Policy != nil { body["policy"] = createPolicyTemplateVersionOptions.Policy } + if createPolicyTemplateVersionOptions.Name != nil { + body["name"] = createPolicyTemplateVersionOptions.Name + } if createPolicyTemplateVersionOptions.Description != nil { body["description"] = createPolicyTemplateVersionOptions.Description } @@ -1966,6 +1969,9 @@ func (iamPolicyManagement *IamPolicyManagementV1) ReplacePolicyTemplateWithConte if replacePolicyTemplateOptions.Policy != nil { body["policy"] = replacePolicyTemplateOptions.Policy } + if replacePolicyTemplateOptions.Name != nil { + body["name"] = replacePolicyTemplateOptions.Name + } if replacePolicyTemplateOptions.Description != nil { body["description"] = replacePolicyTemplateOptions.Description } @@ -2149,9 +2155,6 @@ func (iamPolicyManagement *IamPolicyManagementV1) CommitPolicyTemplateWithContex for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } - if commitPolicyTemplateOptions.IfMatch != nil { - builder.AddHeader("If-Match", fmt.Sprint(*commitPolicyTemplateOptions.IfMatch)) - } request, err := builder.Build() if err != nil { @@ -2319,21 +2322,15 @@ type CommitPolicyTemplateOptions struct { // The policy template version. Version *string `json:"version" validate:"required,ne="` - // The revision number for updating a policy template version and must match the ETag value of the existing policy - // template version. The Etag can be retrieved using the GET - // /v1/policy_templates/{policy_template_id}/versions/{version} API and looking at the ETag response header. - IfMatch *string `json:"If-Match" validate:"required"` - // Allows users to set headers on API requests Headers map[string]string } // NewCommitPolicyTemplateOptions : Instantiate CommitPolicyTemplateOptions -func (*IamPolicyManagementV1) NewCommitPolicyTemplateOptions(policyTemplateID string, version string, ifMatch string) *CommitPolicyTemplateOptions { +func (*IamPolicyManagementV1) NewCommitPolicyTemplateOptions(policyTemplateID string, version string) *CommitPolicyTemplateOptions { return &CommitPolicyTemplateOptions{ PolicyTemplateID: core.StringPtr(policyTemplateID), Version: core.StringPtr(version), - IfMatch: core.StringPtr(ifMatch), } } @@ -2349,12 +2346,6 @@ func (_options *CommitPolicyTemplateOptions) SetVersion(version string) *CommitP return _options } -// SetIfMatch : Allow user to set IfMatch -func (_options *CommitPolicyTemplateOptions) SetIfMatch(ifMatch string) *CommitPolicyTemplateOptions { - _options.IfMatch = core.StringPtr(ifMatch) - return _options -} - // SetHeaders : Allow user to set Headers func (options *CommitPolicyTemplateOptions) SetHeaders(param map[string]string) *CommitPolicyTemplateOptions { options.Headers = param @@ -2628,6 +2619,10 @@ type CreatePolicyTemplateVersionOptions struct { // The core set of properties associated with the template's policy objet. Policy *TemplatePolicy `json:"policy" validate:"required"` + // Required field when creating a new template. Otherwise this field is optional. If the field is included it will + // change the name value for all existing versions of the template. + Name *string `json:"name,omitempty"` + // Description of the policy template. This is shown to users in the enterprise account. Use this to describe the // purpose or context of the policy for enterprise users managing IAM templates. Description *string `json:"description,omitempty"` @@ -2659,6 +2654,12 @@ func (_options *CreatePolicyTemplateVersionOptions) SetPolicy(policy *TemplatePo return _options } +// SetName : Allow user to set Name +func (_options *CreatePolicyTemplateVersionOptions) SetName(name string) *CreatePolicyTemplateVersionOptions { + _options.Name = core.StringPtr(name) + return _options +} + // SetDescription : Allow user to set Description func (_options *CreatePolicyTemplateVersionOptions) SetDescription(description string) *CreatePolicyTemplateVersionOptions { _options.Description = core.StringPtr(description) @@ -4157,9 +4158,6 @@ type Policy struct { // The policy state. State *string `json:"state,omitempty"` - - // Origin Template information. - Template *TemplateMetadata `json:"template,omitempty"` } // Constants associated with the Policy.State property. @@ -4220,10 +4218,6 @@ func UnmarshalPolicy(m map[string]json.RawMessage, result interface{}) (err erro if err != nil { return } - err = core.UnmarshalModel(m, "template", &obj.Template, UnmarshalTemplateMetadata) - if err != nil { - return - } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) return } @@ -4246,7 +4240,7 @@ type PolicyAssignment struct { Target *string `json:"target" validate:"required"` // List of objects with required properties for a policy assignment. - Options []PolicyAssignmentRequestOptionsItem `json:"options" validate:"required"` + Options []PolicyAssignmentOptions `json:"options" validate:"required"` // Policy assignment ID. ID *string `json:"id,omitempty"` @@ -4314,7 +4308,7 @@ func UnmarshalPolicyAssignment(m map[string]json.RawMessage, result interface{}) if err != nil { return } - err = core.UnmarshalModel(m, "options", &obj.Options, UnmarshalPolicyAssignmentRequestOptionsItem) + err = core.UnmarshalModel(m, "options", &obj.Options, UnmarshalPolicyAssignmentOptions) if err != nil { return } @@ -4358,8 +4352,8 @@ func UnmarshalPolicyAssignment(m map[string]json.RawMessage, result interface{}) return } -// PolicyAssignmentRequestOptionsItem : The set of properties required for a policy assignment. -type PolicyAssignmentRequestOptionsItem struct { +// PolicyAssignmentOptions : The set of properties required for a policy assignment. +type PolicyAssignmentOptions struct { // The policy subject type; either 'iam_id' or 'access_group_id'. SubjectType *string `json:"subject_type" validate:"required"` @@ -4376,16 +4370,16 @@ type PolicyAssignmentRequestOptionsItem struct { RootTemplateVersion *string `json:"root_template_version,omitempty"` } -// Constants associated with the PolicyAssignmentRequestOptionsItem.SubjectType property. +// Constants associated with the PolicyAssignmentOptions.SubjectType property. // The policy subject type; either 'iam_id' or 'access_group_id'. const ( - PolicyAssignmentRequestOptionsItemSubjectTypeAccessGroupIDConst = "access_group_id" - PolicyAssignmentRequestOptionsItemSubjectTypeIamIDConst = "iam_id" + PolicyAssignmentOptionsSubjectTypeAccessGroupIDConst = "access_group_id" + PolicyAssignmentOptionsSubjectTypeIamIDConst = "iam_id" ) -// UnmarshalPolicyAssignmentRequestOptionsItem unmarshals an instance of PolicyAssignmentRequestOptionsItem from the specified map of raw messages. -func UnmarshalPolicyAssignmentRequestOptionsItem(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(PolicyAssignmentRequestOptionsItem) +// UnmarshalPolicyAssignmentOptions unmarshals an instance of PolicyAssignmentOptions from the specified map of raw messages. +func UnmarshalPolicyAssignmentOptions(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(PolicyAssignmentOptions) err = core.UnmarshalPrimitive(m, "subject_type", &obj.SubjectType) if err != nil { return @@ -4410,23 +4404,30 @@ func UnmarshalPolicyAssignmentRequestOptionsItem(m map[string]json.RawMessage, r return } -// PolicyAssignmentResources : The policy assignment resources. -type PolicyAssignmentResources struct { - // Account ID where resources are assigned. - Target *string `json:"target,omitempty"` +// PolicyAssignmentResourcePolicy : Set of properties for the assigned resource. +type PolicyAssignmentResourcePolicy struct { + // On success, includes the policy assigned. + ResourceCreated *AssignmentResourceCreated `json:"resource_created,omitempty"` - // Set of properties for the assigned resource. - Policy *PolicyAssignmentResourcesPolicy `json:"policy,omitempty"` + // policy status. + Status *string `json:"status,omitempty"` + + // The error response from API. + ErrorMessage *ErrorResponse `json:"error_message,omitempty"` } -// UnmarshalPolicyAssignmentResources unmarshals an instance of PolicyAssignmentResources from the specified map of raw messages. -func UnmarshalPolicyAssignmentResources(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(PolicyAssignmentResources) - err = core.UnmarshalPrimitive(m, "target", &obj.Target) +// UnmarshalPolicyAssignmentResourcePolicy unmarshals an instance of PolicyAssignmentResourcePolicy from the specified map of raw messages. +func UnmarshalPolicyAssignmentResourcePolicy(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(PolicyAssignmentResourcePolicy) + err = core.UnmarshalModel(m, "resource_created", &obj.ResourceCreated, UnmarshalAssignmentResourceCreated) if err != nil { return } - err = core.UnmarshalModel(m, "policy", &obj.Policy, UnmarshalPolicyAssignmentResourcesPolicy) + err = core.UnmarshalPrimitive(m, "status", &obj.Status) + if err != nil { + return + } + err = core.UnmarshalModel(m, "error_message", &obj.ErrorMessage, UnmarshalErrorResponse) if err != nil { return } @@ -4434,23 +4435,23 @@ func UnmarshalPolicyAssignmentResources(m map[string]json.RawMessage, result int return } -// PolicyAssignmentResourcesPolicy : Set of properties for the assigned resource. -type PolicyAssignmentResourcesPolicy struct { - // On success, includes the policy assigned. - ResourceCreated *AssignmentResourceCreated `json:"resource_created" validate:"required"` +// PolicyAssignmentResources : The policy assignment resources. +type PolicyAssignmentResources struct { + // Account ID where resources are assigned. + Target *string `json:"target,omitempty"` - // The error response from API. - ErrorMessage *ErrorResponse `json:"error_message,omitempty"` + // Set of properties for the assigned resource. + Policy *PolicyAssignmentResourcePolicy `json:"policy,omitempty"` } -// UnmarshalPolicyAssignmentResourcesPolicy unmarshals an instance of PolicyAssignmentResourcesPolicy from the specified map of raw messages. -func UnmarshalPolicyAssignmentResourcesPolicy(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(PolicyAssignmentResourcesPolicy) - err = core.UnmarshalModel(m, "resource_created", &obj.ResourceCreated, UnmarshalAssignmentResourceCreated) +// UnmarshalPolicyAssignmentResources unmarshals an instance of PolicyAssignmentResources from the specified map of raw messages. +func UnmarshalPolicyAssignmentResources(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(PolicyAssignmentResources) + err = core.UnmarshalPrimitive(m, "target", &obj.Target) if err != nil { return } - err = core.UnmarshalModel(m, "error_message", &obj.ErrorMessage, UnmarshalErrorResponse) + err = core.UnmarshalModel(m, "policy", &obj.Policy, UnmarshalPolicyAssignmentResourcePolicy) if err != nil { return } @@ -4461,13 +4462,13 @@ func UnmarshalPolicyAssignmentResourcesPolicy(m map[string]json.RawMessage, resu // PolicyCollection : A collection of policies. type PolicyCollection struct { // List of policies. - Policies []Policy `json:"policies,omitempty"` + Policies []PolicyTemplateMetaData `json:"policies,omitempty"` } // UnmarshalPolicyCollection unmarshals an instance of PolicyCollection from the specified map of raw messages. func UnmarshalPolicyCollection(m map[string]json.RawMessage, result interface{}) (err error) { obj := new(PolicyCollection) - err = core.UnmarshalModel(m, "policies", &obj.Policies, UnmarshalPolicy) + err = core.UnmarshalModel(m, "policies", &obj.Policies, UnmarshalPolicyTemplateMetaData) if err != nil { return } @@ -4686,6 +4687,115 @@ func UnmarshalPolicyTemplateCollection(m map[string]json.RawMessage, result inte return } +// PolicyTemplateMetaData : The core set of properties associated with a policy. +type PolicyTemplateMetaData 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 subjects associated with a policy. + Subjects []PolicySubject `json:"subjects" validate:"required"` + + // A set of role cloud resource names (CRNs) granted by the policy. + Roles []PolicyRole `json:"roles" validate:"required"` + + // The resources associated with a policy. + Resources []PolicyResource `json:"resources" validate:"required"` + + // 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"` + + // The details of the IAM template that was used to create an enterprise-managed policy in your account. When returned, + // this indicates that the policy is created from and managed by a template in the root enterprise account. + Template *TemplateMetadata `json:"template,omitempty"` +} + +// Constants associated with the PolicyTemplateMetaData.State property. +// The policy state. +const ( + PolicyTemplateMetaDataStateActiveConst = "active" + PolicyTemplateMetaDataStateDeletedConst = "deleted" +) + +// UnmarshalPolicyTemplateMetaData unmarshals an instance of PolicyTemplateMetaData from the specified map of raw messages. +func UnmarshalPolicyTemplateMetaData(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(PolicyTemplateMetaData) + 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, "subjects", &obj.Subjects, UnmarshalPolicySubject) + if err != nil { + return + } + err = core.UnmarshalModel(m, "roles", &obj.Roles, UnmarshalPolicyRole) + if err != nil { + return + } + err = core.UnmarshalModel(m, "resources", &obj.Resources, UnmarshalPolicyResource) + 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) + if err != nil { + return + } + err = core.UnmarshalModel(m, "template", &obj.Template, UnmarshalTemplateMetadata) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + // PolicyTemplateVersionsCollection : A collection of versions for a specific policy template. type PolicyTemplateVersionsCollection struct { // List of policy templates versions. @@ -4807,6 +4917,10 @@ type ReplacePolicyTemplateOptions struct { // The core set of properties associated with the template's policy objet. Policy *TemplatePolicy `json:"policy" validate:"required"` + // Required field when creating a new template. Otherwise this field is optional. If the field is included it will + // change the name value for all existing versions of the template. + Name *string `json:"name,omitempty"` + // Description of the policy template. This is shown to users in the enterprise account. Use this to describe the // purpose or context of the policy for enterprise users managing IAM templates. Description *string `json:"description,omitempty"` @@ -4852,6 +4966,12 @@ func (_options *ReplacePolicyTemplateOptions) SetPolicy(policy *TemplatePolicy) return _options } +// SetName : Allow user to set Name +func (_options *ReplacePolicyTemplateOptions) SetName(name string) *ReplacePolicyTemplateOptions { + _options.Name = core.StringPtr(name) + return _options +} + // SetDescription : Allow user to set Description func (_options *ReplacePolicyTemplateOptions) SetDescription(description string) *ReplacePolicyTemplateOptions { _options.Description = core.StringPtr(description) @@ -5363,19 +5483,29 @@ func UnmarshalSubjectAttribute(m map[string]json.RawMessage, result interface{}) return } -// TemplateMetadata : Origin Template information. +// TemplateMetadata : The details of the IAM template that was used to create an enterprise-managed policy in your account. When returned, +// this indicates that the policy is created from and managed by a template in the root enterprise account. type TemplateMetadata struct { - // Origin Template CRN. - CRN *string `json:"crn,omitempty"` + // The policy template ID. + ID *string `json:"id,omitempty"` // Template version. Version *string `json:"version,omitempty"` + + // policy assignment id. + AssignmentID *string `json:"assignment_id,omitempty"` + + // orchestrator template id. + RootID *string `json:"root_id,omitempty"` + + // orchestrator template version. + RootVersion *string `json:"root_version,omitempty"` } // UnmarshalTemplateMetadata unmarshals an instance of TemplateMetadata from the specified map of raw messages. func UnmarshalTemplateMetadata(m map[string]json.RawMessage, result interface{}) (err error) { obj := new(TemplateMetadata) - err = core.UnmarshalPrimitive(m, "crn", &obj.CRN) + err = core.UnmarshalPrimitive(m, "id", &obj.ID) if err != nil { return } @@ -5383,6 +5513,18 @@ func UnmarshalTemplateMetadata(m map[string]json.RawMessage, result interface{}) if err != nil { return } + err = core.UnmarshalPrimitive(m, "assignment_id", &obj.AssignmentID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "root_id", &obj.RootID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "root_version", &obj.RootVersion) + if err != nil { + return + } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) return } @@ -5397,7 +5539,7 @@ type TemplatePolicy struct { Description *string `json:"description,omitempty"` // The resource attributes to which the policy grants access. - Resource *V2PolicyResource `json:"resource" validate:"required"` + 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'. @@ -5418,10 +5560,9 @@ const ( ) // NewTemplatePolicy : Instantiate TemplatePolicy (Generic Model Constructor) -func (*IamPolicyManagementV1) NewTemplatePolicy(typeVar string, resource *V2PolicyResource, control *Control) (_model *TemplatePolicy, err error) { +func (*IamPolicyManagementV1) NewTemplatePolicy(typeVar string, control *Control) (_model *TemplatePolicy, err error) { _model = &TemplatePolicy{ Type: core.StringPtr(typeVar), - Resource: resource, Control: control, } err = core.ValidateStruct(_model, "required parameters") @@ -5564,9 +5705,6 @@ type V2Policy struct { // 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"` - - // Origin Template information. - Template *TemplateMetadata `json:"template,omitempty"` } // Constants associated with the V2Policy.Type property. @@ -5650,10 +5788,6 @@ func UnmarshalV2Policy(m map[string]json.RawMessage, result interface{}) (err er if err != nil { return } - err = core.UnmarshalModel(m, "template", &obj.Template, UnmarshalTemplateMetadata) - if err != nil { - return - } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) return } @@ -5661,13 +5795,13 @@ func UnmarshalV2Policy(m map[string]json.RawMessage, result interface{}) (err er // V2PolicyCollection : A collection of policies. type V2PolicyCollection struct { // List of policies. - Policies []V2Policy `json:"policies,omitempty"` + Policies []V2PolicyTemplateMetaData `json:"policies,omitempty"` } // 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) + err = core.UnmarshalModel(m, "policies", &obj.Policies, UnmarshalV2PolicyTemplateMetaData) if err != nil { return } @@ -5947,6 +6081,151 @@ func UnmarshalV2PolicySubjectAttribute(m map[string]json.RawMessage, result inte return } +// V2PolicyTemplateMetaData : The core set of properties associated with the policy. +type V2PolicyTemplateMetaData struct { + // The policy type; either 'access' or 'authorization'. + Type *string `json:"type" validate:"required"` + + // Description of the 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"` + + // The policy ID. + ID *string `json:"id,omitempty"` + + // The href URL that links to the policies API by policy ID. + Href *string `json:"href,omitempty"` + + Control ControlResponseIntf `json:"control" validate:"required"` + + // 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, 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"` + + // The details of the IAM template that was used to create an enterprise-managed policy in your account. When returned, + // this indicates that the policy is created from and managed by a template in the root enterprise account. + Template *TemplateMetadata `json:"template,omitempty"` +} + +// Constants associated with the V2PolicyTemplateMetaData.Type property. +// The policy type; either 'access' or 'authorization'. +const ( + V2PolicyTemplateMetaDataTypeAccessConst = "access" + V2PolicyTemplateMetaDataTypeAuthorizationConst = "authorization" +) + +// Constants associated with the V2PolicyTemplateMetaData.State property. +// The policy state, either 'deleted' or 'active'. +const ( + V2PolicyTemplateMetaDataStateActiveConst = "active" + V2PolicyTemplateMetaDataStateDeletedConst = "deleted" +) + +// UnmarshalV2PolicyTemplateMetaData unmarshals an instance of V2PolicyTemplateMetaData from the specified map of raw messages. +func UnmarshalV2PolicyTemplateMetaData(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(V2PolicyTemplateMetaData) + 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 + } + err = core.UnmarshalModel(m, "template", &obj.Template, UnmarshalTemplateMetadata) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + // ControlResponseControl : Specifies the type of access granted by the policy. // This model "extends" ControlResponse type ControlResponseControl struct { diff --git a/iampolicymanagementv1/iam_policy_management_v1_examples_test.go b/iampolicymanagementv1/iam_policy_management_v1_examples_test.go index 634a3084..3608c515 100644 --- a/iampolicymanagementv1/iam_policy_management_v1_examples_test.go +++ b/iampolicymanagementv1/iam_policy_management_v1_examples_test.go @@ -68,6 +68,7 @@ var _ = Describe(`IamPolicyManagementV1 Examples Tests`, func() { examplePolicyTemplateETag string examplePolicyTemplateVersion string testPolicyAssignmentId string + assignmentPolicyID string ) var shouldSkipTest = func() { @@ -941,7 +942,6 @@ var _ = Describe(`IamPolicyManagementV1 Examples Tests`, func() { commitPolicyTemplateOptions := iamPolicyManagementService.NewCommitPolicyTemplateOptions( examplePolicyTemplateID, examplePolicyTemplateVersion, - examplePolicyTemplateETag, ) response, err := iamPolicyManagementService.CommitPolicyTemplate(commitPolicyTemplateOptions) @@ -1031,6 +1031,35 @@ var _ = Describe(`IamPolicyManagementV1 Examples Tests`, func() { Expect(policyAssignmentRecord.LastModifiedAt).ToNot(BeNil()) Expect(policyAssignmentRecord.LastModifiedByID).ToNot(BeNil()) Expect(policyAssignmentRecord.Href).ToNot(BeNil()) + assignmentPolicyID = *policyAssignmentRecord.Resources[0].Policy.ResourceCreated.ID + }) + + It(`GetV2Policy to get Template meta data request example`, func() { + fmt.Println("\nGetV2Policy() result:") + // begin-get_v2_policy template metadata + + options := iamPolicyManagementService.NewGetV2PolicyOptions( + assignmentPolicyID, + ) + + policy, response, err := iamPolicyManagementService.GetV2Policy(options) + if err != nil { + panic(err) + } + b, _ := json.MarshalIndent(policy, "", " ") + fmt.Println(string(b)) + + // end-get_v2_policy + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(policy).ToNot(BeNil()) + Expect(policy.Template).ToNot(BeNil()) + Expect(policy.Template.ID).ToNot(BeNil()) + Expect(policy.Template.Version).ToNot(BeNil()) + Expect(policy.Template.AssignmentID).ToNot(BeNil()) + Expect(policy.Template.RootID).ToNot(BeNil()) + Expect(policy.Template.RootVersion).ToNot(BeNil()) }) It(`DeletePolicyTemplateVersion request example`, func() { diff --git a/iampolicymanagementv1/iam_policy_management_v1_integration_test.go b/iampolicymanagementv1/iam_policy_management_v1_integration_test.go index 3b80e7ff..a0d98ac6 100644 --- a/iampolicymanagementv1/iam_policy_management_v1_integration_test.go +++ b/iampolicymanagementv1/iam_policy_management_v1_integration_test.go @@ -66,6 +66,7 @@ var _ = Describe("IAM Policy Management - Integration Tests", func() { testPolicyTemplateVersion string = "" testPolicyAssignmentId string = "" examplePolicyTemplateName = "PolicySampleTemplateTestV1" + assignmentPolicyID string ) var shouldSkipTest = func() { @@ -900,7 +901,6 @@ var _ = Describe("IAM Policy Management - Integration Tests", func() { commitPolicyTemplateOptions := &iampolicymanagementv1.CommitPolicyTemplateOptions{ PolicyTemplateID: &testPolicyTemplateID, Version: &testPolicyTemplateVersion, - IfMatch: &testPolicyTemplateETag, } response, err := service.CommitPolicyTemplate(commitPolicyTemplateOptions) @@ -970,6 +970,30 @@ var _ = Describe("IAM Policy Management - Integration Tests", func() { Expect(policyAssignmentRecord.LastModifiedAt).ToNot(BeNil()) Expect(policyAssignmentRecord.LastModifiedByID).ToNot(BeNil()) Expect(policyAssignmentRecord.Href).ToNot(BeNil()) + + assignmentPolicyID = *policyAssignmentRecord.Resources[0].Policy.ResourceCreated.ID + }) + }) + + Describe("GetPolicyV2 - Retrieve Policy Template MetaData created from assignment", func() { + + It("Successfully retrieved a v2 access policy", func() { + shouldSkipTest() + Expect(testPolicyId).To(Not(BeNil())) + + options := service.NewGetV2PolicyOptions(assignmentPolicyID) + policy, detailedResponse, err := service.GetV2Policy(options) + Expect(err).To(BeNil()) + Expect(detailedResponse.StatusCode).To(Equal(200)) + Expect(policy).ToNot(BeNil()) + fmt.Fprintf(GinkgoWriter, "GetV2Policy() result:\n%s\n", common.ToJSON(policy)) + Expect(*policy.ID).To(Equal(assignmentPolicyID)) + Expect(policy.Template).ToNot(BeNil()) + Expect(policy.Template.ID).ToNot(BeNil()) + Expect(policy.Template.Version).ToNot(BeNil()) + Expect(policy.Template.AssignmentID).ToNot(BeNil()) + Expect(policy.Template.RootID).ToNot(BeNil()) + Expect(policy.Template.RootVersion).ToNot(BeNil()) }) }) diff --git a/iampolicymanagementv1/iam_policy_management_v1_test.go b/iampolicymanagementv1/iam_policy_management_v1_test.go index 4454ff35..e1f394bb 100644 --- a/iampolicymanagementv1/iam_policy_management_v1_test.go +++ b/iampolicymanagementv1/iam_policy_management_v1_test.go @@ -259,7 +259,7 @@ 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", "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", "template": {"crn": "CRN", "version": "Version"}}]}`) + fmt.Fprintf(res, "%s", `{"policies": [{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active", "template": {"id": "ID", "version": "Version", "assignment_id": "AssignmentID", "root_id": "RootID", "root_version": "RootVersion"}}]}`) })) }) It(`Invoke ListPolicies successfully with retries`, func() { @@ -335,7 +335,7 @@ 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", "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", "template": {"crn": "CRN", "version": "Version"}}]}`) + fmt.Fprintf(res, "%s", `{"policies": [{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active", "template": {"id": "ID", "version": "Version", "assignment_id": "AssignmentID", "root_id": "RootID", "root_version": "RootVersion"}}]}`) })) }) It(`Invoke ListPolicies successfully`, func() { @@ -578,7 +578,7 @@ 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", "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", "template": {"crn": "CRN", "version": "Version"}}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active"}`) })) }) It(`Invoke CreatePolicy successfully with retries`, func() { @@ -685,7 +685,7 @@ 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", "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", "template": {"crn": "CRN", "version": "Version"}}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active"}`) })) }) It(`Invoke CreatePolicy successfully`, func() { @@ -1004,7 +1004,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active", "template": {"crn": "CRN", "version": "Version"}}`) + 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 ReplacePolicy successfully with retries`, func() { @@ -1112,7 +1112,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active", "template": {"crn": "CRN", "version": "Version"}}`) + 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 ReplacePolicy successfully`, func() { @@ -1378,7 +1378,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active", "template": {"crn": "CRN", "version": "Version"}}`) + 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", "template": {"id": "ID", "version": "Version", "assignment_id": "AssignmentID", "root_id": "RootID", "root_version": "RootVersion"}}`) })) }) It(`Invoke GetPolicy successfully with retries`, func() { @@ -1432,7 +1432,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active", "template": {"crn": "CRN", "version": "Version"}}`) + 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", "template": {"id": "ID", "version": "Version", "assignment_id": "AssignmentID", "root_id": "RootID", "root_version": "RootVersion"}}`) })) }) It(`Invoke GetPolicy successfully`, func() { @@ -1680,7 +1680,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active", "template": {"crn": "CRN", "version": "Version"}}`) + 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 UpdatePolicyState successfully with retries`, func() { @@ -1754,7 +1754,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active", "template": {"crn": "CRN", "version": "Version"}}`) + 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 UpdatePolicyState successfully`, func() { @@ -3033,7 +3033,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - 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"}]}}, "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, "template": {"crn": "CRN", "version": "Version"}}]}`) + 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"}]}}, "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, "template": {"id": "ID", "version": "Version", "assignment_id": "AssignmentID", "root_id": "RootID", "root_version": "RootVersion"}}]}`) })) }) It(`Invoke ListV2Policies successfully with retries`, func() { @@ -3109,7 +3109,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - 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"}]}}, "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, "template": {"crn": "CRN", "version": "Version"}}]}`) + 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"}]}}, "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, "template": {"id": "ID", "version": "Version", "assignment_id": "AssignmentID", "root_id": "RootID", "root_version": "RootVersion"}}]}`) })) }) It(`Invoke ListV2Policies successfully`, func() { @@ -3369,7 +3369,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - 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"}]}}, "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, "template": {"crn": "CRN", "version": "Version"}}`) + 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"}]}}, "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 CreateV2Policy successfully with retries`, func() { @@ -3493,7 +3493,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - 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"}]}}, "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, "template": {"crn": "CRN", "version": "Version"}}`) + 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"}]}}, "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 CreateV2Policy successfully`, func() { @@ -3880,7 +3880,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - 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"}]}}, "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, "template": {"crn": "CRN", "version": "Version"}}`) + 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"}]}}, "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 ReplaceV2Policy successfully with retries`, func() { @@ -4005,7 +4005,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - 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"}]}}, "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, "template": {"crn": "CRN", "version": "Version"}}`) + 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"}]}}, "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 ReplaceV2Policy successfully`, func() { @@ -4325,7 +4325,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - 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"}]}}, "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, "template": {"crn": "CRN", "version": "Version"}}`) + 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"}]}}, "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, "template": {"id": "ID", "version": "Version", "assignment_id": "AssignmentID", "root_id": "RootID", "root_version": "RootVersion"}}`) })) }) It(`Invoke GetV2Policy successfully with retries`, func() { @@ -4381,7 +4381,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - 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"}]}}, "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, "template": {"crn": "CRN", "version": "Version"}}`) + 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"}]}}, "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, "template": {"id": "ID", "version": "Version", "assignment_id": "AssignmentID", "root_id": "RootID", "root_version": "RootVersion"}}`) })) }) It(`Invoke GetV2Policy successfully`, func() { @@ -5620,6 +5620,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { createPolicyTemplateVersionOptionsModel := new(iampolicymanagementv1.CreatePolicyTemplateVersionOptions) createPolicyTemplateVersionOptionsModel.PolicyTemplateID = core.StringPtr("testString") createPolicyTemplateVersionOptionsModel.Policy = templatePolicyModel + createPolicyTemplateVersionOptionsModel.Name = core.StringPtr("testString") createPolicyTemplateVersionOptionsModel.Description = core.StringPtr("testString") createPolicyTemplateVersionOptionsModel.Committed = core.BoolPtr(true) createPolicyTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} @@ -5734,6 +5735,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { createPolicyTemplateVersionOptionsModel := new(iampolicymanagementv1.CreatePolicyTemplateVersionOptions) createPolicyTemplateVersionOptionsModel.PolicyTemplateID = core.StringPtr("testString") createPolicyTemplateVersionOptionsModel.Policy = templatePolicyModel + createPolicyTemplateVersionOptionsModel.Name = core.StringPtr("testString") createPolicyTemplateVersionOptionsModel.Description = core.StringPtr("testString") createPolicyTemplateVersionOptionsModel.Committed = core.BoolPtr(true) createPolicyTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} @@ -5856,6 +5858,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { createPolicyTemplateVersionOptionsModel := new(iampolicymanagementv1.CreatePolicyTemplateVersionOptions) createPolicyTemplateVersionOptionsModel.PolicyTemplateID = core.StringPtr("testString") createPolicyTemplateVersionOptionsModel.Policy = templatePolicyModel + createPolicyTemplateVersionOptionsModel.Name = core.StringPtr("testString") createPolicyTemplateVersionOptionsModel.Description = core.StringPtr("testString") createPolicyTemplateVersionOptionsModel.Committed = core.BoolPtr(true) createPolicyTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} @@ -5923,6 +5926,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { createPolicyTemplateVersionOptionsModel := new(iampolicymanagementv1.CreatePolicyTemplateVersionOptions) createPolicyTemplateVersionOptionsModel.PolicyTemplateID = core.StringPtr("testString") createPolicyTemplateVersionOptionsModel.Policy = templatePolicyModel + createPolicyTemplateVersionOptionsModel.Name = core.StringPtr("testString") createPolicyTemplateVersionOptionsModel.Description = core.StringPtr("testString") createPolicyTemplateVersionOptionsModel.Committed = core.BoolPtr(true) createPolicyTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} @@ -6011,6 +6015,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { createPolicyTemplateVersionOptionsModel := new(iampolicymanagementv1.CreatePolicyTemplateVersionOptions) createPolicyTemplateVersionOptionsModel.PolicyTemplateID = core.StringPtr("testString") createPolicyTemplateVersionOptionsModel.Policy = templatePolicyModel + createPolicyTemplateVersionOptionsModel.Name = core.StringPtr("testString") createPolicyTemplateVersionOptionsModel.Description = core.StringPtr("testString") createPolicyTemplateVersionOptionsModel.Committed = core.BoolPtr(true) createPolicyTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} @@ -6315,6 +6320,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { replacePolicyTemplateOptionsModel.Version = core.StringPtr("testString") replacePolicyTemplateOptionsModel.IfMatch = core.StringPtr("testString") replacePolicyTemplateOptionsModel.Policy = templatePolicyModel + replacePolicyTemplateOptionsModel.Name = core.StringPtr("testString") replacePolicyTemplateOptionsModel.Description = core.StringPtr("testString") replacePolicyTemplateOptionsModel.Committed = core.BoolPtr(true) replacePolicyTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} @@ -6433,6 +6439,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { replacePolicyTemplateOptionsModel.Version = core.StringPtr("testString") replacePolicyTemplateOptionsModel.IfMatch = core.StringPtr("testString") replacePolicyTemplateOptionsModel.Policy = templatePolicyModel + replacePolicyTemplateOptionsModel.Name = core.StringPtr("testString") replacePolicyTemplateOptionsModel.Description = core.StringPtr("testString") replacePolicyTemplateOptionsModel.Committed = core.BoolPtr(true) replacePolicyTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} @@ -6559,6 +6566,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { replacePolicyTemplateOptionsModel.Version = core.StringPtr("testString") replacePolicyTemplateOptionsModel.IfMatch = core.StringPtr("testString") replacePolicyTemplateOptionsModel.Policy = templatePolicyModel + replacePolicyTemplateOptionsModel.Name = core.StringPtr("testString") replacePolicyTemplateOptionsModel.Description = core.StringPtr("testString") replacePolicyTemplateOptionsModel.Committed = core.BoolPtr(true) replacePolicyTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} @@ -6628,6 +6636,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { replacePolicyTemplateOptionsModel.Version = core.StringPtr("testString") replacePolicyTemplateOptionsModel.IfMatch = core.StringPtr("testString") replacePolicyTemplateOptionsModel.Policy = templatePolicyModel + replacePolicyTemplateOptionsModel.Name = core.StringPtr("testString") replacePolicyTemplateOptionsModel.Description = core.StringPtr("testString") replacePolicyTemplateOptionsModel.Committed = core.BoolPtr(true) replacePolicyTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} @@ -6718,6 +6727,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { replacePolicyTemplateOptionsModel.Version = core.StringPtr("testString") replacePolicyTemplateOptionsModel.IfMatch = core.StringPtr("testString") replacePolicyTemplateOptionsModel.Policy = templatePolicyModel + replacePolicyTemplateOptionsModel.Name = core.StringPtr("testString") replacePolicyTemplateOptionsModel.Description = core.StringPtr("testString") replacePolicyTemplateOptionsModel.Committed = core.BoolPtr(true) replacePolicyTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} @@ -7033,8 +7043,6 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(req.URL.EscapedPath()).To(Equal(commitPolicyTemplatePath)) Expect(req.Method).To(Equal("POST")) - Expect(req.Header["If-Match"]).ToNot(BeNil()) - Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) res.WriteHeader(204) })) }) @@ -7055,7 +7063,6 @@ var _ = Describe(`IamPolicyManagementV1`, func() { commitPolicyTemplateOptionsModel := new(iampolicymanagementv1.CommitPolicyTemplateOptions) commitPolicyTemplateOptionsModel.PolicyTemplateID = core.StringPtr("testString") commitPolicyTemplateOptionsModel.Version = core.StringPtr("testString") - commitPolicyTemplateOptionsModel.IfMatch = core.StringPtr("testString") commitPolicyTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) @@ -7075,7 +7082,6 @@ var _ = Describe(`IamPolicyManagementV1`, func() { commitPolicyTemplateOptionsModel := new(iampolicymanagementv1.CommitPolicyTemplateOptions) commitPolicyTemplateOptionsModel.PolicyTemplateID = core.StringPtr("testString") commitPolicyTemplateOptionsModel.Version = core.StringPtr("testString") - commitPolicyTemplateOptionsModel.IfMatch = core.StringPtr("testString") commitPolicyTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := iamPolicyManagementService.SetServiceURL("") @@ -7171,7 +7177,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"assignments": [{"template_id": "TemplateID", "template_version": "TemplateVersion", "assignment_id": "AssignmentID", "target_type": "Account", "target": "Target", "options": [{"subject_type": "iam_id", "subject_id": "SubjectID", "root_requester_id": "RootRequesterID", "root_template_id": "RootTemplateID", "root_template_version": "RootTemplateVersion"}], "id": "ID", "account_id": "AccountID", "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", "resources": [{"target": "Target", "policy": {"resource_created": {"id": "ID"}, "error_message": {"trace": "Trace", "errors": [{"code": "insufficent_permissions", "message": "Message", "details": {"conflicts_with": {"etag": "Etag", "role": "Role", "policy": "Policy"}}, "more_info": "MoreInfo"}], "status_code": 10}}}], "status": "in_progress"}]}`) + fmt.Fprintf(res, "%s", `{"assignments": [{"template_id": "TemplateID", "template_version": "TemplateVersion", "assignment_id": "AssignmentID", "target_type": "Account", "target": "Target", "options": [{"subject_type": "iam_id", "subject_id": "SubjectID", "root_requester_id": "RootRequesterID", "root_template_id": "RootTemplateID", "root_template_version": "RootTemplateVersion"}], "id": "ID", "account_id": "AccountID", "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", "resources": [{"target": "Target", "policy": {"resource_created": {"id": "ID"}, "status": "Status", "error_message": {"trace": "Trace", "errors": [{"code": "insufficent_permissions", "message": "Message", "details": {"conflicts_with": {"etag": "Etag", "role": "Role", "policy": "Policy"}}, "more_info": "MoreInfo"}], "status_code": 10}}}], "status": "in_progress"}]}`) })) }) It(`Invoke ListPolicyAssignments successfully with retries`, func() { @@ -7233,7 +7239,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"assignments": [{"template_id": "TemplateID", "template_version": "TemplateVersion", "assignment_id": "AssignmentID", "target_type": "Account", "target": "Target", "options": [{"subject_type": "iam_id", "subject_id": "SubjectID", "root_requester_id": "RootRequesterID", "root_template_id": "RootTemplateID", "root_template_version": "RootTemplateVersion"}], "id": "ID", "account_id": "AccountID", "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", "resources": [{"target": "Target", "policy": {"resource_created": {"id": "ID"}, "error_message": {"trace": "Trace", "errors": [{"code": "insufficent_permissions", "message": "Message", "details": {"conflicts_with": {"etag": "Etag", "role": "Role", "policy": "Policy"}}, "more_info": "MoreInfo"}], "status_code": 10}}}], "status": "in_progress"}]}`) + fmt.Fprintf(res, "%s", `{"assignments": [{"template_id": "TemplateID", "template_version": "TemplateVersion", "assignment_id": "AssignmentID", "target_type": "Account", "target": "Target", "options": [{"subject_type": "iam_id", "subject_id": "SubjectID", "root_requester_id": "RootRequesterID", "root_template_id": "RootTemplateID", "root_template_version": "RootTemplateVersion"}], "id": "ID", "account_id": "AccountID", "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", "resources": [{"target": "Target", "policy": {"resource_created": {"id": "ID"}, "status": "Status", "error_message": {"trace": "Trace", "errors": [{"code": "insufficent_permissions", "message": "Message", "details": {"conflicts_with": {"etag": "Etag", "role": "Role", "policy": "Policy"}}, "more_info": "MoreInfo"}], "status_code": 10}}}], "status": "in_progress"}]}`) })) }) It(`Invoke ListPolicyAssignments successfully`, func() { @@ -7400,7 +7406,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"template_id": "TemplateID", "template_version": "TemplateVersion", "assignment_id": "AssignmentID", "target_type": "Account", "target": "Target", "options": [{"subject_type": "iam_id", "subject_id": "SubjectID", "root_requester_id": "RootRequesterID", "root_template_id": "RootTemplateID", "root_template_version": "RootTemplateVersion"}], "id": "ID", "account_id": "AccountID", "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", "resources": [{"target": "Target", "policy": {"resource_created": {"id": "ID"}, "error_message": {"trace": "Trace", "errors": [{"code": "insufficent_permissions", "message": "Message", "details": {"conflicts_with": {"etag": "Etag", "role": "Role", "policy": "Policy"}}, "more_info": "MoreInfo"}], "status_code": 10}}}], "status": "in_progress"}`) + fmt.Fprintf(res, "%s", `{"template_id": "TemplateID", "template_version": "TemplateVersion", "assignment_id": "AssignmentID", "target_type": "Account", "target": "Target", "options": [{"subject_type": "iam_id", "subject_id": "SubjectID", "root_requester_id": "RootRequesterID", "root_template_id": "RootTemplateID", "root_template_version": "RootTemplateVersion"}], "id": "ID", "account_id": "AccountID", "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", "resources": [{"target": "Target", "policy": {"resource_created": {"id": "ID"}, "status": "Status", "error_message": {"trace": "Trace", "errors": [{"code": "insufficent_permissions", "message": "Message", "details": {"conflicts_with": {"etag": "Etag", "role": "Role", "policy": "Policy"}}, "more_info": "MoreInfo"}], "status_code": 10}}}], "status": "in_progress"}`) })) }) It(`Invoke GetPolicyAssignment successfully with retries`, func() { @@ -7454,7 +7460,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"template_id": "TemplateID", "template_version": "TemplateVersion", "assignment_id": "AssignmentID", "target_type": "Account", "target": "Target", "options": [{"subject_type": "iam_id", "subject_id": "SubjectID", "root_requester_id": "RootRequesterID", "root_template_id": "RootTemplateID", "root_template_version": "RootTemplateVersion"}], "id": "ID", "account_id": "AccountID", "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", "resources": [{"target": "Target", "policy": {"resource_created": {"id": "ID"}, "error_message": {"trace": "Trace", "errors": [{"code": "insufficent_permissions", "message": "Message", "details": {"conflicts_with": {"etag": "Etag", "role": "Role", "policy": "Policy"}}, "more_info": "MoreInfo"}], "status_code": 10}}}], "status": "in_progress"}`) + fmt.Fprintf(res, "%s", `{"template_id": "TemplateID", "template_version": "TemplateVersion", "assignment_id": "AssignmentID", "target_type": "Account", "target": "Target", "options": [{"subject_type": "iam_id", "subject_id": "SubjectID", "root_requester_id": "RootRequesterID", "root_template_id": "RootTemplateID", "root_template_version": "RootTemplateVersion"}], "id": "ID", "account_id": "AccountID", "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", "resources": [{"target": "Target", "policy": {"resource_created": {"id": "ID"}, "status": "Status", "error_message": {"trace": "Trace", "errors": [{"code": "insufficent_permissions", "message": "Message", "details": {"conflicts_with": {"etag": "Etag", "role": "Role", "policy": "Policy"}}, "more_info": "MoreInfo"}], "status_code": 10}}}], "status": "in_progress"}`) })) }) It(`Invoke GetPolicyAssignment successfully`, func() { @@ -7560,16 +7566,13 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Construct an instance of the CommitPolicyTemplateOptions model policyTemplateID := "testString" version := "testString" - ifMatch := "testString" - commitPolicyTemplateOptionsModel := iamPolicyManagementService.NewCommitPolicyTemplateOptions(policyTemplateID, version, ifMatch) + commitPolicyTemplateOptionsModel := iamPolicyManagementService.NewCommitPolicyTemplateOptions(policyTemplateID, version) commitPolicyTemplateOptionsModel.SetPolicyTemplateID("testString") commitPolicyTemplateOptionsModel.SetVersion("testString") - commitPolicyTemplateOptionsModel.SetIfMatch("testString") commitPolicyTemplateOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(commitPolicyTemplateOptionsModel).ToNot(BeNil()) Expect(commitPolicyTemplateOptionsModel.PolicyTemplateID).To(Equal(core.StringPtr("testString"))) Expect(commitPolicyTemplateOptionsModel.Version).To(Equal(core.StringPtr("testString"))) - Expect(commitPolicyTemplateOptionsModel.IfMatch).To(Equal(core.StringPtr("testString"))) Expect(commitPolicyTemplateOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) It(`Invoke NewControl successfully`, func() { @@ -7821,12 +7824,14 @@ var _ = Describe(`IamPolicyManagementV1`, func() { createPolicyTemplateVersionOptionsModel := iamPolicyManagementService.NewCreatePolicyTemplateVersionOptions(policyTemplateID, createPolicyTemplateVersionOptionsPolicy) createPolicyTemplateVersionOptionsModel.SetPolicyTemplateID("testString") createPolicyTemplateVersionOptionsModel.SetPolicy(templatePolicyModel) + createPolicyTemplateVersionOptionsModel.SetName("testString") createPolicyTemplateVersionOptionsModel.SetDescription("testString") createPolicyTemplateVersionOptionsModel.SetCommitted(true) createPolicyTemplateVersionOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(createPolicyTemplateVersionOptionsModel).ToNot(BeNil()) Expect(createPolicyTemplateVersionOptionsModel.PolicyTemplateID).To(Equal(core.StringPtr("testString"))) Expect(createPolicyTemplateVersionOptionsModel.Policy).To(Equal(templatePolicyModel)) + Expect(createPolicyTemplateVersionOptionsModel.Name).To(Equal(core.StringPtr("testString"))) Expect(createPolicyTemplateVersionOptionsModel.Description).To(Equal(core.StringPtr("testString"))) Expect(createPolicyTemplateVersionOptionsModel.Committed).To(Equal(core.BoolPtr(true))) Expect(createPolicyTemplateVersionOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) @@ -8359,6 +8364,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { replacePolicyTemplateOptionsModel.SetVersion("testString") replacePolicyTemplateOptionsModel.SetIfMatch("testString") replacePolicyTemplateOptionsModel.SetPolicy(templatePolicyModel) + replacePolicyTemplateOptionsModel.SetName("testString") replacePolicyTemplateOptionsModel.SetDescription("testString") replacePolicyTemplateOptionsModel.SetCommitted(true) replacePolicyTemplateOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) @@ -8367,6 +8373,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(replacePolicyTemplateOptionsModel.Version).To(Equal(core.StringPtr("testString"))) Expect(replacePolicyTemplateOptionsModel.IfMatch).To(Equal(core.StringPtr("testString"))) Expect(replacePolicyTemplateOptionsModel.Policy).To(Equal(templatePolicyModel)) + Expect(replacePolicyTemplateOptionsModel.Name).To(Equal(core.StringPtr("testString"))) Expect(replacePolicyTemplateOptionsModel.Description).To(Equal(core.StringPtr("testString"))) Expect(replacePolicyTemplateOptionsModel.Committed).To(Equal(core.BoolPtr(true))) Expect(replacePolicyTemplateOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) @@ -8537,9 +8544,8 @@ var _ = Describe(`IamPolicyManagementV1`, func() { }) It(`Invoke NewTemplatePolicy successfully`, func() { typeVar := "access" - var resource *iampolicymanagementv1.V2PolicyResource = nil var control *iampolicymanagementv1.Control = nil - _, err := iamPolicyManagementService.NewTemplatePolicy(typeVar, resource, control) + _, err := iamPolicyManagementService.NewTemplatePolicy(typeVar, control) Expect(err).ToNot(BeNil()) }) It(`Invoke NewUpdatePolicyStateOptions successfully`, func() {