Exemplo n.º 1
0
 def get_user_ak(self, format, username):  # 获取用户所有的ak信息
     from aliyunsdkram.request.v20150501.ListAccessKeysRequest import ListAccessKeysRequest
     request = ListAccessKeysRequest()
     request.set_accept_format(format)
     request.set_UserName(username)
     try:
         response = self.client.do_action_with_exception(request)
     except:
         return False
     return response
    def _create_access_key(self):
        if self.ram_user_access_key_id and self.ram_user_access_key_secret:
            return

        response = request_helper(self.client, ListAccessKeysRequest(),
                                  UserName=self.default_ram_user_name)
        for access_key in find_in_response(response, keys=['AccessKeys', 'AccessKey']):
            access_key_id = access_key['AccessKeyId']
            request_helper(self.client, DeleteAccessKeyRequest(),
                           UserAccessKeyId=access_key_id,
                           UserName=self.default_ram_user_name)

        response = request_helper(self.client, CreateAccessKeyRequest(),
                                  UserName=self.default_ram_user_name)
        self.ram_user_access_key_id = find_in_response(response, keys=['AccessKey', 'AccessKeyId'])
        self.ram_user_access_key_secret = find_in_response(
            response,
            keys=['AccessKey', 'AccessKeySecret'])
Exemplo n.º 3
0
 def test_products_without_location_service(self):
     request = ListAccessKeysRequest()
     response = self.client.do_action_with_exception(request)
 def test_request_with_ram(self):
     from aliyunsdkram.request.v20150501.ListAccessKeysRequest import ListAccessKeysRequest
     request = ListAccessKeysRequest()
     response = self.client.do_action_with_exception(request)
     response = self.get_dict_response(response)
     self.assertTrue(response.get("AccessKeys"))