Example #1
0
    def test_route53_resource_id(self):
        event = 'before-parameter-build.route53.GetHostedZone'
        params = {
            'Id': '/hostedzone/ABC123',
            'HostedZoneId': '/hostedzone/ABC123',
            'ResourceId': '/hostedzone/DEF456',
            'DelegationSetId': '/hostedzone/GHI789',
            'Other': '/hostedzone/foo'
        }
        operation_def = {
            'name': 'GetHostedZone',
            'input': {
                'shape': 'GetHostedZoneInput'
            }
        }
        service_def = {
            'metadata': {},
            'shapes': {
                'GetHostedZoneInput': {
                    'type': 'structure',
                    'members': {
                        'Id': {
                            'shape': 'ResourceId'
                        },
                        'HostedZoneId': {
                            'shape': 'ResourceId'
                        },
                        'ResourceId': {
                            'shape': 'ResourceId'
                        },
                        'DelegationSetId': {
                            'shape': 'DelegationSetId'
                        },
                        'Other': {
                            'shape': 'String'
                        }
                    }
                },
                'ResourceId': {
                    'type': 'string'
                },
                'DelegationSetId': {
                    'type': 'string'
                },
                'String': {
                    'type': 'string'
                }
            }
        }
        model = OperationModel(operation_def, ServiceModel(service_def))
        self.session.emit(event, params=params, model=model)

        self.assertEqual(params['Id'], '/hostedzone/ABC123')
        self.assertEqual(params['HostedZoneId'], '/hostedzone/ABC123')
        self.assertEqual(params['ResourceId'], '/hostedzone/DEF456')
        self.assertEqual(params['DelegationSetId'], '/hostedzone/GHI789')

        # This one should have been left alone
        self.assertEqual(params['Other'], '/hostedzone/foo')
Example #2
0
    def test_route53_resource_id_missing_input_shape(self):
        event = 'before-parameter-build.route53.GetHostedZone'
        params = {'HostedZoneId': '/hostedzone/ABC123'}
        operation_def = {'name': 'GetHostedZone'}
        service_def = {'metadata': {}, 'shapes': {}}
        model = OperationModel(operation_def, ServiceModel(service_def))
        self.session.emit(event, params=params, model=model)

        self.assertEqual(params['HostedZoneId'], '/hostedzone/ABC123')
Example #3
0
def document_load_reload_action(
    section,
    action_name,
    resource_name,
    event_emitter,
    load_model,
    service_model,
    include_signature=True,
):
    """Documents the resource load action

    :param section: The section to write to

    :param action_name: The name of the loading action should be load or reload

    :param resource_name: The name of the resource

    :param event_emitter: The event emitter to use to emit events

    :param load_model: The model of the load action

    :param service_model: The model of the service

    :param include_signature: Whether or not to include the signature.
        It is useful for generating docstrings.
    """
    description = (
        'Calls :py:meth:`{}.Client.{}` to update the attributes of the '
        '{} resource. Note that the load and reload methods are '
        'the same method and can be used interchangeably.'.format(
            get_service_module_name(service_model),
            xform_name(load_model.request.operation),
            resource_name,
        ))
    example_resource_name = xform_name(resource_name)
    if service_model.service_name == resource_name:
        example_resource_name = resource_name
    example_prefix = f'{example_resource_name}.{action_name}'
    document_model_driven_method(
        section=section,
        method_name=action_name,
        operation_model=OperationModel({}, service_model),
        event_emitter=event_emitter,
        method_description=description,
        example_prefix=example_prefix,
        include_signature=include_signature,
    )
 def build_models(self):
     self.service_model = ServiceModel(self.json_model)
     self.operation_model = OperationModel(
         self.json_model['operations']['SampleOperation'],
         self.service_model)