-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create
azurerm_role_management_policy
resource
- Loading branch information
Showing
3 changed files
with
1,139 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
internal/services/authorization/parse/role_management_policy.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package parse | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" | ||
) | ||
|
||
type RoleManagementPolicyId struct { | ||
Scope string | ||
Name string | ||
} | ||
|
||
var _ resourceids.Id = RoleManagementPolicyId{} | ||
|
||
func NewRoleManagementPolicyID(scope, name string) *RoleManagementPolicyId { | ||
return &RoleManagementPolicyId{ | ||
Scope: scope, | ||
Name: name, | ||
} | ||
} | ||
|
||
func RoleManagementPolicyID(id string) (*RoleManagementPolicyId, error) { | ||
parts := strings.Split(id, "/providers/Microsoft.Authorization/roleManagementPolicies/") | ||
if len(parts) != 2 { | ||
return nil, fmt.Errorf("invalid role management policy ID: %s", id) | ||
} | ||
|
||
return NewRoleManagementPolicyID(parts[0], parts[1]), nil | ||
} | ||
|
||
func (id RoleManagementPolicyId) ID() string { | ||
fmtString := "%s/providers/Microsoft.Authorization/roleManagementPolicies/%s" | ||
return fmt.Sprintf(fmtString, id.Scope, id.Name) | ||
} | ||
|
||
func (id RoleManagementPolicyId) String() string { | ||
segments := []string{ | ||
fmt.Sprintf("Scope %q", id.Scope), | ||
fmt.Sprintf("Policy Name %q", id.Name), | ||
} | ||
segmentsStr := strings.Join(segments, " / ") | ||
return fmt.Sprintf("%s: (%s)", "Role Management Policy ID", segmentsStr) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.