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

Python utils.camelize函数代码示例

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

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



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

示例1: test_waiting_for_job

    def test_waiting_for_job(self):
        """test Job.wait_for(<id>) works"""

        with open(self.json_file) as f:
            running_data = json.load(f)

        with open(self.json_file) as f:
            finished_data = json.load(f)

        running_data[self.cls.COLLECTION_NAME][:] = [d for d in running_data[self.cls.COLLECTION_NAME] if
                                                     d[camelize(self.cls.PRIMARY_KEY)] == 4]

        finished_data[self.cls.COLLECTION_NAME][:] = [d for d in finished_data[self.cls.COLLECTION_NAME] if
                                                     d[camelize(self.cls.PRIMARY_KEY)] == 4]

        finished_data[self.cls.COLLECTION_NAME][0]['status'] = 'COMPLETE'
        finished_data[self.cls.COLLECTION_NAME][0]['message'] = '12345'


        HTTPretty.register_uri(HTTPretty.GET,
            self.es_url+'/'+str(4),
            responses = [
                #HTTPretty.Response(body=json.dumps(running_data), status=200, content_type='application/json')
                HTTPretty.Response(body=json.dumps(finished_data), status=200, content_type='application/json')
            ])

        def validate(x):
            assert isinstance(x, self.cls)
            assert x.status == 'COMPLETE'
            assert x.message == '12345'

        y = self.cls.wait_for(4, callback=validate)
        z = self.cls.wait_for(4)
        assert z is True
开发者ID:JPWKU,项目名称:mixcoatl,代码行数:34,代码来源:test_job.py


示例2: all

    def all(cls, **kwargs):
        """List all volumes

        :param account_id: Restrict to volumes owned by `account_id`
        :type account_id: int.
        :param datacenter_id: Restrict to volumes based in `datacenter_id`
        :type datacenter_id: int.
        :param region_id: Restrict to volumes in `region_id`
        :type region_id: int.
        :param keys_only: Return :attr:`snapshot_id` or :class:`Snapshot`
        :type keys_only: bool.
        :param detail: Level of detail to return - `basic` or `extended`
        :type detail: str.
        :returns: `list` of :attr:`volume_id` or :class:`Volume`
        :raises: :class:`VolumeException`
        """
        params = {}
        r = Resource(cls.PATH)
        r.request_details = 'none'
        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 'datacenter_id' in kwargs:
            params['dataCenterId'] = kwargs['datacenter_id']
        if 'region_id' in kwargs:
            params['regionId'] = kwargs['region_id']
        if 'account_id' in kwargs:
            params['accountId'] = kwargs['account_id']

        x = r.get(params=params)
        if r.last_error is None:
            keys = [i[camelize(cls.PRIMARY_KEY)] for i in x[cls.COLLECTION_NAME]]
            if keys_only is True:
                volumes = keys
            else:
                volumes = []
                for i in x[cls.COLLECTION_NAME]:
                    key = i[camelize(cls.PRIMARY_KEY)]
                    volume = cls(key)
                    volume.request_details = request_details
                    volume.load()
                    volumes.append(volume)
            return volumes
        else:
            raise VolumeException(r.last_error)
开发者ID:JPWKU,项目名称:mixcoatl,代码行数:52,代码来源:volume.py


示例3: test_has_one

    def test_has_one(self):
        """test Snapshot(<id>) returns a valid resource"""
        pk = 23237460
        with open(self.json_file) as f:
            data = json.load(f)
        data[self.cls.COLLECTION_NAME][:] = [d for d in data[self.cls.COLLECTION_NAME] if
                                             d[camelize(self.cls.PRIMARY_KEY)] == pk]

        HTTPretty.register_uri(HTTPretty.GET,
            self.es_url+'/'+str(pk),
            body=json.dumps(data),
            status=200,
            content_type="application/json")

        s = self.cls(pk)

        assert s.snapshot_id == 23237460
        assert s.available is True
        assert s.label is None
        assert s.budget  == 10287
        assert s.created_timestamp == '2012-11-20T01:31:53.000+0000'
        assert s.status == 'ACTIVE'
        assert s.region['region_id'] == 19556
        assert s.customer['customer_id'] == 12345
        assert s.encrypted is False
        assert s.description == 'snap-b0810e80'
        assert s.sharable is True
        assert s.name == 'snap-b0810e80'
        assert s.volume['volume_id'] == 209179
        assert s.provider_id == 'snap-b0810e80'
        assert s.cloud['cloud_id'] == 1
        assert s.owning_account['account_id'] == 16000
        assert s.removable is True
        assert s.size_in_gb -- 8
开发者ID:JPWKU,项目名称:mixcoatl,代码行数:34,代码来源:test_snapshot.py


示例4: 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


示例5: 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


示例6: 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


示例7: 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


