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

Python core.handle_request函数代码示例

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

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



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

示例1: modify

    def modify(self, name=None, data=None, ttl=None):
        """Modify this Record's properties.

        :param name: Modify the Record's name.
        :type ttl: str
        :param data: Modify the Record's data.
        :type data: str
        :param ttl: Modify the Record's time-to-live (TTL).
        :type ttl: int
        :returns: A list of Records.
        :rtype: A list of :class:`Record`

        .. versionadded:: 0.1
        """
        assert 'id' in self
        assert 'domain_id' in self
        data = {}
        if name is not None:
            data['name'] = name
        if data is not None:
            data['data'] = data
        if ttl is not None:
            data['ttl'] = int(ttl)
        data = json.dumps(data)
        url = '/'.join([get_url('clouddns'), 'domains', str(self['domain_id']),
                        'records', str(self['id'])])
        handle_request('put', url, data)
        if name is not None:
            self['name'] = name
        if data is not None:
            self['data'] = data
        if ttl is not None:
            self['ttl'] = int(ttl)
        return self
开发者ID:abg,项目名称:vaporize,代码行数:34,代码来源:domains.py


示例2: resize

    def resize(self, flavor=None, size=None):
        """Resize the memory and/or volume of the instance.

        This operation changes the memory and/or volume size of the instance,
        assuming a valid Flavor is provided. Restarts MySQL in the process.

        :param flavor: New Flavor (memory size) ofr the Instance.
        :type flavor: :class:`Flavor`
        :param size: New volume size Iin GBs) for Instance, 1 to 25.
        :type size: int

        .. versionadded:: 0.2
        """
        assert 'id' in self, "Missing Instance ID"
        if isinstance(flavor, Flavor):
            flavor = flavor.ref
        data = {'resize': {}}
        if flavor is not None:
            data['resize']['flavorRef'] = flavor
        if size is not None:
            data['resize']['volume'] = {'size': int(size)}
        data = json.dumps(data)
        url = '/'.join([get_url('clouddatabases'), 'instances',
                        str(self['id']), 'action'])
        handle_request('post', url, data)
开发者ID:rvoicilas,项目名称:vaporize,代码行数:25,代码来源:databases.py


示例3: volume_detach

    def volume_detach(self, volumeId):
        """Detach the volume specified by volume_id from this NextGenServer.

        """
        assert 'id' in self
        url = '/'.join([get_url('cloudserversopenstack'), 'servers',
            str(self['id']), 'os-volume_attachments', str(volumeId)])
        handle_request('delete', url)
开发者ID:kolanos,项目名称:vaporize,代码行数:8,代码来源:nextgen_servers.py


示例4: delete

    def delete(self):
        """Delete this Shared IP Group.

        .. versionadded:: 0.1
        """
        assert 'id' in self
        url = '/'.join([get_url('cloudservers'), 'shared_ip_groups',
                        str(self['id'])])
        handle_request('delete', url)
开发者ID:mihait,项目名称:vaporize,代码行数:9,代码来源:servers.py


示例5: unshare_ip

    def unshare_ip(self, address):
        """Unshare this Server's IP

        .. versionadded:: 0.1
        """
        assert 'id' in self
        url = '/'.join([get_url('cloudservers'), 'servers', str(self['id']),
                        'ips', 'public', address])
        handle_request('delete', url)
开发者ID:mihait,项目名称:vaporize,代码行数:9,代码来源:servers.py


示例6: revert_resize

    def revert_resize(self):
        """Revert an unsuccessful resize operation

        .. versionadded:: 0.3
        """
        assert 'id' in self
        data = json.dumps({'revertResize': None})
        url = '/'.join([get_url('cloudserversopenstack'), 'servers',
                        str(self['id']), 'action'])
        handle_request('post', url, data)
开发者ID:kolanos,项目名称:vaporize,代码行数:10,代码来源:nextgen_servers.py


示例7: confirm_resize

    def confirm_resize(self):
        """Confirm a successful resize operation

        .. versionadded:: 0.1
        """
        assert 'id' in self
        data = json.dumps({'confirmResize': None})
        url = '/'.join([get_url('cloudservers'), 'servers',
                        str(self['id']), 'action'])
        handle_request('post', url, data)
