in chalice/deploy/planner.py [0:0]
def _add_apimapping_plan(self,
resource, # type: models.APIMapping
domain_name # type: models.DomainName
):
# type: (...) -> Sequence[InstructionMsg]
api_calls = [] # type: List[InstructionMsg]
params = {
'domain_name': domain_name.domain_name,
'path_key': resource.mount_path,
'stage': resource.api_gateway_stage
} # type: Dict[str, Any]
if domain_name.protocol == models.APIType.WEBSOCKET:
params['api_id'] = Variable('websocket_api_id')
variable_name = 'websocket_api_mapping'
api_call = models.APICall(
method_name='create_api_mapping',
params=params,
output_var='api_mapping'
)
else:
params['api_id'] = Variable('rest_api_id')
variable_name = 'rest_api_mapping'
api_call = models.APICall(
method_name='create_base_path_mapping',
params=params,
output_var='api_mapping'
)
if not self._remote_state.resource_exists(
resource, domain_name.domain_name
):
path_to_print = '/'
if resource.mount_path != '(none)' and \
not resource.mount_path.startswith("/"):
path_to_print = '/%s' % resource.mount_path
api_calls.extend([
(api_call, "Creating api mapping: %s\n" % path_to_print),
models.StoreMultipleValue(
name=variable_name,
value=[Variable('api_mapping')]
),
models.RecordResourceVariable(
resource_type='domain_name',
resource_name=domain_name.resource_name,
name='api_mapping',
variable_name=variable_name
),
])
else:
deployed = self._remote_state.resource_deployed_values(
domain_name
)
for api_mapping in deployed['api_mapping']:
mount_path = api_mapping['key'].lstrip('/')
if not mount_path:
mount_path = '(none)'
if mount_path != resource.mount_path:
continue
api_calls.extend([
models.StoreMultipleValue(
name=variable_name,
value=[api_mapping]
),
models.RecordResourceVariable(
resource_type='domain_name',
resource_name=domain_name.resource_name,
name='api_mapping',
variable_name=variable_name
),
])
return api_calls