updateCampaign method

Future<UpdateCampaignResponse> updateCampaign({
  1. required String campaignArn,
  2. CampaignConfig? campaignConfig,
  3. int? minProvisionedTPS,
  4. String? solutionVersionArn,
})

Updates a campaign by either deploying a new solution or changing the value of the campaign's minProvisionedTPS parameter.

To update a campaign, the campaign status must be ACTIVE or CREATE FAILED. Check the campaign status using the DescribeCampaign API. For more information on campaigns, see CreateCampaign.

May throw InvalidInputException. May throw ResourceNotFoundException. May throw ResourceInUseException.

Parameter campaignArn : The Amazon Resource Name (ARN) of the campaign.

Parameter campaignConfig : The configuration details of a campaign.

Parameter minProvisionedTPS : Specifies the requested minimum provisioned transactions (recommendations) per second that Amazon Personalize will support.

Parameter solutionVersionArn : The ARN of a new solution version to deploy.

Implementation

Future<UpdateCampaignResponse> updateCampaign({
  required String campaignArn,
  CampaignConfig? campaignConfig,
  int? minProvisionedTPS,
  String? solutionVersionArn,
}) async {
  ArgumentError.checkNotNull(campaignArn, 'campaignArn');
  _s.validateStringLength(
    'campaignArn',
    campaignArn,
    0,
    256,
    isRequired: true,
  );
  _s.validateNumRange(
    'minProvisionedTPS',
    minProvisionedTPS,
    1,
    1152921504606846976,
  );
  _s.validateStringLength(
    'solutionVersionArn',
    solutionVersionArn,
    0,
    256,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AmazonPersonalize.UpdateCampaign'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'campaignArn': campaignArn,
      if (campaignConfig != null) 'campaignConfig': campaignConfig,
      if (minProvisionedTPS != null) 'minProvisionedTPS': minProvisionedTPS,
      if (solutionVersionArn != null)
        'solutionVersionArn': solutionVersionArn,
    },
  );

  return UpdateCampaignResponse.fromJson(jsonResponse.body);
}