createObject method

Future<CreateObjectResponse> createObject({
  1. required String directoryArn,
  2. required List<SchemaFacet> schemaFacets,
  3. String? linkName,
  4. List<AttributeKeyAndValue>? objectAttributeList,
  5. ObjectReference? parentReference,
})

Creates an object in a Directory. Additionally attaches the object to a parent, if a parent reference and LinkName is specified. An object is simply a collection of Facet attributes. You can also use this API call to create a policy object, if the facet from which you create the object is a policy facet.

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 Amazon Resource Name (ARN) that is associated with the Directory in which the object will be created. For more information, see arns.

Parameter schemaFacets : A list of schema facets to be associated with the object. Do not provide minor version components. See SchemaFacet for details.

Parameter linkName : The name of link that is used to attach this object to a parent.

Parameter objectAttributeList : The attribute map whose attribute ARN contains the key and attribute value as the map value.

Parameter parentReference : If specified, the parent reference to which this object will be attached.

Implementation

Future<CreateObjectResponse> createObject({
  required String directoryArn,
  required List<SchemaFacet> schemaFacets,
  String? linkName,
  List<AttributeKeyAndValue>? objectAttributeList,
  ObjectReference? parentReference,
}) async {
  ArgumentError.checkNotNull(directoryArn, 'directoryArn');
  ArgumentError.checkNotNull(schemaFacets, 'schemaFacets');
  _s.validateStringLength(
    'linkName',
    linkName,
    1,
    64,
  );
  final headers = <String, String>{
    'x-amz-data-partition': directoryArn.toString(),
  };
  final $payload = <String, dynamic>{
    'SchemaFacets': schemaFacets,
    if (linkName != null) 'LinkName': linkName,
    if (objectAttributeList != null)
      'ObjectAttributeList': objectAttributeList,
    if (parentReference != null) 'ParentReference': parentReference,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'PUT',
    requestUri: '/amazonclouddirectory/2017-01-11/object',
    headers: headers,
    exceptionFnMap: _exceptionFns,
  );
  return CreateObjectResponse.fromJson(response);
}