NAT API

The Network Address Translation Class

The nat high-level interface is available through the nat member of a Connection object. The nat member will only be added if the otcextensions.sdk.register_otc_extensions(conn) method is called.

Gateway Operations

class otcextensions.sdk.nat.v2._proxy.Proxy(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)
create_gateway(**attrs)

Create a new gateway from attributes

Parameters

attrs (dict) – Keyword arguments which will be used to create a Gateway, comprised of the properties on the Gateway class.

Returns

The results of the Gateway Creation

Return type

Gateway

delete_gateway(gateway, ignore_missing=True)

Delete a gateway

Parameters
  • gateway – The value can be the ID of a NAT Gatway or a Gateway instance.

  • ignore_missing (bool) – When set to False ResourceNotFound will be raised when the gateway does not exist. When set to True, no exception will be set when attempting to delete a nonexistent gateway.

Returns

None

gateways(**query)

Return a generator of gateways

Parameters

query (dict) – Optional query parameters to be sent to limit the resources being returned.

Returns

A generator of gateway objects.

update_gateway(gateway, **attrs)

Update a gateway

Parameters
  • gateway – The value can be either the ID of a gateway or a Gateway instance.

  • attrs (dict) – The attributes to update on the gateway represented by gateway.

Returns

The updated gateway.

Return type

Gateway

find_gateway(name_or_id, ignore_missing=False)

Find a single gateway

Parameters
  • name_or_id – The name or ID of a gateway

  • ignore_missing (bool) – When set to False ResourceNotFound will be raised when the gateway does not exist. When set to True, no exception will be set when attempting to find a nonexistent gateway.

Returns

One Gateway or None

SNAT Rule Operations

class otcextensions.sdk.nat.v2._proxy.Proxy(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)
create_snat_rule(**attrs)

Create a new SNAT rule from attributes

Parameters

attrs (dict) – Keyword arguments which will be used to create a Snat, comprised of the properties on the Snat class.

Returns

The result of Snat rule creation

Return type

Snat

delete_snat_rule(snat, ignore_missing=True)

Delete a SNAT rule

Parameters
  • gateway – The value can be the ID of a snat rule or a Snat instance.

  • ignore_missing (bool) – When set to False ResourceNotFound will be raised when the snat rule does not exist. When set to True, no exception will be set when attempting to delete a nonexistent snat rule.

Returns

None

get_snat_rule(snat_rule)

Get a single SNAT rule

Parameters

snat_rule – The value can be the ID of a snat rule or a Snat instance.

Returns

One Snat

Raises

ResourceNotFound when no resource can be found.

snat_rules(**query)

Return a generator of SNAT rules

Parameters

query (dict) – Optional query parameters to be sent to limit the snat rules being returned.

Returns

A generator of Snat objects.

DNAT Rule Operations

class otcextensions.sdk.nat.v2._proxy.Proxy(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)
create_dnat_rule(**attrs)

Create a new DNAT rule from attributes

Parameters

attrs (dict) – Keyword arguments which will be used to create a Dnat, comprised of the properties on the Dnat class.

Returns

The result of Dnat rule creation.

Return type

Dnat

delete_dnat_rule(dnat, ignore_missing=True)

Delete a DNAT rule

Parameters
  • gateway – The value can be the ID of a dnat rule or a Dnat instance.

  • ignore_missing (bool) – When set to False ResourceNotFound will be raised when the dnat rule does not exist. When set to True, no exception will be set when attempting to delete a nonexistent dnat rule.

Returns

None

get_dnat_rule(dnat_rule)

Get a single DNAT rule

Parameters

snat_rule – The value can be the ID of a dnat rule or a Dnat instance.

Returns

One Dnat

Raises

ResourceNotFound when no resource can be found.

dnat_rules(**query)

Return a generator of DNAT rules

Parameters

query (dict) – Optional query parameters to be sent to limit the resources being returned.

Returns

A generator of Dnat objects.