diff --git a/go.mod b/go.mod index 37a4f57fc7..0738721ee0 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/hashicorp/terraform-plugin-sdk/v2 v2.7.0 github.com/hashicorp/yamux v0.0.0-20210316155119-a95892c5f864 // indirect github.com/klauspost/compress v1.12.2 // indirect - github.com/manicminer/hamilton v0.31.1 + github.com/manicminer/hamilton v0.32.0 github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/mitchellh/mapstructure v1.4.1 // indirect diff --git a/go.sum b/go.sum index 9ca5b56cde..ad67dc9ccd 100644 --- a/go.sum +++ b/go.sum @@ -285,8 +285,8 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/manicminer/hamilton v0.31.1 h1:uDM9q4bE2mJGieH42M17A6Q1avSxZP9UKwpD6ctX+LI= -github.com/manicminer/hamilton v0.31.1/go.mod h1:QryxpD/4+cdKuXNi0UjLDvgxYdP0LLmYz7dYU7DAX4U= +github.com/manicminer/hamilton v0.32.0 h1:awVHVXOLp9P5QbWaOFqneuWjAvzAk3BYtTEX6AeWB5k= +github.com/manicminer/hamilton v0.32.0/go.mod h1:QryxpD/4+cdKuXNi0UjLDvgxYdP0LLmYz7dYU7DAX4U= github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= diff --git a/internal/services/applications/application_resource.go b/internal/services/applications/application_resource.go index 2a40846e7f..fbb6732702 100644 --- a/internal/services/applications/application_resource.go +++ b/internal/services/applications/application_resource.go @@ -918,6 +918,13 @@ func applicationResourceCreate(ctx context.Context, d *schema.ResourceData, meta if callerObject == nil { return tf.ErrorDiagF(errors.New("returned callerObject was nil"), "Could not retrieve calling principal object %q", callerId) } + // TODO: remove this workaround for https://github.com/hashicorp/terraform-provider-azuread/issues/588 + //if callerObject.ODataId == nil { + // return tf.ErrorDiagF(errors.New("ODataId was nil"), "Could not retrieve calling principal object %q", callerId) + //} + callerObject.ODataId = (*odata.Id)(utils.String(fmt.Sprintf("%s/v1.0/%s/directoryObjects/%s", + client.BaseClient.Endpoint, client.BaseClient.TenantId, callerId))) + ownersFirst20 := msgraph.Owners{*callerObject} var ownersExtra msgraph.Owners @@ -927,21 +934,25 @@ func applicationResourceCreate(ctx context.Context, d *schema.ResourceData, meta // Retrieve and set the initial owners, which can be up to 20 in total when creating the application if v, ok := d.GetOk("owners"); ok { ownerCount := 0 - for _, id := range v.(*schema.Set).List() { - if strings.EqualFold(id.(string), callerId) { + for _, ownerId := range v.(*schema.Set).List() { + if strings.EqualFold(ownerId.(string), callerId) { removeCallerOwner = false continue } - ownerObject, _, err := directoryObjectsClient.Get(ctx, id.(string), odata.Query{}) + ownerObject, _, err := directoryObjectsClient.Get(ctx, ownerId.(string), odata.Query{}) if err != nil { - return tf.ErrorDiagF(err, "Could not retrieve owner principal object %q", id) + return tf.ErrorDiagF(err, "Could not retrieve owner principal object %q", ownerId) } if ownerObject == nil { - return tf.ErrorDiagF(errors.New("ownerObject was nil"), "Could not retrieve owner principal object %q", id) - } - if ownerObject.ODataId == nil { - return tf.ErrorDiagF(errors.New("ODataId was nil"), "Could not retrieve owner principal object %q", id) + return tf.ErrorDiagF(errors.New("ownerObject was nil"), "Could not retrieve owner principal object %q", ownerId) } + // TODO: remove this workaround for https://github.com/hashicorp/terraform-provider-azuread/issues/588 + //if ownerObject.ODataId == nil { + // return tf.ErrorDiagF(errors.New("ODataId was nil"), "Could not retrieve owner principal object %q", ownerId) + //} + ownerObject.ODataId = (*odata.Id)(utils.String(fmt.Sprintf("%s/v1.0/%s/directoryObjects/%s", + client.BaseClient.Endpoint, client.BaseClient.TenantId, ownerId))) + if ownerCount < 19 { ownersFirst20 = append(ownersFirst20, *ownerObject) } else { @@ -1077,14 +1088,21 @@ func applicationResourceUpdate(ctx context.Context, d *schema.ResourceData, meta if len(ownersToAdd) > 0 { newOwners := make(msgraph.Owners, 0) - for _, m := range ownersToAdd { - ownerObject, _, err := directoryObjectsClient.Get(ctx, m, odata.Query{}) + for _, ownerId := range ownersToAdd { + ownerObject, _, err := directoryObjectsClient.Get(ctx, ownerId, odata.Query{}) if err != nil { - return tf.ErrorDiagF(err, "Could not retrieve owner principal object %q", m) + return tf.ErrorDiagF(err, "Could not retrieve owner principal object %q", ownerId) } if ownerObject == nil { - return tf.ErrorDiagF(errors.New("returned ownerObject was nil"), "Could not retrieve owner principal object %q", m) + return tf.ErrorDiagF(errors.New("returned ownerObject was nil"), "Could not retrieve owner principal object %q", ownerId) } + // TODO: remove this workaround for https://github.com/hashicorp/terraform-provider-azuread/issues/588 + //if ownerObject.ODataId == nil { + // return tf.ErrorDiagF(errors.New("ODataId was nil"), "Could not retrieve owner principal object %q", ownerId) + //} + ownerObject.ODataId = (*odata.Id)(utils.String(fmt.Sprintf("%s/v1.0/%s/directoryObjects/%s", + client.BaseClient.Endpoint, client.BaseClient.TenantId, ownerId))) + newOwners = append(newOwners, *ownerObject) } diff --git a/internal/services/directoryroles/directory_role_member_resource.go b/internal/services/directoryroles/directory_role_member_resource.go index 9a25feca6c..b4204cc08e 100644 --- a/internal/services/directoryroles/directory_role_member_resource.go +++ b/internal/services/directoryroles/directory_role_member_resource.go @@ -17,6 +17,7 @@ import ( "github.com/hashicorp/terraform-provider-azuread/internal/clients" "github.com/hashicorp/terraform-provider-azuread/internal/services/directoryroles/parse" "github.com/hashicorp/terraform-provider-azuread/internal/tf" + "github.com/hashicorp/terraform-provider-azuread/internal/utils" "github.com/hashicorp/terraform-provider-azuread/internal/validate" ) @@ -90,9 +91,13 @@ func directoryRoleMemberResourceCreate(ctx context.Context, d *schema.ResourceDa if memberObject == nil { return tf.ErrorDiagF(errors.New("returned memberObject was nil"), "Could not retrieve member principal object %q", id.MemberId) } - if memberObject.ODataId == nil { - return tf.ErrorDiagF(errors.New("ODataId was nil"), "Could not retrieve member principal object %q", id.MemberId) - } + // TODO: remove this workaround for https://github.com/hashicorp/terraform-provider-azuread/issues/588 + //if memberObject.ODataId == nil { + // return tf.ErrorDiagF(errors.New("ODataId was nil"), "Could not retrieve member principal object %q", id.MemberId) + //} + memberObject.ODataId = (*odata.Id)(utils.String(fmt.Sprintf("%s/v1.0/%s/directoryObjects/%s", + client.BaseClient.Endpoint, client.BaseClient.TenantId, id.MemberId))) + role.Members = &msgraph.Members{*memberObject} if _, err := client.AddMembers(ctx, role); err != nil { diff --git a/internal/services/groups/group_member_resource.go b/internal/services/groups/group_member_resource.go index 7093c7b5c4..04a1d9eaec 100644 --- a/internal/services/groups/group_member_resource.go +++ b/internal/services/groups/group_member_resource.go @@ -3,6 +3,7 @@ package groups import ( "context" "errors" + "fmt" "log" "net/http" "strings" @@ -16,6 +17,7 @@ import ( "github.com/hashicorp/terraform-provider-azuread/internal/clients" "github.com/hashicorp/terraform-provider-azuread/internal/services/groups/parse" "github.com/hashicorp/terraform-provider-azuread/internal/tf" + "github.com/hashicorp/terraform-provider-azuread/internal/utils" "github.com/hashicorp/terraform-provider-azuread/internal/validate" ) @@ -95,9 +97,13 @@ func groupMemberResourceCreate(ctx context.Context, d *schema.ResourceData, meta if memberObject == nil { return tf.ErrorDiagF(errors.New("returned memberObject was nil"), "Could not retrieve member principal object %q", memberId) } - if memberObject.ODataId == nil { - return tf.ErrorDiagF(errors.New("ODataId was nil"), "Could not retrieve member principal object %q", memberId) - } + // TODO: remove this workaround for https://github.com/hashicorp/terraform-provider-azuread/issues/588 + //if memberObject.ODataId == nil { + // return tf.ErrorDiagF(errors.New("ODataId was nil"), "Could not retrieve member principal object %q", memberId) + //} + memberObject.ODataId = (*odata.Id)(utils.String(fmt.Sprintf("%s/v1.0/%s/directoryObjects/%s", + client.BaseClient.Endpoint, client.BaseClient.TenantId, memberId))) + group.Members = &msgraph.Members{*memberObject} if _, err := client.AddMembers(ctx, group); err != nil { diff --git a/internal/services/groups/group_resource.go b/internal/services/groups/group_resource.go index 6092943506..f7e7978cfd 100644 --- a/internal/services/groups/group_resource.go +++ b/internal/services/groups/group_resource.go @@ -418,9 +418,13 @@ func groupResourceCreate(ctx context.Context, d *schema.ResourceData, meta inter if ownerObject.ID == nil { return nil, errors.New("ownerObject ID was nil") } - if ownerObject.ODataId == nil { - return nil, errors.New("ODataId was nil") - } + // TODO: remove this workaround for https://github.com/hashicorp/terraform-provider-azuread/issues/588 + //if ownerObject.ODataId == nil { + // return nil, errors.New("ODataId was nil") + //} + ownerObject.ODataId = (*odata.Id)(utils.String(fmt.Sprintf("%s/v1.0/%s/directoryObjects/%s", + client.BaseClient.Endpoint, client.BaseClient.TenantId, id))) + if ownerObject.ODataType == nil { return nil, errors.New("ownerObject ODataType was nil") } @@ -436,15 +440,12 @@ func groupResourceCreate(ctx context.Context, d *schema.ResourceData, meta inter // First look for the calling principal in the specified owners; it should always be included in the initial // owners to avoid orphaning a group when the caller doesn't have the Groups.ReadWrite.All scope. - for _, id := range owners { - ownerObject, err := getOwnerObject(ctx, id.(string)) + for _, ownerId := range owners { + ownerObject, err := getOwnerObject(ctx, ownerId.(string)) if err != nil { - return tf.ErrorDiagF(err, "Could not retrieve owner principal object %q", id) + return tf.ErrorDiagF(err, "Could not retrieve owner principal object %q", ownerId) } if strings.EqualFold(*ownerObject.ID, callerId) { - if ownerObject.ODataId == nil { - return tf.ErrorDiagF(errors.New("ODataId was nil"), "Could not retrieve owner principal object %q", id) - } if ownerCount < 20 { ownersFirst20 = append(ownersFirst20, *ownerObject) } else { @@ -456,10 +457,10 @@ func groupResourceCreate(ctx context.Context, d *schema.ResourceData, meta inter // Then look for users, and finally service principals for _, t := range []odata.Type{odata.TypeUser, odata.TypeServicePrincipal} { - for _, id := range owners { - ownerObject, err := getOwnerObject(ctx, id.(string)) + for _, ownerId := range owners { + ownerObject, err := getOwnerObject(ctx, ownerId.(string)) if err != nil { - return tf.ErrorDiagF(err, "Could not retrieve owner principal object %q", id) + return tf.ErrorDiagF(err, "Could not retrieve owner principal object %q", ownerId) } if *ownerObject.ODataType == t && !strings.EqualFold(*ownerObject.ID, callerId) { if ownerCount < 20 { @@ -508,17 +509,21 @@ func groupResourceCreate(ctx context.Context, d *schema.ResourceData, meta inter // Add members after the group is created members := make(msgraph.Members, 0) if v, ok := d.GetOk("members"); ok { - for _, id := range v.(*schema.Set).List() { - memberObject, _, err := directoryObjectsClient.Get(ctx, id.(string), odata.Query{}) + for _, memberId := range v.(*schema.Set).List() { + memberObject, _, err := directoryObjectsClient.Get(ctx, memberId.(string), odata.Query{}) if err != nil { - return tf.ErrorDiagF(err, "Could not retrieve member principal object %q", id) + return tf.ErrorDiagF(err, "Could not retrieve member principal object %q", memberId) } if memberObject == nil { - return tf.ErrorDiagF(errors.New("memberObject was nil"), "Could not retrieve member principal object %q", id) - } - if memberObject.ODataId == nil { - return tf.ErrorDiagF(errors.New("ODataId was nil"), "Could not retrieve member principal object %q", id) + return tf.ErrorDiagF(errors.New("memberObject was nil"), "Could not retrieve member principal object %q", memberId) } + // TODO: remove this workaround for https://github.com/hashicorp/terraform-provider-azuread/issues/588 + //if memberObject.ODataId == nil { + // return tf.ErrorDiagF(errors.New("ODataId was nil"), "Could not retrieve member principal object %q", memberId) + //} + memberObject.ODataId = (*odata.Id)(utils.String(fmt.Sprintf("%s/v1.0/%s/directoryObjects/%s", + client.BaseClient.Endpoint, client.BaseClient.TenantId, memberId))) + members = append(members, *memberObject) } } @@ -603,14 +608,21 @@ func groupResourceUpdate(ctx context.Context, d *schema.ResourceData, meta inter if len(membersToAdd) > 0 { newMembers := make(msgraph.Members, 0) - for _, m := range membersToAdd { - memberObject, _, err := directoryObjectsClient.Get(ctx, m, odata.Query{}) + for _, memberId := range membersToAdd { + memberObject, _, err := directoryObjectsClient.Get(ctx, memberId, odata.Query{}) if err != nil { - return tf.ErrorDiagF(err, "Could not retrieve principal object %q", m) + return tf.ErrorDiagF(err, "Could not retrieve principal object %q", memberId) } if memberObject == nil { - return tf.ErrorDiagF(errors.New("returned memberObject was nil"), "Could not retrieve member principal object %q", m) + return tf.ErrorDiagF(errors.New("returned memberObject was nil"), "Could not retrieve member principal object %q", memberId) } + // TODO: remove this workaround for https://github.com/hashicorp/terraform-provider-azuread/issues/588 + //if ownerObject.ODataId == nil { + // return tf.ErrorDiagF(errors.New("ODataId was nil"), "Could not retrieve owner principal object %q", memberId) + //} + memberObject.ODataId = (*odata.Id)(utils.String(fmt.Sprintf("%s/v1.0/%s/directoryObjects/%s", + client.BaseClient.Endpoint, client.BaseClient.TenantId, memberId))) + newMembers = append(newMembers, *memberObject) } @@ -641,14 +653,21 @@ func groupResourceUpdate(ctx context.Context, d *schema.ResourceData, meta inter if len(ownersToAdd) > 0 { newOwners := make(msgraph.Owners, 0) - for _, m := range ownersToAdd { - ownerObject, _, err := directoryObjectsClient.Get(ctx, m, odata.Query{}) + for _, ownerId := range ownersToAdd { + ownerObject, _, err := directoryObjectsClient.Get(ctx, ownerId, odata.Query{}) if err != nil { - return tf.ErrorDiagF(err, "Could not retrieve owner principal object %q", m) + return tf.ErrorDiagF(err, "Could not retrieve owner principal object %q", ownerId) } if ownerObject == nil { - return tf.ErrorDiagF(errors.New("returned ownerObject was nil"), "Could not retrieve owner principal object %q", m) + return tf.ErrorDiagF(errors.New("returned ownerObject was nil"), "Could not retrieve owner principal object %q", ownerId) } + // TODO: remove this workaround for https://github.com/hashicorp/terraform-provider-azuread/issues/588 + //if ownerObject.ODataId == nil { + // return tf.ErrorDiagF(errors.New("ODataId was nil"), "Could not retrieve owner principal object %q", ownerId) + //} + ownerObject.ODataId = (*odata.Id)(utils.String(fmt.Sprintf("%s/v1.0/%s/directoryObjects/%s", + client.BaseClient.Endpoint, client.BaseClient.TenantId, ownerId))) + newOwners = append(newOwners, *ownerObject) } diff --git a/internal/services/serviceprincipals/service_principal_resource.go b/internal/services/serviceprincipals/service_principal_resource.go index d5bf9eb33e..ef7ae84b77 100644 --- a/internal/services/serviceprincipals/service_principal_resource.go +++ b/internal/services/serviceprincipals/service_principal_resource.go @@ -376,6 +376,13 @@ func servicePrincipalResourceCreate(ctx context.Context, d *schema.ResourceData, if callerObject == nil { return tf.ErrorDiagF(errors.New("returned callerObject was nil"), "Could not retrieve calling principal object %q", callerId) } + // TODO: remove this workaround for https://github.com/hashicorp/terraform-provider-azuread/issues/588 + //if callerObject.ODataId == nil { + // return tf.ErrorDiagF(errors.New("ODataId was nil"), "Could not retrieve calling principal object %q", callerId) + //} + callerObject.ODataId = (*odata.Id)(utils.String(fmt.Sprintf("%s/v1.0/%s/directoryObjects/%s", + client.BaseClient.Endpoint, client.BaseClient.TenantId, callerId))) + ownersFirst20 := msgraph.Owners{*callerObject} var ownersExtra msgraph.Owners @@ -385,21 +392,25 @@ func servicePrincipalResourceCreate(ctx context.Context, d *schema.ResourceData, // Retrieve and set the initial owners, which can be up to 20 in total when creating the service principal if v, ok := d.GetOk("owners"); ok { ownerCount := 0 - for _, id := range v.(*schema.Set).List() { - if strings.EqualFold(id.(string), callerId) { + for _, ownerId := range v.(*schema.Set).List() { + if strings.EqualFold(ownerId.(string), callerId) { removeCallerOwner = false continue } - ownerObject, _, err := directoryObjectsClient.Get(ctx, id.(string), odata.Query{}) + ownerObject, _, err := directoryObjectsClient.Get(ctx, ownerId.(string), odata.Query{}) if err != nil { - return tf.ErrorDiagF(err, "Could not retrieve owner principal object %q", id) + return tf.ErrorDiagF(err, "Could not retrieve owner principal object %q", ownerId) } if ownerObject == nil { - return tf.ErrorDiagF(errors.New("ownerObject was nil"), "Could not retrieve owner principal object %q", id) - } - if ownerObject.ODataId == nil { - return tf.ErrorDiagF(errors.New("ODataId was nil"), "Could not retrieve owner principal object %q", id) + return tf.ErrorDiagF(errors.New("ownerObject was nil"), "Could not retrieve owner principal object %q", ownerId) } + // TODO: remove this workaround for https://github.com/hashicorp/terraform-provider-azuread/issues/588 + //if ownerObject.ODataId == nil { + // return tf.ErrorDiagF(errors.New("ODataId was nil"), "Could not retrieve owner principal object %q", ownerId) + //} + ownerObject.ODataId = (*odata.Id)(utils.String(fmt.Sprintf("%s/v1.0/%s/directoryObjects/%s", + client.BaseClient.Endpoint, client.BaseClient.TenantId, ownerId))) + if ownerCount < 19 { ownersFirst20 = append(ownersFirst20, *ownerObject) } else { @@ -485,14 +496,20 @@ func servicePrincipalResourceUpdate(ctx context.Context, d *schema.ResourceData, if len(ownersToAdd) > 0 { newOwners := make(msgraph.Owners, 0) - for _, m := range ownersToAdd { - ownerObject, _, err := directoryObjectsClient.Get(ctx, m, odata.Query{}) + for _, ownerId := range ownersToAdd { + ownerObject, _, err := directoryObjectsClient.Get(ctx, ownerId, odata.Query{}) if err != nil { - return tf.ErrorDiagF(err, "Could not retrieve owner principal object %q", m) + return tf.ErrorDiagF(err, "Could not retrieve owner principal object %q", ownerId) } if ownerObject == nil { - return tf.ErrorDiagF(errors.New("returned ownerObject was nil"), "Could not retrieve owner principal object %q", m) + return tf.ErrorDiagF(errors.New("returned ownerObject was nil"), "Could not retrieve owner principal object %q", ownerId) } + // TODO: remove this workaround for https://github.com/hashicorp/terraform-provider-azuread/issues/588 + //if ownerObject.ODataId == nil { + // return tf.ErrorDiagF(errors.New("ODataId was nil"), "Could not retrieve owner principal object %q", ownerId) + //} + ownerObject.ODataId = (*odata.Id)(utils.String(fmt.Sprintf("%s/v1.0/%s/directoryObjects/%s", + client.BaseClient.Endpoint, client.BaseClient.TenantId, ownerId))) newOwners = append(newOwners, *ownerObject) } diff --git a/vendor/github.com/manicminer/hamilton/environments/published.go b/vendor/github.com/manicminer/hamilton/environments/published.go index a33374e1ed..82904447b3 100644 --- a/vendor/github.com/manicminer/hamilton/environments/published.go +++ b/vendor/github.com/manicminer/hamilton/environments/published.go @@ -45,6 +45,7 @@ var PublishedApis = map[string]ApiAppId{ "AzureSynapseGateway": "1ac05c7e-12d2-4605-bf9d-549d7041c6b3", "AzureSynapseStudio": "ec52d13d-2e85-410e-a89a-8c79fb6a32ac", "AzureTimeSeriesInsights": "120d688d-1518-4cf7-bd38-182f158850b6", + "AzureVPN": "41b23e61-6c1e-4545-b367-cd054e0ed4b4", "Bing": "9ea1ad79-fdb6-4f9a-8bc3-2b70f96e34c7", "BotFrameworkDevPortal": "f3723d34-6ff5-4ceb-a148-d99dcd2511fc", "BranchConnectWebService": "57084ef3-d413-4087-a28f-f6f3b1ad7786", diff --git a/vendor/github.com/manicminer/hamilton/msgraph/accesspackage.go b/vendor/github.com/manicminer/hamilton/msgraph/accesspackage.go index 8e85be81a4..e89efb8497 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/accesspackage.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/accesspackage.go @@ -25,10 +25,10 @@ func NewAccessPackageClient(tenantId string) *AccessPackageClient { func (c *AccessPackageClient) List(ctx context.Context, query odata.Query) (*[]AccessPackage, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ DisablePaging: query.Top > 0, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: "/identityGovernance/entitlementManagement/accessPackages", - Params: query.Values(), HasTenantId: true, }, }) @@ -90,10 +90,10 @@ func (c *AccessPackageClient) Create(ctx context.Context, accessPackage AccessPa func (c *AccessPackageClient) Get(ctx context.Context, id string, query odata.Query) (*AccessPackage, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/identityGovernance/entitlementManagement/accessPackages/%s", id), - Params: query.Values(), HasTenantId: true, }, }) diff --git a/vendor/github.com/manicminer/hamilton/msgraph/accesspackageassignmentpolicy.go b/vendor/github.com/manicminer/hamilton/msgraph/accesspackageassignmentpolicy.go index d5541f3418..5d3f537a4b 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/accesspackageassignmentpolicy.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/accesspackageassignmentpolicy.go @@ -25,10 +25,10 @@ func NewAccessPackageAssignmentPolicyClient(tenantId string) *AccessPackageAssig func (c *AccessPackageAssignmentPolicyClient) List(ctx context.Context, query odata.Query) (*[]AccessPackageAssignmentPolicy, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ DisablePaging: query.Top > 0, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: "/identityGovernance/entitlementManagement/accessPackageAssignmentPolicies", - Params: query.Values(), HasTenantId: true, }, }) @@ -90,10 +90,10 @@ func (c *AccessPackageAssignmentPolicyClient) Create(ctx context.Context, access func (c *AccessPackageAssignmentPolicyClient) Get(ctx context.Context, id string, query odata.Query) (*AccessPackageAssignmentPolicy, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/identityGovernance/entitlementManagement/accessPackageAssignmentPolicies/%s", id), - Params: query.Values(), HasTenantId: true, }, }) diff --git a/vendor/github.com/manicminer/hamilton/msgraph/accesspackagecatalog.go b/vendor/github.com/manicminer/hamilton/msgraph/accesspackagecatalog.go index 9f94c3c641..e417c024b9 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/accesspackagecatalog.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/accesspackagecatalog.go @@ -25,10 +25,10 @@ func NewAccessPackageCatalogClient(tenantId string) *AccessPackageCatalogClient func (c *AccessPackageCatalogClient) List(ctx context.Context, query odata.Query) (*[]AccessPackageCatalog, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ DisablePaging: query.Top > 0, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: "/identityGovernance/entitlementManagement/accessPackageCatalogs", - Params: query.Values(), HasTenantId: true, }, }) @@ -90,10 +90,10 @@ func (c *AccessPackageCatalogClient) Create(ctx context.Context, accessPackageCa func (c *AccessPackageCatalogClient) Get(ctx context.Context, id string, query odata.Query) (*AccessPackageCatalog, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/identityGovernance/entitlementManagement/accessPackageCatalogs/%s", id), - Params: query.Values(), HasTenantId: true, }, }) diff --git a/vendor/github.com/manicminer/hamilton/msgraph/accesspackageresource.go b/vendor/github.com/manicminer/hamilton/msgraph/accesspackageresource.go index 2600d93703..711694e19f 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/accesspackageresource.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/accesspackageresource.go @@ -24,10 +24,10 @@ func NewAccessPackageResourceClient(tenantId string) *AccessPackageResourceClien func (c *AccessPackageResourceClient) List(ctx context.Context, catalogId string, query odata.Query) (*[]AccessPackageResource, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ DisablePaging: query.Top > 0, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/identityGovernance/entitlementManagement/accessPackageCatalogs/%s/accessPackageResources", catalogId), - Params: query.Values(), HasTenantId: true, }, }) @@ -56,12 +56,12 @@ func (c *AccessPackageResourceClient) List(ctx context.Context, catalogId string func (c *AccessPackageResourceClient) Get(ctx context.Context, catalogId string, originId string) (*AccessPackageResource, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, - ValidStatusCodes: []int{http.StatusOK}, + OData: odata.Query{ + Filter: fmt.Sprintf("startswith(originId,'%s')", originId), + }, + ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ - Entity: fmt.Sprintf("/identityGovernance/entitlementManagement/accessPackageCatalogs/%s/accessPackageResources", catalogId), - Params: odata.Query{ - Filter: fmt.Sprintf("startswith(originId,'%s')", originId), - }.Values(), + Entity: fmt.Sprintf("/identityGovernance/entitlementManagement/accessPackageCatalogs/%s/accessPackageResources", catalogId), HasTenantId: true, }, }) diff --git a/vendor/github.com/manicminer/hamilton/msgraph/accesspackageresourcerolescope.go b/vendor/github.com/manicminer/hamilton/msgraph/accesspackageresourcerolescope.go index a50d05bb11..d908d253a0 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/accesspackageresourcerolescope.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/accesspackageresourcerolescope.go @@ -31,10 +31,10 @@ func (c *AccessPackageResourceRoleScopeClient) List(ctx context.Context, query o } resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/identityGovernance/entitlementManagement/accessPackages/%s", accessPackageId), - Params: query.Values(), HasTenantId: true, }, }) @@ -111,16 +111,15 @@ func (c *AccessPackageResourceRoleScopeClient) Create(ctx context.Context, acces // Get retrieves a AccessPackageResourceRoleScope. func (c *AccessPackageResourceRoleScopeClient) Get(ctx context.Context, accessPackageId string, id string) (*AccessPackageResourceRoleScope, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ + OData: odata.Query{ + Expand: odata.Expand{ + Relationship: "accessPackageResourceRoleScopes", + Select: []string{"accessPackageResourceRole", "accessPackageResourceScope"}, + }, + }, //The Resource we made a request to add ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ - Entity: fmt.Sprintf("/identityGovernance/entitlementManagement/accessPackages/%s", accessPackageId), - Params: odata.Query{ - Expand: odata.Expand{ - Relationship: "accessPackageResourceRoleScopes", - Select: []string{"accessPackageResourceRole", "accessPackageResourceScope"}, - }, - //Filter: fmt.Sprintf("startswith(originId,'%s')", id), - }.Values(), //The Resource we made a request to add + Entity: fmt.Sprintf("/identityGovernance/entitlementManagement/accessPackages/%s", accessPackageId), HasTenantId: true, }, }) diff --git a/vendor/github.com/manicminer/hamilton/msgraph/app_role_assignments.go b/vendor/github.com/manicminer/hamilton/msgraph/app_role_assignments.go index fadb5cca5f..6c077e8452 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/app_role_assignments.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/app_role_assignments.go @@ -156,11 +156,11 @@ func NewAppRoleAssignedToClient(tenantId string) *AppRoleAssignedToClient { // List returns a list of app role assignments granted for a service principal func (c *AppRoleAssignedToClient) List(ctx context.Context, id string, query odata.Query) (*[]AppRoleAssignment, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/servicePrincipals/%s/appRoleAssignedTo", id), HasTenantId: true, - Params: query.Values(), }, }) if err != nil { diff --git a/vendor/github.com/manicminer/hamilton/msgraph/application_templates.go b/vendor/github.com/manicminer/hamilton/msgraph/application_templates.go index 05d390b70f..60cb1444e0 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/application_templates.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/application_templates.go @@ -27,10 +27,10 @@ func NewApplicationTemplatesClient(tenantId string) *ApplicationTemplatesClient func (c *ApplicationTemplatesClient) List(ctx context.Context, query odata.Query) (*[]ApplicationTemplate, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ DisablePaging: query.Top > 0, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: "/applicationTemplates", - Params: query.Values(), HasTenantId: true, }, }) @@ -57,10 +57,10 @@ func (c *ApplicationTemplatesClient) List(ctx context.Context, query odata.Query // Get retrieves an ApplicationTemplate func (c *ApplicationTemplatesClient) Get(ctx context.Context, id string, query odata.Query) (*ApplicationTemplate, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/applicationTemplates/%s", id), - Params: query.Values(), HasTenantId: true, }, }) diff --git a/vendor/github.com/manicminer/hamilton/msgraph/applications.go b/vendor/github.com/manicminer/hamilton/msgraph/applications.go index 158aeaaee1..81b924af74 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/applications.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/applications.go @@ -27,10 +27,10 @@ func NewApplicationsClient(tenantId string) *ApplicationsClient { func (c *ApplicationsClient) List(ctx context.Context, query odata.Query) (*[]Application, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ DisablePaging: query.Top > 0, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: "/applications", - Params: query.Values(), HasTenantId: true, }, }) @@ -93,10 +93,10 @@ func (c *ApplicationsClient) Create(ctx context.Context, application Application func (c *ApplicationsClient) Get(ctx context.Context, id string, query odata.Query) (*Application, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/applications/%s", id), - Params: query.Values(), HasTenantId: true, }, }) @@ -123,10 +123,10 @@ func (c *ApplicationsClient) Get(ctx context.Context, id string, query odata.Que func (c *ApplicationsClient) GetDeleted(ctx context.Context, id string, query odata.Query) (*Application, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/directory/deletedItems/%s", id), - Params: query.Values(), HasTenantId: true, }, }) @@ -229,10 +229,10 @@ func (c *ApplicationsClient) DeletePermanently(ctx context.Context, id string) ( func (c *ApplicationsClient) ListDeleted(ctx context.Context, query odata.Query) (*[]Application, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ DisablePaging: query.Top > 0, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: "/directory/deleteditems/microsoft.graph.application", - Params: query.Values(), HasTenantId: true, }, }) @@ -355,10 +355,12 @@ func (c *ApplicationsClient) RemovePassword(ctx context.Context, applicationId s func (c *ApplicationsClient) ListOwners(ctx context.Context, id string) (*[]string, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, - ValidStatusCodes: []int{http.StatusOK}, + OData: odata.Query{ + Select: []string{"id"}, + }, + ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/applications/%s/owners", id), - Params: odata.Query{Select: []string{"id"}}.Values(), HasTenantId: true, }, }) @@ -396,10 +398,12 @@ func (c *ApplicationsClient) ListOwners(ctx context.Context, id string) (*[]stri func (c *ApplicationsClient) GetOwner(ctx context.Context, applicationId, ownerId string) (*string, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, - ValidStatusCodes: []int{http.StatusOK}, + OData: odata.Query{ + Select: []string{"id", "url"}, + }, + ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/applications/%s/owners/%s/$ref", applicationId, ownerId), - Params: odata.Query{Select: []string{"id", "url"}}.Values(), HasTenantId: true, }, }) @@ -518,10 +522,10 @@ func (c *ApplicationsClient) RemoveOwners(ctx context.Context, applicationId str func (c *ApplicationsClient) ListExtensions(ctx context.Context, id string, query odata.Query) (*[]ApplicationExtension, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/applications/%s/extensionProperties", id), - Params: query.Values(), HasTenantId: true, }, }) diff --git a/vendor/github.com/manicminer/hamilton/msgraph/authentication_methods.go b/vendor/github.com/manicminer/hamilton/msgraph/authentication_methods.go index 20285c8262..271ddc1821 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/authentication_methods.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/authentication_methods.go @@ -27,10 +27,10 @@ func NewAuthenticationMethodsClient(tenantId string) *AuthenticationMethodsClien func (c *AuthenticationMethodsClient) List(ctx context.Context, userID string, query odata.Query) (*[]AuthenticationMethod, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ DisablePaging: query.Top > 0, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/users/%s/authentication/methods", userID), - Params: query.Values(), HasTenantId: true, }, }) @@ -121,10 +121,10 @@ func (c *AuthenticationMethodsClient) List(ctx context.Context, userID string, q func (c *AuthenticationMethodsClient) ListFido2Methods(ctx context.Context, userID string, query odata.Query) (*[]Fido2AuthenticationMethod, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ DisablePaging: query.Top > 0, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/users/%s/authentication/fido2Methods", userID), - Params: query.Values(), HasTenantId: true, }, }) @@ -151,10 +151,10 @@ func (c *AuthenticationMethodsClient) ListFido2Methods(ctx context.Context, user func (c *AuthenticationMethodsClient) GetFido2Method(ctx context.Context, userID, id string, query odata.Query) (*Fido2AuthenticationMethod, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/users/%s/authentication/fido2Methods/%s", userID, id), - Params: query.Values(), HasTenantId: true, }, }) @@ -195,10 +195,10 @@ func (c *AuthenticationMethodsClient) DeleteFido2Method(ctx context.Context, use func (c *AuthenticationMethodsClient) ListMicrosoftAuthenticatorMethods(ctx context.Context, userID string, query odata.Query) (*[]MicrosoftAuthenticatorAuthenticationMethod, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ DisablePaging: query.Top > 0, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/users/%s/authentication/microsoftAuthenticatorMethods", userID), - Params: query.Values(), HasTenantId: true, }, }) @@ -225,10 +225,10 @@ func (c *AuthenticationMethodsClient) ListMicrosoftAuthenticatorMethods(ctx cont func (c *AuthenticationMethodsClient) GetMicrosoftAuthenticatorMethod(ctx context.Context, userID, id string, query odata.Query) (*MicrosoftAuthenticatorAuthenticationMethod, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/users/%s/authentication/microsoftAuthenticatorMethods/%s", userID, id), - Params: query.Values(), HasTenantId: true, }, }) @@ -269,10 +269,10 @@ func (c *AuthenticationMethodsClient) DeleteMicrosoftAuthenticatorMethod(ctx con func (c *AuthenticationMethodsClient) ListWindowsHelloMethods(ctx context.Context, userID string, query odata.Query) (*[]WindowsHelloForBusinessAuthenticationMethod, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ DisablePaging: query.Top > 0, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/users/%s/authentication/windowsHelloForBusinessMethods", userID), - Params: query.Values(), HasTenantId: true, }, }) @@ -299,10 +299,10 @@ func (c *AuthenticationMethodsClient) ListWindowsHelloMethods(ctx context.Contex func (c *AuthenticationMethodsClient) GetWindowsHelloMethod(ctx context.Context, userID, id string, query odata.Query) (*WindowsHelloForBusinessAuthenticationMethod, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/users/%s/authentication/windowsHelloForBusinessMethods/%s", userID, id), - Params: query.Values(), HasTenantId: true, }, }) @@ -343,10 +343,10 @@ func (c *AuthenticationMethodsClient) DeleteWindowsHelloMethod(ctx context.Conte func (c *AuthenticationMethodsClient) ListTemporaryAccessPassMethods(ctx context.Context, userID string, query odata.Query) (*[]TemporaryAccessPassAuthenticationMethod, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ DisablePaging: query.Top > 0, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/users/%s/authentication/temporaryAccessPassMethods", userID), - Params: query.Values(), HasTenantId: true, }, }) @@ -373,10 +373,10 @@ func (c *AuthenticationMethodsClient) ListTemporaryAccessPassMethods(ctx context func (c *AuthenticationMethodsClient) GetTemporaryAccessPassMethod(ctx context.Context, userID, id string, query odata.Query) (*TemporaryAccessPassAuthenticationMethod, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/users/%s/authentication/temporaryAccessPassMethods/%s", userID, id), - Params: query.Values(), HasTenantId: true, }, }) @@ -451,10 +451,10 @@ func (c *AuthenticationMethodsClient) DeleteTemporaryAccessPassMethod(ctx contex func (c *AuthenticationMethodsClient) ListPhoneMethods(ctx context.Context, userID string, query odata.Query) (*[]PhoneAuthenticationMethod, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ DisablePaging: query.Top > 0, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/users/%s/authentication/phoneMethods", userID), - Params: query.Values(), HasTenantId: true, }, }) @@ -481,10 +481,10 @@ func (c *AuthenticationMethodsClient) ListPhoneMethods(ctx context.Context, user func (c *AuthenticationMethodsClient) GetPhoneMethod(ctx context.Context, userID, id string, query odata.Query) (*PhoneAuthenticationMethod, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/users/%s/authentication/phoneMethods/%s", userID, id), - Params: query.Values(), HasTenantId: true, }, }) @@ -623,10 +623,10 @@ func (c *AuthenticationMethodsClient) DisablePhoneSMS(ctx context.Context, userI func (c *AuthenticationMethodsClient) ListEmailMethods(ctx context.Context, userID string, query odata.Query) (*[]EmailAuthenticationMethod, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ DisablePaging: query.Top > 0, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/users/%s/authentication/emailMethods", userID), - Params: query.Values(), HasTenantId: true, }, }) @@ -653,10 +653,10 @@ func (c *AuthenticationMethodsClient) ListEmailMethods(ctx context.Context, user func (c *AuthenticationMethodsClient) GetEmailMethod(ctx context.Context, userID, id string, query odata.Query) (*EmailAuthenticationMethod, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/users/%s/authentication/emailMethods/%s", userID, id), - Params: query.Values(), HasTenantId: true, }, }) @@ -759,10 +759,10 @@ func (c *AuthenticationMethodsClient) CreateEmailMethod(ctx context.Context, use func (c *AuthenticationMethodsClient) ListPasswordMethods(ctx context.Context, userID string, query odata.Query) (*[]PasswordAuthenticationMethod, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ DisablePaging: query.Top > 0, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/users/%s/authentication/passwordMethods", userID), - Params: query.Values(), HasTenantId: true, }, }) @@ -789,10 +789,9 @@ func (c *AuthenticationMethodsClient) ListPasswordMethods(ctx context.Context, u func (c *AuthenticationMethodsClient) GetPasswordMethod(ctx context.Context, userID, id string, query odata.Query) (*PasswordAuthenticationMethod, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ - Entity: fmt.Sprintf("/users/%s/authentication/passwordMethods/%s", userID, id), - Params: query.Values(), HasTenantId: true, }, }) diff --git a/vendor/github.com/manicminer/hamilton/msgraph/client.go b/vendor/github.com/manicminer/hamilton/msgraph/client.go index 1eee9f9b5f..3e958b86d9 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/client.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/client.go @@ -45,6 +45,7 @@ type ValidStatusFunc func(*http.Response, *odata.OData) bool type HttpRequestInput interface { GetConsistencyFailureFunc() ConsistencyFailureFunc GetContentType() string + GetOData() odata.Query GetValidStatusCodes() []int GetValidStatusFunc() ValidStatusFunc } @@ -132,6 +133,10 @@ func (c Client) buildUri(uri Uri) (string, error) { func (c Client) performRequest(req *http.Request, input HttpRequestInput) (*http.Response, int, *odata.OData, error) { var status int + query := input.GetOData() + req.Header = query.AppendHeaders(req.Header) + req.Header.Add("Content-Type", input.GetContentType()) + if c.Authorizer != nil { token, err := c.Authorizer.Token() if err != nil { @@ -140,10 +145,6 @@ func (c Client) performRequest(req *http.Request, input HttpRequestInput) (*http token.SetAuthHeader(req) } - req.Header.Add("Accept", "application/json") - req.Header.Add("Content-Type", input.GetContentType()) - //req.Header.Add("ConsistencyLevel", "eventual") - if c.UserAgent != "" { req.Header.Add("User-Agent", c.UserAgent) } @@ -256,6 +257,7 @@ func containsStatusCode(expected []int, actual int) bool { // DeleteHttpRequestInput configures a DELETE request. type DeleteHttpRequestInput struct { ConsistencyFailureFunc ConsistencyFailureFunc + OData odata.Query ValidStatusCodes []int ValidStatusFunc ValidStatusFunc Uri Uri @@ -271,6 +273,11 @@ func (i DeleteHttpRequestInput) GetContentType() string { return "application/json; charset=utf-8" } +// GetOData returns the OData request metadata +func (i DeleteHttpRequestInput) GetOData() odata.Query { + return i.OData +} + // GetValidStatusCodes returns a []int of status codes considered valid for a DELETE request. func (i DeleteHttpRequestInput) GetValidStatusCodes() []int { return i.ValidStatusCodes @@ -303,6 +310,7 @@ func (c Client) Delete(ctx context.Context, input DeleteHttpRequestInput) (*http type GetHttpRequestInput struct { ConsistencyFailureFunc ConsistencyFailureFunc DisablePaging bool + OData odata.Query ValidStatusCodes []int ValidStatusFunc ValidStatusFunc Uri Uri @@ -319,6 +327,11 @@ func (i GetHttpRequestInput) GetContentType() string { return "application/json; charset=utf-8" } +// GetOData returns the OData request metadata +func (i GetHttpRequestInput) GetOData() odata.Query { + return i.OData +} + // GetValidStatusCodes returns a []int of status codes considered valid for a GET request. func (i GetHttpRequestInput) GetValidStatusCodes() []int { return i.ValidStatusCodes @@ -336,6 +349,9 @@ func (c Client) Get(ctx context.Context, input GetHttpRequestInput) (*http.Respo // Check for a raw uri, else build one from the Uri field url := input.rawUri if url == "" { + // Append odata query parameters + input.Uri.Params = input.OData.AppendValues(input.Uri.Params) + var err error url, err = c.buildUri(input.Uri) if err != nil { @@ -422,6 +438,7 @@ func (c Client) Get(ctx context.Context, input GetHttpRequestInput) (*http.Respo type PatchHttpRequestInput struct { ConsistencyFailureFunc ConsistencyFailureFunc Body []byte + OData odata.Query ValidStatusCodes []int ValidStatusFunc ValidStatusFunc Uri Uri @@ -437,6 +454,11 @@ func (i PatchHttpRequestInput) GetContentType() string { return "application/json; charset=utf-8" } +// GetOData returns the OData request metadata +func (i PatchHttpRequestInput) GetOData() odata.Query { + return i.OData +} + // GetValidStatusCodes returns a []int of status codes considered valid for a PATCH request. func (i PatchHttpRequestInput) GetValidStatusCodes() []int { return i.ValidStatusCodes @@ -469,6 +491,7 @@ func (c Client) Patch(ctx context.Context, input PatchHttpRequestInput) (*http.R type PostHttpRequestInput struct { Body []byte ConsistencyFailureFunc ConsistencyFailureFunc + OData odata.Query ValidStatusCodes []int ValidStatusFunc ValidStatusFunc Uri Uri @@ -484,6 +507,11 @@ func (i PostHttpRequestInput) GetContentType() string { return "application/json; charset=utf-8" } +// GetOData returns the OData request metadata +func (i PostHttpRequestInput) GetOData() odata.Query { + return i.OData +} + // GetValidStatusCodes returns a []int of status codes considered valid for a POST request. func (i PostHttpRequestInput) GetValidStatusCodes() []int { return i.ValidStatusCodes @@ -517,6 +545,7 @@ type PutHttpRequestInput struct { ConsistencyFailureFunc ConsistencyFailureFunc ContentType string Body []byte + OData odata.Query ValidStatusCodes []int ValidStatusFunc ValidStatusFunc Uri Uri @@ -535,6 +564,11 @@ func (i PutHttpRequestInput) GetContentType() string { return "application/json; charset=utf-8" } +// GetOData returns the OData request metadata +func (i PutHttpRequestInput) GetOData() odata.Query { + return i.OData +} + // GetValidStatusCodes returns a []int of status codes considered valid for a PUT request. func (i PutHttpRequestInput) GetValidStatusCodes() []int { return i.ValidStatusCodes diff --git a/vendor/github.com/manicminer/hamilton/msgraph/conditionalaccesspolicy.go b/vendor/github.com/manicminer/hamilton/msgraph/conditionalaccesspolicy.go index 0c99d3a2a8..a1b9a77f53 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/conditionalaccesspolicy.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/conditionalaccesspolicy.go @@ -27,10 +27,10 @@ func NewConditionalAccessPolicyClient(tenantId string) *ConditionalAccessPolicyC func (c *ConditionalAccessPolicyClient) List(ctx context.Context, query odata.Query) (*[]ConditionalAccessPolicy, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ DisablePaging: query.Top > 0, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: "/identity/conditionalAccess/policies", - Params: query.Values(), HasTenantId: true, }, }) @@ -92,10 +92,10 @@ func (c *ConditionalAccessPolicyClient) Create(ctx context.Context, conditionalA func (c *ConditionalAccessPolicyClient) Get(ctx context.Context, id string, query odata.Query) (*ConditionalAccessPolicy, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/identity/conditionalAccess/policies/%s", id), - Params: query.Values(), HasTenantId: true, }, }) diff --git a/vendor/github.com/manicminer/hamilton/msgraph/directory_audit_reports.go b/vendor/github.com/manicminer/hamilton/msgraph/directory_audit_reports.go index 38cb78b02b..2d93d66934 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/directory_audit_reports.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/directory_audit_reports.go @@ -26,10 +26,10 @@ func NewDirectoryAuditReportsClient(tenantId string) *DirectoryAuditReportsClien func (c *DirectoryAuditReportsClient) List(ctx context.Context, query odata.Query) (*[]DirectoryAudit, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ DisablePaging: query.Top > 0, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: "/auditLogs/directoryAudits", - Params: query.Values(), HasTenantId: true, }, }) @@ -57,10 +57,10 @@ func (c *DirectoryAuditReportsClient) List(ctx context.Context, query odata.Quer func (c *DirectoryAuditReportsClient) Get(ctx context.Context, id string, query odata.Query) (*DirectoryAudit, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/auditLogs/directoryAudits/%s", id), - Params: query.Values(), HasTenantId: true, }, }) diff --git a/vendor/github.com/manicminer/hamilton/msgraph/directory_objects.go b/vendor/github.com/manicminer/hamilton/msgraph/directory_objects.go index f9183fd7cf..4fb2ccec56 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/directory_objects.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/directory_objects.go @@ -25,12 +25,14 @@ func NewDirectoryObjectsClient(tenantId string) *DirectoryObjectsClient { // Get retrieves a DirectoryObject. func (c *DirectoryObjectsClient) Get(ctx context.Context, id string, query odata.Query) (*DirectoryObject, int, error) { + query.Metadata = odata.MetadataFull + resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/directoryObjects/%s", id), - Params: query.Values(), HasTenantId: true, }, }) diff --git a/vendor/github.com/manicminer/hamilton/msgraph/directory_roles.go b/vendor/github.com/manicminer/hamilton/msgraph/directory_roles.go index 98cffad40c..35b546b21e 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/directory_roles.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/directory_roles.go @@ -110,10 +110,12 @@ func (c *DirectoryRolesClient) GetByTemplateId(ctx context.Context, templateId s // id is the object ID of the directory role. func (c *DirectoryRolesClient) ListMembers(ctx context.Context, id string) (*[]string, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ + OData: odata.Query{ + Select: []string{"id"}, + }, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/directoryRoles/%s/members", id), - Params: odata.Query{Select: []string{"id"}}.Values(), HasTenantId: true, }, }) @@ -228,10 +230,12 @@ func (c *DirectoryRolesClient) RemoveMembers(ctx context.Context, directoryRoleI // memberId is the object ID of the member object. func (c *DirectoryRolesClient) GetMember(ctx context.Context, directoryRoleId, memberId string) (*string, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ + OData: odata.Query{ + Select: []string{"id", "url"}, + }, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/directoryRoles/%s/members/%s/$ref", directoryRoleId, memberId), - Params: odata.Query{Select: []string{"id", "url"}}.Values(), HasTenantId: true, }, }) diff --git a/vendor/github.com/manicminer/hamilton/msgraph/domains.go b/vendor/github.com/manicminer/hamilton/msgraph/domains.go index 7a14c78b8f..9ff687f821 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/domains.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/domains.go @@ -27,9 +27,9 @@ func (c *DomainsClient) List(ctx context.Context, query odata.Query) (*[]Domain, var status int resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ ValidStatusCodes: []int{http.StatusOK}, + OData: query, Uri: Uri{ Entity: "/domains", - Params: query.Values(), HasTenantId: true, }, }) @@ -59,10 +59,10 @@ func (c *DomainsClient) Get(ctx context.Context, id string, query odata.Query) ( resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/domains/%s", id), - Params: query.Values(), HasTenantId: true, }, }) diff --git a/vendor/github.com/manicminer/hamilton/msgraph/groups.go b/vendor/github.com/manicminer/hamilton/msgraph/groups.go index 43e3de3a99..5ee3885c57 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/groups.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/groups.go @@ -26,10 +26,10 @@ func NewGroupsClient(tenantId string) *GroupsClient { func (c *GroupsClient) List(ctx context.Context, query odata.Query) (*[]Group, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ DisablePaging: query.Top > 0, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: "/groups", - Params: query.Values(), HasTenantId: true, }, }) @@ -100,10 +100,10 @@ func (c *GroupsClient) Create(ctx context.Context, group Group) (*Group, int, er func (c *GroupsClient) Get(ctx context.Context, id string, query odata.Query) (*Group, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/groups/%s", id), - Params: query.Values(), HasTenantId: true, }, }) @@ -145,10 +145,10 @@ func (c *GroupsClient) GetWithSchemaExtensions(ctx context.Context, id string, q var resp *http.Response resp, status, _, err = c.BaseClient.Get(ctx, GetHttpRequestInput{ ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/groups/%s", id), - Params: query.Values(), HasTenantId: true, }, }) @@ -174,10 +174,10 @@ func (c *GroupsClient) GetWithSchemaExtensions(ctx context.Context, id string, q func (c *GroupsClient) GetDeleted(ctx context.Context, id string, query odata.Query) (*Group, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/directory/deletedItems/%s", id), - Params: query.Values(), HasTenantId: true, }, }) @@ -262,10 +262,10 @@ func (c *GroupsClient) DeletePermanently(ctx context.Context, id string) (int, e func (c *GroupsClient) ListDeleted(ctx context.Context, query odata.Query) (*[]Group, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ DisablePaging: query.Top > 0, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: "/directory/deleteditems/microsoft.graph.group", - Params: query.Values(), HasTenantId: true, }, }) @@ -318,10 +318,12 @@ func (c *GroupsClient) RestoreDeleted(ctx context.Context, id string) (*Group, i func (c *GroupsClient) ListMembers(ctx context.Context, id string) (*[]string, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, - ValidStatusCodes: []int{http.StatusOK}, + OData: odata.Query{ + Select: []string{"id"}, + }, + ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/groups/%s/members", id), - Params: odata.Query{Select: []string{"id"}}.Values(), HasTenantId: true, }, }) @@ -359,10 +361,12 @@ func (c *GroupsClient) ListMembers(ctx context.Context, id string) (*[]string, i func (c *GroupsClient) GetMember(ctx context.Context, groupId, memberId string) (*string, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, - ValidStatusCodes: []int{http.StatusOK}, + OData: odata.Query{ + Select: []string{"id", "url"}, + }, + ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/groups/%s/members/%s/$ref", groupId, memberId), - Params: odata.Query{Select: []string{"id", "url"}}.Values(), HasTenantId: true, }, }) @@ -480,10 +484,12 @@ func (c *GroupsClient) RemoveMembers(ctx context.Context, id string, memberIds * func (c *GroupsClient) ListOwners(ctx context.Context, id string) (*[]string, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, - ValidStatusCodes: []int{http.StatusOK}, + OData: odata.Query{ + Select: []string{"id"}, + }, + ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/groups/%s/owners", id), - Params: odata.Query{Select: []string{"id"}}.Values(), HasTenantId: true, }, }) @@ -521,10 +527,12 @@ func (c *GroupsClient) ListOwners(ctx context.Context, id string) (*[]string, in func (c *GroupsClient) GetOwner(ctx context.Context, groupId, ownerId string) (*string, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, - ValidStatusCodes: []int{http.StatusOK}, + OData: odata.Query{ + Select: []string{"id", "url"}, + }, + ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/groups/%s/owners/%s/$ref", groupId, ownerId), - Params: odata.Query{Select: []string{"id", "url"}}.Values(), HasTenantId: true, }, }) diff --git a/vendor/github.com/manicminer/hamilton/msgraph/me.go b/vendor/github.com/manicminer/hamilton/msgraph/me.go index 40b3970f8b..93d147a73c 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/me.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/me.go @@ -27,10 +27,10 @@ func (c *MeClient) Get(ctx context.Context, query odata.Query) (*Me, int, error) var status int resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: "/me", - Params: query.Values(), HasTenantId: false, }, }) @@ -57,10 +57,10 @@ func (c *MeClient) GetProfile(ctx context.Context, query odata.Query) (*Me, int, var status int resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: "/me/profile", - Params: query.Values(), HasTenantId: false, }, }) diff --git a/vendor/github.com/manicminer/hamilton/msgraph/namedlocations.go b/vendor/github.com/manicminer/hamilton/msgraph/namedlocations.go index ac5c5845a6..7bd91edb07 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/namedlocations.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/namedlocations.go @@ -27,10 +27,10 @@ func NewNamedLocationsClient(tenantId string) *NamedLocationsClient { func (c *NamedLocationsClient) List(ctx context.Context, query odata.Query) (*[]NamedLocation, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ DisablePaging: query.Top > 0, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: "/identity/conditionalAccess/namedLocations", - Params: query.Values(), HasTenantId: true, }, }) @@ -183,10 +183,10 @@ func (c *NamedLocationsClient) CreateCountry(ctx context.Context, countryNamedLo func (c *NamedLocationsClient) GetIP(ctx context.Context, id string, query odata.Query) (*IPNamedLocation, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/identity/conditionalAccess/namedLocations/%s", id), - Params: query.Values(), HasTenantId: true, }, }) @@ -212,10 +212,10 @@ func (c *NamedLocationsClient) GetIP(ctx context.Context, id string, query odata func (c *NamedLocationsClient) Get(ctx context.Context, id string, query odata.Query) (*NamedLocation, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/identity/conditionalAccess/namedLocations/%s", id), - Params: query.Values(), HasTenantId: true, }, }) @@ -265,10 +265,10 @@ func (c *NamedLocationsClient) Get(ctx context.Context, id string, query odata.Q func (c *NamedLocationsClient) GetCountry(ctx context.Context, id string, query odata.Query) (*CountryNamedLocation, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/identity/conditionalAccess/namedLocations/%s", id), - Params: query.Values(), HasTenantId: true, }, }) diff --git a/vendor/github.com/manicminer/hamilton/msgraph/reports.go b/vendor/github.com/manicminer/hamilton/msgraph/reports.go index 61ca552457..477ea8ad61 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/reports.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/reports.go @@ -25,10 +25,10 @@ func NewReportsClient(tenantId string) *ReportsClient { func (c *ReportsClient) GetCredentialUserRegistrationCount(ctx context.Context, query odata.Query) (*[]CredentialUserRegistrationCount, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ DisablePaging: query.Top > 0, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: "/reports/getCredentialUserRegistrationCount", - Params: query.Values(), HasTenantId: true, }, }) @@ -55,10 +55,10 @@ func (c *ReportsClient) GetCredentialUserRegistrationCount(ctx context.Context, func (c *ReportsClient) GetCredentialUserRegistrationDetails(ctx context.Context, query odata.Query) (*[]CredentialUserRegistrationDetails, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ DisablePaging: query.Top > 0, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: "/reports/credentialUserRegistrationDetails", - Params: query.Values(), HasTenantId: true, }, }) @@ -85,10 +85,10 @@ func (c *ReportsClient) GetCredentialUserRegistrationDetails(ctx context.Context func (c *ReportsClient) GetUserCredentialUsageDetails(ctx context.Context, query odata.Query) (*[]UserCredentialUsageDetails, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ DisablePaging: query.Top > 0, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: "/reports/userCredentialUsageDetails", - Params: query.Values(), HasTenantId: true, }, }) @@ -115,10 +115,10 @@ func (c *ReportsClient) GetUserCredentialUsageDetails(ctx context.Context, query func (c *ReportsClient) GetCredentialUsageSummary(ctx context.Context, period CredentialUsageSummaryPeriod, query odata.Query) (*[]CredentialUsageSummary, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ DisablePaging: query.Top > 0, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/reports/getCredentialUsageSummary(period='%s')", period), - Params: query.Values(), HasTenantId: true, }, }) @@ -145,10 +145,10 @@ func (c *ReportsClient) GetCredentialUsageSummary(ctx context.Context, period Cr func (c *ReportsClient) GetAuthenticationMethodsUsersRegisteredByFeature(ctx context.Context, query odata.Query) (*UserRegistrationFeatureSummary, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ DisablePaging: query.Top > 0, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: "/reports/authenticationMethods/usersRegisteredByFeature", - Params: query.Values(), HasTenantId: true, }, }) @@ -173,10 +173,10 @@ func (c *ReportsClient) GetAuthenticationMethodsUsersRegisteredByFeature(ctx con func (c *ReportsClient) GetAuthenticationMethodsUsersRegisteredByMethod(ctx context.Context, query odata.Query) (*UserRegistrationMethodSummary, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ DisablePaging: query.Top > 0, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: "/reports/authenticationMethods/usersRegisteredByMethod", - Params: query.Values(), HasTenantId: true, }, }) diff --git a/vendor/github.com/manicminer/hamilton/msgraph/schema_extensions.go b/vendor/github.com/manicminer/hamilton/msgraph/schema_extensions.go index 9cb378bcf1..8a40a811e1 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/schema_extensions.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/schema_extensions.go @@ -26,10 +26,10 @@ func NewSchemaExtensionsClient(tenantId string) *SchemaExtensionsClient { func (c *SchemaExtensionsClient) List(ctx context.Context, query odata.Query) (*[]SchemaExtension, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ DisablePaging: query.Top > 0, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: "/schemaExtensions", - Params: query.Values(), HasTenantId: true, }, }) @@ -57,10 +57,10 @@ func (c *SchemaExtensionsClient) List(ctx context.Context, query odata.Query) (* func (c *SchemaExtensionsClient) Get(ctx context.Context, id string, query odata.Query) (*SchemaExtension, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/schemaExtensions/%s", id), - Params: query.Values(), HasTenantId: true, }, }) diff --git a/vendor/github.com/manicminer/hamilton/msgraph/serviceprincipals.go b/vendor/github.com/manicminer/hamilton/msgraph/serviceprincipals.go index cd7f7cef64..bb9340be3e 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/serviceprincipals.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/serviceprincipals.go @@ -27,10 +27,10 @@ func NewServicePrincipalsClient(tenantId string) *ServicePrincipalsClient { func (c *ServicePrincipalsClient) List(ctx context.Context, query odata.Query) (*[]ServicePrincipal, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ DisablePaging: query.Top > 0, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: "/servicePrincipals", - Params: query.Values(), HasTenantId: true, }, }) @@ -106,10 +106,10 @@ func (c *ServicePrincipalsClient) Create(ctx context.Context, servicePrincipal S func (c *ServicePrincipalsClient) Get(ctx context.Context, id string, query odata.Query) (*ServicePrincipal, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/servicePrincipals/%s", id), - Params: query.Values(), HasTenantId: true, }, }) @@ -182,10 +182,12 @@ func (c *ServicePrincipalsClient) Delete(ctx context.Context, id string) (int, e func (c *ServicePrincipalsClient) ListOwners(ctx context.Context, id string) (*[]string, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, - ValidStatusCodes: []int{http.StatusOK}, + OData: odata.Query{ + Select: []string{"id"}, + }, + ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/servicePrincipals/%s/owners", id), - Params: odata.Query{Select: []string{"id"}}.Values(), HasTenantId: true, }, }) @@ -223,10 +225,12 @@ func (c *ServicePrincipalsClient) ListOwners(ctx context.Context, id string) (*[ func (c *ServicePrincipalsClient) GetOwner(ctx context.Context, servicePrincipalId, ownerId string) (*string, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, - ValidStatusCodes: []int{http.StatusOK}, + OData: odata.Query{ + Select: []string{"id", "url"}, + }, + ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/servicePrincipals/%s/owners/%s/$ref", servicePrincipalId, ownerId), - Params: odata.Query{Select: []string{"id", "url"}}.Values(), HasTenantId: true, }, }) @@ -344,12 +348,12 @@ func (c *ServicePrincipalsClient) RemoveOwners(ctx context.Context, servicePrinc // ListGroupMemberships returns a list of Groups the Service Principal is member of, optionally queried using OData. func (c *ServicePrincipalsClient) ListGroupMemberships(ctx context.Context, id string, query odata.Query) (*[]Group, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ - DisablePaging: query.Top > 0, ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + DisablePaging: query.Top > 0, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/servicePrincipals/%s/transitiveMemberOf", id), - Params: query.Values(), HasTenantId: true, }, }) @@ -447,10 +451,12 @@ func (c *ServicePrincipalsClient) RemovePassword(ctx context.Context, servicePri func (c *ServicePrincipalsClient) ListOwnedObjects(ctx context.Context, id string) (*[]string, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, - ValidStatusCodes: []int{http.StatusOK}, + OData: odata.Query{ + Select: []string{"id"}, + }, + ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/servicePrincipals/%s/ownedObjects", id), - Params: odata.Query{Select: []string{"id"}}.Values(), HasTenantId: true, }, }) @@ -482,10 +488,10 @@ func (c *ServicePrincipalsClient) ListOwnedObjects(ctx context.Context, id strin func (c *ServicePrincipalsClient) ListAppRoleAssignments(ctx context.Context, resourceId string, query odata.Query) (*[]AppRoleAssignment, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/servicePrincipals/%s/appRoleAssignedTo", resourceId), - Params: query.Values(), HasTenantId: true, }, }) diff --git a/vendor/github.com/manicminer/hamilton/msgraph/sign_in_reports.go b/vendor/github.com/manicminer/hamilton/msgraph/sign_in_reports.go index 73706832df..4075aa193b 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/sign_in_reports.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/sign_in_reports.go @@ -32,12 +32,12 @@ func (c *SignInReportsClient) List(ctx context.Context, query odata.Query) (*[]S } resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ - DisablePaging: query.Top > 0, ConsistencyFailureFunc: unknownError, + DisablePaging: query.Top > 0, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: "/auditLogs/signIns", - Params: query.Values(), HasTenantId: true, }, }) @@ -65,10 +65,10 @@ func (c *SignInReportsClient) List(ctx context.Context, query odata.Query) (*[]S func (c *SignInReportsClient) Get(ctx context.Context, id string, query odata.Query) (*SignInReport, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/auditLogs/signIns/%s", id), - Params: query.Values(), HasTenantId: true, }, }) diff --git a/vendor/github.com/manicminer/hamilton/msgraph/users.go b/vendor/github.com/manicminer/hamilton/msgraph/users.go index 83b36c9d6a..9606761adc 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/users.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/users.go @@ -26,10 +26,10 @@ func NewUsersClient(tenantId string) *UsersClient { func (c *UsersClient) List(ctx context.Context, query odata.Query) (*[]User, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ DisablePaging: query.Top > 0, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: "/users", - Params: query.Values(), HasTenantId: true, }, }) @@ -92,10 +92,10 @@ func (c *UsersClient) Create(ctx context.Context, user User) (*User, int, error) func (c *UsersClient) Get(ctx context.Context, id string, query odata.Query) (*User, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/users/%s", id), - Params: query.Values(), HasTenantId: true, }, }) @@ -137,10 +137,10 @@ func (c *UsersClient) GetWithSchemaExtensions(ctx context.Context, id string, qu var resp *http.Response resp, status, _, err = c.BaseClient.Get(ctx, GetHttpRequestInput{ ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/users/%s", id), - Params: query.Values(), HasTenantId: true, }, }) @@ -166,10 +166,10 @@ func (c *UsersClient) GetWithSchemaExtensions(ctx context.Context, id string, qu func (c *UsersClient) GetDeleted(ctx context.Context, id string, query odata.Query) (*User, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/directory/deletedItems/%s", id), - Params: query.Values(), HasTenantId: true, }, }) @@ -254,10 +254,10 @@ func (c *UsersClient) DeletePermanently(ctx context.Context, id string) (int, er func (c *UsersClient) ListDeleted(ctx context.Context, query odata.Query) (*[]User, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ DisablePaging: query.Top > 0, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: "/directory/deleteditems/microsoft.graph.user", - Params: query.Values(), HasTenantId: true, }, }) @@ -308,12 +308,12 @@ func (c *UsersClient) RestoreDeleted(ctx context.Context, id string) (*User, int // ListGroupMemberships returns a list of Groups the user is member of, optionally queried using OData. func (c *UsersClient) ListGroupMemberships(ctx context.Context, id string, query odata.Query) (*[]Group, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ - DisablePaging: query.Top > 0, ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + DisablePaging: query.Top > 0, + OData: query, ValidStatusCodes: []int{http.StatusOK}, Uri: Uri{ Entity: fmt.Sprintf("/users/%s/transitiveMemberOf", id), - Params: query.Values(), HasTenantId: true, }, }) @@ -361,3 +361,53 @@ func (c *UsersClient) Sendmail(ctx context.Context, id string, message MailMessa return status, nil } + +// GetManager retrieves an user or organizational contact assigned as the user's manager. +func (c *UsersClient) GetManager(ctx context.Context, id string) (*User, int, error) { + resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ + ValidStatusCodes: []int{http.StatusOK}, + Uri: Uri{ + Entity: fmt.Sprintf("/users/%s/manager", id), + }, + }) + if err != nil { + return nil, status, err + } + + defer resp.Body.Close() + respBody, _ := io.ReadAll(resp.Body) + var manager User + if err := json.Unmarshal(respBody, &manager); err != nil { + return nil, status, err + } + + return &manager, status, nil +} + +// AssignManager assigns a user's manager. +func (c *UsersClient) AssignManager(ctx context.Context, id string, manager User) (int, error) { + var status int + + body, err := json.Marshal(struct { + Manager odata.Id `json:"@odata.id"` + }{ + Manager: *manager.ODataId, + }) + if err != nil { + return status, fmt.Errorf("json.Marshal(): %v", err) + } + + _, status, _, err = c.BaseClient.Put(ctx, PutHttpRequestInput{ + Body: body, + ValidStatusCodes: []int{http.StatusNoContent}, + Uri: Uri{ + Entity: fmt.Sprintf("/users/%s/manager/$ref", id), + HasTenantId: true, + }, + }) + if err != nil { + return status, fmt.Errorf("UsersClient.BaseClient.Post(): %v", err) + } + + return status, nil +} diff --git a/vendor/github.com/manicminer/hamilton/odata/errors.go b/vendor/github.com/manicminer/hamilton/odata/errors.go new file mode 100644 index 0000000000..84c8b50b3a --- /dev/null +++ b/vendor/github.com/manicminer/hamilton/odata/errors.go @@ -0,0 +1,12 @@ +package odata + +const ( + ErrorAddedObjectReferencesAlreadyExist = "One or more added object references already exist" + ErrorCannotDeleteOrUpdateEnabledEntitlement = "Permission (scope or role) cannot be deleted or updated unless disabled first" + ErrorConflictingObjectPresentInDirectory = "A conflicting object with one or more of the specified property values is present in the directory" + ErrorResourceDoesNotExist = "Resource '.+' does not exist or one of its queried reference-property objects are not present" + ErrorRemovedObjectReferencesDoNotExist = "One or more removed object references do not exist" + ErrorServicePrincipalAppInOtherTenant = "When using this permission, the backing application of the service principal being created must in the local tenant" + ErrorServicePrincipalInvalidAppId = "The appId '.+' of the service principal does not reference a valid application object" + ErrorUnknownUnsupportedQuery = "UnknownError: Unsupported Query" +) diff --git a/vendor/github.com/manicminer/hamilton/odata/odata.go b/vendor/github.com/manicminer/hamilton/odata/odata.go index 804ffc2a4d..cfb08bdc75 100644 --- a/vendor/github.com/manicminer/hamilton/odata/odata.go +++ b/vendor/github.com/manicminer/hamilton/odata/odata.go @@ -7,16 +7,7 @@ import ( "strings" ) -const ( - ErrorAddedObjectReferencesAlreadyExist = "One or more added object references already exist" - ErrorCannotDeleteOrUpdateEnabledEntitlement = "Permission (scope or role) cannot be deleted or updated unless disabled first" - ErrorConflictingObjectPresentInDirectory = "A conflicting object with one or more of the specified property values is present in the directory" - ErrorResourceDoesNotExist = "Resource '.+' does not exist or one of its queried reference-property objects are not present" - ErrorRemovedObjectReferencesDoNotExist = "One or more removed object references do not exist" - ErrorServicePrincipalAppInOtherTenant = "When using this permission, the backing application of the service principal being created must in the local tenant" - ErrorServicePrincipalInvalidAppId = "The appId '.+' of the service principal does not reference a valid application object" - ErrorUnknownUnsupportedQuery = "UnknownError: Unsupported Query" -) +const ODataVersion = "4.0" // TODO: support 4.01 - https://docs.oasis-open.org/odata/odata-json-format/v4.01/cs01/odata-json-format-v4.01-cs01.html#_Toc499720587 type Id string @@ -29,75 +20,16 @@ func (o *Id) UnmarshalJSON(data []byte) error { return nil } -type ShortType = string - -const ( - ShortTypeAccessPackage ShortType = "accessPackage" - ShortTypeAccessPackageAssignmentPolicy ShortType = "accessPackageAssignmentPolicy" - ShortTypeAccessPackageCatalog ShortType = "accessPackageCatalog" - ShortTypeAccessPackageResourceRequest ShortType = "accessPackageResourceRequest" - ShortTypeAdministrativeUnit ShortType = "administrativeUnit" - ShortTypeApplication ShortType = "application" - ShortTypeConditionalAccessPolicy ShortType = "conditionalAccessPolicy" - ShortTypeConnectedOrganizationMembers ShortType = "connectedOrganizationMembers" - ShortTypeConnectionInfo ShortType = "connectionInfo" - ShortTypeCountryNamedLocation ShortType = "countryNamedLocation" - ShortTypeDevice ShortType = "device" - ShortTypeDirectoryRole ShortType = "directoryRole" - ShortTypeDirectoryRoleTemplate ShortType = "directoryRoleTemplate" - ShortTypeDomain ShortType = "domain" - ShortTypeEmailAuthenticationMethod ShortType = "emailAuthenticationMethod" - ShortTypeFido2AuthenticationMethod ShortType = "fido2AuthenticationMethod" - ShortTypeGroup ShortType = "group" - ShortTypeGroupMembers ShortType = "groupMembers" - ShortTypeIpNamedLocation ShortType = "ipNamedLocation" - ShortTypeNamedLocation ShortType = "namedLocation" - ShortTypeMicrosoftAuthenticatorAuthenticationMethod ShortType = "microsoftAuthenticatorAuthenticationMethod" - ShortTypeOrganization ShortType = "organization" - ShortTypePasswordAuthenticationMethod ShortType = "passwordAuthenticationMethod" - ShortTypePhoneAuthenticationMethod ShortType = "phoneAuthenticationMethod" - ShortTypeServicePrincipal ShortType = "servicePrincipal" - ShortTypeSingleUser ShortType = "singleUser" - ShortTypeSocialIdentityProvider ShortType = "socialIdentityProvider" - ShortTypeTemporaryAccessPassAuthenticationMethod ShortType = "temporaryAccessPassAuthenticationMethod" - ShortTypeUser ShortType = "user" - ShortTypeWindowsHelloForBusinessAuthenticationMethod ShortType = "windowsHelloForBusinessAuthenticationMethod" -) +type Link string -type Type = string - -const ( - TypeAccessPackage Type = "#microsoft.graph.accessPackage" - TypeAccessPackageAssignmentPolicy Type = "#microsoft.graph.accessPackageAssignmentPolicy" - TypeAccessPackageCatalog Type = "#microsoft.graph.accessPackageCatalog" - TypeAccessPackageResourceRequest Type = "#microsoft.graph.accessPackageResourceRequest" - TypeAdministrativeUnit Type = "#microsoft.graph.administrativeUnit" - TypeApplication Type = "#microsoft.graph.application" - TypeConditionalAccessPolicy Type = "#microsoft.graph.conditionalAccessPolicy" - TypeConnectedOrganizationMembers Type = "#microsoft.graph.connectedOrganizationMembers" - TypeConnectionInfo Type = "#microsoft.graph.connectionInfo" - TypeCountryNamedLocation Type = "#microsoft.graph.countryNamedLocation" - TypeDevice Type = "#microsoft.graph.device" - TypeDirectoryRole Type = "#microsoft.graph.directoryRole" - TypeDirectoryRoleTemplate Type = "#microsoft.graph.directoryRoleTemplate" - TypeDomain Type = "#microsoft.graph.domain" - TypeEmailAuthenticationMethod Type = "#microsoft.graph.emailAuthenticationMethod" - TypeFido2AuthenticationMethod Type = "#microsoft.graph.fido2AuthenticationMethod" - TypeGroup Type = "#microsoft.graph.group" - TypeGroupMembers Type = "#microsoft.graph.groupMembers" - TypeIpNamedLocation Type = "#microsoft.graph.ipNamedLocation" - TypeNamedLocation Type = "#microsoft.graph.namedLocation" - TypeMicrosoftAuthenticatorAuthenticationMethod Type = "#microsoft.graph.microsoftAuthenticatorAuthenticationMethod" - TypeOrganization Type = "#microsoft.graph.organization" - TypePasswordAuthenticationMethod Type = "#microsoft.graph.passwordAuthenticationMethod" - TypePhoneAuthenticationMethod Type = "#microsoft.graph.phoneAuthenticationMethod" - TypeServicePrincipal Type = "#microsoft.graph.servicePrincipal" - TypeSingleUser Type = "#microsoft.graph.singleUser" - TypeSocialIdentityProvider Type = "#microsoft.graph.socialIdentityProvider" - TypeTemporaryAccessPassAuthenticationMethod Type = "#microsoft.graph.temporaryAccessPassAuthenticationMethod" - TypeUser Type = "#microsoft.graph.user" - TypeWindowsHelloForBusinessAuthenticationMethod Type = "#microsoft.graph.windowsHelloForBusinessAuthenticationMethod" -) +func (o *Link) UnmarshalJSON(data []byte) error { + var link string + if err := json.Unmarshal(data, &link); err != nil { + return err + } + *o = Link(regexp.MustCompile(`/v2/`).ReplaceAllString(link, `/v1.0/`)) + return nil +} // OData is used to unmarshall OData metadata from an API response. type OData struct { @@ -109,6 +41,7 @@ type OData struct { Delta *string `json:"@odata.delta"` DeltaLink *string `json:"@odata.deltaLink"` Id *Id `json:"@odata.id"` + EditLink *Link `json:"@odata.editLink"` Etag *string `json:"@odata.etag"` Error *Error `json:"-"` diff --git a/vendor/github.com/manicminer/hamilton/odata/query.go b/vendor/github.com/manicminer/hamilton/odata/query.go index 3e79e96c7f..d66bfe890e 100644 --- a/vendor/github.com/manicminer/hamilton/odata/query.go +++ b/vendor/github.com/manicminer/hamilton/odata/query.go @@ -2,12 +2,33 @@ package odata import ( "fmt" + "net/http" "net/url" "strconv" "strings" ) +type ConsistencyLevel string + +const ( + ConsistencyLevelEventual ConsistencyLevel = "eventual" +) + +type Metadata string + +const ( + MetadataFull Metadata = "full" + MetadataMinimal Metadata = "minimal" + MetadataNone Metadata = "none" +) + type Query struct { + // ConsistencyLevel sets the corresponding http header + ConsistencyLevel ConsistencyLevel + + // Metadata indicates how much control information is requested (services assume "minimal" when not specified) + Metadata Metadata + // Count includes a count of the total number of items in a collection alongside the page of data values Count bool @@ -36,6 +57,41 @@ type Query struct { Top int } +// Headers returns an http.Header map containing OData specific headers, for use in requests +func (q Query) Headers() http.Header { + // Take extra care over canonicalization of header names + headers := http.Header{ + "Odata-Maxversion": []string{ODataVersion}, + "Odata-Version": []string{ODataVersion}, + } + + accept := "application/json; charset=utf-8; IEEE754Compatible=false" + if q.Metadata != "" { + accept = fmt.Sprintf("%s; odata.metadata=%s", accept, q.Metadata) + } + headers.Set("Accept", accept) + + if q.ConsistencyLevel != "" { + headers.Set("Consistencylevel", string(q.ConsistencyLevel)) + } + + return headers +} + +// AppendHeaders returns the provided http.Header map with OData specific headers appended, for use in requests +func (q Query) AppendHeaders(header http.Header) http.Header { + if header == nil { + header = http.Header{} + } + for k, v := range q.Headers() { + if len(v) > 0 { + header.Set(k, v[0]) + } + } + return header +} + +// Values returns a url.Values map containing OData specific query parameters, for use in requests func (q Query) Values() url.Values { p := url.Values{} if q.Count { @@ -68,6 +124,19 @@ func (q Query) Values() url.Values { return p } +// AppendValues returns the provided url.Values map with OData specific query parameters appended, for use in requests +func (q Query) AppendValues(values url.Values) url.Values { + if values == nil { + values = url.Values{} + } + for k, v := range q.Values() { + if len(v) > 0 { + values.Set(k, v[0]) + } + } + return values +} + type Expand struct { Relationship string Select []string diff --git a/vendor/github.com/manicminer/hamilton/odata/types.go b/vendor/github.com/manicminer/hamilton/odata/types.go new file mode 100644 index 0000000000..0f6976d9c0 --- /dev/null +++ b/vendor/github.com/manicminer/hamilton/odata/types.go @@ -0,0 +1,71 @@ +package odata + +type ShortType = string + +const ( + ShortTypeAccessPackage ShortType = "accessPackage" + ShortTypeAccessPackageAssignmentPolicy ShortType = "accessPackageAssignmentPolicy" + ShortTypeAccessPackageCatalog ShortType = "accessPackageCatalog" + ShortTypeAccessPackageResourceRequest ShortType = "accessPackageResourceRequest" + ShortTypeAdministrativeUnit ShortType = "administrativeUnit" + ShortTypeApplication ShortType = "application" + ShortTypeConditionalAccessPolicy ShortType = "conditionalAccessPolicy" + ShortTypeConnectedOrganizationMembers ShortType = "connectedOrganizationMembers" + ShortTypeConnectionInfo ShortType = "connectionInfo" + ShortTypeCountryNamedLocation ShortType = "countryNamedLocation" + ShortTypeDevice ShortType = "device" + ShortTypeDirectoryRole ShortType = "directoryRole" + ShortTypeDirectoryRoleTemplate ShortType = "directoryRoleTemplate" + ShortTypeDomain ShortType = "domain" + ShortTypeEmailAuthenticationMethod ShortType = "emailAuthenticationMethod" + ShortTypeFido2AuthenticationMethod ShortType = "fido2AuthenticationMethod" + ShortTypeGroup ShortType = "group" + ShortTypeGroupMembers ShortType = "groupMembers" + ShortTypeIpNamedLocation ShortType = "ipNamedLocation" + ShortTypeNamedLocation ShortType = "namedLocation" + ShortTypeMicrosoftAuthenticatorAuthenticationMethod ShortType = "microsoftAuthenticatorAuthenticationMethod" + ShortTypeOrganization ShortType = "organization" + ShortTypePasswordAuthenticationMethod ShortType = "passwordAuthenticationMethod" + ShortTypePhoneAuthenticationMethod ShortType = "phoneAuthenticationMethod" + ShortTypeServicePrincipal ShortType = "servicePrincipal" + ShortTypeSingleUser ShortType = "singleUser" + ShortTypeSocialIdentityProvider ShortType = "socialIdentityProvider" + ShortTypeTemporaryAccessPassAuthenticationMethod ShortType = "temporaryAccessPassAuthenticationMethod" + ShortTypeUser ShortType = "user" + ShortTypeWindowsHelloForBusinessAuthenticationMethod ShortType = "windowsHelloForBusinessAuthenticationMethod" +) + +type Type = string + +const ( + TypeAccessPackage Type = "#microsoft.graph.accessPackage" + TypeAccessPackageAssignmentPolicy Type = "#microsoft.graph.accessPackageAssignmentPolicy" + TypeAccessPackageCatalog Type = "#microsoft.graph.accessPackageCatalog" + TypeAccessPackageResourceRequest Type = "#microsoft.graph.accessPackageResourceRequest" + TypeAdministrativeUnit Type = "#microsoft.graph.administrativeUnit" + TypeApplication Type = "#microsoft.graph.application" + TypeConditionalAccessPolicy Type = "#microsoft.graph.conditionalAccessPolicy" + TypeConnectedOrganizationMembers Type = "#microsoft.graph.connectedOrganizationMembers" + TypeConnectionInfo Type = "#microsoft.graph.connectionInfo" + TypeCountryNamedLocation Type = "#microsoft.graph.countryNamedLocation" + TypeDevice Type = "#microsoft.graph.device" + TypeDirectoryRole Type = "#microsoft.graph.directoryRole" + TypeDirectoryRoleTemplate Type = "#microsoft.graph.directoryRoleTemplate" + TypeDomain Type = "#microsoft.graph.domain" + TypeEmailAuthenticationMethod Type = "#microsoft.graph.emailAuthenticationMethod" + TypeFido2AuthenticationMethod Type = "#microsoft.graph.fido2AuthenticationMethod" + TypeGroup Type = "#microsoft.graph.group" + TypeGroupMembers Type = "#microsoft.graph.groupMembers" + TypeIpNamedLocation Type = "#microsoft.graph.ipNamedLocation" + TypeNamedLocation Type = "#microsoft.graph.namedLocation" + TypeMicrosoftAuthenticatorAuthenticationMethod Type = "#microsoft.graph.microsoftAuthenticatorAuthenticationMethod" + TypeOrganization Type = "#microsoft.graph.organization" + TypePasswordAuthenticationMethod Type = "#microsoft.graph.passwordAuthenticationMethod" + TypePhoneAuthenticationMethod Type = "#microsoft.graph.phoneAuthenticationMethod" + TypeServicePrincipal Type = "#microsoft.graph.servicePrincipal" + TypeSingleUser Type = "#microsoft.graph.singleUser" + TypeSocialIdentityProvider Type = "#microsoft.graph.socialIdentityProvider" + TypeTemporaryAccessPassAuthenticationMethod Type = "#microsoft.graph.temporaryAccessPassAuthenticationMethod" + TypeUser Type = "#microsoft.graph.user" + TypeWindowsHelloForBusinessAuthenticationMethod Type = "#microsoft.graph.windowsHelloForBusinessAuthenticationMethod" +) diff --git a/vendor/modules.txt b/vendor/modules.txt index bb8722137e..d92ed92bd8 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -192,7 +192,7 @@ github.com/klauspost/compress/fse github.com/klauspost/compress/huff0 github.com/klauspost/compress/zstd github.com/klauspost/compress/zstd/internal/xxhash -# github.com/manicminer/hamilton v0.31.1 +# github.com/manicminer/hamilton v0.32.0 ## explicit github.com/manicminer/hamilton/auth github.com/manicminer/hamilton/environments