开发者ID:mihait,项目名称:vaporize,代码行数:10,代码来源:servers.py


示例8: remove_record

    def remove_record(self, record):
        """Remove a Record from this Domain.

        :param record: A Record or ``id`` for the Record to remove.
        :type record: int or :class:`REcord`

        .. versionadded:: 0.1
        """
        assert 'id' in self
        record = record.id if isinstance(record, Record) else int(record)
        url = '/'.join([get_url('clouddns'), 'domains', str(self['id']),
                        'records', str(record)])
        handle_request('delete', url)
开发者ID:abg,项目名称:vaporize,代码行数:13,代码来源:domains.py


示例9: backup_schedule

    def backup_schedule(self):
        """Disable a backup schedule for this Server

            >>> server = vaporize.servers.Server.get(...)
            >>> del server.backup_schedule

        .. versionadded:: 0.1
        """
        assert 'id' in self
        url = '/'.join([get_url('cloudservers'), 'servers', str(self['id']),
                        'backup_schedule'])
        handle_request('delete', url)
        del self['backup_schedule']
开发者ID:mihait,项目名称:vaporize,代码行数:13,代码来源:servers.py


示例10: rebuild

    def rebuild(self, name, image, flavor, adminpass, accessIPv4=None,
            accessIPv6=None, metadata={}, files={}, diskConfig='AUTO'):
        """Rebuild this NextGenServer using a specified NextGenImage

        :param image: The NextGenImage or ``id``
        :type image: int or :class:`NextGenImage`
        :param flavor: The NextGenFlavor or  ``id``
        :type image: int or :class:`NextGenFlavor`
        :param adminpass: Admin Password.
        :param accessIPv4: IPv4 access address
        :type type: str
        :param accessIPv6: IPv6 access address
        :type type: str
        :param metadata: key/value pairs
        :type type: dict
        :param files: path,contents dict
        :type type: dict
        :param diskConfig: OS-DCF:diskConfig AUTO or MANUAL
        :type type: str

        .. versionadded:: 0.3
        """
        assert 'id' in self, "id is missing"
        assert 'name' in self or len(name) > 0, "name is missing"
        assert len(adminpass) >= 8, "Admin password must be >= 8 chars long"
        assert diskConfig in ['AUTO', 'MANUAL'], ("diskConfig must be"
        "'AUTO' or 'MANUAL'")
        if name:
            self['name'] = name
        if isinstance(image, NextGenImage):
            image = image.id
        if isinstance(flavor, NextGenFlavor):
            flavor = flavor.id
        data = {'rebuild':{
                    'name': str(self['name']),
                    'imageRef': str(image),
                    'flavorRef': str(flavor),
                    'adminPass': str(adminpass),
                    'OS-DCF:diskConfig': str(diskConfig)
                    }}
        if accessIPv4 is not None:
            data['rebuild']['accessIPv4'] = str(accessIPv4)
        if accessIPv6 is not None:
            data['rebuild']['accessIPv6'] = str(accessIPv6)
        if isinstance(files, dict):
            for path, contents in list(files.items()):
                data['rebuild']['personality'].append({'path': path, 'contents': contents})
        data = json.dumps(data)
        url = '/'.join([get_url('cloudserversopenstack'), 'servers',
                        str(self['id']), 'action'])
        handle_request('post', url, data)
开发者ID:kolanos,项目名称:vaporize,代码行数:51,代码来源:nextgen_servers.py


示例11: reboot

    def reboot(self, type='SOFT'):
        """Perform a soft/hard reboot on this NextGenServer.

        :param type: A reboot type (``SOFT`` or ``HARD``).
        :type type: str

        .. versionadded:: 0.3
        """
        assert 'id' in self, "Missing NextGenServer ID"
        assert type in ['SOFT', 'HARD'], "Reboot type must be 'SOFT' or 'HARD'"
        data = json.dumps({'reboot': {'type': type}})
        url = '/'.join([get_url('cloudserversopenstack'), 'servers',
                        str(self['id']), 'action'])
        handle_request('post', url, data)
