HTTP Redirect

class dyn.tm.services.httpredirect.HTTPRedirect(zone, fqdn, *args, **kwargs)[source]

HTTPRedirect is a service which sets up a redirect to the specified URL.//

__init__(zone, fqdn, *args, **kwargs)[source]

Create a new HTTPRedirect service object

Parameters:
  • zone – The zone to attach this HTTPRedirect Service to
  • fqdn – The FQDN of the node where this service will be attached
  • code – HTTP response code to return for redirection.
  • url – The target URL where the client is sent. Must begin with either http:// or https://
  • keep_uri – A flag indicating whether the redirection should include the originally requested URI.
code

HTTP response code to return for redirection. Valid values:

301 – Permanent redirect 302 – Temporary redirect
delete(publish='Y')[source]

Delete this HTTPRedirect service from the DynECT System publish=’N’ can be passed into this function to do a soft-delete which will be acted upon during a zone publish.

fqdn

The fqdn that this HTTPRedirect Service is attached to is a read-only attribute

keep_uri

A flag indicating whether the redirection should include the originally requested URI.

Valid values: Y, N
url

The target URL where the client is sent. Must begin with either http:// or https://

zone

The zone that this HTTPRedirect Service is attached to is a read-only attribute

HTTP Redirect Examples

The following examples highlight how to use the HTTPRedirect class to get/create HTTPRedirect‘s on the dyn.tm System and how to edit these objects from within a Python script.

Creating a new HTTP Redirect Service

The following example shows how to create a new HTTPRedirect on the dyn.tm System and how to edit some of the fields using the returned HTTPRedirect object.

>>> from dyn.tm.services.httpredirect import HTTPRedirect
>>> # Create a dyn.tmSession
>>> # Assuming you own the zone 'example.com'
>>> redir = HTTPRedirect('example.com', 'example.com', 302, keep_uri='Y',
...                      url='http://dyn.com')
>>> redir.zone
'example.com'
>>> redir.code
302

Getting an Existing HTTP Redirect DNS Service

The following example shows how to get an existing HTTPRedirect from the dyn.tm System and how to edit some of the same fields mentioned above.

>>> from dyn.tm.services.httpredirect import HTTPRedirect
>>> # Create a dyn.tmSession
>>> # Once again, assuming you own 'example.com'
>>> rdns = HTTPRedirect('example.com', 'example.com', my_rdns_id)