Skip to content

Commit

Permalink
rename SAMLGroupMappingDetailsInput to SAMLGroupDetailsInput + move U…
Browse files Browse the repository at this point in the history
…pdateSAMLGroupMappingInput to resource impl
  • Loading branch information
NerdJeremia committed Aug 8, 2024
1 parent 6794356 commit ceaca18
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
16 changes: 11 additions & 5 deletions internal/provider/resource_saml_group_mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ type ReadSAMLGroupMappings struct {
SAMLGroupMappings wiz.SAMLIdentityProviderGroupMappingsConnection `json:"samlIdentityProviderGroupMappings"`
}

// UpdateSAMLGroupMappingInput struct
type UpdateSAMLGroupMappingInput struct {
ID string `json:"id"`
Patch wiz.ModifySAMLGroupMappingPatch `json:"patch"`
}

// SAMLGroupMappingsImport represents the structure of a SAML group mapping import.
// It includes the SAML IdP ID, provider group ID, project IDs, and role.
type SAMLGroupMappingsImport struct {
Expand Down Expand Up @@ -140,10 +146,10 @@ func resourceSAMLGroupMappingCreate(ctx context.Context, d *schema.ResourceData,
}
}`
// populate the graphql variables
vars := &wiz.UpdateSAMLGroupMappingInput{}
vars := &UpdateSAMLGroupMappingInput{}
vars.ID = samlIdpID
vars.Patch = wiz.ModifySAMLGroupMappingPatch{
Upsert: &wiz.SAMLGroupMappingDetailsInput{
Upsert: &wiz.SAMLGroupDetailsInput{
ProviderGroupID: providerGroupID,
Role: role,
Projects: projectIDs,
Expand Down Expand Up @@ -263,10 +269,10 @@ func resourceSAMLGroupMappingUpdate(ctx context.Context, d *schema.ResourceData,
projects := utils.ConvertListToString(d.Get("projects").([]interface{}))

// populate the graphql variables
vars := &wiz.UpdateSAMLGroupMappingInput{}
vars := &UpdateSAMLGroupMappingInput{}
vars.ID = samlIdpID
vars.Patch = wiz.ModifySAMLGroupMappingPatch{
Upsert: &wiz.SAMLGroupMappingDetailsInput{
Upsert: &wiz.SAMLGroupDetailsInput{
ProviderGroupID: providerGroupID,
Role: role,
Projects: projects,
Expand Down Expand Up @@ -303,7 +309,7 @@ func resourceSAMLGroupMappingDelete(ctx context.Context, d *schema.ResourceData,
providerGroupID := d.Get("provider_group_id").(string)

// populate the graphql variables
vars := &wiz.UpdateSAMLGroupMappingInput{}
vars := &UpdateSAMLGroupMappingInput{}
vars.ID = samlIdpID
vars.Patch.Delete = &[]string{providerGroupID}

Expand Down
15 changes: 5 additions & 10 deletions internal/wiz/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,23 +244,18 @@ type SAMLGroupMappingCreateInput struct {
Projects []string `json:"projects"`
}

// UpdateSAMLGroupMappingInput struct
type UpdateSAMLGroupMappingInput struct {
ID string `json:"id"`
Patch ModifySAMLGroupMappingPatch `json:"patch"`
}

// SAMLGroupMappingDetailsInput struct
type SAMLGroupMappingDetailsInput struct {
// SAMLGroupDetailsInput struct
// Incomplete because 'description' field is missing as in the schema
type SAMLGroupDetailsInput struct {
ProviderGroupID string `json:"providerGroupId"`
Role string `json:"role"`
Projects []string `json:"projects"`
}

// ModifySAMLGroupMappingPatch struct
type ModifySAMLGroupMappingPatch struct {
Upsert *SAMLGroupMappingDetailsInput `json:"upsert,omitempty"`
Delete *[]string `json:"delete,omitempty"`
Upsert *SAMLGroupDetailsInput `json:"upsert,omitempty"`
Delete *[]string `json:"delete,omitempty"`
}

// SAMLIdentityProviderGroupMappingsConnection struct
Expand Down

0 comments on commit ceaca18

Please sign in to comment.