0.17.0 (latest) 0.16.0 0.15.1 0.14.1 0.8.0 0.7.0 0.6.2 0.5.0 0.4.1 0.3.1 0.2.0 0.1.3 Reference documentation and code samples for the Google Ads Ad Manager V1 Client class AdRule.

An AdRule contains data that the ad server will use to generate a playlist of
video ads.

Generated from protobuf message `google.ads.admanager.v1.AdRule`

## Namespace

Google \\ Ads \\ AdManager \\ V1

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `data` | `array` Optional. Data for populating the Message object. |
| `↳ name` | `string` Identifier. The resource name of the `AdRule`. Format: `networks/{network_code}/adRules/{ad_rule_id}` |
| `↳ display_name` | `string` Required. The unique name of the AdRule. This attribute is required to create an ad rule and has a maximum length of 255 characters. |
| `↳ priority` | `int` Optional. The priority of the AdRule. This attribute is required and can range from 1 to 1000, with 1 being the highest possible priority. Changing an ad rule's priority can affect the priorities of other ad rules. For example, increasing an ad rule's priority from 5 to 1 will shift the ad rules that were previously in priority positions 1 through 4 down one. |
| `↳ start_time` | `Google\Protobuf\Timestamp` Required. The start time of the AdRule. This attribute is required and must be a date in the future for new ad rules. |
| `↳ end_time` | `Google\Protobuf\Timestamp` Optional. This end time of the AdRule. This attribute is required unless [endTimeUnlimited](https://docs.cloud.google.com/php/docs/reference/ad-manager/latest/V1.AdRule.md.txt#_Google_Ads_AdManager_V1_AdRule__getEndTimeUnlimited__) is set to true. If specified, it must be after the [startTime](https://docs.cloud.google.com/php/docs/reference/ad-manager/latest/V1.AdRule.md.txt#_Google_Ads_AdManager_V1_AdRule__getStartTime__). |
| `↳ end_time_unlimited` | `bool` Optional. Specifies whether or not the AdRule has an end time. This attribute is optional and defaults to false. |
| `↳ status` | `int` Output only. The AdRuleStatus of the AdRule. This attribute is read-only and defaults to [AdRuleStatusEnum.AdRuleStatus.INACTIVE](https://docs.cloud.google.com/php/docs/reference/ad-manager/latest/V1.AdRuleStatusEnum.AdRuleStatus.md.txt#_Google_Ads_AdManager_V1_AdRuleStatusEnum_AdRuleStatus__INACTIVE). |
| `↳ frequency_cap_behavior` | `int` Optional. The FrequencyCapBehavior of the AdRule. This attribute is optional and defaults to [AdRuleFrequencyCapBehaviorEnum.AdRuleFrequencyCapBehavior.DEFER](https://docs.cloud.google.com/php/docs/reference/ad-manager/latest/V1.AdRuleFrequencyCapBehaviorEnum.AdRuleFrequencyCapBehavior.md.txt#_Google_Ads_AdManager_V1_AdRuleFrequencyCapBehaviorEnum_AdRuleFrequencyCapBehavior__DEFER). |
| `↳ max_impressions_per_line_item_per_stream` | `int` Optional. This AdRule object's frequency cap for the maximum impressions per stream. This attribute is optional and defaults to 0. |
| `↳ max_impressions_per_line_item_per_pod` | `int` Optional. This AdRule object's frequency cap for the maximum impressions per pod. This attribute is optional and defaults to 0. |
| `↳ preroll` | `AdRuleSlot` Required. This AdRule object's pre-roll slot. This attribute is required. |
| `↳ midrolls` | `array<AdRuleSlot>` Required. This AdRule object's video mid-roll slots. This attribute is required, and there must be at least one mid-roll. |
| `↳ postroll` | `AdRuleSlot` Required. This AdRule object's post-roll slot. This attribute is required. |
| `↳ targeting` | `Targeting` Required. The targeting of the `AdRule`. |

### getName

Identifier. The resource name of the `AdRule`.

Format: `networks/{network_code}/adRules/{ad_rule_id}`

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

### setName

Identifier. The resource name of the `AdRule`.

Format: `networks/{network_code}/adRules/{ad_rule_id}`

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

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

### getDisplayName

Required. The unique name of the AdRule. This attribute is required to
create an ad rule and has a maximum length of 255 characters.

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

### hasDisplayName

### clearDisplayName

### setDisplayName

Required. The unique name of the AdRule. This attribute is required to
create an ad rule and has a maximum length of 255 characters.

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

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

### getPriority

Optional. The priority of the AdRule. This attribute is required and can
range from 1 to 1000, with 1 being the highest possible priority.

Changing an ad rule's priority can affect the priorities of other ad rules.
For example,
increasing an ad rule's priority from 5 to 1 will shift the ad rules that
were previously in
priority positions 1 through 4 down one.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int` |   |

### hasPriority

### clearPriority

### setPriority

Optional. The priority of the AdRule. This attribute is required and can
range from 1 to 1000, with 1 being the highest possible priority.

Changing an ad rule's priority can affect the priorities of other ad rules.
For example,
increasing an ad rule's priority from 5 to 1 will shift the ad rules that
were previously in
priority positions 1 through 4 down one.

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

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

### getStartTime

Required. The start time of the AdRule. This attribute is required and must
be a date in the future for new ad rules.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Google\Protobuf\Timestamp|null` |   |

### hasStartTime

### clearStartTime

### setStartTime

Required. The start time of the AdRule. This attribute is required and must
be a date in the future for new ad rules.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `Google\Protobuf\Timestamp` |

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

### getEndTime

Optional. This end time of the AdRule. This attribute is required
unless
[endTimeUnlimited](https://docs.cloud.google.com/php/docs/reference/ad-manager/latest/V1.AdRule.md.txt#_Google_Ads_AdManager_V1_AdRule__getEndTimeUnlimited__) is
set to true. If specified, it must be after the
[startTime](https://docs.cloud.google.com/php/docs/reference/ad-manager/latest/V1.AdRule.md.txt#_Google_Ads_AdManager_V1_AdRule__getStartTime__).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Google\Protobuf\Timestamp|null` |   |

### hasEndTime

### clearEndTime

### setEndTime

Optional. This end time of the AdRule. This attribute is required
unless
[endTimeUnlimited](https://docs.cloud.google.com/php/docs/reference/ad-manager/latest/V1.AdRule.md.txt#_Google_Ads_AdManager_V1_AdRule__getEndTimeUnlimited__) is
set to true. If specified, it must be after the
[startTime](https://docs.cloud.google.com/php/docs/reference/ad-manager/latest/V1.AdRule.md.txt#_Google_Ads_AdManager_V1_AdRule__getStartTime__).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `Google\Protobuf\Timestamp` |

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

### getEndTimeUnlimited

Optional. Specifies whether or not the AdRule has an end time. This
attribute is optional and defaults to false.

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

### hasEndTimeUnlimited

### clearEndTimeUnlimited

### setEndTimeUnlimited

Optional. Specifies whether or not the AdRule has an end time. This
attribute is optional and defaults to false.

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

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

### getStatus

Output only. The AdRuleStatus of the AdRule. This attribute is read-only
and defaults to
[AdRuleStatusEnum.AdRuleStatus.INACTIVE](https://docs.cloud.google.com/php/docs/reference/ad-manager/latest/V1.AdRuleStatusEnum.AdRuleStatus.md.txt#_Google_Ads_AdManager_V1_AdRuleStatusEnum_AdRuleStatus__INACTIVE).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int` |   |

### hasStatus

### clearStatus

### setStatus

Output only. The AdRuleStatus of the AdRule. This attribute is read-only
and defaults to
[AdRuleStatusEnum.AdRuleStatus.INACTIVE](https://docs.cloud.google.com/php/docs/reference/ad-manager/latest/V1.AdRuleStatusEnum.AdRuleStatus.md.txt#_Google_Ads_AdManager_V1_AdRuleStatusEnum_AdRuleStatus__INACTIVE).

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

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

### getFrequencyCapBehavior

Optional. The FrequencyCapBehavior of the AdRule. This attribute is
optional and defaults to
[AdRuleFrequencyCapBehaviorEnum.AdRuleFrequencyCapBehavior.DEFER](https://docs.cloud.google.com/php/docs/reference/ad-manager/latest/V1.AdRuleFrequencyCapBehaviorEnum.AdRuleFrequencyCapBehavior.md.txt#_Google_Ads_AdManager_V1_AdRuleFrequencyCapBehaviorEnum_AdRuleFrequencyCapBehavior__DEFER).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int` |   |

### hasFrequencyCapBehavior

### clearFrequencyCapBehavior

### setFrequencyCapBehavior

Optional. The FrequencyCapBehavior of the AdRule. This attribute is
optional and defaults to
[AdRuleFrequencyCapBehaviorEnum.AdRuleFrequencyCapBehavior.DEFER](https://docs.cloud.google.com/php/docs/reference/ad-manager/latest/V1.AdRuleFrequencyCapBehaviorEnum.AdRuleFrequencyCapBehavior.md.txt#_Google_Ads_AdManager_V1_AdRuleFrequencyCapBehaviorEnum_AdRuleFrequencyCapBehavior__DEFER).

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

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

### getMaxImpressionsPerLineItemPerStream

Optional. This AdRule object's frequency cap for the maximum impressions
per stream. This attribute is optional and defaults to 0.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int` |   |

### hasMaxImpressionsPerLineItemPerStream

### clearMaxImpressionsPerLineItemPerStream

### setMaxImpressionsPerLineItemPerStream

Optional. This AdRule object's frequency cap for the maximum impressions
per stream. This attribute is optional and defaults to 0.

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

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

### getMaxImpressionsPerLineItemPerPod

Optional. This AdRule object's frequency cap for the maximum impressions
per pod. This attribute is optional and defaults to 0.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int` |   |

### hasMaxImpressionsPerLineItemPerPod

### clearMaxImpressionsPerLineItemPerPod

### setMaxImpressionsPerLineItemPerPod

Optional. This AdRule object's frequency cap for the maximum impressions
per pod. This attribute is optional and defaults to 0.

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

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

### getPreroll

Required. This AdRule object's pre-roll slot. This attribute is required.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `AdRuleSlot|null` |   |

### hasPreroll

### clearPreroll

### setPreroll

Required. This AdRule object's pre-roll slot. This attribute is required.

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

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

### getMidrolls

Required. This AdRule object's video mid-roll slots. This attribute is
required, and there must be at least one mid-roll.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Google\Protobuf\RepeatedField<AdRuleSlot>` |   |

### setMidrolls

Required. This AdRule object's video mid-roll slots. This attribute is
required, and there must be at least one mid-roll.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `array<AdRuleSlot>` |

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

### getPostroll

Required. This AdRule object's post-roll slot. This attribute is required.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `AdRuleSlot|null` |   |

### hasPostroll

### clearPostroll

### setPostroll

Required. This AdRule object's post-roll slot. This attribute is required.

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

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

### getTargeting

Required. The targeting of the `AdRule`.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Targeting|null` |   |

### hasTargeting

### clearTargeting

### setTargeting

Required. The targeting of the `AdRule`.

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

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