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 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/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 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..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 @@ -4,12 +4,11 @@ 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" ) -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 @@ -17,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: 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()), } + } 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: types.BoolPointerValue(remoteMac.GetIsMicrosoft365AppsEnabled()), - IsSkypeForBusinessEnabled: types.BoolPointerValue(remoteMac.GetIsSkypeForBusinessEnabled()), + 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")