• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python resource.Resource类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mixcoatl.resource.Resource的典型用法代码示例。如果您正苦于以下问题:Python Resource类的具体用法?Python Resource怎么用?Python Resource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Resource类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: all

    def all(cls, server_id, keys_only=False, **kwargs):
        """Get all analytics for `server_id`

        :param server_id: The server represented in the analytics
        :type server_id: int.
        :param data_only: Return only the datapoints
        :type data_only: bool.
        :param interval: The interval in minutes for the requested data points
        :type interval: int.
        :param period_start: The start time in UNIX milliseconds for the first datapoint
        :param period_start: int.
        :param period_end: The end time in UNIX milliseconds for the last datapoint
        :param period_end: int.
        :returns: :class:`ServerAnalytics` or `list` of :attr:`data_points`
        """
        r = Resource(cls.PATH)
        params = {}
        if 'detail' in kwargs:
            r.request_details = kwargs['detail']
        else:
            r.request_details = 'basic'

        if 'server_id' in kwargs:
            params['server_id'] = kwargs['server_id']

        x = r.get(params=params)
        if r.last_error is None:
            if keys_only is True:
                return [i[camelize(cls.PRIMARY_KEY)] for i in x[cls.COLLECTION_NAME]]
            else:
                return [type(cls.__name__, (object,), i) for i in uncamel_keys(x)[cls.COLLECTION_NAME]]
        else:
            raise ServerAnalyticsException(r.last_error)
开发者ID:cjblythe25,项目名称:mixcoatl,代码行数:33,代码来源:server_analytics.py


示例2: all

    def all(cls, endpoint=None, **kwargs):
        r = Resource(cls.PATH,endpoint=endpoint)
        params = {}
        if 'detail' in kwargs:
            r.request_details = kwargs['detail']
        else:
            r.request_details = 'basic'

        if 'keys_only' in kwargs:
            keys_only = kwargs['keys_only']
        else:
            keys_only = False

        if 'params' in kwargs:
            params = kwargs['params']

        x = r.get(params=params)
        if r.last_error is None:
            if keys_only is True:
                results = [i[camelize(cls.PRIMARY_KEY)] for i in x[cls.COLLECTION_NAME]]
            else:
                results = [type(cls.__name__, (object,), i) for i in uncamel_keys(x)[cls.COLLECTION_NAME]]
            return results
        else:
            raise RelationalDatabaseException(r.last_error)
开发者ID:enStratus,项目名称:mixcoatl,代码行数:25,代码来源:relational_database.py


示例3: __init__

    def __init__(self, network_id = None, *args, **kwargs):
        Resource.__init__(self)

        if 'detail' in kwargs:
            self.request_details = kwargs['detail']

        self.__network_id = network_id
开发者ID:irvingpop,项目名称:mixcoatl,代码行数:7,代码来源:network.py


示例4: all

    def all(cls, region_id, **kwargs):
        """Return all data centers

        :param region_id: Required. The region to query against
        :type region_id: int.
        :param keys_only: Return :attr:`data_center_id` instead of :class:`DataCenter`
        :type keys_only: bool.
        :param detail: The level of detail to return - `basic` or `extended`
        :type detail: str.
        :returns: `list` of :class:`DataCenter` or :attr:`data_center_id`
        :raises: :class:`DataCenterException`
        """
        if 'keys_only' in kwargs:
            keys_only = kwargs['keys_only']
        else:
            keys_only = False

        r = Resource(cls.PATH)
        r.request_details = 'basic'
        params = {'regionId':region_id}
        c = r.get(params=params)
        if r.last_error is None:
            if keys_only is True:
                dcs = [i['dataCenterId'] for i in c[cls.COLLECTION_NAME]]
            else:
                dcs = []
                for i in c[cls.COLLECTION_NAME]:
                    dc = cls(i['dataCenterId'])
                    if 'detail' in kwargs:
                        dc.request_details = kwargs['detail']
                    dc.load()
                    dcs.append(dc)
            return dcs
        else:
            raise DataCenterException(r.last_error)
开发者ID:JPWKU,项目名称:mixcoatl,代码行数:35,代码来源:datacenter.py


示例5: all

    def all(cls, region_id, endpoint=None, **kwargs):
        """Return all server products

        :param region_id: The region id to search in
        :type region_id: int.
        :param keys_only: Return :attr:`product_id` or :class:`ServerProduct`
        :type keys_only: bool.
        :param detail: Level of detail to return - `basic` or `extended`
        :type detail: str.
        :returns: `list` of :attr:`product_id` or :class:`ServerProduct`
        :raises: :class:`ServerProductException`
        """
        r = Resource(cls.PATH, endpoint=endpoint)
        r.request_details = 'basic'
        params = {'regionId': region_id}
        if 'keys_only' in kwargs:
            keys_only = kwargs['keys_only']
        else:
            keys_only = False

        x = r.get(params=params)
        if r.last_error is None:
            if keys_only is True:
                return [i[camelize(cls.PRIMARY_KEY)] for i in x[cls.COLLECTION_NAME]]
            else:
                return [type(cls.__name__, (object,), i) for i in uncamel_keys(x)[uncamel(cls.COLLECTION_NAME)]]
        else:
            raise ServerProductException(r.last_error)
