當前位置: 首頁>>代碼示例>>Python>>正文


Python webservice.AWSQueryClient類代碼示例

本文整理匯總了Python中lib.aws.webservice.AWSQueryClient的典型用法代碼示例。如果您正苦於以下問題:Python AWSQueryClient類的具體用法?Python AWSQueryClient怎麽用?Python AWSQueryClient使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了AWSQueryClient類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

 def __init__(self, accessKey, secretKey, endpoint, result_format = 'json'):
     '''
     Constructor
     '''
     self._accessKey = accessKey
     self._secretKey = secretKey
     self._endpoint = endpoint
     self._format = result_format
     
     self._client = AWSQueryClient(self._accessKey, self._secretKey, 
                                   self._endpoint, self._format, 
                                   self._signature_version, self._api_version)
開發者ID:basilbeltran,項目名稱:bashitol,代碼行數:12,代碼來源:servicecall.py

示例2: __init__

    def __init__(self, accessKey, secretKey, endpoint, region, result_format="json"):
        """
        Constructor
        """
        self._accessKey = accessKey
        self._secretKey = secretKey
        self._endpoint = endpoint
        self._format = result_format
        self._region = region

        self._client = AWSQueryClient(
            self._accessKey,
            self._secretKey,
            self._endpoint,
            self._region,
            self._service_name,
            self._format,
            self._signature_version,
            self._api_version,
        )
開發者ID:cpdean,項目名稱:cpd.dotfiles,代碼行數:20,代碼來源:servicecall.py

示例3: IamClient

class IamClient(object):
    '''
    Web service client for IAM
    '''
    _signature_version = AWSSignature.SigV4
    _api_version = u'2010-05-08'
    _service_name = u'iam'

    def __init__(self, accessKey, secretKey, result_format = 'json'):
        '''
        Constructor
        '''
        self._accessKey = accessKey
        self._secretKey = secretKey
        self._endpoint = IamEndpoint
        self._format = result_format
        self._region = IamRegion
        
        self._client = AWSQueryClient(self._accessKey, self._secretKey, 
                                      self._endpoint, self._region, 
                                      self._service_name, self._format, 
                                      self._signature_version, self._api_version)

        
    def call(self, request):
        '''Make API call and translate AWSServiceException to more specific exception'''
        try:
            log.debug(request)
            return_msg = self._client.call(request, self._format)
            log.debug(u'Request ID: {0}'.format(return_msg.json().values()[0]\
                                                [u'ResponseMetadata'][u'RequestId'])) 
                      
            return return_msg.json()
            
        except AwsServiceException as ex:
            log.debug(misc.to_unicode(ex))

            # Translate general IAM exception
            if misc.string_equal_ignore_case(ex.code, AwsErrorCode.AccessDenied):
                raise AccessDeniedException(ex)

            elif misc.string_equal_ignore_case(ex.code, AwsErrorCode.OptInRequired):
                raise OptInRequiredException(ex)

            elif misc.string_equal_ignore_case(ex.code, AwsErrorCode.InsufficientPrivileges):
                raise InsufficientPrivilegesException(ex)

            elif misc.string_equal_ignore_case(ex.code, AwsErrorCode.InvalidParameterValue):
                raise InvalidParameterValueException(ex)
            
            elif misc.string_equal_ignore_case(ex.code, AwsErrorCode.MissingParameter):
                raise MissingParameterException(ex)

            elif misc.string_equal_ignore_case(ex.code, IamErrorCode.EntityAlreadyExists):
                raise IamEntityAlreadyExistsException(ex)

            elif misc.string_equal_ignore_case(ex.code, IamErrorCode.NoSuchEntity):
                raise IamNoSuchEntityException(ex)

            elif misc.string_equal_ignore_case(ex.code, IamErrorCode.MalformedPolicyDocument):
                raise IamMalformedPolicyDocumentException(ex)

            elif misc.string_equal_ignore_case(ex.code, IamErrorCode.LimitExceeded):
                raise IamLimitExceededException(ex)
            
            raise
            
 
    #---------------------------------------
    # service calls
    def create_role(self, role_name, assume_role_policy_document, path = None):
        request = Request()
        request.set_action(u'CreateRole')
        request.set_role_name(role_name)
        request.set_assume_role_policy_document(assume_role_policy_document)
        if path is not None: 
            request.set_path(path)
        
        try:    
            response = self.call(request)
        except AwsServiceException:       
            raise 
        
        role = Role.from_json(response[u'CreateRoleResponse'][u'CreateRoleResult'][u'Role'])
        request_id = response[u'CreateRoleResponse'][u'ResponseMetadata'][u'RequestId']
                
        return Response(request_id, role)
    
    
    def create_instance_profile(self, instance_profile_name, path = None):
        request = Request()
        request.set_action(u'CreateInstanceProfile')
        request.set_instance_profile_name(instance_profile_name)
        if path is not None: 
            request.set_path(path)
        
        try:    
            response = self.call(request)
        except AwsServiceException:
            raise 
