createResourceSnapshot method

Future<CreateResourceSnapshotResponse> createResourceSnapshot({
  1. required String catalog,
  2. required String engagementIdentifier,
  3. required String resourceIdentifier,
  4. required String resourceSnapshotTemplateIdentifier,
  5. required ResourceType resourceType,
  6. String? clientToken,
})

This action allows you to create an immutable snapshot of a specific resource, such as an opportunity, within the context of an engagement. The snapshot captures a subset of the resource's data based on the schema defined by the provided template.

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

Parameter catalog : Specifies the catalog where the snapshot is created. Valid values are AWS and Sandbox.

Parameter engagementIdentifier : The unique identifier of the engagement associated with this snapshot. This field links the snapshot to a specific engagement context.

Parameter resourceIdentifier : The unique identifier of the specific resource to be snapshotted. The format and constraints of this identifier depend on the ResourceType specified. For example: For Opportunity type, it will be an opportunity ID.

Parameter resourceSnapshotTemplateIdentifier : The name of the template that defines the schema for the snapshot. This template determines which subset of the resource data will be included in the snapshot. Must correspond to an existing and valid template for the specified ResourceType.

Parameter resourceType : Specifies the type of resource for which the snapshot is being created. This field determines the structure and content of the snapshot. Must be one of the supported resource types, such as: Opportunity.

Parameter clientToken : Specifies a unique, client-generated UUID to ensure that the request is handled exactly once. This token helps prevent duplicate snapshot creations.

Implementation

Future<CreateResourceSnapshotResponse> createResourceSnapshot({
  required String catalog,
  required String engagementIdentifier,
  required String resourceIdentifier,
  required String resourceSnapshotTemplateIdentifier,
  required ResourceType resourceType,
  String? clientToken,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'AWSPartnerCentralSelling.CreateResourceSnapshot'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'Catalog': catalog,
      'EngagementIdentifier': engagementIdentifier,
      'ResourceIdentifier': resourceIdentifier,
      'ResourceSnapshotTemplateIdentifier':
          resourceSnapshotTemplateIdentifier,
      'ResourceType': resourceType.value,
      'ClientToken': clientToken ?? _s.generateIdempotencyToken(),
    },
  );

  return CreateResourceSnapshotResponse.fromJson(jsonResponse.body);
}