开发者ID:enStratus,项目名称:mixcoatl,代码行数:28,代码来源:server_product.py


示例6: all

    def all(cls, **kwargs):
        """Get a list of all known servers

        >>> Server.all()
        [{'server_id':1,...},{'server_id':2,...}]

        :returns: list -- a list of :class:`Server`
        :raises: ServerException
        """
        r = Resource(cls.PATH)
        params = {}

        if 'detail' in kwargs:
            r.request_details = kwargs['detail']
        else:
            r.request_details = 'basic'

        if 'keys_only' in kwargs:
            keys_only = kwargs['keys_only']
        else:
            keys_only = False

        if 'region_id' in kwargs:
            params['regionId'] = kwargs['region_id']

        x = r.get(params=params)
        if r.last_error is None:
            if keys_only is True:
                return [i[camelize(cls.PRIMARY_KEY)] for i in x[cls.COLLECTION_NAME]]
            else:
                return [type(cls.__name__, (object,), i) for i in uncamel_keys(x)[cls.COLLECTION_NAME]]
        else:
            raise ServerException(r.last_error)
开发者ID:cjblythe25,项目名称:mixcoatl,代码行数:33,代码来源:server.py


示例7: all

    def all(cls, keys_only=False, **kwargs):
        """Return all users

        .. note::

            The keys used to make the request determine results visibility

        :param keys_only: Return :attr:`user_id` instead of :class:`User`
        :type keys_only: bool.
        :param detail: str. The level of detail to return - `basic` or `extended`
        :type detail: str.
        :returns: `list` of :class:`User` or :attr:`user_id`
        :raises: :class:`UserException`
        """
        r = Resource(cls.PATH)
        if 'detail' in kwargs:
            r.request_details = kwargs['detail']
        else:
            r.request_details = 'basic'

        x = r.get()
        if r.last_error is None:
            if keys_only is True:
                return [i['userId'] for i in x[cls.COLLECTION_NAME]]
            else:
                return [cls(i['userId']) for i in x[cls.COLLECTION_NAME]]
        else:
            raise UserException(r.last_error)
开发者ID:irvingpop,项目名称:mixcoatl,代码行数:28,代码来源:user.py


示例8: __init__

    def __init__(self, firewall_id=None, endpoint=None, **kwargs):
        Resource.__init__(self, endpoint=endpoint)

        if 'detail' in kwargs:
            self.request_details = kwargs['detail']

        self.__firewall_id = firewall_id
开发者ID:cbrandtw0rk,项目名称:mixcoatl,代码行数:7,代码来源:firewall.py


示例9: all

    def all(cls, keys_only=False, **kwargs):
        """Return all clouds

        :param keys_only: Return :attr:`cloud_id` instead of :class:`Cloud`
        :type keys_only: bool.
        :param detail: The level of detail to return - `basic` or `extended`
        :type detail: str.
        :returns: `list` of :class:`Cloud` or :attr:`cloud_id`
        """
        r = Resource(cls.PATH)
        r.request_details = 'basic'
        params = {}

        if 'public_only' in kwargs:
            params['publicOnly'] = kwargs['public_only']
        if 'status' in kwargs:
            params['status'] = kwargs['status']

        c = r.get(params=params)

        if r.last_error is None:
            if keys_only is True:
                return [i['cloudId'] for i in c[cls.COLLECTION_NAME]]
            else:
                clouds = []
                for i in c[cls.COLLECTION_NAME]:
                    cloud = cls(i['cloudId'])
                    if 'detail' in kwargs:
                        cloud.request_details = kwargs['detail']
                    cloud.params = params
                    cloud.load()
                    clouds.append(cloud)
                return clouds
        else:
            return r.last_error
开发者ID:JPWKU,项目名称:mixcoatl,代码行数:35,代码来源:cloud.py


示例10: all

    def all(cls, keys_only=False, **kwargs):
        """Get all groups

        .. note::

            The keys used to make the request determine results visibility

        :param keys_only: Only return `group_id` instead of `Group` objects
        :type keys_only: bool.
        :param detail: The level of detail to return - `basic` or `extended`
        :type detail: str.
        :param account_id: Restrict results to `account_id`
        :type account_id: int.
        :returns: `list` - List of :class:`Group` or :attr:`group_id`
        :raises: :class:`GroupException`
        """
        r = Resource(cls.PATH)
        if 'detail' in kwargs:
            r.request_details = kwargs['detail']
        else:
            r.request_details = 'basic'

        if 'account_id' in kwargs:
            params = {'accountId': kwargs['account_id']}
        else:
            params = {}

        x = r.get(params=params)
        if r.last_error is None:
            if keys_only is True:
                return [i['groupId'] for i in x[cls.COLLECTION_NAME]]
            else:
                return [cls(i['groupId']) for i in x[cls.COLLECTION_NAME]]
        else:
            raise GroupException(r.last_error)
