Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IAM Policy Assignment: S2S Policy Assignments #5499

Merged
merged 13 commits into from
Jul 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -18,15 +18,15 @@ require (
github.com/IBM/event-notifications-go-admin-sdk v0.6.1
github.com/IBM/eventstreams-go-sdk v1.4.0
github.com/IBM/go-sdk-core/v3 v3.2.4
github.com/IBM/go-sdk-core/v5 v5.17.3
github.com/IBM/go-sdk-core/v5 v5.17.4
github.com/IBM/ibm-cos-sdk-go v1.10.3
github.com/IBM/ibm-cos-sdk-go-config/v2 v2.1.0
github.com/IBM/ibm-hpcs-tke-sdk v0.0.0-20211109141421-a4b61b05f7d1
github.com/IBM/ibm-hpcs-uko-sdk v0.0.20-beta
github.com/IBM/keyprotect-go-client v0.14.0
github.com/IBM/logs-go-sdk v0.3.0
github.com/IBM/networking-go-sdk v0.47.1
github.com/IBM/platform-services-go-sdk v0.62.11
github.com/IBM/platform-services-go-sdk v0.64.3
github.com/IBM/project-go-sdk v0.3.5
github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5
github.com/IBM/scc-go-sdk/v5 v5.1.6
8 changes: 6 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -155,6 +155,8 @@ github.com/IBM/go-sdk-core/v5 v5.9.5/go.mod h1:YlOwV9LeuclmT/qi/LAK2AsobbAP42veV
github.com/IBM/go-sdk-core/v5 v5.10.2/go.mod h1:WZPFasUzsKab/2mzt29xPcfruSk5js2ywAPwW4VJjdI=
github.com/IBM/go-sdk-core/v5 v5.17.3 h1:CZSVCKzhQc/hRQZOtuEmi9dlNtWMnxJvOsPtQKP7cZ4=
github.com/IBM/go-sdk-core/v5 v5.17.3/go.mod h1:GatGZpxlo1KaxiRN6E10/rNgWtUtx1hN/GoHSCaSPKA=
github.com/IBM/go-sdk-core/v5 v5.17.4 h1:VGb9+mRrnS2HpHZFM5hy4J6ppIWnwNrw0G+tLSgcJLc=
github.com/IBM/go-sdk-core/v5 v5.17.4/go.mod h1:KsAAI7eStAWwQa4F96MLy+whYSh39JzNjklZRbN/8ns=
github.com/IBM/ibm-cos-sdk-go v1.10.3 h1:YfZSLqMiCrqDPbr3r+amY2sicIXlrd+3L5pok6QRXIQ=
github.com/IBM/ibm-cos-sdk-go v1.10.3/go.mod h1:T9x7pC47DUd5jD/TMFzlvly39P6EdW5wOemA78XEo2g=
github.com/IBM/ibm-cos-sdk-go-config/v2 v2.1.0 h1:U7EmXSfv7jtugRpTpOkPUmgS/xiNKtGfKVH3BGyC1hg=
@@ -174,8 +176,10 @@ github.com/IBM/networking-go-sdk v0.47.1 h1:Zqqu9CrZ86jkjMyuIJtBLLOE0D7YtirxnlFy
github.com/IBM/networking-go-sdk v0.47.1/go.mod h1:yF4XStkswGgVwQVqPUk6b4YTP0dVap52q8HDYwY4gXQ=
github.com/IBM/platform-services-go-sdk v0.62.11 h1:EGsiY90bM9M9sSdBVgpsX4QK1z99JZzedVDlrY2gzmc=
github.com/IBM/platform-services-go-sdk v0.62.11/go.mod h1:M26dloj9C48k9AjfMcKGsgH/acEjaUvxjVS8z41Q8dg=
github.com/IBM/project-go-sdk v0.3.5 h1:L+YClFUa14foS0B/hOOY9n7sIdsT5/XQicnXOyJSpyM=
github.com/IBM/project-go-sdk v0.3.5/go.mod h1:FOJM9ihQV3EEAY6YigcWiTNfVCThtdY8bLC/nhQHFvo=
github.com/IBM/platform-services-go-sdk v0.64.3 h1:AKDrLXjybG09i5MyqptY0UpyejeiYrTbdylDC7FQM1k=
github.com/IBM/platform-services-go-sdk v0.64.3/go.mod h1:6rYd3stLSnotYmZlxclw45EJPaQuLmh5f7c+Mg7rOg4=
github.com/IBM/project-go-sdk v0.3.4 h1:VJqGdrWZLlb+f5/fH5mcSpt8t0QoYEq4QgFWVnn8mCs=
github.com/IBM/project-go-sdk v0.3.4/go.mod h1:FOJM9ihQV3EEAY6YigcWiTNfVCThtdY8bLC/nhQHFvo=
github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 h1:NPUhkoOCRuv3OFWt19PmwjXGGTKlvmbuPg9fUrBUNe4=
github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5/go.mod h1:b07XHUVh0XYnQE9s2mqgjYST1h9buaQNqN4EcKhOsX0=
github.com/IBM/sarama v1.41.2 h1:ZDBZfGPHAD4uuAtSv4U22fRZBgst0eEwGFzLj0fb85c=
98 changes: 0 additions & 98 deletions ibm/service/iampolicy/data_source_ibm_iam_policy_assignment.go
Original file line number Diff line number Diff line change
@@ -207,50 +207,6 @@ func DataSourceIBMIAMPolicyAssignment() *schema.Resource {
},
},
},
"options": {
Type: schema.TypeList,
Computed: true,
Description: "The set of properties required for a policy assignment.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"root": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"requester_id": {
Type: schema.TypeString,
Computed: true,
},
"assignment_id": {
Type: schema.TypeString,
Computed: true,
Description: "Passed in value to correlate with other assignments.",
},
"template": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeString,
Computed: true,
Description: "The template id where this policy is being assigned from.",
},
"version": {
Type: schema.TypeString,
Computed: true,
Description: "The template version where this policy is being assigned from.",
},
},
},
},
},
},
},
},
},
},
"account_id": {
Type: schema.TypeString,
Computed: true,
@@ -301,13 +257,6 @@ func dataSourceIBMIAMPolicyAssignmentRead(context context.Context, d *schema.Res
return diag.FromErr(fmt.Errorf("error setting template: %s", err))
}
}
optionsMap, err := ResourceIBMPolicyAssignmentPolicyAssignmentV1OptionsToMap(policyAssignmentRecord.Options)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove options also from Schema

