Exemple #1
0
    def create_collection(self, service, name):
        """Creates a collection object corresponding to the given service and
        name.

        :param str service: Name of the parent service.
        :param str name: Name of the collection.

        :returns: A ``jnpr.space.collection.Collection`` object.

        """
        if name in self._meta_collections:
            from jnpr.space import collection
            m_obj = collection.get_meta_object(self.get_application_name(),
                                               service._name, name,
                                               self._meta_collections[name])
            return collection.Collection(service, name, m_obj)
Exemple #2
0
    def create_collection(self, service, name):
        """Creates a collection object corresponding to the given service and
        name.

        :param str service: Name of the parent service.
        :param str name: Name of the collection.

        :returns: A ``jnpr.space.collection.Collection`` object.

        """
        if name in self._meta_collections:
            from jnpr.space import collection
            m_obj = collection.get_meta_object(self.get_application_name(),
                                               service._name,
                                               name,
                                               self._meta_collections[name])
            return collection.Collection(service, name, m_obj)
Exemple #3
0
    def __init__(self, app_name, service_name, key, values):
        """Initializes a MetaResource object.

        :param str app_name: Name of the app to which this resource
            belongs. Some examples are:

            * ``servicenow``
            * ``serviceinsight``

        :param str service_name: Name of the service to which this resource
            belongs. Some examples are:

            * ``device_management``
            * ``user_management``

        :param str key: Type name of the resource. Some examples are:

            * ``device``
            * ``user``

        :param dict values:  Attribute value settings which form the meta data
            for this resource. This is read from the descriptions yml file for
            the corresponding service.

        """
        self.values = values
        self.app_name = app_name
        self.service_name = service_name
        self.key = key
        self.name = values['name'] \
            if ('name' in values) else None
        self.xml_name = values['xml_name'] \
            if ('xml_name' in values) else None
        self.media_type = values['media_type'] \
            if ('media_type' in values) else None
        self.retain_charset_in_accept = values['retain_charset_in_accept'] \
            if ('retain_charset_in_accept' in values) else False
        self.collection_name = values['collection_name'] \
            if ('collection_name' in values) else None
        self.service_url = values['service_url'] \
            if ('service_url' in values) else None
        self.use_uri_for_delete = values['use_uri_for_delete'] \
            if ('use_uri_for_delete' in values) else False
        self.remove_junos_group = values['remove_junos_group'] \
            if ('remove_junos_group' in values) else False
        self.collections = {}
        self.methods = {}

        self.request_type = values['request_type'] \
            if ('request_type' in values) else None
        self.response_type = values['response_type'] \
            if 'response_type' in values else None

        if 'request_template' in values:
            env = Environment(loader=PackageLoader('jnpr.space', 'templates'))
            self.request_template = env.get_template(
                values['request_template'])
        else:
            self.request_template = None

        try:
            from jnpr.space import collection
            for key in values['collections']:
                value = values['collections'][key]
                m_obj = collection.get_meta_object(self.app_name,
                                                   self.service_name,
                                                   self.key + ':' + key, value)
                self.collections[key] = m_obj
        except KeyError:
            pass

        try:
            from jnpr.space import method
            for key in values['methods']:
                value = values['methods'][key]
                m_obj = method.get_meta_object(self.app_name,
                                               self.service_name, key, value)
                self.methods[key] = m_obj
        except KeyError:
            pass
    def __init__(self, app_name, service_name, key, values):
        """Initializes a MetaResource object.

        :param str app_name: Name of the app to which this resource
            belongs. Some examples are:

            * ``servicenow``
            * ``serviceinsight``

        :param str service_name: Name of the service to which this resource
            belongs. Some examples are:

            * ``device_management``
            * ``user_management``

        :param str key: Type name of the resource. Some examples are:

            * ``device``
            * ``user``

        :param dict values:  Attribute value settings which form the meta data
            for this resource. This is read from the descriptions yml file for
            the corresponding service.

        """
        self.values = values
        self.app_name = app_name
        self.service_name = service_name
        self.key = key
        self.name = values['name'] \
            if ('name' in values) else None
        self.xml_name = values['xml_name'] \
            if ('xml_name' in values) else None
        self.media_type = values['media_type'] \
            if ('media_type' in values) else None
        self.retain_charset_in_accept = values['retain_charset_in_accept'] \
            if ('retain_charset_in_accept' in values) else False
        self.collection_name = values['collection_name'] \
            if ('collection_name' in values) else None
        self.service_url = values['service_url'] \
            if ('service_url' in values) else None
        self.use_uri_for_delete = values['use_uri_for_delete'] \
            if ('use_uri_for_delete' in values) else False
        self.remove_junos_group = values['remove_junos_group'] \
            if ('remove_junos_group' in values) else False
        self.collections = {}
        self.methods = {}

        self.request_type = values['request_type'] \
            if ('request_type' in values) else None
        self.response_type = values['response_type'] \
            if 'response_type' in values else None

        if 'request_template' in values:
            env = Environment(loader=PackageLoader('jnpr.space',
                                                   'templates'))
            self.request_template = env.get_template(values['request_template'])
        else:
            self.request_template = None

        try:
            from jnpr.space import collection
            for key in values['collections']:
                value = values['collections'][key]
                m_obj = collection.get_meta_object(self.app_name,
                                                   self.service_name,
                                                   self.key + ':' + key,
                                                   value)
                self.collections[key] = m_obj
        except KeyError:
            pass

        try:
            from jnpr.space import method
            for key in values['methods']:
                value = values['methods'][key]
                m_obj = method.get_meta_object(self.app_name,
                                               self.service_name,
                                               key,
                                               value)
                self.methods[key] = m_obj
        except KeyError:
            pass