Exemple #1
0
def _print_generic_response(response,
                            output_type,
                            aws_output,
                            text_message=None,
                            json_output=None,
                            verbose_output=None,
                            output_file=None):
    if output_type == OutputType.BINARY.value:
        with open(output_file, "wb") as out:
            out.write(StrUtils.decode_base64(response['Payload']['body']))
    elif output_type == OutputType.PLAIN_TEXT.value:
        output = text_message
        logger.info(output)
    else:
        if output_type == OutputType.JSON.value:
            output = json_output if json_output else {
                aws_output: {
                    'RequestId':
                    response['ResponseMetadata']['RequestId'],
                    'HTTPStatusCode':
                    response['ResponseMetadata']['HTTPStatusCode']
                }
            }
        elif output_type == OutputType.VERBOSE.value:
            output = verbose_output if verbose_output else {
                aws_output: response
            }
        logger.info_json(output)
Exemple #2
0
def _print_generic_response(resources_info: Dict, output_type: int, text_message: str, json_output: Dict) -> None:
    # Support 'PLAIN_TEXT', 'JSON' and 'VERBOSE' output types
    if output_type == OutputType.PLAIN_TEXT.value:
        output = text_message
        logger.info(output)
    else:
        if output_type == OutputType.JSON.value:
            output = json_output
        elif output_type == OutputType.VERBOSE.value:
            output = resources_info
        logger.info_json(output)