开发者ID:kolanos,项目名称:vaporize,代码行数:14,代码来源:nextgen_servers.py


示例12: restart

    def restart(self):
        """Restart the database service on the instance.

        The restart operation will restart only the MySQL Instance. Restarting
        MySQL will erase any dynamic configuration settings that you have made
        within MySQL.

        .. versionadded:: 0.2
        """
        assert 'id' in self
        data = json.dumps({'restart': {}})
        url = '/'.join([get_url('clouddatabases'), 'instances',
                        str(self['id']), 'action'])
        handle_request('post', url, dataa)
开发者ID:rvoicilas,项目名称:vaporize,代码行数:14,代码来源:databases.py


示例13: change_admin_pass

    def change_admin_pass(self, password):
        """Change admin password.

        :param password: Admin Password.
        :type type: str

        """
        assert len(password) >= 8, "Admin password must be >= 8 chars long"

        assert 'id' in self
        url = '/'.join([get_url('cloudserversopenstack'), 'servers',
            str(self['id']), 'action'])
        data = json.dumps({ "changePassword": { "adminPass" : str(password)}})
        handle_request('post', url, data)
开发者ID:kolanos,项目名称:vaporize,代码行数:14,代码来源:nextgen_servers.py


示例14: delete

    def delete(self):
        """Delete this NextGenServer.

        .. warning::

            There is no confirmation step for this operation. When you delete a
            server it is permanent. If in doubt, create a backup image
            (:func:`vaporize.images.create`) first before deleting.

        .. versionadded:: 0.1
        """
        assert 'id' in self
        url = '/'.join([get_url('cloudserversopenstack'), 'servers', str(self['id'])])
        handle_request('delete', url)
开发者ID:kolanos,项目名称:vaporize,代码行数:14,代码来源:nextgen_servers.py


示例15: update_server

    def update_server(self, name=None, accessIPv4=None, accessIPv6=None):
        """Update this NextGenServer's name or ip addresses.

        :param name: Change the NextGenServer's name
        :type name: str
        :param accessIPv4: IPv4 access address
        :type name: str
        :param accessIPv6: IPv6 access address
        :type name: str
        :returns: A modified CloudNextGenServers NextGenServer.
        :rtype: :class:`NextGenServer`

        .. versionadded:: 0.3
        """
        assert 'id' in self
        data = {'server': {}}
        if name is not None:
            data['server']['name'] = name
        if addressIPv4 is not None:
            data['server']['addressIPv4'] = addressIPv4
        if addressIPv6 is not None:
            data['server']['addressIPv6'] = addressIPv6
        data = json.dumps(data)
        url = '/'.join([get_url('cloudserversopenstack'), 'servers', str(self['id'])])
        response = handle_request('put', url, data=data)
        if response:
            if name is not None:
                self['name'] = name
        return self
开发者ID:kolanos,项目名称:vaporize,代码行数:29,代码来源:nextgen_servers.py


示例16: rebuild

    def rebuild(self, image):
        """Rebuild this Server using a specified Image

        :param image: The Image or ``id``
        :type image: int or :class:`Image`

        .. versionadded:: 0.1
        """
        assert 'id' in self
        if isinstance(image, Image):
            image = image.id
        image = int(image)
        data = json.dumps({'rebuild': {'imageId': int(image)}})
        url = '/'.join([get_url('cloudservers'), 'servers',
                        str(self['id']), 'action'])
        handle_request('post', url, data)
开发者ID:mihait,项目名称:vaporize,代码行数:16,代码来源:servers.py


