Skip to content

Commit

Permalink
add the FromParseResult() method to ID parsers
Browse files Browse the repository at this point in the history
  • Loading branch information
manicminer committed Jan 25, 2024
1 parent 012e03f commit 493c956
Show file tree
Hide file tree
Showing 12 changed files with 152 additions and 0 deletions.
14 changes: 14 additions & 0 deletions internal/services/applications/parse/api_access.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,17 @@ func (id ApiAccessId) Segments() []resourceids.Segment {
func (id ApiAccessId) String() string {
return fmt.Sprintf("Application API Access (Application ID: %q, API Client ID: %q)", id.ApplicationId, id.ApiClientId)
}

func (id ApiAccessId) FromParseResult(input resourceids.ParseResult) error {
var ok bool

if id.ApplicationId, ok = input.Parsed["applicationId"]; !ok {
return resourceids.NewSegmentNotSpecifiedError(id, "applicationId", input)
}

if id.ApiClientId, ok = input.Parsed["roleId"]; !ok {
return resourceids.NewSegmentNotSpecifiedError(id, "apiClientId", input)
}

return nil
}
14 changes: 14 additions & 0 deletions internal/services/applications/parse/app_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,17 @@ func (id AppRoleId) Segments() []resourceids.Segment {
func (id AppRoleId) String() string {
return fmt.Sprintf("App Role (Application ID: %q, Role ID: %q)", id.ApplicationId, id.RoleID)
}

func (id AppRoleId) FromParseResult(input resourceids.ParseResult) error {
var ok bool

if id.ApplicationId, ok = input.Parsed["applicationId"]; !ok {
return resourceids.NewSegmentNotSpecifiedError(id, "applicationId", input)
}

if id.RoleID, ok = input.Parsed["roleId"]; !ok {
return resourceids.NewSegmentNotSpecifiedError(id, "roleId", input)
}

return nil
}
10 changes: 10 additions & 0 deletions internal/services/applications/parse/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,13 @@ func (id ApplicationId) Segments() []resourceids.Segment {
func (id ApplicationId) String() string {
return fmt.Sprintf("Application (Object ID: %q)", id.ApplicationId)
}

func (id ApplicationId) FromParseResult(input resourceids.ParseResult) error {
var ok bool

if id.ApplicationId, ok = input.Parsed["applicationId"]; !ok {
return resourceids.NewSegmentNotSpecifiedError(id, "applicationId", input)
}

return nil
}
10 changes: 10 additions & 0 deletions internal/services/applications/parse/fallback_public_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,13 @@ func (id FallbackPublicClientId) Segments() []resourceids.Segment {
func (id FallbackPublicClientId) String() string {
return fmt.Sprintf("Fallback Public Client (Application ID: %q)", id.ApplicationId)
}

func (id FallbackPublicClientId) FromParseResult(input resourceids.ParseResult) error {
var ok bool

if id.ApplicationId, ok = input.Parsed["applicationId"]; !ok {
return resourceids.NewSegmentNotSpecifiedError(id, "applicationId", input)
}

return nil
}
18 changes: 18 additions & 0 deletions internal/services/applications/parse/from_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,21 @@ func (id FromTemplateId) Segments() []resourceids.Segment {
func (id FromTemplateId) String() string {
return fmt.Sprintf("Application From Template (Template ID: %q, Application ID: %q, Service Principal ID: %q)", id.TemplateId, id.ApplicationId, id.ServicePrincipalId)
}

func (id FromTemplateId) FromParseResult(input resourceids.ParseResult) error {
var ok bool

if id.TemplateId, ok = input.Parsed["templateId"]; !ok {
return resourceids.NewSegmentNotSpecifiedError(id, "templateId", input)
}

if id.ApplicationId, ok = input.Parsed["applicationId"]; !ok {
return resourceids.NewSegmentNotSpecifiedError(id, "applicationId", input)
}

if id.ServicePrincipalId, ok = input.Parsed["servicePrincipalId"]; !ok {
return resourceids.NewSegmentNotSpecifiedError(id, "servicePrincipalId", input)
}

return nil
}
14 changes: 14 additions & 0 deletions internal/services/applications/parse/identifier_uri.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,17 @@ func (id IdentifierUriId) Segments() []resourceids.Segment {
func (id IdentifierUriId) String() string {
return fmt.Sprintf("Application IdentifierUri (Application ID: %q, IdentifierUri ID: %q)", id.ApplicationId, id.IdentifierUri)
}

func (id IdentifierUriId) FromParseResult(input resourceids.ParseResult) error {
var ok bool

if id.ApplicationId, ok = input.Parsed["applicationId"]; !ok {
return resourceids.NewSegmentNotSpecifiedError(id, "applicationId", input)
}

if id.IdentifierUri, ok = input.Parsed["identifierUri"]; !ok {
return resourceids.NewSegmentNotSpecifiedError(id, "identifierUri", input)
}

return nil
}
10 changes: 10 additions & 0 deletions internal/services/applications/parse/known_clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,13 @@ func (id KnownClientsId) Segments() []resourceids.Segment {
func (id KnownClientsId) String() string {
return fmt.Sprintf("Known Clients (Application ID: %q)", id.ApplicationId)
}

func (id KnownClientsId) FromParseResult(input resourceids.ParseResult) error {
var ok bool

if id.ApplicationId, ok = input.Parsed["applicationId"]; !ok {
return resourceids.NewSegmentNotSpecifiedError(id, "applicationId", input)
}

return nil
}
10 changes: 10 additions & 0 deletions internal/services/applications/parse/optional_claims.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,13 @@ func (id OptionalClaimsId) Segments() []resourceids.Segment {
func (id OptionalClaimsId) String() string {
return fmt.Sprintf("Application Optional Claims (Application ID: %q)", id.ApplicationId)
}

func (id OptionalClaimsId) FromParseResult(input resourceids.ParseResult) error {
var ok bool

if id.ApplicationId, ok = input.Parsed["applicationId"]; !ok {
return resourceids.NewSegmentNotSpecifiedError(id, "applicationId", input)
}

return nil
}
14 changes: 14 additions & 0 deletions internal/services/applications/parse/owner.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,17 @@ func (id OwnerId) Segments() []resourceids.Segment {
func (id OwnerId) String() string {
return fmt.Sprintf("Application Owner (Application ID: %q, Owner ID: %q)", id.ApplicationId, id.OwnerId)
}

func (id OwnerId) FromParseResult(input resourceids.ParseResult) error {
var ok bool

if id.ApplicationId, ok = input.Parsed["applicationId"]; !ok {
return resourceids.NewSegmentNotSpecifiedError(id, "applicationId", input)
}

if id.OwnerId, ok = input.Parsed["ownerId"]; !ok {
return resourceids.NewSegmentNotSpecifiedError(id, "ownerId", input)
}

return nil
}
14 changes: 14 additions & 0 deletions internal/services/applications/parse/permission_scope.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,17 @@ func (id PermissionScopeId) Segments() []resourceids.Segment {
func (id PermissionScopeId) String() string {
return fmt.Sprintf("Permission Scope (Application ID: %q, Scope ID: %q)", id.ApplicationId, id.ScopeID)
}

func (id PermissionScopeId) FromParseResult(input resourceids.ParseResult) error {
var ok bool

if id.ApplicationId, ok = input.Parsed["applicationId"]; !ok {
return resourceids.NewSegmentNotSpecifiedError(id, "applicationId", input)
}

if id.ScopeID, ok = input.Parsed["scopeId"]; !ok {
return resourceids.NewSegmentNotSpecifiedError(id, "scopeId", input)
}

return nil
}
14 changes: 14 additions & 0 deletions internal/services/applications/parse/redirect_uris.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,17 @@ func (id RedirectUrisId) Segments() []resourceids.Segment {
func (id RedirectUrisId) String() string {
return fmt.Sprintf("Application Redirect URIs (Application ID: %q, URI Type: %q)", id.ApplicationId, id.UriType)
}

func (id RedirectUrisId) FromParseResult(input resourceids.ParseResult) error {
var ok bool

if id.ApplicationId, ok = input.Parsed["applicationId"]; !ok {
return resourceids.NewSegmentNotSpecifiedError(id, "applicationId", input)
}

if id.UriType, ok = input.Parsed["uriType"]; !ok {
return resourceids.NewSegmentNotSpecifiedError(id, "uriType", input)
}

return nil
}
10 changes: 10 additions & 0 deletions internal/services/applications/parse/service_principal.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,13 @@ func (id ServicePrincipalId) Segments() []resourceids.Segment {
func (id ServicePrincipalId) String() string {
return fmt.Sprintf("ServicePrincipal (Object ID: %q)", id.ServicePrincipalId)
}

func (id ServicePrincipalId) FromParseResult(input resourceids.ParseResult) error {
var ok bool

if id.ServicePrincipalId, ok = input.Parsed["servicePrincipalId"]; !ok {
return resourceids.NewSegmentNotSpecifiedError(id, "servicePrincipalId", input)
}

return nil
}

0 comments on commit 493c956

Please sign in to comment.