-
Notifications
You must be signed in to change notification settings - Fork 295
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
azuread_group - support for the
owners
property (#62)
closes #36
- Loading branch information
Showing
20 changed files
with
693 additions
and
203 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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,58 @@ | ||
package graph | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/hashicorp/go-uuid" | ||
) | ||
|
||
type ObjectSubResourceId struct { | ||
objectId string | ||
subId string | ||
Type string | ||
} | ||
|
||
func (id ObjectSubResourceId) String() string { | ||
return id.objectId + "/" + id.Type + "/" + id.subId | ||
} | ||
|
||
func ParseObjectSubResourceId(idString, expectedType string) (ObjectSubResourceId, error) { | ||
parts := strings.Split(idString, "/") | ||
if len(parts) != 3 { | ||
return ObjectSubResourceId{}, fmt.Errorf("Object Resource ID should be in the format {objectId}/{keyId} - but got %q", idString) | ||
} | ||
|
||
id := ObjectSubResourceId{ | ||
objectId: parts[0], | ||
Type: parts[1], | ||
subId: parts[2], | ||
} | ||
|
||
if _, err := uuid.ParseUUID(id.objectId); err != nil { | ||
return ObjectSubResourceId{}, fmt.Errorf("Object ID isn't a valid UUID (%q): %+v", id.objectId, err) | ||
} | ||
|
||
if id.Type == "" { | ||
return ObjectSubResourceId{}, fmt.Errorf("Type in {objectID}/{type}/{subID} should not blank") | ||
} | ||
|
||
if id.Type != expectedType { | ||
return ObjectSubResourceId{}, fmt.Errorf("Type in {objectID}/{type}/{subID} was expected to be %s, got %s", expectedType, parts[2]) | ||
} | ||
|
||
if _, err := uuid.ParseUUID(id.subId); err != nil { | ||
return ObjectSubResourceId{}, fmt.Errorf("Object Sub Resource ID isn't a valid UUID (%q): %+v", id.subId, err) | ||
} | ||
|
||
return id, nil | ||
|
||
} | ||
|
||
func ObjectSubResourceIdFrom(objectId, typeId, subId string) ObjectSubResourceId { | ||
return ObjectSubResourceId{ | ||
objectId: objectId, | ||
Type: typeId, | ||
subId: subId, | ||
} | ||
} |
Oops, something went wrong.