createCampaign method
- required int minProvisionedTPS,
- required String name,
- required String solutionVersionArn,
- CampaignConfig? campaignConfig,
Creates a campaign by deploying a solution version. When a client calls the GetRecommendations and GetPersonalizedRanking APIs, a campaign is specified in the request.
Minimum Provisioned TPS and Auto-Scaling
A transaction is a single GetRecommendations
or
GetPersonalizedRanking
call. Transactions per second (TPS) is
the throughput and unit of billing for Amazon Personalize. The minimum
provisioned TPS (minProvisionedTPS
) specifies the baseline
throughput provisioned by Amazon Personalize, and thus, the minimum
billing charge. If your TPS increases beyond
minProvisionedTPS
, Amazon Personalize auto-scales the
provisioned capacity up and down, but never below
minProvisionedTPS
, to maintain a 70% utilization. There's a
short time delay while the capacity is increased that might cause loss of
transactions. It's recommended to start with a low
minProvisionedTPS
, track your usage using Amazon CloudWatch
metrics, and then increase the minProvisionedTPS
as
necessary.
Status
A campaign can be in one of the following states:
- CREATE PENDING > CREATE IN_PROGRESS > ACTIVE -or- CREATE FAILED
- DELETE PENDING > DELETE IN_PROGRESS
Related APIs
May throw InvalidInputException. May throw ResourceNotFoundException. May throw ResourceAlreadyExistsException. May throw LimitExceededException. May throw ResourceInUseException.
Parameter minProvisionedTPS
:
Specifies the requested minimum provisioned transactions (recommendations)
per second that Amazon Personalize will support.
Parameter name
:
A name for the new campaign. The campaign name must be unique within your
account.
Parameter solutionVersionArn
:
The Amazon Resource Name (ARN) of the solution version to deploy.
Parameter campaignConfig
:
The configuration details of a campaign.
Implementation
Future<CreateCampaignResponse> createCampaign({
required int minProvisionedTPS,
required String name,
required String solutionVersionArn,
CampaignConfig? campaignConfig,
}) async {
ArgumentError.checkNotNull(minProvisionedTPS, 'minProvisionedTPS');
_s.validateNumRange(
'minProvisionedTPS',
minProvisionedTPS,
1,
1152921504606846976,
isRequired: true,
);
ArgumentError.checkNotNull(name, 'name');
_s.validateStringLength(
'name',
name,
1,
63,
isRequired: true,
);
ArgumentError.checkNotNull(solutionVersionArn, 'solutionVersionArn');
_s.validateStringLength(
'solutionVersionArn',
solutionVersionArn,
0,
256,
isRequired: true,
);
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'AmazonPersonalize.CreateCampaign'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'minProvisionedTPS': minProvisionedTPS,
'name': name,
'solutionVersionArn': solutionVersionArn,
if (campaignConfig != null) 'campaignConfig': campaignConfig,
},
);
return CreateCampaignResponse.fromJson(jsonResponse.body);
}