# Managed Zones

0.37.0 (latest) 0.36.1 0.35.1 0.34.2 0.33.1 0.32.3 0.31.0 0.30.2 Define API ManagedZones.

### *class* google.cloud.dns.zone.ManagedZone(name, dns_name=None, client=None, description=None)

Bases: [`object`](https://docs.python.org/3/library/functions.html#object)

ManagedZones are containers for DNS resource records.

See
<https://cloud.google.com/dns/api/v1/managedZones>

- **Parameters**

  - **name** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) -- the name of the zone

  - **dns_name** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) -- (Optional) the DNS name of the zone. If not passed, then calls to
    `create()` will fail.

  - **client** ([`google.cloud.dns.client.Client`](https://docs.cloud.google.com/python/docs/reference/dns/latest/client#google.cloud.dns.client.Client)) -- A client which holds credentials and project configuration
    for the zone (which requires a project).

  - **description** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) -- (Optional) the description for the zone. If not passed, defaults to
    the value of 'dns_name'.

#### changes()

Construct a change set bound to this zone.

- **Return type**

  [`google.cloud.dns.changes.Changes`](https://docs.cloud.google.com/python/docs/reference/dns/latest/changes#google.cloud.dns.changes.Changes)
- **Returns**

  a new `Changes` instance

#### create(client=None)

API call: create the zone via a PUT request

See
<https://cloud.google.com/dns/api/v1/managedZones/create>

- **Parameters**

  **client** ([`google.cloud.dns.client.Client`](https://docs.cloud.google.com/python/docs/reference/dns/latest/client#google.cloud.dns.client.Client)) -- (Optional) the client to use. If not passed, falls back to the
  `client` stored on the current zone.

#### *property* created()

Datetime at which the zone was created.

- **Return type**

  `datetime.datetime`, or `NoneType`
- **Returns**

  the creation time (None until set from the server).

#### delete(client=None)

API call: delete the zone via a DELETE request

See
<https://cloud.google.com/dns/api/v1/managedZones/delete>

- **Parameters**

  **client** ([`google.cloud.dns.client.Client`](https://docs.cloud.google.com/python/docs/reference/dns/latest/client#google.cloud.dns.client.Client)) -- (Optional) the client to use. If not passed, falls back to the
  `client` stored on the current zone.

#### *property* description()

Description of the zone.

- **Return type**

  str, or `NoneType`
- **Returns**

  The description as set by the user, or None (the default).

#### exists(client=None)

API call: test for the existence of the zone via a GET request

See
<https://cloud.google.com/dns/api/v1/managedZones/get>

- **Parameters**

  **client** ([`google.cloud.dns.client.Client`](https://docs.cloud.google.com/python/docs/reference/dns/latest/client#google.cloud.dns.client.Client)) -- (Optional) the client to use. If not passed, falls back to the
  `client` stored on the current zone.
- **Return type**

  [bool](https://docs.python.org/3/library/functions.html#bool)
- **Returns**

  Boolean indicating existence of the managed zone.

#### *classmethod* from_api_repr(resource, client)

Factory: construct a zone given its API representation

- **Parameters**

  - **resource** ([*dict*](https://docs.python.org/3/library/stdtypes.html#dict)) -- zone resource representation returned from the API

  - **client** ([`google.cloud.dns.client.Client`](https://docs.cloud.google.com/python/docs/reference/dns/latest/client#google.cloud.dns.client.Client)) -- Client which holds credentials and project
    configuration for the zone.

- **Return type**

  `google.cloud.dns.zone.ManagedZone`
- **Returns**

  Zone parsed from `resource`.

#### list_changes(max_results=None, page_token=None, client=None)

List change sets for this zone.

See
<https://cloud.google.com/dns/api/v1/resourceRecordSets/list>

- **Parameters**

  - **max_results** ([*int*](https://docs.python.org/3/library/functions.html#int)) -- Optional. The maximum number of change sets
    to return. Defaults to a sensible value set by the API.

  - **page_token** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) -- Optional. If present, return the next batch of
    change sets, using the value, which must correspond to the
    `nextPageToken` value returned in the previous response.
    Deprecated: use the `pages` property of the returned iterator
    instead of manually passing the token.

  - **client** ([`google.cloud.dns.client.Client`](https://docs.cloud.google.com/python/docs/reference/dns/latest/client#google.cloud.dns.client.Client)) -- (Optional) the client to use. If not passed, falls back to the
    `client` stored on the current zone.

- **Return type**

  [`Iterator`](https://googleapis.dev/python/google-api-core/latest/page_iterator.html#google.api_core.page_iterator.Iterator)
- **Returns**

  Iterator of [`Changes`](https://docs.cloud.google.com/python/docs/reference/dns/latest/changes#google.cloud.dns.changes.Changes)
  belonging to this zone.

#### list_resource_record_sets(max_results=None, page_token=None, client=None)

List resource record sets for this zone.

See
<https://cloud.google.com/dns/api/v1/resourceRecordSets/list>

- **Parameters**

  - **max_results** ([*int*](https://docs.python.org/3/library/functions.html#int)) -- Optional. The maximum number of resource record
    sets to return. Defaults to a sensible value
    set by the API.

  - **page_token** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) -- Optional. If present, return the next batch of
    resource record sets, using the value, which must correspond to
    the `nextPageToken` value returned in the previous response.
    Deprecated: use the `pages` property of the returned iterator
    instead of manually passing the token.

  - **client** ([`google.cloud.dns.client.Client`](https://docs.cloud.google.com/python/docs/reference/dns/latest/client#google.cloud.dns.client.Client)) -- (Optional) the client to use. If not passed, falls back to the
    `client` stored on the current zone.

- **Return type**

  [`Iterator`](https://googleapis.dev/python/google-api-core/latest/page_iterator.html#google.api_core.page_iterator.Iterator)
- **Returns**

  Iterator of [`ResourceRecordSet`](https://docs.cloud.google.com/python/docs/reference/dns/latest/resource-record-set#google.cloud.dns.resource_record_set.ResourceRecordSet)
  belonging to this zone.

#### *property* name_server_set()

Named set of DNS name servers that all host the same ManagedZones.

Most users will leave this blank.

See
<https://cloud.google.com/dns/api/v1/managedZones#nameServerSet>

- **Return type**

  str, or `NoneType`
- **Returns**

  The name as set by the user, or None (the default).

#### *property* name_servers()

Datetime at which the zone was created.

- **Return type**

  list of strings, or `NoneType`.
- **Returns**

  the assigned name servers (None until set from the server).

#### *property* path()

URL path for the zone's APIs.

- **Return type**

  [str](https://docs.python.org/3/library/stdtypes.html#str)
- **Returns**

  the path based on project and dataste name.

#### *property* project()

Project bound to the zone.

- **Return type**

  [str](https://docs.python.org/3/library/stdtypes.html#str)
- **Returns**

  the project (derived from the client).

#### reload(client=None)

API call: refresh zone properties via a GET request

See
<https://cloud.google.com/dns/api/v1/managedZones/get>

- **Parameters**

  **client** ([`google.cloud.dns.client.Client`](https://docs.cloud.google.com/python/docs/reference/dns/latest/client#google.cloud.dns.client.Client)) -- (Optional) the client to use. If not passed, falls back to the
  `client` stored on the current zone.

#### resource_record_set(name, record_type, ttl, rrdatas)

Construct a resource record set bound to this zone.

- **Parameters**

  - **name** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) -- Name of the record set.

  - **record_type** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) -- RR type

  - **ttl** ([*int*](https://docs.python.org/3/library/functions.html#int)) -- TTL for the RR, in seconds

  - **rrdatas** (*list of string*) -- resource data for the RR

- **Return type**

  [`google.cloud.dns.resource_record_set.ResourceRecordSet`](https://docs.cloud.google.com/python/docs/reference/dns/latest/resource-record-set#google.cloud.dns.resource_record_set.ResourceRecordSet)
- **Returns**

  a new `ResourceRecordSet` instance

#### *property* zone_id()

ID for the zone resource.

- **Return type**

  str, or `NoneType`
- **Returns**

  the ID (None until set from the server).