开发者ID:JPWKU,项目名称:mixcoatl,代码行数:35,代码来源:group.py


示例11: all

    def all(cls, keys_only=False, endpoint=None, **kwargs):
        """Get all visible billing codes

        .. note::

            The keys used to make the original request determine result visibility

        :param keys_only: Only return :attr:`billing_code_id` instead of :class:`BillingCode` objects
        :type keys_only: bool.
        :param detail: The level of detail to return - `basic` or `extended`
        :type detail: str.
        :returns: `list` - of :class:`BillingCode` or :attr:`billing_code_id`
        :raises: :class:`BillingCodeException`
        """
        r = Resource(cls.PATH, endpoint=endpoint)
        params = {}

        if 'details' in kwargs:
            r.request_details = kwargs['details']
        else:
            r.request_details = 'basic'

        x = r.get()
        if r.last_error is None:
            if keys_only is True:
                return [i[camelize(cls.PRIMARY_KEY)] for i in x[cls.COLLECTION_NAME]]
            else:
                return [type(cls.__name__, (object,), i) for i in uncamel_keys(x)[uncamel(cls.COLLECTION_NAME)]]
        else:
            raise BillingCodeException(r.last_error)
开发者ID:enStratus,项目名称:mixcoatl,代码行数:30,代码来源:billing_code.py


示例12: all

    def all(cls, **kwargs):
        """Returns subscriptions for all regions"""

        r = Resource(cls.PATH)
        r.request_details = 'basic'
        s = r.get()
        return s
开发者ID:JPWKU,项目名称:mixcoatl,代码行数:7,代码来源:subscription.py


示例13: region

    def region(cls, region_id, **kwargs):
        """Returns subscription for given Region"""

        r = Resource(cls.PATH+"/"+str(region_id))
        r.request_details = 'basic'
        s = r.get()
        return s
开发者ID:JPWKU,项目名称:mixcoatl,代码行数:7,代码来源:subscription.py


示例14: all

    def all(cls, region_id, engine, **kwargs):
        """Get a list of all known relational_databases

        >>> RelationalDatabaseProduct.all(region_id=100, engine='MYSQL51')
        [{'product_id':1,...},{'product_id':2,...}]

        :returns: list -- a list of :class:`RelationalDatabaseProduct`
        :raises: RelationalDatabaseProductException
        """
        r = Resource(cls.PATH)
        r.request_details = 'basic'
        params = {'regionId': region_id, 'engine': engine}

        if 'detail' in kwargs:
            r.request_details = kwargs['detail']
        else:
            r.request_details = 'basic'

        if 'keys_only' in kwargs:
            keys_only = kwargs['keys_only']
        else:
            keys_only = False

        x = r.get(params=params)
        if r.last_error is None:
            if keys_only is True:
                results = [i[camelize(cls.PRIMARY_KEY)] for i in x[cls.COLLECTION_NAME]]
            else:
                results = [type(cls.__name__, (object,), i) for i in uncamel_keys(x)[uncamel(cls.COLLECTION_NAME)]]
            return results
        else:
            raise RelationalDatabaseProductException(r.last_error)
开发者ID:cjblythe25,项目名称:mixcoatl,代码行数:32,代码来源:relational_database_product.py


示例15: all

    def all(cls, region_id, endpoint=None, **kwargs):
        """Return all data centers

        :param region_id: Required. The region to query against
        :type region_id: int.
        :param keys_only: Return :attr:`data_center_id` instead of :class:`DataCenter`
        :type keys_only: bool.
        :param detail: The level of detail to return - `basic` or `extended`
        :type detail: str.
        :returns: `list` of :class:`DataCenter` or :attr:`data_center_id`
        :raises: :class:`DataCenterException`
        """
        r = Resource(cls.PATH, endpoint=endpoint)

        if 'detail' in kwargs:
            r.request_details = kwargs['detail']
        else:
            r.request_details = 'basic'

        if 'keys_only' in kwargs:
            keys_only = kwargs['keys_only']
        else:
            keys_only = False

        params = {'regionId': region_id}

        x = r.get(params=params)
        if r.last_error is None:
            if keys_only is True:
                return [i[camelize(cls.PRIMARY_KEY)] for i in x[cls.COLLECTION_NAME]]
            else:
                return [type(cls.__name__, (object,), i) for i in uncamel_keys(x)[uncamel(cls.COLLECTION_NAME)]]
        else:
            raise DataCenterException(r.last_error)
