joinDomain method

Future<JoinDomainOutput> joinDomain({
  1. required String domainName,
  2. required String gatewayARN,
  3. required String password,
  4. required String userName,
  5. List<String>? domainControllers,
  6. String? organizationalUnit,
  7. int? timeoutInSeconds,
})

Adds a file gateway to an Active Directory domain. This operation is only supported for file gateways that support the SMB file protocol.

May throw InvalidGatewayRequestException. May throw InternalServerError.

Parameter domainName : The name of the domain that you want the gateway to join.

Parameter gatewayARN : The Amazon Resource Name (ARN) of the gateway. Use the ListGateways operation to return a list of gateways for your account and AWS Region.

Parameter password : Sets the password of the user who has permission to add the gateway to the Active Directory domain.

Parameter userName : Sets the user name of user who has permission to add the gateway to the Active Directory domain. The domain user account should be enabled to join computers to the domain. For example, you can use the domain administrator account or an account with delegated permissions to join computers to the domain.

Parameter domainControllers : List of IPv4 addresses, NetBIOS names, or host names of your domain server. If you need to specify the port number include it after the colon (“:”). For example, mydc.mydomain.com:389.

Parameter organizationalUnit : The organizational unit (OU) is a container in an Active Directory that can hold users, groups, computers, and other OUs and this parameter specifies the OU that the gateway will join within the AD domain.

Parameter timeoutInSeconds : Specifies the time in seconds, in which the JoinDomain operation must complete. The default is 20 seconds.

Implementation

Future<JoinDomainOutput> joinDomain({
  required String domainName,
  required String gatewayARN,
  required String password,
  required String userName,
  List<String>? domainControllers,
  String? organizationalUnit,
  int? timeoutInSeconds,
}) async {
  ArgumentError.checkNotNull(domainName, 'domainName');
  _s.validateStringLength(
    'domainName',
    domainName,
    1,
    1024,
    isRequired: true,
  );
  ArgumentError.checkNotNull(gatewayARN, 'gatewayARN');
  _s.validateStringLength(
    'gatewayARN',
    gatewayARN,
    50,
    500,
    isRequired: true,
  );
  ArgumentError.checkNotNull(password, 'password');
  _s.validateStringLength(
    'password',
    password,
    1,
    1024,
    isRequired: true,
  );
  ArgumentError.checkNotNull(userName, 'userName');
  _s.validateStringLength(
    'userName',
    userName,
    1,
    1024,
    isRequired: true,
  );
  _s.validateStringLength(
    'organizationalUnit',
    organizationalUnit,
    1,
    1024,
  );
  _s.validateNumRange(
    'timeoutInSeconds',
    timeoutInSeconds,
    0,
    3600,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'StorageGateway_20130630.JoinDomain'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'DomainName': domainName,
      'GatewayARN': gatewayARN,
      'Password': password,
      'UserName': userName,
      if (domainControllers != null) 'DomainControllers': domainControllers,
      if (organizationalUnit != null)
        'OrganizationalUnit': organizationalUnit,
      if (timeoutInSeconds != null) 'TimeoutInSeconds': timeoutInSeconds,
    },
  );

  return JoinDomainOutput.fromJson(jsonResponse.body);
}