From 305aee2b2d7fe35dd456aa05f2a48dc1d9cf95fa Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 14 Sep 2024 10:45:16 +0000 Subject: [PATCH 1/5] terraform-docs: automated action --- .../README.md | 2 +- .../README.md | 2 +- .../README.md | 2 +- .../README.md | 3 +-- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/examples/microsoft365_graph/microsoft365_graph_device_and_app_management_cloud_pc_device_image/README.md b/examples/microsoft365_graph/microsoft365_graph_device_and_app_management_cloud_pc_device_image/README.md index aa93382f..0eaf225d 100644 --- a/examples/microsoft365_graph/microsoft365_graph_device_and_app_management_cloud_pc_device_image/README.md +++ b/examples/microsoft365_graph/microsoft365_graph_device_and_app_management_cloud_pc_device_image/README.md @@ -17,7 +17,7 @@ No modules. | Name | Type | |------|------| -| [microsoft365_cloud_pc_device_image.example](https://registry.terraform.io/providers/hashicorp/microsoft365/latest/docs/resources/cloud_pc_device_image) | resource | +| [microsoft365_device_and_app_management_cloud_pc_device_image.example](https://registry.terraform.io/providers/hashicorp/microsoft365/latest/docs/resources/device_and_app_management_cloud_pc_device_image) | resource | | [microsoft365_cloud_pc_device_image.existing](https://registry.terraform.io/providers/hashicorp/microsoft365/latest/docs/data-sources/cloud_pc_device_image) | data source | ## Inputs diff --git a/examples/microsoft365_graph/microsoft365_graph_device_and_app_management_cloud_pc_provisioning_policy/README.md b/examples/microsoft365_graph/microsoft365_graph_device_and_app_management_cloud_pc_provisioning_policy/README.md index 084faf01..69e9ab01 100644 --- a/examples/microsoft365_graph/microsoft365_graph_device_and_app_management_cloud_pc_provisioning_policy/README.md +++ b/examples/microsoft365_graph/microsoft365_graph_device_and_app_management_cloud_pc_provisioning_policy/README.md @@ -17,7 +17,7 @@ No modules. | Name | Type | |------|------| -| [microsoft365_graph_cloud_pc_provisioning_policy.example](https://registry.terraform.io/providers/hashicorp/microsoft365/latest/docs/resources/graph_cloud_pc_provisioning_policy) | resource | +| [microsoft365_graph_device_and_app_management_cloud_pc_provisioning_policy.example](https://registry.terraform.io/providers/hashicorp/microsoft365/latest/docs/resources/graph_device_and_app_management_cloud_pc_provisioning_policy) | resource | ## Inputs diff --git a/examples/microsoft365_graph/microsoft365_graph_device_and_app_management_cloud_pc_user_setting/README.md b/examples/microsoft365_graph/microsoft365_graph_device_and_app_management_cloud_pc_user_setting/README.md index 1d17624b..6d77bb34 100644 --- a/examples/microsoft365_graph/microsoft365_graph_device_and_app_management_cloud_pc_user_setting/README.md +++ b/examples/microsoft365_graph/microsoft365_graph_device_and_app_management_cloud_pc_user_setting/README.md @@ -17,7 +17,7 @@ No modules. | Name | Type | |------|------| -| [microsoft365_graph_cloud_pc_user_setting.example](https://registry.terraform.io/providers/hashicorp/microsoft365/latest/docs/resources/graph_cloud_pc_user_setting) | resource | +| [microsoft365_graph_device_and_app_management_cloud_pc_user_setting.example](https://registry.terraform.io/providers/hashicorp/microsoft365/latest/docs/resources/graph_device_and_app_management_cloud_pc_user_setting) | resource | ## Inputs diff --git a/examples/microsoft365_graph/microsoft365_graph_device_and_app_management_role_definition/README.md b/examples/microsoft365_graph/microsoft365_graph_device_and_app_management_role_definition/README.md index f5da7c51..a91e178e 100644 --- a/examples/microsoft365_graph/microsoft365_graph_device_and_app_management_role_definition/README.md +++ b/examples/microsoft365_graph/microsoft365_graph_device_and_app_management_role_definition/README.md @@ -17,8 +17,7 @@ No modules. | Name | Type | |------|------| -| [microsoft365_graph_device_and_app_management_role_definition.example](https://registry.terraform.io/providers/hashicorp/microsoft365/latest/docs/resources/graph_device_and_app_management_role_definition) | resource | -| [microsoft365_graph_device_and_app_management_role_definition.helpdesk_assignment](https://registry.terraform.io/providers/hashicorp/microsoft365/latest/docs/resources/graph_device_and_app_management_role_definition) | resource | +| [microsoft365_graph_beta_device_and_app_management_role_definition.example](https://registry.terraform.io/providers/hashicorp/microsoft365/latest/docs/resources/graph_beta_device_and_app_management_role_definition) | resource | | [microsoft365_graph_device_and_app_management_role_definition.helpdesk_admin](https://registry.terraform.io/providers/hashicorp/microsoft365/latest/docs/data-sources/graph_device_and_app_management_role_definition) | data source | ## Inputs From ffe297e1d5a3446f04d68234279a9d902a67d63e Mon Sep 17 00:00:00 2001 From: ShocOne Date: Sat, 14 Sep 2024 11:50:58 +0100 Subject: [PATCH 2/5] refactor: Update M365AppsInstallationOptions CRUD methods Refactor the CRUD methods for M365AppsInstallationOptions to use the correct API endpoints. The `Create`, `Read`, and `Update` methods now call the `InstallationOptions` endpoint instead of the deprecated `Microsoft365Apps` endpoint. This ensures that the correct API is used for managing installation options for Microsoft 365 apps. --- .../beta/m365_apps_installation_options/crud.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/resources/device_and_app_management/beta/m365_apps_installation_options/crud.go b/internal/resources/device_and_app_management/beta/m365_apps_installation_options/crud.go index d3d23d4a..dc959423 100644 --- a/internal/resources/device_and_app_management/beta/m365_apps_installation_options/crud.go +++ b/internal/resources/device_and_app_management/beta/m365_apps_installation_options/crud.go @@ -38,7 +38,7 @@ func (r *M365AppsInstallationOptionsResource) Create(ctx context.Context, req re return } - options, err := r.client.Admin().Microsoft365Apps().Patch(ctx, requestBody, nil) + options, err := r.client.Admin().Microsoft365Apps().InstallationOptions().Patch(ctx, requestBody, nil) if err != nil { resp.Diagnostics.AddError( "Error creating M365AppsInstallationOptions", @@ -75,7 +75,7 @@ func (r *M365AppsInstallationOptionsResource) Read(ctx context.Context, req reso } defer cancel() - options, err := r.client.Admin().Microsoft365Apps().Get(ctx, nil) + options, err := r.client.Admin().Microsoft365Apps().InstallationOptions().Get(ctx, nil) if err != nil { crud.HandleReadErrorIfNotFound(ctx, resp, r, &state, err) return @@ -112,7 +112,7 @@ func (r *M365AppsInstallationOptionsResource) Update(ctx context.Context, req re return } - options, err := r.client.Admin().Microsoft365Apps().Patch(ctx, requestBody, nil) + options, err := r.client.Admin().Microsoft365Apps().InstallationOptions().Patch(ctx, requestBody, nil) if err != nil { crud.HandleUpdateErrorIfNotFound(ctx, resp, r, &plan, err) return From 754f45cafdce389ff654f58807729b086b04030c Mon Sep 17 00:00:00 2001 From: ShocOne Date: Sat, 14 Sep 2024 11:59:53 +0100 Subject: [PATCH 3/5] refactor: Update M365AppsInstallationOptions construct and state functions --- .../beta/m365_apps_installation_options/construct.go | 7 ++----- .../beta/m365_apps_installation_options/state.go | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/internal/resources/device_and_app_management/beta/m365_apps_installation_options/construct.go b/internal/resources/device_and_app_management/beta/m365_apps_installation_options/construct.go index fb0603ab..e15a8a52 100644 --- a/internal/resources/device_and_app_management/beta/m365_apps_installation_options/construct.go +++ b/internal/resources/device_and_app_management/beta/m365_apps_installation_options/construct.go @@ -11,7 +11,7 @@ import ( ) // constructResource maps the Terraform schema to the SDK model -func constructResource(ctx context.Context, data *M365AppsInstallationOptionsResourceModel) (models.AdminMicrosoft365Appsable, error) { +func constructResource(ctx context.Context, data *M365AppsInstallationOptionsResourceModel) (models.M365AppsInstallationOptionsable, error) { tflog.Debug(ctx, "Constructing M365AppsInstallationOptions Resource") construct.DebugPrintStruct(ctx, "Constructed M365AppsInstallationOptions Resource from model", data) @@ -44,8 +44,5 @@ func constructResource(ctx context.Context, data *M365AppsInstallationOptionsRes installationOptions.SetAppsForMac(appsForMac) } - requestBody := models.NewAdminMicrosoft365Apps() - requestBody.SetInstallationOptions(installationOptions) - - return requestBody, nil + return installationOptions, nil } diff --git a/internal/resources/device_and_app_management/beta/m365_apps_installation_options/state.go b/internal/resources/device_and_app_management/beta/m365_apps_installation_options/state.go index e1bafc2b..a5c40000 100644 --- a/internal/resources/device_and_app_management/beta/m365_apps_installation_options/state.go +++ b/internal/resources/device_and_app_management/beta/m365_apps_installation_options/state.go @@ -9,7 +9,7 @@ import ( "github.com/microsoftgraph/msgraph-beta-sdk-go/models" ) -func MapRemoteStateToTerraform(ctx context.Context, data *M365AppsInstallationOptionsResourceModel, remoteResource models.AdminMicrosoft365Appsable) { +func MapRemoteStateToTerraform(ctx context.Context, data *M365AppsInstallationOptionsResourceModel, remoteResource models.M365AppsInstallationOptionsable) { if remoteResource == nil { tflog.Debug(ctx, "Remote resource is nil") return From 64a409cd52e077e3dc954c189ac16ddd3e0309b7 Mon Sep 17 00:00:00 2001 From: ShocOne Date: Sat, 14 Sep 2024 12:03:29 +0100 Subject: [PATCH 4/5] refactor: Update M365AppsInstallationOptions struct mapping in state.go --- .../beta/m365_apps_installation_options/state.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/internal/resources/device_and_app_management/beta/m365_apps_installation_options/state.go b/internal/resources/device_and_app_management/beta/m365_apps_installation_options/state.go index a5c40000..7b6151de 100644 --- a/internal/resources/device_and_app_management/beta/m365_apps_installation_options/state.go +++ b/internal/resources/device_and_app_management/beta/m365_apps_installation_options/state.go @@ -4,7 +4,6 @@ import ( "context" "github.com/deploymenttheory/terraform-provider-microsoft365/internal/resources/common/state" - "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/microsoftgraph/msgraph-beta-sdk-go/models" ) @@ -29,18 +28,18 @@ func MapRemoteStateToTerraform(ctx context.Context, data *M365AppsInstallationOp // Map AppsForWindows if remoteWindows := installationOptions.GetAppsForWindows(); remoteWindows != nil { data.AppsForWindows = &AppsInstallationOptionsForWindows{ - IsMicrosoft365AppsEnabled: types.BoolPointerValue(remoteWindows.GetIsMicrosoft365AppsEnabled()), - IsProjectEnabled: types.BoolPointerValue(remoteWindows.GetIsProjectEnabled()), - IsSkypeForBusinessEnabled: types.BoolPointerValue(remoteWindows.GetIsSkypeForBusinessEnabled()), - IsVisioEnabled: types.BoolPointerValue(remoteWindows.GetIsVisioEnabled()), + IsMicrosoft365AppsEnabled: state.BoolPtrToTypeBool(remoteWindows.GetIsMicrosoft365AppsEnabled()), + IsProjectEnabled: state.BoolPtrToTypeBool(remoteWindows.GetIsProjectEnabled()), + IsSkypeForBusinessEnabled: state.BoolPtrToTypeBool(remoteWindows.GetIsSkypeForBusinessEnabled()), + IsVisioEnabled: state.BoolPtrToTypeBool(remoteWindows.GetIsVisioEnabled()), } } // Map AppsForMac if remoteMac := installationOptions.GetAppsForMac(); remoteMac != nil { data.AppsForMac = &AppsInstallationOptionsForMac{ - IsMicrosoft365AppsEnabled: types.BoolPointerValue(remoteMac.GetIsMicrosoft365AppsEnabled()), - IsSkypeForBusinessEnabled: types.BoolPointerValue(remoteMac.GetIsSkypeForBusinessEnabled()), + IsMicrosoft365AppsEnabled: state.BoolPtrToTypeBool(remoteMac.GetIsMicrosoft365AppsEnabled()), + IsSkypeForBusinessEnabled: state.BoolPtrToTypeBool(remoteMac.GetIsSkypeForBusinessEnabled()), } } From cb5ee02086c88a376f4a3ee985f464d42eb96790 Mon Sep 17 00:00:00 2001 From: ShocOne Date: Sat, 14 Sep 2024 12:05:51 +0100 Subject: [PATCH 5/5] refactor: Improve mapping of M365AppsInstallationOptions in state.go --- .../m365_apps_installation_options/state.go | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/internal/resources/device_and_app_management/beta/m365_apps_installation_options/state.go b/internal/resources/device_and_app_management/beta/m365_apps_installation_options/state.go index 7b6151de..11f5219c 100644 --- a/internal/resources/device_and_app_management/beta/m365_apps_installation_options/state.go +++ b/internal/resources/device_and_app_management/beta/m365_apps_installation_options/state.go @@ -16,31 +16,32 @@ func MapRemoteStateToTerraform(ctx context.Context, data *M365AppsInstallationOp tflog.Debug(ctx, "Starting to map remote state to Terraform state for M365AppsInstallationOptions") - installationOptions := remoteResource.GetInstallationOptions() - if installationOptions == nil { - tflog.Debug(ctx, "Installation options are nil") - return + // Check if UpdateChannel exists and map it + updateChannel := remoteResource.GetUpdateChannel() + if updateChannel != nil { + data.UpdateChannel = state.EnumPtrToTypeString(updateChannel) } - // Map UpdateChannel - data.UpdateChannel = state.EnumPtrToTypeString(installationOptions.GetUpdateChannel()) - - // Map AppsForWindows - if remoteWindows := installationOptions.GetAppsForWindows(); remoteWindows != nil { + // Map AppsForWindows if it exists + if remoteWindows := remoteResource.GetAppsForWindows(); remoteWindows != nil { data.AppsForWindows = &AppsInstallationOptionsForWindows{ IsMicrosoft365AppsEnabled: state.BoolPtrToTypeBool(remoteWindows.GetIsMicrosoft365AppsEnabled()), IsProjectEnabled: state.BoolPtrToTypeBool(remoteWindows.GetIsProjectEnabled()), IsSkypeForBusinessEnabled: state.BoolPtrToTypeBool(remoteWindows.GetIsSkypeForBusinessEnabled()), IsVisioEnabled: state.BoolPtrToTypeBool(remoteWindows.GetIsVisioEnabled()), } + } else { + data.AppsForWindows = nil } - // Map AppsForMac - if remoteMac := installationOptions.GetAppsForMac(); remoteMac != nil { + // Map AppsForMac if it exists + if remoteMac := remoteResource.GetAppsForMac(); remoteMac != nil { data.AppsForMac = &AppsInstallationOptionsForMac{ IsMicrosoft365AppsEnabled: state.BoolPtrToTypeBool(remoteMac.GetIsMicrosoft365AppsEnabled()), IsSkypeForBusinessEnabled: state.BoolPtrToTypeBool(remoteMac.GetIsSkypeForBusinessEnabled()), } + } else { + data.AppsForMac = nil } tflog.Debug(ctx, "Finished mapping remote state to Terraform state for M365AppsInstallationOptions")