api_gw.py 文件源码

python
阅读 15 收藏 0 点赞 0 评论 0

项目:ansible-api-gateway 作者: pjodouin 项目源码 文件源码
def create_models(client, module, rest_api_id, schemas):
    """
    Creates models based on schemas.
    """

    models = None

    try:
        for model in schemas.keys():
            schema = schemas[model]
            schema.update({
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "title": "{0} schema".format(model)
            })
            models = client.create_model(
                restApiId=rest_api_id,
                name=model,
                description='added by Ansible module',
                contentType='application/json',
                schema=json.dumps(schema)
            )

    except (ClientError, ParamValidationError, MissingParametersError) as e:
        #TODO: should report warning or update existing model
        if not e.response['Error']['Code'] == 'ConflictException':
            module.fail_json(msg='Error creating API model {0}: {1}'.format(model, e))

    return models
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号