示例8: test_has_one

    def test_has_one(self):
        '''test LaunchConfiguration(<id>) returns a valid resource'''
        pk = 16415
        with open(self.json_file) as f:
            data = json.load(f)

        data[self.cls.COLLECTION_NAME][:] = [d for d in data[self.cls.COLLECTION_NAME] if
                                             d[camelize(self.cls.PRIMARY_KEY)] == pk]
        HTTPretty.register_uri(HTTPretty.GET,
            self.es_url + '/' + str(pk),
            body=json.dumps(data),
            status=200,
            content_type="application/json")
        s = self.cls(pk)
        assert s.launch_configuration_id == 16415
        assert s.primary_product['product_id'] == 'm1.medium'
        assert s.secondary_product['product_id'] == 'm1.medium'
        assert s.primary_machine_image['machine_image_id'] == 281731
        assert s.secondary_machine_image['machine_image_id'] == 281731
        assert s.server_name_template == '{group}-{role}-{count}-{timestamp}'
        assert s.firewalls[0]['firewall_id'] == 116387
        assert s.array_volume_capacity == 0
        assert s.array_volume_count == 0
        assert s.customer['customer_id'] == 12345
        assert s.region['region_id'] == 19344
开发者ID:JPWKU,项目名称:mixcoatl,代码行数:25,代码来源:test_launch_configuration.py


示例9: test_has_one

 def test_has_one(self):
     '''test Tier(<id>) returns a valid resource'''
     pk = 10429
     with open(self.json_file) as f:
         data = json.load(f)
     data[self.cls.COLLECTION_NAME][:] = [d for d in data[self.cls.COLLECTION_NAME] if
                                          d[camelize(self.cls.PRIMARY_KEY)] == pk]
     HTTPretty.register_uri(HTTPretty.GET,
         self.es_url + '/' + str(pk),
         body=json.dumps(data),
         status=200,
         content_type="application/json")
     s = self.cls(pk)
     assert s.tier_id == pk
     assert s.breach_increment == 1
     assert s.breach_period_in_minutes == 5
     assert s.cooldown_period_in_minutes == 5
     assert s.deployment['deployment_id'] == 13607
     assert s.description == 'This is what we call a tier.'
     assert s.last_breach_change_timestamp == '2012-12-18T18:42:06.160+0000'
     assert s.lower_cpu_threshold == 25
     assert s.lower_ram_threshold == 25
     assert s.maximum_servers == 1
     assert s.minimum_servers == 1
     assert s.name == 'Sample Tier'
     assert s.removable is False
     assert s.scaling_rules == 'BASIC'
     assert s.status == 'BREACH_LOWER'
     assert s.upper_cpu_threshold == 75
     assert s.upper_ram_threshold == 75
开发者ID:JPWKU,项目名称:mixcoatl,代码行数:30,代码来源:test_tier.py


示例10: 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


示例11: test_has_one

 def test_has_one(self):
     '''test ConfigurationManagementAccount(<id>) returns a valid resource'''
     pk = 3610
     with open(self.json_file) as f:
         data = json.load(f)
     data[self.cls.COLLECTION_NAME][:] = [d for d in data[self.cls.COLLECTION_NAME] if
                                          d[camelize(self.cls.PRIMARY_KEY)] == pk]
     HTTPretty.register_uri(HTTPretty.GET,
         self.es_url + '/' + str(pk),
         body=json.dumps(data),
         status=200,
         content_type="application/json")
     s = self.cls(pk)
     assert s.cm_account_id == pk
     assert s.account_number == ''
     assert s.budget is -1
     assert s.cm_service['cm_service_id'] == 3710
     assert s.created_timestamp == '2013-01-06T06:50:29.326+0000'
     assert s.customer['customer_id'] == 12345
     assert s.description == 'a chef cm account'
     assert s.guid == '/customer/12345/cmAccount/3610'
     assert s.label == 'iconlightbulb'
     assert s.removable is True
     assert s.status == 'ACTIVE'
     assert s.last_modified_timestamp == '2013-01-06T06:50:29.326+0000'
开发者ID:cjblythe25,项目名称:mixcoatl,代码行数:25,代码来源:test_cm_account.py