开发者ID:enStratus,项目名称:mixcoatl,代码行数:34,代码来源:datacenter.py


示例16: all

    def all(cls, region_id, endpoint=None, **kwargs):
        """Get a list of all known storage objects.

        >>> StorageObject.all(region_id=100)
        [{'storage_object_id':1,...},{'storage_object_id':2,...}]

        :returns: list -- a list of :class:`StorageObject`
        :raises: StorageObjectException
        """
        r = Resource(cls.PATH, endpoint=endpoint)
        params = {'regionId': region_id}

        if 'detail' in kwargs:
            r.request_details = kwargs['detail']
        else:
            r.request_details = 'basic'

        if 'keys_only' in kwargs:
            keys_only = kwargs['keys_only']
        else:
            keys_only = False

        x = r.get(params=params)
        if r.last_error is None:
            if keys_only is True:
                results = [i[camelize(cls.PRIMARY_KEY)] for i in x[cls.COLLECTION_NAME]]
            else:
                results = [type(cls.__name__, (object,), i) for i in uncamel_keys(x)[uncamel(cls.COLLECTION_NAME)]]
            return results
        else:
            raise StorageObjectException(r.last_error)
开发者ID:enStratus,项目名称:mixcoatl,代码行数:31,代码来源:storage_object.py


示例17: all

 def all(cls, cmAccountId, **kwargs):
     r = Resource(cls.PATH)
     r.request_details = "basic"
     params = {"cmAccountId": cmAccountId}
     c = r.get(params=params)
     if r.last_error is None:
         return c[cls.COLLECTION_NAME]
     else:
         raise PersonalityException(r.last_error)
开发者ID:jaronson,项目名称:mixcoatl,代码行数:9,代码来源:personality.py


示例18: all

 def all(cls, cmAccountId, **kwargs):
     r = Resource(cls.PATH)
     r.request_details = 'basic'
     params = {'cmAccountId':cmAccountId}
     x = r.get(params=params)
     if r.last_error is None:
     	return x[cls.COLLECTION_NAME]
     else:
     	return r.last_error
开发者ID:JPWKU,项目名称:mixcoatl,代码行数:9,代码来源:environment.py


示例19: all

    def all(cls, **kwargs):
        """List all networks in `region_id`

        :param region_id: Limit results to `region_id`
        :type region_id: int.
        :param data_center_id: Limit results to `data_center_id`
        :type region_id: int.
        :param account_id: limit results to `account_id`
        :type account_id: int.
        :param detail: Level of detail to return - `basic` or `extended`
        :type detail: str.
        :param keys_only: Return only :attr:`network_id` in results
        :type keys_only: bool.
        :param active_only: Limits the list of networks to only active networks if true. Default is True.
        :type keys_only: bool.
        :returns: `list` of :attr:`network_id` or :class:`Network`
        :raises: :class:`NetworkException`
        """
        params = {}
        r = Resource(cls.PATH)

        if 'detail' in kwargs:
            request_details = kwargs['detail']
        else:
            request_details = 'extended'

        if 'keys_only' in kwargs:
            keys_only = kwargs['keys_only']
        else:
            keys_only = False

        if 'region_id' in kwargs:
            params['regionId'] = kwargs['region_id']

        if 'data_center_id' in kwargs:
            params['dataCenterId'] = kwargs['data_center_id']

        if 'account_id' in kwargs:
            params['accountId'] = kwargs['account_id']

        if 'active_only' in kwargs:
            params['activeOnly'] = kwargs['active_only']
        else:
            params['activeOnly'] = True

        x = r.get(params=params)
        if r.last_error is None:
            if keys_only is True:
                return [i[camelize(cls.PRIMARY_KEY)] for i in x[cls.COLLECTION_NAME]]
            else:
                return [type(cls.__name__, (object,), i) for i in uncamel_keys(x)[cls.COLLECTION_NAME]]
        else:
            raise NetworkException(r.last_error)
开发者ID:cjblythe25,项目名称:mixcoatl,代码行数:53,代码来源:network.py


示例20: all

    def all(cls, **kwargs):
        r = Resource(cls.PATH)
        if 'details' in kwargs:
            r.request_details = kwargs['details']
        else:
            r.request_details = 'basic'

        x = r.get()
        if r.last_error is None:
            return [cls(i[camelize(cls.PRIMARY_KEY)]) for i in x[cls.COLLECTION_NAME]]
        else:
            return x.last_error
开发者ID:bdwilliams,项目名称:mixcoatl,代码行数:12,代码来源:configuration_management_account.py



注:本文中的mixcoatl.resource.Resource类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.camelize函数代码示例发布时间:2022-05-27
下一篇:
Python shortcuts.render_to_string函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap