generated from deploymenttheory/Template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add endpoint privilege management resource construction and settings …
…catalog export
- Loading branch information
Showing
4 changed files
with
180 additions
and
824 deletions.
There are no files selected for viewing
74 changes: 3 additions & 71 deletions
74
...ndpoint_privilege_management/construct.go → ...on/construct/settings_catalog_settings.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
...ources/device_and_app_management/beta/endpoint_privilege_management/construct_resource.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package graphBetaEndpointPrivilegeManagement | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/deploymenttheory/terraform-provider-microsoft365/internal/resources/common/construct" | ||
"github.com/hashicorp/terraform-plugin-log/tflog" | ||
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models" | ||
) | ||
|
||
// Main entry point to construct the intune settings catalog profile resource for the Terraform provider. | ||
func constructResource(ctx context.Context, data *EndpointPrivilegeManagementResourceModel) (graphmodels.DeviceManagementConfigurationPolicyable, error) { | ||
tflog.Debug(ctx, fmt.Sprintf("Constructing %s resource from model", ResourceName)) | ||
|
||
requestBody := graphmodels.NewDeviceManagementConfigurationPolicy() | ||
|
||
Name := data.Name.ValueString() | ||
requestBody.SetName(&Name) | ||
|
||
description := data.Description.ValueString() | ||
requestBody.SetDescription(&description) | ||
|
||
platformStr := data.Platforms.ValueString() | ||
var platform graphmodels.DeviceManagementConfigurationPlatforms | ||
switch platformStr { | ||
case "android": | ||
platform = graphmodels.ANDROID_DEVICEMANAGEMENTCONFIGURATIONPLATFORMS | ||
case "androidEnterprise": | ||
platform = graphmodels.ANDROIDENTERPRISE_DEVICEMANAGEMENTCONFIGURATIONPLATFORMS | ||
case "aosp": | ||
platform = graphmodels.AOSP_DEVICEMANAGEMENTCONFIGURATIONPLATFORMS | ||
case "iOS": | ||
platform = graphmodels.IOS_DEVICEMANAGEMENTCONFIGURATIONPLATFORMS | ||
case "linux": | ||
platform = graphmodels.LINUX_DEVICEMANAGEMENTCONFIGURATIONPLATFORMS | ||
case "macOS": | ||
platform = graphmodels.MACOS_DEVICEMANAGEMENTCONFIGURATIONPLATFORMS | ||
case "windows10": | ||
platform = graphmodels.WINDOWS10_DEVICEMANAGEMENTCONFIGURATIONPLATFORMS | ||
case "windows10X": | ||
platform = graphmodels.WINDOWS10X_DEVICEMANAGEMENTCONFIGURATIONPLATFORMS | ||
} | ||
requestBody.SetPlatforms(&platform) | ||
|
||
var technologiesStr []string | ||
for _, tech := range data.Technologies { | ||
technologiesStr = append(technologiesStr, tech.ValueString()) | ||
} | ||
parsedTechnologies, _ := graphmodels.ParseDeviceManagementConfigurationTechnologies(strings.Join(technologiesStr, ",")) | ||
requestBody.SetTechnologies(parsedTechnologies.(*graphmodels.DeviceManagementConfigurationTechnologies)) | ||
|
||
if len(data.RoleScopeTagIds) > 0 { | ||
var tagIds []string | ||
for _, tag := range data.RoleScopeTagIds { | ||
tagIds = append(tagIds, tag.ValueString()) | ||
} | ||
requestBody.SetRoleScopeTagIds(tagIds) | ||
} else { | ||
requestBody.SetRoleScopeTagIds([]string{"0"}) | ||
} | ||
|
||
settings := construct.ConstructSettingsCatalogSettings(ctx, data.Settings) | ||
requestBody.SetSettings(settings) | ||
|
||
if err := construct.DebugLogGraphObject(ctx, fmt.Sprintf("Final JSON to be sent to Graph API for resource %s", ResourceName), requestBody); err != nil { | ||
tflog.Error(ctx, "Failed to debug log object", map[string]interface{}{ | ||
"error": err.Error(), | ||
}) | ||
} | ||
|
||
tflog.Debug(ctx, fmt.Sprintf("Finished constructing %s resource", ResourceName)) | ||
|
||
return requestBody, nil | ||
} |
Oops, something went wrong.