MCPcopy Index your code
hub / github.com/aws/aws-cli / CLIOperationCaller

Class CLIOperationCaller

awscli/clidriver.py:1056–1117  ·  view source on GitHub ↗

Call an AWS operation and format the response.

Source from the content-addressed store, hash-verified

1054
1055
1056class CLIOperationCaller:
1057 """Call an AWS operation and format the response."""
1058
1059 def __init__(self, session):
1060 self._session = session
1061 self._output_stream_factory = OutputStreamFactory(session)
1062
1063 def invoke(self, service_name, operation_name, parameters, parsed_globals):
1064 """Invoke an operation and format the response.
1065
1066 :type service_name: str
1067 :param service_name: The name of the service. Note this is the
1068 service name, not the endpoint prefix (e.g. ``ses`` not ``email``).
1069
1070 :type operation_name: str
1071 :param operation_name: The operation name of the service. The casing
1072 of the operation name should match the exact casing used by the
1073 service, e.g. ``DescribeInstances``, not ``describe-instances`` or
1074 ``describe_instances``.
1075
1076 :type parameters: dict
1077 :param parameters: The parameters for the operation call. Again,
1078 these values have the same casing used by the service.
1079
1080 :type parsed_globals: Namespace
1081 :param parsed_globals: The parsed globals from the command line.
1082
1083 :return: None, the result is displayed through a formatter, but no
1084 value is returned.
1085
1086 """
1087 client = self._session.create_client(
1088 service_name,
1089 region_name=parsed_globals.region,
1090 endpoint_url=parsed_globals.endpoint_url,
1091 verify=parsed_globals.verify_ssl,
1092 )
1093 response = self._make_client_call(
1094 client, operation_name, parameters, parsed_globals
1095 )
1096 self._display_response(operation_name, response, parsed_globals)
1097 return 0
1098
1099 def _make_client_call(
1100 self, client, operation_name, parameters, parsed_globals
1101 ):
1102 py_operation_name = xform_name(operation_name)
1103 if client.can_paginate(py_operation_name) and parsed_globals.paginate:
1104 paginator = client.get_paginator(py_operation_name)
1105 response = paginator.paginate(**parameters)
1106 else:
1107 response = getattr(client, py_operation_name)(**parameters)
1108 return response
1109
1110 def _display_response(self, command_name, response, parsed_globals):
1111 output = parsed_globals.output
1112 if output is None:
1113 output = self._session.get_config_variable('output')

Callers 6

_building_command_tableFunction · 0.90
display_responseFunction · 0.90
display_responseFunction · 0.90
display_responseFunction · 0.90
_create_command_tableMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected