updateAssetFile method

Future<UpdateAssetFileResponse> updateAssetFile({
  1. required String agentSpaceId,
  2. required String assetId,
  3. required String path,
  4. String? clientToken,
  5. AssetFileBody? content,
  6. Document? metadata,
})

Updates a file in an asset

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

Parameter agentSpaceId : The unique identifier for the agent space containing the asset

Parameter assetId : The unique identifier of the asset containing the file

Parameter path : The path of the file within the asset to update

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

Parameter content : Updated file content. If omitted, the existing content is unchanged.

Parameter metadata : Metadata fields to update. Only the fields present in this document are updated. Omitted fields retain their current values.

Implementation

Future<UpdateAssetFileResponse> updateAssetFile({
  required String agentSpaceId,
  required String assetId,
  required String path,
  String? clientToken,
  AssetFileBody? content,
  Document? metadata,
}) async {
  final $payload = <String, dynamic>{
    'clientToken': clientToken ?? _s.generateIdempotencyToken(),
    if (content != null) 'content': content,
    if (metadata != null) 'metadata': metadata,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'PATCH',
    requestUri:
        '/asset/agent-space/${Uri.encodeComponent(agentSpaceId)}/assets/${Uri.encodeComponent(assetId)}/files/${path.split('/').map(Uri.encodeComponent).join('/')}',
    hostPrefix: 'dp.',
    exceptionFnMap: _exceptionFns,
  );
  return UpdateAssetFileResponse.fromJson(response);
}