importSshPublicKey method

Future<ImportSshPublicKeyResponse> importSshPublicKey({
  1. required String serverId,
  2. required String sshPublicKeyBody,
  3. required String userName,
})

Adds a Secure Shell (SSH) public key to a user account identified by a UserName value assigned to the specific file transfer protocol-enabled server, identified by ServerId.

The response returns the UserName value, the ServerId value, and the name of the SshPublicKeyId.

May throw ServiceUnavailableException. May throw InternalServiceError. May throw InvalidRequestException. May throw ResourceExistsException. May throw ResourceNotFoundException. May throw ThrottlingException.

Parameter serverId : A system-assigned unique identifier for a server.

Parameter sshPublicKeyBody : The public key portion of an SSH key pair.

Parameter userName : The name of the user account that is assigned to one or more servers.

Implementation

Future<ImportSshPublicKeyResponse> importSshPublicKey({
  required String serverId,
  required String sshPublicKeyBody,
  required String userName,
}) async {
  ArgumentError.checkNotNull(serverId, 'serverId');
  _s.validateStringLength(
    'serverId',
    serverId,
    19,
    19,
    isRequired: true,
  );
  ArgumentError.checkNotNull(sshPublicKeyBody, 'sshPublicKeyBody');
  _s.validateStringLength(
    'sshPublicKeyBody',
    sshPublicKeyBody,
    0,
    2048,
    isRequired: true,
  );
  ArgumentError.checkNotNull(userName, 'userName');
  _s.validateStringLength(
    'userName',
    userName,
    3,
    100,
    isRequired: true,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'TransferService.ImportSshPublicKey'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'ServerId': serverId,
      'SshPublicKeyBody': sshPublicKeyBody,
      'UserName': userName,
    },
  );

  return ImportSshPublicKeyResponse.fromJson(jsonResponse.body);
}