createAsset method

Future<CreateAssetResponse> createAsset({
  1. required String agentSpaceId,
  2. required String assetType,
  3. required AssetContent content,
  4. String? clientToken,
  5. Document? metadata,
})

Creates a new asset in the specified agent space

May throw AccessDeniedException. May throw ConflictException. May throw InternalServerException. May throw ThrottlingException. May throw ValidationException.

Parameter agentSpaceId : The unique identifier for the agent space where the asset will be created

Parameter assetType : The type of asset to create

Parameter content : The content for the asset. Provide a single file, a zip bundle, or a sourceUrl to import from an external source.

Parameter clientToken : A unique, case-sensitive identifier used for idempotent asset creation

Parameter metadata : The metadata describing this asset

Implementation

Future<CreateAssetResponse> createAsset({
  required String agentSpaceId,
  required String assetType,
  required AssetContent content,
  String? clientToken,
  Document? metadata,
}) async {
  final $payload = <String, dynamic>{
    'assetType': assetType,
    'content': content,
    'clientToken': clientToken ?? _s.generateIdempotencyToken(),
    if (metadata != null) 'metadata': metadata,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri:
        '/asset/agent-space/${Uri.encodeComponent(agentSpaceId)}/assets',
    hostPrefix: 'dp.',
    exceptionFnMap: _exceptionFns,
  );
  return CreateAssetResponse.fromJson(response);
}