示例12: 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[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 UserException(r.last_error)
开发者ID:cjblythe25,项目名称:mixcoatl,代码行数:28,代码来源:user.py


示例13: 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


示例14: test_has_one

 def test_has_one(self):
     '''test Volume(<id>) returns a valid resource'''
     pk = 211309
     with open(self.json_file) as f:
         data = json.load(f)
     data[self.cls.COLLECTION_NAME][:] = [d for d in data[self.cls.COLLECTION_NAME] if
                                          d[camelize(self.cls.PRIMARY_KEY)] == pk]
     HTTPretty.register_uri(HTTPretty.GET,
         self.es_url + '/' + str(pk),
         body=json.dumps(data),
         status=200,
         content_type="application/json")
     s = self.cls(pk)
     s.load()
     assert s.volume_id == pk
     assert s.available is True
     assert s.budget == 10287
     assert s.cloud['cloud_id'] == 1
     assert s.creation_timestamp == '1970-01-01T00:00:00.000+0000'
     assert s.customer['customer_id'] == 12345
     assert s.data_center['data_center_id'] == 64716
     assert s.description == 'vol-4816d27b'
     assert s.device_id == '/dev/sda1'
     assert s.encrypted is False
     assert s.name == 'vol-4816d27b'
     assert s.owning_account['account_id'] == 16000
     assert s.owning_groups[0]['group_id'] == 9465
     assert s.provider_id == 'vol-4816d27b'
     assert s.owning_user['user_id'] == 54321
     assert s.region['region_id'] == 19556
     assert s.removable is False
     assert s.server['server_id'] == 322765
     assert s.size_in_gb == 8
     assert s.size_string == '8GB'
     assert s.status == 'ACTIVE'
开发者ID:cjblythe25,项目名称:mixcoatl,代码行数:35,代码来源:test_volume.py


示例15: test_has_one

 def test_has_one(self):
     '''test LoadBalancer(<id>) returns a valid resource'''
     pk = 12516
     with open(self.json_file) as f:
         data = json.load(f)
     data[self.cls.COLLECTION_NAME][:] = [d for d in data[self.cls.COLLECTION_NAME] if
                                          d[camelize(self.cls.PRIMARY_KEY)] == pk]
     HTTPretty.register_uri(HTTPretty.GET,
         self.es_url + '/' + str(pk),
         body=json.dumps(data),
         status=200,
         content_type="application/json")
     s = self.cls(pk)
     s.load()
     assert s.load_balancer_id == pk
     assert s.address == 'wordpress-lb.us-west-2.elb.amazonaws.com'
     assert s.budget == 10287
     assert s.cloud['cloud_id'] == 1
     assert s.cname_based is True
     assert s.customer['customer_id'] == 12345
     assert s.description == 'Cloud Load Balancer for wordpress demo deployment'
     assert s.owning_account['account_id'] == 16000
     assert s.owning_groups[0]['group_id'] == 9465
     assert s.owning_user['user_id'] == 54321
     assert s.provider_id == 'wordpress-deployment'
     assert s.region['region_id'] == 19344
     assert s.status == 'ACTIVE'
开发者ID:cjblythe25,项目名称:mixcoatl,代码行数:27,代码来源:test_load_balancer.py


示例16: 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


示例17: 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


示例18: all

    def all(cls, keys_only=False):
        """Get all jobs


        :param keys_only: Only return :attr:`job_id` instead of :class:`Job`
        :type keys_only: bool.
        :returns: `list` of :class:`Job` or :attr:`job_id`
        :raises: :class:`JobException`
        """
        r = Resource(cls.PATH)
        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 [cls(i[camelize(cls.PRIMARY_KEY)]) for i in x[cls.COLLECTION_NAME]]
        else:
            raise JobException(r.last_error)
开发者ID:JPWKU,项目名称:mixcoatl,代码行数:18,代码来源:job.py


示例19: all

    def all(cls, firewall_id, **kwargs):
        """List all rules for `firewall_id`

        :param firewall_id: The id of the firewall to list rules for
        :type firewall_id: int.
        :param detail: Level of detail to return - `basic` or `extended`
        :type detail: str.
        :param keys_only: Return only :attr:`firewall_rule_id` in results
        :type keys_only: bool.
        :returns: `list` of :attr:`firewall_rule_id` or :class:`FirewallRule`
        :raises: :class:`FirewallRuleException`
        """

        params = {}
        r = Resource(cls.PATH)
        r.request_details = 'none'
        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

        params['firewallId'] = firewall_id
        x = r.get(params=params)
        if r.last_error is None:
            keys = [i[camelize(cls.PRIMARY_KEY)] for i in x[cls.COLLECTION_NAME]]
            if keys_only is True:
                rules = keys
            else:
                rules = []
                for i in x[cls.COLLECTION_NAME]:
                    key = i[camelize(cls.PRIMARY_KEY)]
                    rule = cls(key)
                    rule.request_details = request_details
                    rule.load()
                    rules.append(rule)
            return rules
        else:
            raise FirewallRuleException(r.last_error)
开发者ID:JPWKU,项目名称:mixcoatl,代码行数:43,代码来源:firewall_rule.py


示例20: all

    def all(cls, endpoint=None, **kwargs):
        """Return all regions

        :param account_id: Limit results to regions with the specified account
        :type account_id: int.
        :param jurisdiction: Limit results to the specified jurisdiction
        :type jurisdiction: str.
        :param scope: Limit results to `all` (Default - cross-cloud)
            or `account` (cloud-specific)
        :type scope: str.
        :param keys_only: Return :attr:`region_id` instead of :class:`Region`
        :type keys_only: bool.
        :param detail: The level of detail to return - `basic` or `extended`
        :type detail: str.
        :returns: `list` of :class:`Region` or :attr:`region_id`
        :raises: :class:`RegionException`
        """
        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

        for x in ['account_id', 'jurisdiction', 'scope']:
            if x in kwargs:
                params[camelize(x)] = kwargs[x]

        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 RegionException(r.last_error)
开发者ID:enStratus,项目名称:mixcoatl,代码行数:42,代码来源:region.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python mixer.blend函数代码示例发布时间:2022-05-27
下一篇:
Python resource.Resource类代码示例发布时间: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