#.........這裏部分代碼省略.........
開發者ID:Gbuomprisco,項目名稱:step-elastic-beanstalk-deploy,代碼行數:101,代碼來源:servicecall.py

示例4: RdsClient

class RdsClient(object):
    '''
    Web service client for RDS
    '''
    _signature_version = AWSSignature.SigV4
    _api_version = u'2012-04-23'
    _service_name = u'rds'

    def __init__(self, accessKey, secretKey, endpoint, region, result_format = 'json'):
        '''
        Constructor
        '''
        self._accessKey = accessKey
        self._secretKey = secretKey
        self._endpoint = endpoint
        self._format = result_format
        self._region = region
        
        self._client = AWSQueryClient(self._accessKey, self._secretKey, 
                                      self._endpoint, self._region, 
                                      self._service_name, self._format, 
                                      self._signature_version, self._api_version)

        
    def call(self, request):
        '''Make API call and translate AWSServiceException to more specific exception'''
        try:
            log.debug(request)
            return_msg = self._client.call(request, self._format)
            log.debug(u'Request ID: {0}'.format(return_msg.json().values()[0]\
                                                [u'ResponseMetadata'][u'RequestId'])) 
                      
            return return_msg.json()
            
        except AwsServiceException as ex:
            log.debug(misc.to_unicode(ex))

            # Translate general RDS exception
            if misc.string_equal_ignore_case(ex.code, AwsErrorCode.OptInRequired):
                raise OptInRequiredException(ex)

            if misc.string_equal_ignore_case(ex.code, AwsErrorCode.InsufficientPrivileges):
                raise InsufficientPrivilegesException(ex)

            if misc.string_equal_ignore_case(ex.code, AwsErrorCode.InvalidParameterValue):
                raise InvalidParameterValueException(ex)
            
            if misc.string_equal_ignore_case(ex.code, AwsErrorCode.MissingParameter):
                raise MissingParameterException(ex)
            
            raise
            
 
    #---------------------------------------
    # service calls
    def describe_db_engine_versions(self, db_parameter_group_family = None, default_only = None, 
                                    engine = None, engine_version = None, 
                                    list_supported_character_sets = None,
                                    marker = None, max_records = None):
        request = Request()
        request.set_action(u'DescribeDBEngineVersions')
        if db_parameter_group_family is not None: 
            request.set_db_parameter_group_family(db_parameter_group_family)
        if default_only is not None: 
            request.set_default_only(default_only)
        if engine is not None: 
            request.set_engine(engine)
        if engine_version is not None: 
            request.set_engine_version(engine_version)
        if list_supported_character_sets is not None: 
            request.set_list_supported_character_sets(list_supported_character_sets)
        if marker is not None: 
            request.set_marker(marker)
        if max_records is not None: 
            request.set_max_records(max_records)
        
        try:    
            response = self.call(request)
        except AwsServiceException:
            raise 
        
        results = response[u'DescribeDBEngineVersionsResponse']\
            [u'DescribeDBEngineVersionsResult'][u'DBEngineVersions']
        marker = response[u'DescribeDBEngineVersionsResponse']\
            [u'DescribeDBEngineVersionsResult'][u'Marker']
        request_id = response[u'DescribeDBEngineVersionsResponse']\
            [u'ResponseMetadata'][u'RequestId']
                
        engine_versions = []
        for result in results:
            engine_versions.append(DBEngineVersion.from_json(result))
        return Response(request_id, engine_versions, marker)


    def describe_db_instances(self, db_instance_identifier = None, 
                              marker = None, max_records = None):
        request = Request()
        request.set_action(u'DescribeDBInstances')
        if db_instance_identifier is not None: 
            request.set_db_instance_identifier(db_instance_identifier)
