# Google Cloud OsConfig V1 Client - Class OSPolicyAssignment (2.2.3)

2.2.3 (latest) 2.2.2 2.1.0 2.0.5 1.3.5 1.2.2 1.1.1 1.0.5 Reference documentation and code samples for the Google Cloud OsConfig V1 Client class OSPolicyAssignment.

OS policy assignment is an API resource that is used to
apply a set of OS policies to a dynamically targeted group of Compute Engine
VM instances.

An OS policy is used to define the desired state configuration for a
Compute Engine VM instance through a set of configuration resources that
provide capabilities such as installing or removing software packages, or
executing a script.
For more information, see [OS policy and OS policy
assignment](https://cloud.google.com/compute/docs/os-configuration-management/working-with-os-policies).

Generated from protobuf message `google.cloud.osconfig.v1.OSPolicyAssignment`

## Namespace

Google \\ Cloud \\ OsConfig \\ V1

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `data` | `array` Optional. Data for populating the Message object. |
| `↳ name` | `string` Resource name. Format: `projects/{project_number}/locations/{location}/osPolicyAssignments/{os_policy_assignment_id}` This field is ignored when you create an OS policy assignment. |
| `↳ description` | `string` OS policy assignment description. Length of the description is limited to 1024 characters. |
| `↳ os_policies` | `array<https://docs.cloud.google.com/php/docs/reference/cloud-osconfig/latest/V1.OSPolicy>` Required. List of OS policies to be applied to the VMs. |
| `↳ instance_filter` | `https://docs.cloud.google.com/php/docs/reference/cloud-osconfig/latest/V1.OSPolicyAssignment.InstanceFilter` Required. Filter to select VMs. |
| `↳ rollout` | `https://docs.cloud.google.com/php/docs/reference/cloud-osconfig/latest/V1.OSPolicyAssignment.Rollout` Required. Rollout to deploy the OS policy assignment. A rollout is triggered in the following situations: 1) OSPolicyAssignment is created. 2) OSPolicyAssignment is updated and the update contains changes to one of the following fields: - instance_filter - os_policies 3) OSPolicyAssignment is deleted. |
| `↳ revision_id` | `string` Output only. The assignment revision ID A new revision is committed whenever a rollout is triggered for a OS policy assignment |
| `↳ revision_create_time` | `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Timestamp` Output only. The timestamp that the revision was created. |
| `↳ etag` | `string` The etag for this OS policy assignment. If this is provided on update, it must match the server's etag. |
| `↳ rollout_state` | `int` Output only. OS policy assignment rollout state |
| `↳ baseline` | `bool` Output only. Indicates that this revision has been successfully rolled out in this zone and new VMs will be assigned OS policies from this revision. For a given OS policy assignment, there is only one revision with a value of `true` for this field. |
| `↳ deleted` | `bool` Output only. Indicates that this revision deletes the OS policy assignment. |
| `↳ reconciling` | `bool` Output only. Indicates that reconciliation is in progress for the revision. This value is `true` when the `rollout_state` is one of: \* \* IN_PROGRESS \* \* CANCELLING |
| `↳ uid` | `string` Output only. Server generated unique id for the OS policy assignment resource. |

### getName

Resource name.

Format:
`projects/{project_number}/locations/{location}/osPolicyAssignments/{os_policy_assignment_id}`
This field is ignored when you create an OS policy assignment.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setName

Resource name.

Format:
`projects/{project_number}/locations/{location}/osPolicyAssignments/{os_policy_assignment_id}`
This field is ignored when you create an OS policy assignment.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getDescription

OS policy assignment description.

Length of the description is limited to 1024 characters.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setDescription

OS policy assignment description.

Length of the description is limited to 1024 characters.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getOsPolicies

Required. List of OS policies to be applied to the VMs.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/RepeatedField<https://docs.cloud.google.com/php/docs/reference/cloud-osconfig/latest/V1.OSPolicy>` |   |

### setOsPolicies

Required. List of OS policies to be applied to the VMs.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `array<https://docs.cloud.google.com/php/docs/reference/cloud-osconfig/latest/V1.OSPolicy>` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getInstanceFilter

Required. Filter to select VMs.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-osconfig/latest/V1.OSPolicyAssignment.InstanceFilter|null` |   |

### hasInstanceFilter

### clearInstanceFilter

### setInstanceFilter

Required. Filter to select VMs.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://docs.cloud.google.com/php/docs/reference/cloud-osconfig/latest/V1.OSPolicyAssignment.InstanceFilter` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getRollout

Required. Rollout to deploy the OS policy assignment.

A rollout is triggered in the following situations:
1) OSPolicyAssignment is created.
2) OSPolicyAssignment is updated and the update contains changes to one of
the following fields:

- instance_filter
- os_policies 3) OSPolicyAssignment is deleted.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-osconfig/latest/V1.OSPolicyAssignment.Rollout|null` |   |

### hasRollout

### clearRollout

### setRollout

Required. Rollout to deploy the OS policy assignment.

A rollout is triggered in the following situations:
1) OSPolicyAssignment is created.
2) OSPolicyAssignment is updated and the update contains changes to one of
the following fields:

- instance_filter
- os_policies 3) OSPolicyAssignment is deleted.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://docs.cloud.google.com/php/docs/reference/cloud-osconfig/latest/V1.OSPolicyAssignment.Rollout` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getRevisionId

Output only. The assignment revision ID
A new revision is committed whenever a rollout is triggered for a OS policy
assignment

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setRevisionId

Output only. The assignment revision ID
A new revision is committed whenever a rollout is triggered for a OS policy
assignment

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getRevisionCreateTime

Output only. The timestamp that the revision was created.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Timestamp|null` |   |

### hasRevisionCreateTime

### clearRevisionCreateTime

### setRevisionCreateTime

Output only. The timestamp that the revision was created.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Timestamp` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getEtag

The etag for this OS policy assignment.

If this is provided on update, it must match the server's etag.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setEtag

The etag for this OS policy assignment.

If this is provided on update, it must match the server's etag.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getRolloutState

Output only. OS policy assignment rollout state

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int` | Enum of type [RolloutState](https://docs.cloud.google.com/php/docs/reference/cloud-osconfig/latest/V1.OSPolicyAssignment.RolloutState). |

### setRolloutState

Output only. OS policy assignment rollout state

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `int` Enum of type [RolloutState](https://docs.cloud.google.com/php/docs/reference/cloud-osconfig/latest/V1.OSPolicyAssignment.RolloutState). |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getBaseline

Output only. Indicates that this revision has been successfully rolled out
in this zone and new VMs will be assigned OS policies from this revision.

For a given OS policy assignment, there is only one revision with a value
of `true` for this field.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `bool` |   |

### setBaseline

Output only. Indicates that this revision has been successfully rolled out
in this zone and new VMs will be assigned OS policies from this revision.

For a given OS policy assignment, there is only one revision with a value
of `true` for this field.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `bool` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getDeleted

Output only. Indicates that this revision deletes the OS policy assignment.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `bool` |   |

### setDeleted

Output only. Indicates that this revision deletes the OS policy assignment.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `bool` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getReconciling

Output only. Indicates that reconciliation is in progress for the revision.

This value is `true` when the `rollout_state` is one of:

- IN_PROGRESS
- CANCELLING

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `bool` |   |

### setReconciling

Output only. Indicates that reconciliation is in progress for the revision.

This value is `true` when the `rollout_state` is one of:

- IN_PROGRESS
- CANCELLING

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `bool` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getUid

Output only. Server generated unique id for the OS policy assignment
resource.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setUid

Output only. Server generated unique id for the OS policy assignment
resource.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |