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

An OS policy resource is used to define the desired state configuration
and provides a specific functionality like installing/removing packages,
executing a script etc.

The system ensures that resources are always in their desired state by
taking necessary actions if they have drifted from their desired state.

Generated from protobuf message `google.cloud.osconfig.v1.OSPolicy.Resource`

## Namespace

Google \\ Cloud \\ OsConfig \\ V1 \\ OSPolicy

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `data` | `array` Optional. Data for populating the Message object. |
| `↳ id` | `string` Required. The id of the resource with the following restrictions: \* \* Must contain only lowercase letters, numbers, and hyphens. \* \* Must start with a letter. \* \* Must be between 1-63 characters. \* \* Must end with a number or a letter. \* \* Must be unique within the OS policy. |
| `↳ pkg` | `https://docs.cloud.google.com/php/docs/reference/cloud-osconfig/latest/V1.OSPolicy.Resource.PackageResource` Package resource |
| `↳ repository` | `https://docs.cloud.google.com/php/docs/reference/cloud-osconfig/latest/V1.OSPolicy.Resource.RepositoryResource` Package repository resource |
| `↳ exec` | `https://docs.cloud.google.com/php/docs/reference/cloud-osconfig/latest/V1.OSPolicy.Resource.ExecResource` Exec resource |
| `↳ file` | `https://docs.cloud.google.com/php/docs/reference/cloud-osconfig/latest/V1.OSPolicy.Resource.FileResource` File resource |

### getId

Required. The id of the resource with the following restrictions:

- Must contain only lowercase letters, numbers, and hyphens.

- Must start with a letter.

- Must be between 1-63 characters.
- Must end with a number or a letter.
- Must be unique within the OS policy.

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

### setId

Required. The id of the resource with the following restrictions:

- Must contain only lowercase letters, numbers, and hyphens.

- Must start with a letter.

- Must be between 1-63 characters.
- Must end with a number or a letter.
- Must be unique within the OS policy.

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

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

### getPkg

Package resource

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

### hasPkg

### setPkg

Package resource

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

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

### getRepository

Package repository resource

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

### hasRepository

### setRepository

Package repository resource

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

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

### getExec

Exec resource

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

### hasExec

### setExec

Exec resource

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

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

### getFile

File resource

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

### hasFile

### setFile

File resource

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

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

### getResourceType

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