diff --git a/internal/clients/builder.go b/internal/clients/builder.go index eb3bd8b6de..0cab335718 100644 --- a/internal/clients/builder.go +++ b/internal/clients/builder.go @@ -4,10 +4,10 @@ import ( "context" "fmt" + "github.com/hashicorp/terraform-provider-azuread/internal/common" "github.com/manicminer/hamilton/auth" "github.com/manicminer/hamilton/environments" - - "github.com/hashicorp/terraform-provider-azuread/internal/common" + "github.com/manicminer/hamilton/msgraph" ) type ClientBuilder struct { @@ -53,6 +53,7 @@ func (b *ClientBuilder) Build(ctx context.Context) (*Client, error) { o := &common.ClientOptions{ Authorizer: authorizer, + ApiVersion: msgraph.Version10, Environment: client.Environment, TenantID: client.TenantID, diff --git a/internal/common/client_options.go b/internal/common/client_options.go index 77019638f5..1406553ebb 100644 --- a/internal/common/client_options.go +++ b/internal/common/client_options.go @@ -11,11 +11,10 @@ import ( "github.com/hashicorp/go-uuid" "github.com/hashicorp/terraform-plugin-sdk/v2/meta" + "github.com/hashicorp/terraform-provider-azuread/version" "github.com/manicminer/hamilton/auth" "github.com/manicminer/hamilton/environments" "github.com/manicminer/hamilton/msgraph" - - "github.com/hashicorp/terraform-provider-azuread/version" ) type contextKey string @@ -28,6 +27,7 @@ type ClientOptions struct { TerraformVersion string Authorizer auth.Authorizer + ApiVersion msgraph.ApiVersion } func (o ClientOptions) ConfigureClient(c *msgraph.Client) { @@ -46,6 +46,9 @@ func (o ClientOptions) ConfigureClient(c *msgraph.Client) { // Default retry limit, can be overridden from within a resource c.RetryableClient.RetryMax = 9 + + // Explicitly set API version + c.ApiVersion = o.ApiVersion } func (o ClientOptions) requestLogger(req *http.Request) (*http.Request, error) { diff --git a/internal/services/applications/client/client.go b/internal/services/applications/client/client.go index af800f12ca..67d7f6ab76 100644 --- a/internal/services/applications/client/client.go +++ b/internal/services/applications/client/client.go @@ -1,10 +1,9 @@ package client import ( + "github.com/hashicorp/terraform-provider-azuread/internal/common" "github.com/manicminer/hamilton/environments" "github.com/manicminer/hamilton/msgraph" - - "github.com/hashicorp/terraform-provider-azuread/internal/common" ) type Client struct { diff --git a/internal/services/conditionalaccess/client/client.go b/internal/services/conditionalaccess/client/client.go index 70ef691af4..fe692312fc 100644 --- a/internal/services/conditionalaccess/client/client.go +++ b/internal/services/conditionalaccess/client/client.go @@ -1,9 +1,8 @@ package client import ( - "github.com/manicminer/hamilton/msgraph" - "github.com/hashicorp/terraform-provider-azuread/internal/common" + "github.com/manicminer/hamilton/msgraph" ) type Client struct { @@ -17,7 +16,6 @@ func NewClient(o *common.ClientOptions) *Client { policiesClient := msgraph.NewConditionalAccessPoliciesClient(o.TenantID) o.ConfigureClient(&policiesClient.BaseClient) - policiesClient.BaseClient.ApiVersion = msgraph.Version10 return &Client{ NamedLocationsClient: namedLocationsClient, diff --git a/internal/services/serviceprincipals/client/client.go b/internal/services/serviceprincipals/client/client.go index 2fd3b7f672..a0c54b6fbd 100644 --- a/internal/services/serviceprincipals/client/client.go +++ b/internal/services/serviceprincipals/client/client.go @@ -20,7 +20,6 @@ func NewClient(o *common.ClientOptions) *Client { o.ConfigureClient(&directoryObjectsClient.BaseClient) servicePrincipalsClient := msgraph.NewServicePrincipalsClient(o.TenantID) - servicePrincipalsClient.BaseClient.ApiVersion = msgraph.Version10 o.ConfigureClient(&servicePrincipalsClient.BaseClient) synchronizationJobClient := msgraph.NewSynchronizationJobClient(o.TenantID)