if err != nil {
return diag.FromErr(err)
}
if err = d.Set("options", []map[string]interface{}{optionsMap}); err != nil {
return diag.FromErr(fmt.Errorf("error setting options: %s", err))
}

if err = d.Set("href", policyAssignmentRecord.Href); err != nil {
return diag.FromErr(fmt.Errorf("error setting href: %s", err))
@@ -317,18 +266,10 @@ func dataSourceIBMIAMPolicyAssignmentRead(context context.Context, d *schema.Res
return diag.FromErr(fmt.Errorf("error setting created_at: %s", err))
}

if err = d.Set("created_by_id", policyAssignmentRecord.CreatedByID); err != nil {
return diag.FromErr(fmt.Errorf("error setting created_by_id: %s", err))
}

if err = d.Set("last_modified_at", flex.DateTimeToString(policyAssignmentRecord.LastModifiedAt)); err != nil {
return diag.FromErr(fmt.Errorf("error setting last_modified_at: %s", err))
}

if err = d.Set("last_modified_by_id", policyAssignmentRecord.LastModifiedByID); err != nil {
return diag.FromErr(fmt.Errorf("error setting last_modified_by_id: %s", err))
}

if err = d.Set("account_id", policyAssignmentRecord.AccountID); err != nil {
return diag.FromErr(fmt.Errorf("error setting account_id: %s", err))
}
@@ -474,45 +415,6 @@ func ResourceIBMPolicyAssignmentPolicyAssignmentV1ResourcesToMap(model *iampolic
}
return modelMap, nil
}
func ResourceIBMPolicyAssignmentPolicyAssignmentV1OptionsRootTemplateToMap(model *iampolicymanagementv1.PolicyAssignmentV1OptionsRootTemplate) (map[string]interface{}, error) {
modelMap := make(map[string]interface{})
if model.ID != nil {
modelMap["id"] = *model.ID
}
if model.Version != nil {
modelMap["version"] = *model.Version
}
return modelMap, nil
}