#.........這裏部分代碼省略.........
開發者ID:noobg1,項目名稱:testsignupaws,代碼行數:101,代碼來源:servicecall.py

示例5: ElasticBeanstalkClient

class ElasticBeanstalkClient(object):
    '''
    Web service client for Elastic Beanstalk
    '''
    _signature_version = 2
    _api_version = '2010-12-01'

    def __init__(self, accessKey, secretKey, endpoint, result_format='json'):
        '''
        Constructor
        '''
        self._accessKey = accessKey
        self._secretKey = secretKey
        self._endpoint = endpoint
        self._format = result_format

        self._client = AWSQueryClient(
            self._accessKey, self._secretKey, self._endpoint, self._format,
            self._signature_version, self._api_version)

    def call(self, request):
        '''Make API call and translate AWSServiceException to more specific exception'''
        try:
            log.debug(request)
            return_msg = self._client.call(request, self._format)
            log.debug(return_msg)

            #TODO: set more specific charset code
            return return_msg.json

        except AwsServiceException as ex:
            # Translate general Elastic Beanstalk exception
            if misc.string_equal_ignore_case(ex.code,
                                             AwsErrorCode.OptInRequired):
                raise OptInRequiredException(ex)

            if misc.string_equal_ignore_case(
                    ex.code, AwsErrorCode.InsufficientPrivileges):
                raise InsufficientPrivilegesException(ex)

            if misc.string_equal_ignore_case(
                    ex.code, AwsErrorCode.InvalidParameterValue):
                raise InvalidParameterValueException(ex)

            if misc.string_equal_ignore_case(ex.code,
                                             AwsErrorCode.MissingParameter):
                raise MissingParameterException(ex)

            raise

    #---------------------------------------
    # service calls
    def create_application(self, name, description=None):
        request = Request()
        request.set_operation('CreateApplication')
        request.set_app_name(name)
        if description is not None:
            request.set_description(description)

        try:
            response = self.call(request)
        except AwsServiceException as ex:
            if ex.code.lower() == AwsErrorCode.InvalidParameterValue.lower()\
                and _re.search(Strings.APP_EXIST_RE, ex.message):
                raise AlreadyExistException(ex)
            raise

        # TODO: take care of too many application exception?
        result = response['CreateApplicationResponse']\
            ['CreateApplicationResult']['Application']
        request_id = response['CreateApplicationResponse']\
            ['ResponseMetadata']['RequestId']

        return Response(request_id, ApplicationDescription.from_json(result))

    def delete_application(self, name, terminate_env='false'):
        request = Request()
        request.set_operation('DeleteApplication')
        request.set_app_name(name)
        request.set_terminate_env(terminate_env)

        try:
            response = self.call(request)
        except AwsServiceException as ex:
            if ex.code.lower() == AwsErrorCode.InvalidParameterValue.lower()\
                and _re.search(Strings.APP_HAS_RUNNING_ENV, ex.message):
                raise ApplicationHasRunningEnvException(ex)
            if ex.code.lower() == EBErrorCode.OperationInProgress.lower():
                raise OperationInProgressException(ex)
            raise

        request_id = response['DeleteApplicationResponse']\
            ['ResponseMetadata']['RequestId']

        return Response(request_id)

    def create_application_version(self,
                                   application,
                                   version_label,
                                   s3bucket=None,
#.........這裏部分代碼省略.........
開發者ID:basilbeltran,項目名稱:bashitol,代碼行數:101,代碼來源:servicecall.py

示例6: ElasticBeanstalkClient

class ElasticBeanstalkClient(object):
    """
    Web service client for Elastic Beanstalk
    """

    _signature_version = AWSSignature.SigV4
    _api_version = u"2010-12-01"
    _service_name = u"elasticbeanstalk"

    def __init__(self, accessKey, secretKey, endpoint, region, result_format="json"):
        """
        Constructor
        """
        self._accessKey = accessKey
        self._secretKey = secretKey
        self._endpoint = endpoint
        self._format = result_format
        self._region = region

        self._client = AWSQueryClient(
            self._accessKey,
            self._secretKey,
            self._endpoint,
            self._region,
            self._service_name,
            self._format,
            self._signature_version,
            self._api_version,
        )

    def call(self, request):
        """Make API call and translate AWSServiceException to more specific exception"""
        try:
            log.debug(request)
            return_msg = self._client.call(request, self._format)
            log.debug(u"Request ID: {0}".format(return_msg.json().values()[0][u"ResponseMetadata"][u"RequestId"]))

            # TODO: set more specific charset code
            return return_msg.json()

        except AwsServiceException as ex:
            log.debug(misc.to_unicode(ex))

            # Translate general Elastic Beanstalk exception
            if misc.string_equal_ignore_case(ex.code, AwsErrorCode.OptInRequired):
                raise OptInRequiredException(ex)

            if misc.string_equal_ignore_case(ex.code, AwsErrorCode.InsufficientPrivileges):
                raise InsufficientPrivilegesException(ex)

            if misc.string_equal_ignore_case(ex.code, AwsErrorCode.InvalidParameterValue):
                raise InvalidParameterValueException(ex)

            if misc.string_equal_ignore_case(ex.code, AwsErrorCode.MissingParameter):
                raise MissingParameterException(ex)

            raise

    # ---------------------------------------
    # service calls
    def create_application(self, name, description=None):
        request = Request()
        request.set_operation(u"CreateApplication")
        request.set_app_name(name)
        if description is not None:
            request.set_description(description)

        try:
            response = self.call(request)
        except AwsServiceException as ex:
            if ex.code.lower() == AwsErrorCode.InvalidParameterValue.lower() and _re.search(
                Strings.APP_EXIST_RE, ex.message
            ):
                raise AlreadyExistException(ex)
            raise

        # TODO: take care of too many application exception?
        result = response[u"CreateApplicationResponse"][u"CreateApplicationResult"][u"Application"]
        request_id = response[u"CreateApplicationResponse"][u"ResponseMetadata"][u"RequestId"]

        return Response(request_id, ApplicationDescription.from_json(result))

    def delete_application(self, name, terminate_env=u"false"):
        request = Request()
        request.set_operation(u"DeleteApplication")
        request.set_app_name(name)
        request.set_terminate_env(terminate_env)

        try:
            response = self.call(request)
        except AwsServiceException as ex:
            if ex.code.lower() == AwsErrorCode.InvalidParameterValue.lower() and _re.search(
                Strings.APP_HAS_RUNNING_ENV, ex.message
            ):
                raise ApplicationHasRunningEnvException(ex)
            if ex.code.lower() == EBErrorCode.OperationInProgress.lower():
                raise OperationInProgressException(ex)
            raise

        request_id = response[u"DeleteApplicationResponse"][u"ResponseMetadata"][u"RequestId"]
#.........這裏部分代碼省略.........
開發者ID:cpdean,項目名稱:cpd.dotfiles,代碼行數:101,代碼來源:servicecall.py


注:本文中的lib.aws.webservice.AWSQueryClient類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。