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


Python TypedAWSClient.get_sdk方法代码示例

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


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

示例1: generate_sdk

# 需要导入模块: from chalice.awsclient import TypedAWSClient [as 别名]
# 或者: from chalice.awsclient.TypedAWSClient import get_sdk [as 别名]
def generate_sdk(ctx, sdk_type, outdir):
    # type: (click.Context, str, str) -> None
    config = create_config_obj(ctx)
    session = create_botocore_session(profile=config.profile,
                                      debug=ctx.obj['debug'])
    client = TypedAWSClient(session)
    rest_api_id = client.get_rest_api_id(config.app_name)
    stage_name = config.stage
    if rest_api_id is None:
        click.echo("Could not find API ID, has this application "
                   "been deployed?")
        raise click.Abort()
    zip_stream = client.get_sdk(rest_api_id, stage=stage_name,
                                sdk_type=sdk_type)
    tmpdir = tempfile.mkdtemp()
    with open(os.path.join(tmpdir, 'sdk.zip'), 'wb') as f:
        f.write(zip_stream.read())
    tmp_extract = os.path.join(tmpdir, 'extracted')
    with zipfile.ZipFile(os.path.join(tmpdir, 'sdk.zip')) as z:
        z.extractall(tmp_extract)
    # The extract zip dir will have a single directory:
    #  ['apiGateway-js-sdk']
    dirnames = os.listdir(tmp_extract)
    if len(dirnames) == 1:
        full_dirname = os.path.join(tmp_extract, dirnames[0])
        if os.path.isdir(full_dirname):
            final_dirname = '%s-js-sdk' % config.app_name
            full_renamed_name = os.path.join(tmp_extract, final_dirname)
            os.rename(full_dirname, full_renamed_name)
            shutil.move(full_renamed_name, outdir)
            return
    click.echo("The downloaded SDK had an unexpected directory structure: %s"
               % (', '.join(dirnames)))
    raise click.Abort()
开发者ID:shunsuke-aikawa,项目名称:chalice,代码行数:36,代码来源:__init__.py

示例2: test_get_sdk

# 需要导入模块: from chalice.awsclient import TypedAWSClient [as 别名]
# 或者: from chalice.awsclient.TypedAWSClient import get_sdk [as 别名]
 def test_get_sdk(self, stubbed_session):
     apig = stubbed_session.stub('apigateway')
     apig.get_sdk(
         restApiId='rest-api-id',
         stageName='dev',
         sdkType='javascript').returns({'body': 'foo'})
     stubbed_session.activate_stubs()
     awsclient = TypedAWSClient(stubbed_session)
     response = awsclient.get_sdk('rest-api-id', 'dev', 'javascript')
     stubbed_session.verify_stubs()
     assert response == 'foo'
开发者ID:shunsuke-aikawa,项目名称:chalice,代码行数:13,代码来源:test_awsclient.py


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