summaryrefslogtreecommitdiff
path: root/designateclient/v1
diff options
context:
space:
mode:
authorErik Olof Gunnar Andersson <eandersson@blizzard.com>2019-09-10 19:45:29 -0700
committerErik Olof Gunnar Andersson <eandersson@blizzard.com>2019-09-10 20:53:25 -0700
commit093d8d7170cbf6ef8c7a7c0ff2a4dcd7ecd6361b (patch)
treeaaa453be6cf3df5cf18937694059911329163bf3 /designateclient/v1
parent5c9bbbfac8f03be416b268798045b5814c3fbe06 (diff)
downloadpython-designateclient-train-em.tar.gz
Removing v1 api supporttrain-em3.0.0
The v1 has officially been removed from Designate since the Queens release, and was deperecated long before that. Change-Id: Ic5b44761ff939e2b319924af87849b3a79f9cb07
Diffstat (limited to 'designateclient/v1')
-rw-r--r--designateclient/v1/__init__.py161
-rw-r--r--designateclient/v1/diagnostics.py27
-rw-r--r--designateclient/v1/domains.py93
-rw-r--r--designateclient/v1/quotas.py39
-rw-r--r--designateclient/v1/records.py115
-rw-r--r--designateclient/v1/reports.py67
-rw-r--r--designateclient/v1/servers.py81
-rw-r--r--designateclient/v1/sync.py37
-rw-r--r--designateclient/v1/touch.py24
9 files changed, 0 insertions, 644 deletions
diff --git a/designateclient/v1/__init__.py b/designateclient/v1/__init__.py
deleted file mode 100644
index 2474a4e..0000000
--- a/designateclient/v1/__init__.py
+++ /dev/null
@@ -1,161 +0,0 @@
-# Copyright 2012 Managed I.T.
-#
-# Author: Kiall Mac Innes <kiall@managedit.ie>
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-from debtcollector import removals
-from stevedore import extension
-
-from designateclient import exceptions
-from designateclient import utils
-from designateclient import version
-
-
-@removals.removed_class(
- 'designateclient.v1.Client',
- replacement='designateclient.v2.client.Client',
- message='Designate v1 API is being retired, and the v1 Client class will '
- 'stop functioning. Please update code to the '
- 'designateclient.v2.client.Client class. The API is deprecated',
- version='2.2.0',
- removal_version='?',
- stacklevel=3)
-class Client(object):
- """Client for the Designate v1 API"""
-
- def __init__(self, endpoint=None, username=None, user_id=None,
- user_domain_id=None, user_domain_name=None, password=None,
- tenant_name=None, tenant_id=None, domain_name=None,
- domain_id=None, project_name=None,
- project_id=None, project_domain_name=None,
- project_domain_id=None, auth_url=None, token=None,
- endpoint_type='publicURL', region_name=None,
- service_type='dns', insecure=False, session=None,
- cacert=None, all_tenants=None, edit_managed=None,
- timeout=None):
- """
- :param endpoint: Endpoint URL
- :param token: A token instead of username / password
- :param insecure: Allow "insecure" HTTPS requests
- """
-
- if endpoint:
- endpoint = endpoint.rstrip('/')
- if not endpoint.endswith('v1'):
- endpoint = "%s/v1" % endpoint
-
- # Compatibility code to mimic the old behaviour of the client
- if session is None:
- session = utils.get_session(
- auth_url=auth_url,
- endpoint=endpoint,
- domain_id=domain_id,
- domain_name=domain_name,
- project_id=project_id or tenant_id,
- project_name=project_name or tenant_name,
- project_domain_name=project_domain_name,
- project_domain_id=project_domain_id,
- username=username,
- user_id=user_id,
- password=password,
- user_domain_id=user_domain_id,
- user_domain_name=user_domain_name,
- token=token,
- insecure=insecure,
- cacert=cacert,
- )
-
- # NOTE: all_tenants and edit_managed are pulled from the session for
- # backwards compat reasons, do not pull additional modifiers from
- # here. Once removed, the kwargs above should default to False.
- if all_tenants is None:
- self.all_tenants = getattr(session, 'all_tenants', False)
- else:
- self.all_tenants = all_tenants
-
- if edit_managed is None:
- self.edit_managed = getattr(session, 'edit_managed', False)
- else:
- self.edit_managed = edit_managed
-
- # Since we have to behave nicely like a legacy client/bindings we use
- # an adapter around the session to not modify it's state.
- interface = endpoint_type.rstrip('URL')
-
- self.session = utils.AdapterWithTimeout(
- session,
- auth=session.auth,
- endpoint_override=endpoint,
- region_name=region_name,
- service_type=service_type,
- interface=interface,
- user_agent='python-designateclient-%s' % version.version_info,
- version='1',
- timeout=timeout,
- )
-
- def _load_controller(ext):
- controller = ext.plugin(client=self)
- setattr(self, ext.name, controller)
-
- # Load all controllers
- mgr = extension.ExtensionManager('designateclient.v1.controllers')
- mgr.map(_load_controller)
-
- def wrap_api_call(self, func, *args, **kw):
- """
- Wrap a self.<rest function> with exception handling
-
- :param func: The function to wrap
- """
- kw['raise_exc'] = False
- kw.setdefault('headers', {})
- kw['headers'].setdefault('Content-Type', 'application/json')
- if self.all_tenants:
- kw['headers'].update({'X-Auth-All-Projects': 'true'})
- if self.edit_managed:
- kw['headers'].update({'X-Designate-Edit-Managed-Records': 'true'})
-
- # Trigger the request
- response = func(*args, **kw)
-
- # Decode is response, if possible
- try:
- response_payload = response.json()
- except ValueError:
- response_payload = {}
-
- if response.status_code == 400:
- raise exceptions.BadRequest(**response_payload)
- elif response.status_code in (401, 403, 413):
- raise exceptions.Forbidden(**response_payload)
- elif response.status_code == 404:
- raise exceptions.NotFound(**response_payload)
- elif response.status_code == 409:
- raise exceptions.Conflict(**response_payload)
- elif response.status_code >= 500:
- raise exceptions.Unknown(**response_payload)
- else:
- return response
-
- def get(self, path, **kw):
- return self.wrap_api_call(self.session.get, path, **kw)
-
- def post(self, path, **kw):
- return self.wrap_api_call(self.session.post, path, **kw)
-
- def put(self, path, **kw):
- return self.wrap_api_call(self.session.put, path, **kw)
-
- def delete(self, path, **kw):
- return self.wrap_api_call(self.session.delete, path, **kw)
diff --git a/designateclient/v1/diagnostics.py b/designateclient/v1/diagnostics.py
deleted file mode 100644
index d2e5153..0000000
--- a/designateclient/v1/diagnostics.py
+++ /dev/null
@@ -1,27 +0,0 @@
-# Copyright 2012 Managed I.T.
-#
-# Author: Kiall Mac Innes <kiall@managedit.ie>
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-from designateclient import client
-
-
-class DiagnosticsController(client.Controller):
- def ping(self, service, host):
- """
- Ping a service on a given host
- """
- response = self.client.get('/diagnostics/ping/%s/%s' %
- (service, host))
-
- return response.json()
diff --git a/designateclient/v1/domains.py b/designateclient/v1/domains.py
deleted file mode 100644
index 1430bbf..0000000
--- a/designateclient/v1/domains.py
+++ /dev/null
@@ -1,93 +0,0 @@
-# Copyright 2012 Managed I.T.
-#
-# Author: Kiall Mac Innes <kiall@managedit.ie>
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from oslo_serialization import jsonutils
-
-from designateclient import client
-from designateclient import utils
-from designateclient import warlock
-
-
-Domain = warlock.model_factory(utils.load_schema('v1', 'domain'))
-Server = warlock.model_factory(utils.load_schema('v1', 'server'))
-
-
-class DomainsController(client.CrudController):
- def list(self):
- """
- Retrieve a list of domains
-
- :returns: A list of :class:`Domain`
- """
- response = self.client.get('/domains')
-
- return [Domain(i) for i in response.json()['domains']]
-
- def get(self, domain_id):
- """
- Retrieve a domain
-
- :param domain_id: Domain Identifier
- :returns: :class:`Domain`
- """
- response = self.client.get('/domains/%s' % domain_id)
-
- return Domain(response.json())
-
- def create(self, domain):
- """
- Create a domain
-
- :param domain: A :class:`Domain` to create
- :returns: :class:`Domain`
- """
- response = self.client.post('/domains', data=jsonutils.dumps(domain))
-
- return Domain(response.json())
-
- def update(self, domain):
- """
- Update a domain
-
- :param domain: A :class:`Domain` to update
- :returns: :class:`Domain`
- """
- response = self.client.put('/domains/%s' % domain.id,
- data=jsonutils.dumps(domain.changes))
-
- return Domain(response.json())
-
- def delete(self, domain):
- """
- Delete a domain
-
- :param domain: A :class:`Domain`, or Domain Identifier to delete
- """
- if isinstance(domain, Domain):
- self.client.delete('/domains/%s' % domain.id)
- else:
- self.client.delete('/domains/%s' % domain)
-
- def list_domain_servers(self, domain_id):
- """
- Retrieve the list of nameservers for a domain
-
- :param domain_id: Domain Identifier
- :returns: A list of :class:`Server`
- """
- response = self.client.get('/domains/%s/servers' % domain_id)
-
- return [Server(i) for i in response.json()['servers']]
diff --git a/designateclient/v1/quotas.py b/designateclient/v1/quotas.py
deleted file mode 100644
index 432edf2..0000000
--- a/designateclient/v1/quotas.py
+++ /dev/null
@@ -1,39 +0,0 @@
-# Copyright 2014 Hewlett-Packard Development Company, L.P.
-#
-# Author: Endre Karlson <endre.karlson@hp.com>
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from oslo_serialization import jsonutils
-
-from designateclient import client
-
-
-class QuotasController(client.Controller):
- def get(self, tenant_id):
- """
- Ping a service on a given host
- """
- response = self.client.get('/quotas/%s' % tenant_id)
-
- return response.json()
-
- def update(self, tenant_id, values):
- response = self.client.put('/quotas/%s' % tenant_id,
- data=jsonutils.dumps(values))
- return response.json()
-
- def reset(self, tenant_id):
- response = self.client.delete('/quotas/%s' % tenant_id)
-
- return response
diff --git a/designateclient/v1/records.py b/designateclient/v1/records.py
deleted file mode 100644
index c239e12..0000000
--- a/designateclient/v1/records.py
+++ /dev/null
@@ -1,115 +0,0 @@
-# Copyright 2012 Managed I.T.
-#
-# Author: Kiall Mac Innes <kiall@managedit.ie>
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from oslo_serialization import jsonutils
-
-from designateclient import client
-from designateclient import utils
-from designateclient.v1.domains import Domain
-from designateclient import warlock
-
-
-Record = warlock.model_factory(utils.load_schema('v1', 'record'))
-
-
-class RecordsController(client.CrudController):
- def list(self, domain):
- """
- Retrieve a list of records
-
- :param domain: :class:`Domain` or Domain Identifier
- :returns: A list of :class:`Record`
- """
- domain_id = domain.id if isinstance(domain, Domain) else domain
-
- response = self.client.get('/domains/%(domain_id)s/records' % {
- 'domain_id': domain_id
- })
-
- return [Record(i) for i in response.json()['records']]
-
- def get(self, domain, record_id):
- """
- Retrieve a record
-
- :param domain: :class:`Domain` or Domain Identifier
- :param record_id: Record Identifier
- :returns: :class:`Record`
- """
- domain_id = domain.id if isinstance(domain, Domain) else domain
-
- uri = '/domains/%(domain_id)s/records/%(record_id)s' % {
- 'domain_id': domain_id,
- 'record_id': record_id
- }
-
- response = self.client.get(uri)
-
- return Record(response.json())
-
- def create(self, domain, record):
- """
- Create a record
-
- :param domain: :class:`Domain` or Domain Identifier
- :param record: A :class:`Record` to create
- :returns: :class:`Record`
- """
- domain_id = domain.id if isinstance(domain, Domain) else domain
-
- uri = '/domains/%(domain_id)s/records' % {
- 'domain_id': domain_id
- }
-
- response = self.client.post(uri, data=jsonutils.dumps(record))
-
- return Record(response.json())
-
- def update(self, domain, record):
- """
- Update a record
-
- :param domain: :class:`Domain` or Domain Identifier
- :param record: A :class:`Record` to update
- :returns: :class:`Record`
- """
- domain_id = domain.id if isinstance(domain, Domain) else domain
-
- uri = '/domains/%(domain_id)s/records/%(record_id)s' % {
- 'domain_id': domain_id,
- 'record_id': record.id
- }
-
- response = self.client.put(uri, data=jsonutils.dumps(record.changes))
-
- return Record(response.json())
-
- def delete(self, domain, record):
- """
- Delete a record
-
- :param domain: :class:`Domain` or Domain Identifier
- :param record: A :class:`Record`, or Record Identifier to delete
- """
- domain_id = domain.id if isinstance(domain, Domain) else domain
- record_id = record.id if isinstance(record, Record) else record
-
- uri = '/domains/%(domain_id)s/records/%(record_id)s' % {
- 'domain_id': domain_id,
- 'record_id': record_id
- }
-
- self.client.delete(uri)
diff --git a/designateclient/v1/reports.py b/designateclient/v1/reports.py
deleted file mode 100644
index 4a32c6c..0000000
--- a/designateclient/v1/reports.py
+++ /dev/null
@@ -1,67 +0,0 @@
-# Copyright 2013 Hewlett-Packard Development Company, L.P. All Rights Reserved.
-#
-# Author: Patrick Galbraith <patg@patg.net>
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-from designateclient import client
-
-
-class ReportsController(client.Controller):
- def count_all(self):
- """
- Domain, Records and tenant total count
- """
- response = self.client.get('/reports/counts')
-
- return response.json()
-
- def count_domains(self):
- """
- Domain total count
- """
- response = self.client.get('/reports/counts/domains')
-
- return response.json()
-
- def count_tenants(self):
- """
- Tenant total count
- """
- response = self.client.get('/reports/counts/tenants')
-
- return response.json()
-
- def count_records(self):
- """
- Record total count
- """
- response = self.client.get('/reports/counts/records')
-
- return response.json()
-
- def tenants_all(self):
- """
- Per tenant count
- """
- response = self.client.get('/reports/tenants')
-
- return response.json()['tenants']
-
- def tenant_domains(self, other_tenant_id):
- """
- Tenant's domain count
- """
- response = self.client.get('/reports/tenants/%s' %
- other_tenant_id)
-
- return [{'domain': d} for d in response.json()['domains']]
diff --git a/designateclient/v1/servers.py b/designateclient/v1/servers.py
deleted file mode 100644
index 34dcca6..0000000
--- a/designateclient/v1/servers.py
+++ /dev/null
@@ -1,81 +0,0 @@
-# Copyright 2012 Managed I.T.
-#
-# Author: Kiall Mac Innes <kiall@managedit.ie>
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from oslo_serialization import jsonutils
-
-from designateclient import client
-from designateclient import utils
-from designateclient import warlock
-
-
-Server = warlock.model_factory(utils.load_schema('v1', 'server'))
-
-
-class ServersController(client.CrudController):
- def list(self):
- """
- Retrieve a list of servers
-
- :returns: A list of :class:`Server`
- """
- response = self.client.get('/servers')
-
- return [Server(i) for i in response.json()['servers']]
-
- def get(self, server_id):
- """
- Retrieve a server
-
- :param server_id: Server Identifier
- :returns: :class:`Server`
- """
- response = self.client.get('/servers/%s' % server_id)
-
- return Server(response.json())
-
- def create(self, server):
- """
- Create a server
-
- :param server: A :class:`Server` to create
- :returns: :class:`Server`
- """
- response = self.client.post('/servers', data=jsonutils.dumps(server))
-
- return Server(response.json())
-
- def update(self, server):
- """
- Update a server
-
- :param server: A :class:`Server` to update
- :returns: :class:`Server`
- """
- response = self.client.put('/servers/%s' % server.id,
- data=jsonutils.dumps(server.changes))
-
- return Server(response.json())
-
- def delete(self, server):
- """
- Delete a server
-
- :param server: A :class:`Server`, or Server Identifier to delete
- """
- if isinstance(server, Server):
- self.client.delete('/servers/%s' % server.id)
- else:
- self.client.delete('/servers/%s' % server)
diff --git a/designateclient/v1/sync.py b/designateclient/v1/sync.py
deleted file mode 100644
index f86e642..0000000
--- a/designateclient/v1/sync.py
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright 2012 Managed I.T.
-#
-# Author: Kiall Mac Innes <kiall@managedit.ie>
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-from designateclient import client
-
-
-class SyncController(client.Controller):
- def sync_all(self):
- """
- Sync Everything
- """
- self.client.post('/domains/sync')
-
- def sync_domain(self, domain_id):
- """
- Sync Single Domain
- """
- self.client.post('/domains/%s/sync' % domain_id)
-
- def sync_record(self, domain_id, record_id):
- """
- Sync Single Record
- """
- self.client.post('/domains/%s/records/%s/sync' %
- (domain_id, record_id))
diff --git a/designateclient/v1/touch.py b/designateclient/v1/touch.py
deleted file mode 100644
index bbbdbd2..0000000
--- a/designateclient/v1/touch.py
+++ /dev/null
@@ -1,24 +0,0 @@
-# Copyright 2013 Hewlett-Packard Development Company, L.P.
-#
-# Author: Kiall Mac Innes <kiall@hp.com>
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-from designateclient import client
-
-
-class TouchController(client.Controller):
- def domain(self, domain_id):
- """
- Touch a single Domain
- """
- self.client.post('/domains/%s/touch' % domain_id)