当前位置: 首页>>代码示例>>Python>>正文


Python Resource.get方法代码示例

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


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

示例1: all

# 需要导入模块: from mixcoatl.resource import Resource [as 别名]
# 或者: from mixcoatl.resource.Resource import get [as 别名]
    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,代码行数:35,代码来源:server_analytics.py

示例2: all

# 需要导入模块: from mixcoatl.resource import Resource [as 别名]
# 或者: from mixcoatl.resource.Resource import get [as 别名]
    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,代码行数:27,代码来源:relational_database.py

示例3: all

# 需要导入模块: from mixcoatl.resource import Resource [as 别名]
# 或者: from mixcoatl.resource.Resource import get [as 别名]
    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,代码行数:32,代码来源:billing_code.py

示例4: all

# 需要导入模块: from mixcoatl.resource import Resource [as 别名]
# 或者: from mixcoatl.resource.Resource import get [as 别名]
    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,代码行数:37,代码来源:datacenter.py

示例5: all

# 需要导入模块: from mixcoatl.resource import Resource [as 别名]
# 或者: from mixcoatl.resource.Resource import get [as 别名]
    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,代码行数:37,代码来源:cloud.py

示例6: all

# 需要导入模块: from mixcoatl.resource import Resource [as 别名]
# 或者: from mixcoatl.resource.Resource import get [as 别名]
    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,代码行数:36,代码来源:datacenter.py

示例7: all

# 需要导入模块: from mixcoatl.resource import Resource [as 别名]
# 或者: from mixcoatl.resource.Resource import get [as 别名]
    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,代码行数:33,代码来源:storage_object.py

示例8: all

# 需要导入模块: from mixcoatl.resource import Resource [as 别名]
# 或者: from mixcoatl.resource.Resource import get [as 别名]
    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,代码行数:35,代码来源:server.py

示例9: all

# 需要导入模块: from mixcoatl.resource import Resource [as 别名]
# 或者: from mixcoatl.resource.Resource import get [as 别名]
    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,代码行数:30,代码来源:user.py

示例10: all

# 需要导入模块: from mixcoatl.resource import Resource [as 别名]
# 或者: from mixcoatl.resource.Resource import get [as 别名]
    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,代码行数:9,代码来源:subscription.py

示例11: all

# 需要导入模块: from mixcoatl.resource import Resource [as 别名]
# 或者: from mixcoatl.resource.Resource import get [as 别名]
    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,代码行数:37,代码来源:group.py

示例12: region

# 需要导入模块: from mixcoatl.resource import Resource [as 别名]
# 或者: from mixcoatl.resource.Resource import get [as 别名]
    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,代码行数:9,代码来源:subscription.py

示例13: all

# 需要导入模块: from mixcoatl.resource import Resource [as 别名]
# 或者: from mixcoatl.resource.Resource import get [as 别名]
    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,代码行数:34,代码来源:relational_database_product.py

示例14: all

# 需要导入模块: from mixcoatl.resource import Resource [as 别名]
# 或者: from mixcoatl.resource.Resource import get [as 别名]
    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,代码行数:30,代码来源:server_product.py

示例15: all

# 需要导入模块: from mixcoatl.resource import Resource [as 别名]
# 或者: from mixcoatl.resource.Resource import get [as 别名]
 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,代码行数:11,代码来源:personality.py


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