graphBetaWindowsRemediationScript

package
v0.15.0-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2025 License: MPL-2.0 Imports: 27 Imported by: 0

Documentation

Overview

REF: https://learn.microsoft.com/en-us/graph/api/resources/intune-devices-devicehealthscript?view=graph-rest-beta

Index

Constants

View Source
const (
	ResourceName  = "graph_beta_device_management_windows_remediation_script"
	CreateTimeout = 180
	UpdateTimeout = 180
	ReadTimeout   = 180
	DeleteTimeout = 180
)

Variables

This section is empty.

Functions

func AssignmentBlock

func AssignmentBlock() schema.ListNestedBlock

AssignmentBlock returns the schema block for Windows remediation script assignments

func MapRemoteAssignmentStateToTerraform

func MapRemoteAssignmentStateToTerraform(ctx context.Context, tfState *DeviceHealthScriptResourceModel, remoteAssignments []graphmodels.DeviceHealthScriptAssignmentable)

MapRemoteAssignmentStateToTerraform maps the remote assignment state to Terraform state following a similar structure to the constructAssignment function

func MapRemoteResourceStateToTerraform

func MapRemoteResourceStateToTerraform(ctx context.Context, data *DeviceHealthScriptResourceModel, remoteResource graphmodels.DeviceHealthScriptable)

MapRemoteResourceStateToTerraform maps the remote DeviceHealthScript resource state to Terraform state

func NewDeviceHealthScriptResource

func NewDeviceHealthScriptResource() resource.Resource

Types

type DeviceHealthScriptParameterModel

type DeviceHealthScriptParameterModel struct {
	Name                             types.String `tfsdk:"name"`
	Description                      types.String `tfsdk:"description"`
	IsRequired                       types.Bool   `tfsdk:"is_required"`
	ApplyDefaultValueWhenNotAssigned types.Bool   `tfsdk:"apply_default_value_when_not_assigned"`
}

DeviceHealthScriptParameterModel defines a single script parameter.

type DeviceHealthScriptResource

type DeviceHealthScriptResource struct {
	ProviderTypeName string
	TypeName         string
	ReadPermissions  []string
	WritePermissions []string
	ResourcePath     string
	// contains filtered or unexported fields
}

func (*DeviceHealthScriptResource) Configure

Configure sets the client for the resource.

func (*DeviceHealthScriptResource) Create

Create handles the Create operation.

func (*DeviceHealthScriptResource) Delete

Delete handles the Delete operation for Device Management Script resources.

  • Retrieves the current state from the delete request
  • Validates the state data and timeout configuration
  • Sends DELETE request to remove the resource from the API
  • Cleans up by removing the resource from Terraform state

All assignments and settings associated with the resource are automatically removed as part of the deletion.

func (*DeviceHealthScriptResource) FullTypeName

func (r *DeviceHealthScriptResource) FullTypeName() string

FullTypeName returns the full resource type name in the format "providername_resourcename".

func (*DeviceHealthScriptResource) ImportState

ImportState imports the resource state.

func (*DeviceHealthScriptResource) Metadata

Metadata returns the resource type name.

func (*DeviceHealthScriptResource) ModifyPlan

ModifyPlan modifies the plan for the resource.

func (*DeviceHealthScriptResource) Read

Read handles the Read operation for macos platform scripts resources.

  • Retrieves the current state from the read request
  • Gets the resource details including assignments from the API using expand
  • Maps both resource and assignment details to Terraform state

The function ensures all components are properly read and mapped into the Terraform state in a single API call, providing a complete view of the resource's current configuration on the server.

func (*DeviceHealthScriptResource) Schema

Schema defines the schema for the resource.

func (*DeviceHealthScriptResource) Update

Update handles the Update operation for macos platform scripts resources.

The function performs the following operations:

  • Patches the existing script resource with updated settings using PATCH
  • Updates assignments using POST if they are defined
  • Retrieves the updated resource with expanded assignments
  • Maps the remote state back to Terraform

