createIndex method

Future<CreateIndexResponse> createIndex({
  1. required String directoryArn,
  2. required bool isUnique,
  3. required List<AttributeKey> orderedIndexedAttributeList,
  4. String? linkName,
  5. ObjectReference? parentReference,
})

Creates an index object. See Indexing for more information.

May throw InternalServiceException. May throw InvalidArnException. May throw RetryableConflictException. May throw ValidationException. May throw LimitExceededException. May throw AccessDeniedException. May throw DirectoryNotEnabledException. May throw ResourceNotFoundException. May throw FacetValidationException. May throw LinkNameAlreadyInUseException. May throw UnsupportedIndexTypeException.

Parameter directoryArn : The ARN of the directory where the index should be created.

Parameter isUnique : Indicates whether the attribute that is being indexed has unique values or not.

Parameter orderedIndexedAttributeList : Specifies the attributes that should be indexed on. Currently only a single attribute is supported.

Parameter linkName : The name of the link between the parent object and the index object.

Parameter parentReference : A reference to the parent object that contains the index object.

Implementation

Future<CreateIndexResponse> createIndex({
  required String directoryArn,
  required bool isUnique,
  required List<AttributeKey> orderedIndexedAttributeList,
  String? linkName,
  ObjectReference? parentReference,
}) async {
  ArgumentError.checkNotNull(directoryArn, 'directoryArn');
  ArgumentError.checkNotNull(isUnique, 'isUnique');
  ArgumentError.checkNotNull(
      orderedIndexedAttributeList, 'orderedIndexedAttributeList');
  _s.validateStringLength(
    'linkName',
    linkName,
    1,
    64,
  );
  final headers = <String, String>{
    'x-amz-data-partition': directoryArn.toString(),
  };
  final $payload = <String, dynamic>{
    'IsUnique': isUnique,
    'OrderedIndexedAttributeList': orderedIndexedAttributeList,
    if (linkName != null) 'LinkName': linkName,
    if (parentReference != null) 'ParentReference': parentReference,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'PUT',
    requestUri: '/amazonclouddirectory/2017-01-11/index',
    headers: headers,
    exceptionFnMap: _exceptionFns,
  );
  return CreateIndexResponse.fromJson(response);
}