Documentation
¶
Overview ¶
Package patch_policy implements the jamfplatform_pro_patch_policy resource, data source, and list resource. Every read of an individual policy — CRUD, the data source, and the list resource's per-item hydration — goes through the Jamf ProClassic /patchpolicies/id/{id} surface, which is the only one carrying a policy's scope and user_interaction sections. The list resource *enumerates* on the Pro v2 /patch-policies collection instead, because the classic collection reads it would otherwise use are deprecated and were for a time withdrawn from the published Classic spec; see crud.go for the endpoint-by-endpoint record.
The construct name mirrors the Jamf Pro admin UI ("Patch Policies", a tab on a software title under Computers → Patch management). A policy is created against a patch software title configuration and targets a single version of that title that has a package assigned. Scope is a LIMITED computer-scope subset (targets + limitations + exclusions, no users) hand-composed from the shared scope primitives.
Index ¶
- func NewPatchPolicyDataSource() datasource.DataSource
- func NewPatchPolicyListResource() list.ListResource
- func NewPatchPolicyResource() resource.Resource
- type PatchPolicyDataSource
- func (d *PatchPolicyDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, ...)
- func (d *PatchPolicyDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, ...)
- func (d *PatchPolicyDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse)
- func (d *PatchPolicyDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, ...)
- type PatchPolicyDataSourceModel
- type PatchPolicyListResource
- func (r *PatchPolicyListResource) Configure(ctx context.Context, req resource.ConfigureRequest, ...)
- func (r *PatchPolicyListResource) List(ctx context.Context, req list.ListRequest, stream *list.ListResultsStream)
- func (r *PatchPolicyListResource) ListResourceConfigSchema(ctx context.Context, req list.ListResourceSchemaRequest, ...)
- func (r *PatchPolicyListResource) Metadata(ctx context.Context, req resource.MetadataRequest, ...)
- type PatchPolicyListResourceModel
- type PatchPolicyResource
- func (r *PatchPolicyResource) Configure(ctx context.Context, req resource.ConfigureRequest, ...)
- func (r *PatchPolicyResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse)
- func (r *PatchPolicyResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse)
- func (r *PatchPolicyResource) IdentitySchema(ctx context.Context, req resource.IdentitySchemaRequest, ...)
- func (r *PatchPolicyResource) ImportState(ctx context.Context, req resource.ImportStateRequest, ...)
- func (r *PatchPolicyResource) Metadata(ctx context.Context, req resource.MetadataRequest, ...)
- func (r *PatchPolicyResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, ...)
- func (r *PatchPolicyResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse)
- func (r *PatchPolicyResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse)
- func (r *PatchPolicyResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse)
- type PatchPolicyResourceModel
- type PatchPolicyScopeExclusionsModel
- type PatchPolicyScopeLimitationsModel
- type PatchPolicyScopeModel
- type PatchPolicyScopeTargetsModel
- type PatchPolicyUserInteractionDeadlinesModel
- type PatchPolicyUserInteractionGracePeriodModel
- type PatchPolicyUserInteractionModel
- type PatchPolicyUserInteractionNotificationsModel
- type PatchPolicyUserInteractionNotificationsRemindersModel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewPatchPolicyDataSource ¶
func NewPatchPolicyDataSource() datasource.DataSource
NewPatchPolicyDataSource returns a new instance of PatchPolicyDataSource.
func NewPatchPolicyListResource ¶
func NewPatchPolicyListResource() list.ListResource
NewPatchPolicyListResource returns a list resource for Jamf Pro patch policy queries.
func NewPatchPolicyResource ¶
NewPatchPolicyResource returns a new instance of PatchPolicyResource.
Types ¶
type PatchPolicyDataSource ¶
type PatchPolicyDataSource struct {
// contains filtered or unexported fields
}
PatchPolicyDataSource implements the Terraform data source for Jamf Pro patch policies. Lookup is by id only, and the reason is no longer the one it used to be: the classic /patchpolicies collection reads that made a name selector an N-GET scan are no longer what this construct enumerates on, and the Pro v2 collection that replaced them accepts a server-side RSQL query on policyName, so a name selector would now cost one filtered list call plus one by-id read. It is therefore unbuilt rather than rejected — note that RSQL string comparison is case-sensitive, so a name selector added here would match exactly, unlike the list resource's deliberately case-insensitive substring filter. The data source surfaces the general fields, including the server-derived ones; manage the policy as a resource for full scope / user_interaction detail.
func (*PatchPolicyDataSource) Configure ¶
func (d *PatchPolicyDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse)
Configure wires the Jamf ProClassic client into the data source via the shared providerdata.ConfigureProClassic helper.
func (*PatchPolicyDataSource) Metadata ¶
func (d *PatchPolicyDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse)
Metadata sets the data source type name for the Terraform provider.
func (*PatchPolicyDataSource) Read ¶
func (d *PatchPolicyDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse)
Read fetches a patch policy by ID and populates Terraform state.
func (*PatchPolicyDataSource) Schema ¶
func (d *PatchPolicyDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse)
Schema returns the data source schema. id is the sole selector; the remaining attributes are populated from the SDK response.
type PatchPolicyDataSourceModel ¶
type PatchPolicyDataSourceModel struct {
ID types.String `tfsdk:"id"`
SoftwareTitleConfigurationID types.String `tfsdk:"software_title_configuration_id"`
Name types.String `tfsdk:"name"`
Enabled types.Bool `tfsdk:"enabled"`
TargetVersion types.String `tfsdk:"target_version"`
DistributionMethod types.String `tfsdk:"distribution_method"`
AllowDowngrade types.Bool `tfsdk:"allow_downgrade"`
PatchUnknown types.Bool `tfsdk:"patch_unknown"`
ReleaseDate types.Int64 `tfsdk:"release_date"`
IncrementalUpdate types.Bool `tfsdk:"incremental_update"`
Reboot types.Bool `tfsdk:"reboot"`
MinimumOS types.String `tfsdk:"minimum_os"`
KillApps types.List `tfsdk:"kill_apps"`
Timeouts datasourceTimeouts.Value `tfsdk:"timeouts"`
}
PatchPolicyDataSourceModel is the flat data source model. Surfaces a read-only projection of the most-frequently looked-up general fields so users can resolve a policy by ID; manage the policy as a resource for full scope / user_interaction detail.
type PatchPolicyListResource ¶
type PatchPolicyListResource struct {
// contains filtered or unexported fields
}
PatchPolicyListResource implements Terraform query list support. Enumeration runs on the Pro v2 patch-policies collection; per-item hydration stays on the ProClassic by-ID read, which is the only surface carrying a policy's scope and user-interaction sections.
The optional `filter` block is applied client-side via filters.ApplyClassicFilter after the full list is fetched: v2 accepts an RSQL query on `policyName`, but RSQL string comparison is case-sensitive and this resource's contract is a case-insensitive substring, so filtering server-side would silently narrow it.
func (*PatchPolicyListResource) Configure ¶
func (r *PatchPolicyListResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse)
Configure wires both clients this list resource spans: the Pro client for the v2 enumeration and the ProClassic client for the per-item read.
func (*PatchPolicyListResource) List ¶
func (r *PatchPolicyListResource) List(ctx context.Context, req list.ListRequest, stream *list.ListResultsStream)
List executes the query and streams patch policy identities back to Terraform.
The Pro v2 collection returns a summary view per policy (id, name, target version, deployment method, deployment counts) and no scope or user-interaction sections, so when IncludeResource is requested (config generation) each policy is fetched individually through the ProClassic by-ID read and hydrated through the shared Read state-builder with includeUnmanaged=true, populating every wire-present section so the generated config is complete rather than identity-only.
A policy the v2 collection enumerated but the classic read cannot return is dropped from the result set, because a result carrying no resource body generates no configuration and the framework additionally reports it as a provider bug. The drop is reported: every skipped policy is collected and one trailing diagnostics-only result carries a warning naming them, so a generated configuration is never silently short of the collection. That matters more here than it did on the classic collection, because enumeration and hydration no longer share an id space by construction — the v2 id is taken on the wire-confirmed equality with the classic by-id path, and this warning is what surfaces a policy where that equality does not hold.
func (*PatchPolicyListResource) ListResourceConfigSchema ¶
func (r *PatchPolicyListResource) ListResourceConfigSchema(ctx context.Context, req list.ListResourceSchemaRequest, resp *list.ListResourceSchemaResponse)
ListResourceConfigSchema describes the supported list filters.
func (*PatchPolicyListResource) Metadata ¶
func (r *PatchPolicyListResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse)
Metadata sets the list resource type name.
type PatchPolicyListResourceModel ¶
type PatchPolicyListResourceModel struct {
Filter *filters.ClassicFilterModel `tfsdk:"filter"`
Timeouts listtimeouts.Value `tfsdk:"timeouts"`
}
PatchPolicyListResourceModel represents the config model for list queries. Classic has no RSQL — the filter shape is the shared client-side substring block. Unlike patch software titles, the patch policies list response carries a display name, so the filter matches the policy name.
type PatchPolicyResource ¶
type PatchPolicyResource struct {
// contains filtered or unexported fields
}
PatchPolicyResource implements the Terraform resource for Jamf Pro patch policies. No directory-service preflight is wired: patch-policy scope exposes no readable name-keyed (LDAP/cloud-IdP) category.
func (*PatchPolicyResource) Configure ¶
func (r *PatchPolicyResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse)
Configure wires the Jamf ProClassic client into the resource via the shared providerdata.ConfigureProClassic helper.
func (*PatchPolicyResource) Create ¶
func (r *PatchPolicyResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse)
Create creates a new Jamf Pro patch policy against the supplied patch software title configuration. The server allocates the integer policy ID and returns it; we then GET by that ID to capture the server-derived general fields.
func (*PatchPolicyResource) Delete ¶
func (r *PatchPolicyResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse)
Delete removes a Jamf Pro patch policy.
func (*PatchPolicyResource) IdentitySchema ¶
func (r *PatchPolicyResource) IdentitySchema(ctx context.Context, req resource.IdentitySchemaRequest, resp *resource.IdentitySchemaResponse)
IdentitySchema defines the identifier used for import and list results.
func (*PatchPolicyResource) ImportState ¶
func (r *PatchPolicyResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse)
ImportState handles import by the Jamf Pro patch policy ID.
func (*PatchPolicyResource) Metadata ¶
func (r *PatchPolicyResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse)
Metadata sets the resource type name for the Terraform provider.
func (*PatchPolicyResource) ModifyPlan ¶
func (r *PatchPolicyResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse)
ModifyPlan emits the impact alert for a scope change. This resource has no other plan-time work, so this is the whole of it.
func (*PatchPolicyResource) Read ¶
func (r *PatchPolicyResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse)
Read refreshes Terraform state with the latest patch policy representation.
func (*PatchPolicyResource) Schema ¶
func (r *PatchPolicyResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse)
Schema returns the Terraform schema for the patch policy resource. Attribute names mirror the Jamf Pro admin UI labels (STYLE_GUIDE §Attribute names mirror the admin UI); the differing wire element names are noted in the attribute descriptions.
func (*PatchPolicyResource) Update ¶
func (r *PatchPolicyResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse)
Update updates a Jamf Pro patch policy. Classic UpdatePatchPolicyByID returns 201 with an empty body — we must GET to refresh state.
type PatchPolicyResourceModel ¶
type PatchPolicyResourceModel struct {
ID types.String `tfsdk:"id"`
SoftwareTitleConfigurationID types.String `tfsdk:"software_title_configuration_id"`
Name types.String `tfsdk:"name"`
Enabled types.Bool `tfsdk:"enabled"`
TargetVersion types.String `tfsdk:"target_version"`
DistributionMethod types.String `tfsdk:"distribution_method"`
AllowDowngrade types.Bool `tfsdk:"allow_downgrade"`
PatchUnknown types.Bool `tfsdk:"patch_unknown"`
ReleaseDate types.Int64 `tfsdk:"release_date"`
IncrementalUpdate types.Bool `tfsdk:"incremental_update"`
Reboot types.Bool `tfsdk:"reboot"`
MinimumOS types.String `tfsdk:"minimum_os"`
KillApps types.List `tfsdk:"kill_apps"`
Scope *PatchPolicyScopeModel `tfsdk:"scope"`
UserInteraction *PatchPolicyUserInteractionModel `tfsdk:"user_interaction"`
Timeouts resourceTimeouts.Value `tfsdk:"timeouts"`
}
PatchPolicyResourceModel is the Terraform resource model for a Jamf Pro patch policy (the classic /patchpolicies endpoint). A policy is created against a patch software title configuration (software_title_configuration_id) and targets a single version of that title that has a package assigned.
scope and user_interaction are pointer-typed optional blocks so an undeclared block stays null in state. The classic server echoes both <scope> and <user_interaction> (with full defaults) on every GET, so Read only refreshes a block the caller manages — populating an unmanaged block would violate the framework's "produced inconsistent result after apply" check.
type PatchPolicyScopeExclusionsModel ¶
type PatchPolicyScopeExclusionsModel struct {
ComputerIDs types.Set `tfsdk:"computer_ids"`
ComputerGroupIDs types.Set `tfsdk:"computer_group_ids"`
BuildingIDs types.Set `tfsdk:"building_ids"`
DepartmentIDs types.Set `tfsdk:"department_ids"`
NetworkSegmentIDs types.Set `tfsdk:"network_segment_ids"`
IbeaconIDs types.Set `tfsdk:"ibeacon_ids"`
}
PatchPolicyScopeExclusionsModel models <scope><exclusions>: computers, computer groups, buildings, departments, network segments, iBeacons.
type PatchPolicyScopeLimitationsModel ¶
type PatchPolicyScopeLimitationsModel struct {
NetworkSegmentIDs types.Set `tfsdk:"network_segment_ids"`
IbeaconIDs types.Set `tfsdk:"ibeacon_ids"`
}
PatchPolicyScopeLimitationsModel models <scope><limitations>: network segments and iBeacons only.
type PatchPolicyScopeModel ¶
type PatchPolicyScopeModel struct {
Targets *PatchPolicyScopeTargetsModel `tfsdk:"targets"`
Limitations *PatchPolicyScopeLimitationsModel `tfsdk:"limitations"`
Exclusions *PatchPolicyScopeExclusionsModel `tfsdk:"exclusions"`
}
PatchPolicyScopeModel models <patch_policy><scope>. A LIMITED computer-scope subset (wire-probed): targets are computers / computer_groups / buildings / departments plus the all_computers flag, a limitations block (network segments + iBeacons), and exclusions. NO target users or user groups — the classic GET never returns user-based patch-policy scope even when set, so they are not modelled. Hand-composed from the shared scope primitives.
The all-flag and per-category target ID sets live inside the `targets` sub-block, mirroring the admin UI's Targets / Limitations / Exclusions tabs.
func (PatchPolicyScopeModel) TargetsOrZero ¶
func (m PatchPolicyScopeModel) TargetsOrZero() PatchPolicyScopeTargetsModel
TargetsOrZero returns the targets sub-model, or a zero value with null flag/sets when the block was omitted, so input-builders can read target fields without a nil-guard.
type PatchPolicyScopeTargetsModel ¶
type PatchPolicyScopeTargetsModel struct {
AllComputers types.Bool `tfsdk:"all_computers"`
ComputerIDs types.Set `tfsdk:"computer_ids"`
ComputerGroupIDs types.Set `tfsdk:"computer_group_ids"`
BuildingIDs types.Set `tfsdk:"building_ids"`
DepartmentIDs types.Set `tfsdk:"department_ids"`
}
PatchPolicyScopeTargetsModel models <scope> targets — the all_computers flag plus the per-category target ID sets, mirroring the admin UI's Targets tab.
type PatchPolicyUserInteractionDeadlinesModel ¶
type PatchPolicyUserInteractionDeadlinesModel struct {
Enabled types.Bool `tfsdk:"enabled"`
Period types.Int64 `tfsdk:"period"`
}
PatchPolicyUserInteractionDeadlinesModel models <user_interaction><deadlines>.
type PatchPolicyUserInteractionGracePeriodModel ¶
type PatchPolicyUserInteractionGracePeriodModel struct {
Duration types.Int64 `tfsdk:"duration"`
NotificationCenterSubject types.String `tfsdk:"notification_center_subject"`
Message types.String `tfsdk:"message"`
}
PatchPolicyUserInteractionGracePeriodModel models <user_interaction><grace_period>.
type PatchPolicyUserInteractionModel ¶
type PatchPolicyUserInteractionModel struct {
InstallButtonText types.String `tfsdk:"install_button_text"`
SelfServiceDescription types.String `tfsdk:"self_service_description"`
SelfServiceIconID types.String `tfsdk:"self_service_icon_id"`
Notifications *PatchPolicyUserInteractionNotificationsModel `tfsdk:"notifications"`
Deadlines *PatchPolicyUserInteractionDeadlinesModel `tfsdk:"deadlines"`
GracePeriod *PatchPolicyUserInteractionGracePeriodModel `tfsdk:"grace_period"`
}
PatchPolicyUserInteractionModel models <patch_policy><user_interaction> — the admin UI "User Interaction" tab. The wrapper and its nested blocks are Optional-only (NOT Optional+Computed) pointer structs: the server echoes a full default superset on GET, and an Optional+Computed SingleNestedAttribute backed by a *struct trips the framework's Unknown-decode at apply (see feedback_optional_computed_nested_object). The leaf scalars inside a declared block ARE Optional+Computed so the server-default null→value transition is legal on create. Read is state-gated: a block is only refreshed when already managed.
type PatchPolicyUserInteractionNotificationsModel ¶
type PatchPolicyUserInteractionNotificationsModel struct {
Enabled types.Bool `tfsdk:"enabled"`
Subject types.String `tfsdk:"subject"`
Message types.String `tfsdk:"message"`
Type types.String `tfsdk:"type"`
Reminders *PatchPolicyUserInteractionNotificationsRemindersModel `tfsdk:"reminders"`
}
PatchPolicyUserInteractionNotificationsModel models <user_interaction><notifications>.
type PatchPolicyUserInteractionNotificationsRemindersModel ¶
type PatchPolicyUserInteractionNotificationsRemindersModel struct {
Enabled types.Bool `tfsdk:"enabled"`
Frequency types.Int64 `tfsdk:"frequency"`
}
PatchPolicyUserInteractionNotificationsRemindersModel models <user_interaction><notifications><reminders>.