Documentation
¶
Overview ¶
Index ¶
- Constants
- func AssignmentBlock() schema.ListNestedBlock
- func MapRemoteAssignmentStateToTerraform(ctx context.Context, tfState *DeviceHealthScriptResourceModel, ...)
- func MapRemoteResourceStateToTerraform(ctx context.Context, data *DeviceHealthScriptResourceModel, ...)
- func NewDeviceHealthScriptResource() resource.Resource
- type DeviceHealthScriptParameterModel
- type DeviceHealthScriptResource
- func (r *DeviceHealthScriptResource) Configure(ctx context.Context, req resource.ConfigureRequest, ...)
- func (r *DeviceHealthScriptResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse)
- func (r *DeviceHealthScriptResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse)
- func (r *DeviceHealthScriptResource) FullTypeName() string
- func (r *DeviceHealthScriptResource) ImportState(ctx context.Context, req resource.ImportStateRequest, ...)
- func (r *DeviceHealthScriptResource) Metadata(ctx context.Context, req resource.MetadataRequest, ...)
- func (r *DeviceHealthScriptResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, ...)
- func (r *DeviceHealthScriptResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse)
- func (r *DeviceHealthScriptResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse)
- func (r *DeviceHealthScriptResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse)
- type DeviceHealthScriptResourceModel
- type IncludeGroupResourceModel
- type RunScheduleResourceModel
- type WindowsRemediationScriptAssignmentResourceModel
Constants ¶
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
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 ¶
func (r *DeviceHealthScriptResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse)
Configure sets the client for the resource.
func (*DeviceHealthScriptResource) Create ¶
func (r *DeviceHealthScriptResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse)
Create handles the Create operation.
func (*DeviceHealthScriptResource) Delete ¶
func (r *DeviceHealthScriptResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse)
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 ¶
func (r *DeviceHealthScriptResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse)
ImportState imports the resource state.
func (*DeviceHealthScriptResource) Metadata ¶
func (r *DeviceHealthScriptResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse)
Metadata returns the resource type name.
func (*DeviceHealthScriptResource) ModifyPlan ¶
func (r *DeviceHealthScriptResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse)
ModifyPlan modifies the plan for the resource.
func (*DeviceHealthScriptResource) Read ¶
func (r *DeviceHealthScriptResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse)
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 ¶
func (r *DeviceHealthScriptResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse)
Schema defines the schema for the resource.
func (*DeviceHealthScriptResource) Update ¶
func (r *DeviceHealthScriptResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse)
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