The Microsoft Graph Beta API supports direct updates of device shell script resources through PATCH operations for the base resource, while assignments are handled through a separate POST operation to the assign endpoint. This allows for atomic updates of both the script properties and its assignments.

type DeviceHealthScriptResourceModel

type DeviceHealthScriptResourceModel struct {
	ID                        types.String                                      `tfsdk:"id"`
	DisplayName               types.String                                      `tfsdk:"display_name"`
	Description               types.String                                      `tfsdk:"description"`
	Publisher                 types.String                                      `tfsdk:"publisher"`
	RunAs32Bit                types.Bool                                        `tfsdk:"run_as_32_bit"`
	RunAsAccount              types.String                                      `tfsdk:"run_as_account"`
	EnforceSignatureCheck     types.Bool                                        `tfsdk:"enforce_signature_check"`
	DetectionScriptContent    types.String                                      `tfsdk:"detection_script_content"`
	RemediationScriptContent  types.String                                      `tfsdk:"remediation_script_content"`
	RoleScopeTagIds           types.Set                                         `tfsdk:"role_scope_tag_ids"`
	Version                   types.String                                      `tfsdk:"version"`
	IsGlobalScript            types.Bool                                        `tfsdk:"is_global_script"`
	DeviceHealthScriptType    types.String                                      `tfsdk:"device_health_script_type"`
	CreatedDateTime           types.String                                      `tfsdk:"created_date_time"`
	LastModifiedDateTime      types.String                                      `tfsdk:"last_modified_date_time"`
	HighestAvailableVersion   types.String                                      `tfsdk:"highest_available_version"`
	DetectionScriptParameters types.List                                        `tfsdk:"detection_script_parameters"`
	Assignment                []WindowsRemediationScriptAssignmentResourceModel `tfsdk:"assignment"`
	Timeouts                  timeouts.Value                                    `tfsdk:"timeouts"`
}

DeviceHealthScriptResourceModel defines the schema for a Device Health Script.

type IncludeGroupResourceModel

type IncludeGroupResourceModel struct {
	GroupId                 types.String              `tfsdk:"group_id"`
	IncludeGroupsFilterType types.String              `tfsdk:"include_groups_filter_type"`
	IncludeGroupsFilterId   types.String              `tfsdk:"include_groups_filter_id"`
	RunRemediationScript    types.Bool                `tfsdk:"run_remediation_script"`
	RunSchedule             *RunScheduleResourceModel `tfsdk:"run_schedule"`
}

IncludeGroupResourceModel represents a group with its corresponding filter type , filter group ID and it's optional run schedule.

type RunScheduleResourceModel

type RunScheduleResourceModel struct {
	ScheduleType types.String `tfsdk:"schedule_type"` // "daily", "hourly", or "once"
	Interval     types.Int32  `tfsdk:"interval"`
	Time         types.String `tfsdk:"time"`    // For daily and once schedules
	Date         types.String `tfsdk:"date"`    // For once schedule
	UseUtc       types.Bool   `tfsdk:"use_utc"` // For daily and once schedules
}

RunScheduleResourceModel represents different schedule types for include groups

type WindowsRemediationScriptAssignmentResourceModel

type WindowsRemediationScriptAssignmentResourceModel struct {
	AllDevices           types.Bool   `tfsdk:"all_devices"`
	AllDevicesFilterType types.String `tfsdk:"all_devices_filter_type"`
	AllDevicesFilterId   types.String `tfsdk:"all_devices_filter_id"`
	AllUsers             types.Bool   `tfsdk:"all_users"`
	AllUsersFilterType   types.String `tfsdk:"all_users_filter_type"`
	AllUsersFilterId     types.String `tfsdk:"all_users_filter_id"`
	IncludeGroups        types.Set    `tfsdk:"include_groups"`
	ExcludeGroupIds      types.Set    `tfsdk:"exclude_group_ids"`
}

WindowsRemediationScriptAssignmentResourceModel struct to hold device configuation assignment configuration

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL