# Google Cloud OsConfig V1 Client - Class OSPolicyCompliance (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 OSPolicyCompliance.

Compliance data for an OS policy

Generated from protobuf message `google.cloud.osconfig.v1.OSPolicyAssignmentReport.OSPolicyCompliance`

## Namespace

Google \\ Cloud \\ OsConfig \\ V1 \\ OSPolicyAssignmentReport

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `data` | `array` Optional. Data for populating the Message object. |
| `↳ os_policy_id` | `string` The OS policy id |
| `↳ compliance_state` | `int` The compliance state of the OS policy. |
| `↳ compliance_state_reason` | `string` The reason for the OS policy to be in an unknown compliance state. This field is always populated when `compliance_state` is `UNKNOWN`. If populated, the field can contain one of the following values: \* \* `vm-not-running`: The VM was not running. \* \* `os-policies-not-supported-by-agent`: The version of the OS Config agent running on the VM does not support running OS policies. \* \* `no-agent-detected`: The OS Config agent is not detected for the VM. \* \* `resource-execution-errors`: The OS Config agent encountered errors while executing one or more resources in the policy. See `os_policy_resource_compliances` for details. \* \* `task-timeout`: The task sent to the agent to apply the policy timed out. \* \* `unexpected-agent-state`: The OS Config agent did not report the final status of the task that attempted to apply the policy. Instead, the agent unexpectedly started working on a different task. This mostly happens when the agent or VM unexpectedly restarts while applying OS policies. \* \* `internal-service-errors`: Internal service errors were encountered while attempting to apply the policy. |
| `↳ os_policy_resource_compliances` | `array<https://docs.cloud.google.com/php/docs/reference/cloud-osconfig/latest/V1.OSPolicyAssignmentReport.OSPolicyCompliance.OSPolicyResourceCompliance>` Compliance data for each resource within the policy that is applied to the VM. |

### getOsPolicyId

The OS policy id

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

### setOsPolicyId

The OS policy id

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

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

### getComplianceState

The compliance state of the OS policy.

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

### setComplianceState

The compliance state of the OS policy.

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

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

### getComplianceStateReason

The reason for the OS policy to be in an unknown compliance state.

This field is always populated when `compliance_state` is `UNKNOWN`.
If populated, the field can contain one of the following values:

- `vm-not-running`: The VM was not running.
- `os-policies-not-supported-by-agent`: The version of the OS Config agent running on the VM does not support running OS policies.
- `no-agent-detected`: The OS Config agent is not detected for the VM.
- `resource-execution-errors`: The OS Config agent encountered errors while executing one or more resources in the policy. See `os_policy_resource_compliances` for details.
- `task-timeout`: The task sent to the agent to apply the policy timed out.
- `unexpected-agent-state`: The OS Config agent did not report the final status of the task that attempted to apply the policy. Instead, the agent unexpectedly started working on a different task. This mostly happens when the agent or VM unexpectedly restarts while applying OS policies.
- `internal-service-errors`: Internal service errors were encountered while attempting to apply the policy.

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

### setComplianceStateReason

The reason for the OS policy to be in an unknown compliance state.

This field is always populated when `compliance_state` is `UNKNOWN`.
If populated, the field can contain one of the following values:

- `vm-not-running`: The VM was not running.
- `os-policies-not-supported-by-agent`: The version of the OS Config agent running on the VM does not support running OS policies.
- `no-agent-detected`: The OS Config agent is not detected for the VM.
- `resource-execution-errors`: The OS Config agent encountered errors while executing one or more resources in the policy. See `os_policy_resource_compliances` for details.
- `task-timeout`: The task sent to the agent to apply the policy timed out.
- `unexpected-agent-state`: The OS Config agent did not report the final status of the task that attempted to apply the policy. Instead, the agent unexpectedly started working on a different task. This mostly happens when the agent or VM unexpectedly restarts while applying OS policies.
- `internal-service-errors`: Internal service errors were encountered while attempting to apply the policy.

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

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

### getOsPolicyResourceCompliances

Compliance data for each resource within the policy that is applied to
the VM.

| **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.OSPolicyAssignmentReport.OSPolicyCompliance.OSPolicyResourceCompliance>` |   |

### setOsPolicyResourceCompliances

Compliance data for each resource within the policy that is applied to
the VM.

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

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