func ResourceIBMPolicyAssignmentPolicyAssignmentV1OptionsRootToMap(model *iampolicymanagementv1.PolicyAssignmentV1OptionsRoot) (map[string]interface{}, error) {
modelMap := make(map[string]interface{})
if model.RequesterID != nil {
modelMap["requester_id"] = *model.RequesterID
}
if model.AssignmentID != nil {
modelMap["assignment_id"] = *model.AssignmentID
}
if model.Template != nil {
templateMap, err := ResourceIBMPolicyAssignmentPolicyAssignmentV1OptionsRootTemplateToMap(model.Template)
if err != nil {
return modelMap, err
}
modelMap["template"] = []map[string]interface{}{templateMap}
}
return modelMap, nil
}

func ResourceIBMPolicyAssignmentPolicyAssignmentV1OptionsToMap(model *iampolicymanagementv1.PolicyAssignmentV1Options) (map[string]interface{}, error) {
modelMap := make(map[string]interface{})
rootMap, err := ResourceIBMPolicyAssignmentPolicyAssignmentV1OptionsRootToMap(model.Root)
if err != nil {
return modelMap, err
}
modelMap["root"] = []map[string]interface{}{rootMap}
return modelMap, nil
}

func DataSourceIBMPolicyAssignmentPolicyAssignmentV1Subject(model *iampolicymanagementv1.GetPolicyAssignmentResponseSubject) (map[string]interface{}, error) {
modelMap := make(map[string]interface{})
if model.ID != nil {
117 changes: 1 addition & 116 deletions ibm/service/iampolicy/data_source_ibm_iam_policy_assignments.go
Original file line number Diff line number Diff line change
@@ -58,50 +58,6 @@ func DataSourceIBMIAMPolicyAssignments() *schema.Resource {
Type: schema.TypeString,
},
},
"options": {
Type: schema.TypeList,
Computed: true,
Description: "The set of properties required for a policy assignment.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"root": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"requester_id": {
Type: schema.TypeString,
Computed: true,
},
"assignment_id": {
Type: schema.TypeString,
Computed: true,
Description: "Passed in value to correlate with other assignments.",
},
"template": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeString,
Computed: true,
Description: "The template id where this policy is being assigned from.",
},
"version": {
Type: schema.TypeString,
Computed: true,
Description: "The template version where this policy is being assigned from.",
},
},
},
},
},
},
},
},
},
},
"id": {
Type: schema.TypeString,
Computed: true,
@@ -370,7 +326,7 @@ func ResourceIBMPolicyAssignmentAssignmentTargetDetailsToMap(model *iampolicyman
func ResourceIBMPolicyAssignmentResourceTargetDetailsToMap(model *iampolicymanagementv1.AssignmentTargetDetails) (map[string]interface{}, error) {
modelMap := make(map[string]interface{})
if model.Type != nil {
modelMap["version"] = *model.Type
modelMap["type"] = *model.Type
}
if model.ID != nil {
modelMap["id"] = *model.ID
@@ -394,13 +350,6 @@ func DataSourceIBMPolicyAssignmentPolicyTemplateAssignmentItemsToMap(model iampo
}
modelMap["target"] = targetMap
}
if model.Options != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove options from Schema

optionsMap, err := DataSourceIBMPolicyAssignmentPolicyAssignmentV1OptionsToMap(model.Options)
if err != nil {
return modelMap, err
}
modelMap["options"] = []map[string]interface{}{optionsMap}
}
if model.ID != nil {
modelMap["id"] = *model.ID
}
@@ -476,45 +425,6 @@ func DataSourceIBMPolicyAssignmentAssignmentTargetDetailsToMap(model *iampolicym
return modelMap, nil
}

func DataSourceIBMPolicyAssignmentPolicyAssignmentV1OptionsToMap(model *iampolicymanagementv1.PolicyAssignmentV1Options) (map[string]interface{}, error) {
modelMap := make(map[string]interface{})
rootMap, err := DataSourceIBMPolicyAssignmentPolicyAssignmentV1OptionsRootToMap(model.Root)
if err != nil {
return modelMap, err
}
modelMap["root"] = []map[string]interface{}{rootMap}
return modelMap, nil
}

func DataSourceIBMPolicyAssignmentPolicyAssignmentV1OptionsRootToMap(model *iampolicymanagementv1.PolicyAssignmentV1OptionsRoot) (map[string]interface{}, error) {
modelMap := make(map[string]interface{})
if model.RequesterID != nil {
modelMap["requester_id"] = *model.RequesterID
}
if model.AssignmentID != nil {
modelMap["assignment_id"] = *model.AssignmentID
}
if model.Template != nil {
templateMap, err := DataSourceIBMPolicyAssignmentPolicyAssignmentV1OptionsRootTemplateToMap(model.Template)
if err != nil {
return modelMap, err
}
modelMap["template"] = []map[string]interface{}{templateMap}
}
return modelMap, nil
}

func DataSourceIBMPolicyAssignmentPolicyAssignmentV1OptionsRootTemplateToMap(model *iampolicymanagementv1.PolicyAssignmentV1OptionsRootTemplate) (map[string]interface{}, error) {
modelMap := make(map[string]interface{})
if model.ID != nil {
modelMap["id"] = *model.ID
}
if model.Version != nil {
modelMap["version"] = *model.Version
}
return modelMap, nil
}

func DataSourceIBMPolicyAssignmentPolicyAssignmentV1ResourcesToMap(model *iampolicymanagementv1.PolicyAssignmentV1Resources) (map[string]interface{}, error) {
modelMap := make(map[string]interface{})
if model.Target != nil {
@@ -665,17 +575,6 @@ func DataSourceIBMPolicyAssignmentPolicyTemplateAssignmentItemsPolicyAssignmentT
if model.Target != nil {
modelMap["target"] = *model.Target
}
if model.Options != nil {
options := []map[string]interface{}{}
for _, optionsItem := range model.Options {
optionsItemMap, err := DataSourceIBMPolicyAssignmentPolicyAssignmentOptionsToMap(&optionsItem)
if err != nil {
return modelMap, err
}
options = append(options, optionsItemMap)
}
modelMap["options"] = options
}
if model.ID != nil {
modelMap["id"] = *model.ID
}
@@ -714,20 +613,6 @@ func DataSourceIBMPolicyAssignmentPolicyTemplateAssignmentItemsPolicyAssignmentT
return modelMap, nil
}

func DataSourceIBMPolicyAssignmentPolicyAssignmentOptionsToMap(model *iampolicymanagementv1.PolicyAssignmentOptions) (map[string]interface{}, error) {
modelMap := make(map[string]interface{})
modelMap["subject_type"] = *model.SubjectType
modelMap["subject_id"] = *model.SubjectID
modelMap["root_requester_id"] = *model.RootRequesterID
if model.RootTemplateID != nil {
modelMap["root_template_id"] = *model.RootTemplateID
}
if model.RootTemplateVersion != nil {
modelMap["root_template_version"] = *model.RootTemplateVersion
}
return modelMap, nil
}

func DataSourceIBMPolicyAssignmentPolicyAssignmentResourcesToMap(model *iampolicymanagementv1.PolicyAssignmentResources) (map[string]interface{}, error) {
modelMap := make(map[string]interface{})
if model.Target != nil {
Loading