#
#      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.

import json

from designateclient import utils
from designateclient.v1.base import CrudController
from designateclient import warlock

Server = warlock.model_factory(utils.load_schema('v1', 'server'))


class ServersController(CrudController):
    def list(self):
        """
        Retrieve a list of servers

        :returns: A list of :class:`Server`s
        """
        response = self.client.get('/servers')

        return [Server(i) for i in response.json()['servers']]

    def get(self, server_id):
        """
#         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.

import uuid

from designateclient.tests import test_v1
from designateclient import utils
from designateclient import warlock


Record = warlock.model_factory(utils.load_schema('v1', 'record'))

DOMAIN = {
    "id": str(uuid.uuid4()),
    "name": "example.com."
}


class TestRecords(test_v1.APIV1TestCase, test_v1.CrudMixin):
    RESOURCE = 'records'

    def new_ref(self, **kwargs):
        ref = super(TestRecords, self).new_ref(**kwargs)
        ref.setdefault("name", uuid.uuid4().hex)
        ref.setdefault("type", "A")
        ref.setdefault("data", "10.0.0.1")
Example #3
0
#      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.

import json

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`s
        """
        domain_id = domain.id if isinstance(domain, Domain) else domain

        response = self.client.get('/domains/%(domain_id)s/records' %
                                   {'domain_id': domain_id})
#    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.

import uuid

from mock import patch

from designateclient.tests import test_v1
from designateclient import utils
from designateclient.v1 import domains
from designateclient import warlock

Domain = warlock.model_factory(utils.load_schema('v1', 'domain'))


class TestDomain(test_v1.APIV1TestCase, test_v1.CrudMixin):
    RESOURCE = 'domains'

    def new_ref(self, **kwargs):
        ref = super(TestDomain, self).new_ref(**kwargs)
        ref.setdefault("name", uuid.uuid4().hex)
        ref.setdefault("email", "[email protected].")
        ref.setdefault("ttl", 3600)
        return ref

    def test_create(self):
        ref = {"id": "89acac79-38e7-497d-807c-a011e1310438",
               "name": "domain1.com.",
#      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):
        """
#    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.

import uuid

from mock import patch

from designateclient.tests import test_v1
from designateclient import utils
from designateclient.v1 import domains
from designateclient import warlock

Domain = warlock.model_factory(utils.load_schema('v1', 'domain'))


class TestDomain(test_v1.APIV1TestCase, test_v1.CrudMixin):
    RESOURCE = 'domains'

    def new_ref(self, **kwargs):
        ref = super(TestDomain, self).new_ref(**kwargs)
        ref.setdefault("name", uuid.uuid4().hex)
        ref.setdefault("email", "[email protected].")
        ref.setdefault("ttl", 3600)
        return ref

    def test_create(self):
        ref = {
            "id": "89acac79-38e7-497d-807c-a011e1310438",
Example #7
0
#
#      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.
import json

from designateclient import utils
from designateclient.v1.base import CrudController
from designateclient import warlock


Domain = warlock.model_factory(utils.load_schema("v1", "domain"))
Server = warlock.model_factory(utils.load_schema("v1", "server"))


class DomainsController(CrudController):
    def list(self):
        """
        Retrieve a list of domains

        :returns: A list of :class:`Domain`s
        """
        response = self.client.get("/domains")

        return [Domain(i) for i in response.json()["domains"]]

    def get(self, domain_id):