getCommandInvocation method

Future<GetCommandInvocationResult> getCommandInvocation({
  1. required String commandId,
  2. required String instanceId,
  3. String? pluginName,
})

Returns detailed information about command execution for an invocation or plugin.

May throw InternalServerError. May throw InvalidCommandId. May throw InvalidInstanceId. May throw InvalidPluginName. May throw InvocationDoesNotExist.

Parameter commandId : (Required) The parent command ID of the invocation plugin.

Parameter instanceId : (Required) The ID of the managed instance targeted by the command. A managed instance can be an EC2 instance or an instance in your hybrid environment that is configured for Systems Manager.

Parameter pluginName : (Optional) The name of the plugin for which you want detailed results. If the document contains only one plugin, the name can be omitted and the details will be returned.

Plugin names are also referred to as step names in Systems Manager documents.

Implementation

Future<GetCommandInvocationResult> getCommandInvocation({
  required String commandId,
  required String instanceId,
  String? pluginName,
}) async {
  ArgumentError.checkNotNull(commandId, 'commandId');
  _s.validateStringLength(
    'commandId',
    commandId,
    36,
    36,
    isRequired: true,
  );
  ArgumentError.checkNotNull(instanceId, 'instanceId');
  _s.validateStringLength(
    'pluginName',
    pluginName,
    4,
    1152921504606846976,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AmazonSSM.GetCommandInvocation'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'CommandId': commandId,
      'InstanceId': instanceId,
      if (pluginName != null) 'PluginName': pluginName,
    },
  );

  return GetCommandInvocationResult.fromJson(jsonResponse.body);
}