示例17: create

    def create(cls, size, name=None, description=None, snapshot=None,
               volume_type=None):
        """Create a CloudBlockStorage Volume.

        :param size: Volume size in GB (min. 100GB max. 1TB).
        :type size: int
        :param name: Name of Volume.
        :type name: str
        :param description: Description of Volume.
        :type description: str
        :param snapshot: Snapshot_ID or :class:`Snapshot` of the volume restore.
        :type snapshot: int or :class:`Snapshot`
        :param volume_type: Volume Type, either ``SATA`` or ``SSD``.
        :type volume_type: str or :class:`VolumeType`
        """
        assert 100  <= int(size) <= 1000
        data = {'volume': {'size': int(size)}}
        if name:
            data['volume']['display_name'] = str(display_name)
        if description:
            data['volume']['display_descrition'] = str(description)
        if snapshot:
            if isinstance(snapshot, Snapshot):
                snapshot = snapshot.id
            data['volume']['snapshot_id'] = int(snapshot)
        if volume_type:
            if isinstance(volume_type, VolumeType):
                volume_type = volume_type.name
            data['volume']['volume_type'] = str(volume_type)
        data = json.dumps(data)
        url = '/'.join([get_url('cloudblockstorage'), 'volumes'])
        return handle_request('post', url, data, cls, 'volume')
开发者ID:kolanos,项目名称:vaporize,代码行数:32,代码来源:volumes.py


示例18: add_records

    def add_records(self, *records):
        """Add Records to a Domain.

            >>> domain = vaporize.domains.create(...)
            >>> record1 = vaporize.domains.Record.create(....)
            >>> record2 = vaporize.domains.Record.create(...)
            >>> domain.add_recrods(record1, record2)

        :param records: Records you wish to add to this Domain.
        :type records: :class:`Record`
        :returns: A list of Records
        :rtype: :class:`Record`

        .. versionadded:: 0.1
        """
        assert 'id' in self
        data = {'records': []}
        for record in records:
            if isinstance(record, Record):
                data['records'].append({
                    'name': record.name,
                    'type': record.type,
                    'data': record.data,
                    'ttl': record.ttl,
                    'priority': record.priority,
                    'comment': record.comment
                    })
        data = json.dumps(data)
        url = '/'.join([get_url('clouddns'), 'domains', str(self['id']),
                        'records'])
        self['records'] = handle_request('post', url, data, Record, 'records',
                                          domain_id=self['id'])
        return self['records']
开发者ID:abg,项目名称:vaporize,代码行数:33,代码来源:domains.py


示例19: create

    def create(cls, name, image, flavor, metadata=None, files=None):
        """Create a CloudServers Server

        :param name: A Server's name
        :type name: str
        :param image: An Image or ``id``
        :type image: int or :class:`Image`
        :param flavor: A Flavor or ``id``
        :type flavor: int or :class:`Flavor`
        :param metadata: Optional meta data to include with Server
        :type metadata: dict
        :param files: A list of files to load on Server
        :type files: dict
        :returns: A shiny new CloudServers Server.
        :rtype: :class:`Server`

        .. versionadded:: 0.1
        """
        if isinstance(image, Image):
            image = image.id
        image = int(image)
        if isinstance(flavor, Flavor):
            flavor = flavor.id
        flavor = int(flavor)
        data = {'server': {'name': name,
                           'imageId': image,
                           'flavorId': flavor,
                           'metadata': metadata or {},
                           'personality': []}}
        if isinstance(files, dict):
            for path, contents in list(files.items()):
                data['personality'].append({'path': path, 'contents': contents})
        data = json.dumps(data)
        url = '/'.join([get_url('cloudservers'), 'servers'])
        return handle_request('post', url, data, cls, 'server')
开发者ID:mihait,项目名称:vaporize,代码行数:35,代码来源:servers.py


示例20: delete

    def delete(self, subdomains=False):
        """Delete this Record.

        .. warning::

            There is no confirmation step to this operation. Deleting this
            record is permanent. If in doubt you can export a copy of the DNS
            zone (:func:`vaporize.domains.Domain.export_zone`) before deleting.

        .. versionadded:: 0.1
        """
        assert 'id' in self
        assert 'domain_id' in self
        url = '/'.join([get_url('clouddns'), 'domains', str(self['domain_id']),
                        'records', str(self['id'])])
        handle_request('delete', url)
开发者ID:abg,项目名称:vaporize,代码行数:16,代码来源:domains.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python vapoursynth.get_core函数代码示例发布时间:2022-05-26
下一篇:
Python core.get_url函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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