/
api_op_CreateCampaign.go
124 lines (111 loc) · 5.03 KB
/
api_op_CreateCampaign.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// Code generated by smithy-go-codegen DO NOT EDIT.
package personalize
import (
"context"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/aws/retry"
"github.com/aws/aws-sdk-go-v2/aws/signer/v4"
smithy "github.com/awslabs/smithy-go"
"github.com/awslabs/smithy-go/middleware"
smithyhttp "github.com/awslabs/smithy-go/transport/http"
)
// Creates a campaign by deploying a solution version. When a client calls the
// GetRecommendations
// (https://docs.aws.amazon.com/personalize/latest/dg/API_RS_GetRecommendations.html)
// and GetPersonalizedRanking
// (https://docs.aws.amazon.com/personalize/latest/dg/API_RS_GetPersonalizedRanking.html)
// APIs, a campaign is specified in the request. <p> <b>Minimum Provisioned TPS
// and Auto-Scaling</b> </p> <p>A transaction is a single
// <code>GetRecommendations</code> or <code>GetPersonalizedRanking</code> call.
// Transactions per second (TPS) is the throughput and unit of billing for Amazon
// Personalize. The minimum provisioned TPS (<code>minProvisionedTPS</code>)
// specifies the baseline throughput provisioned by Amazon Personalize, and thus,
// the minimum billing charge. If your TPS increases beyond
// <code>minProvisionedTPS</code>, Amazon Personalize auto-scales the provisioned
// capacity up and down, but never below <code>minProvisionedTPS</code>, 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 <code>minProvisionedTPS</code>, track your usage using Amazon CloudWatch
// metrics, and then increase the <code>minProvisionedTPS</code> as necessary.</p>
// <p> <b>Status</b> </p> <p>A campaign can be in one of the following states:</p>
// <ul> <li> <p>CREATE PENDING > CREATE IN_PROGRESS > ACTIVE -or- CREATE FAILED</p>
// </li> <li> <p>DELETE PENDING > DELETE IN_PROGRESS</p> </li> </ul> <p>To get the
// campaign status, call <a>DescribeCampaign</a>.</p> <note> <p>Wait until the
// <code>status</code> of the campaign is <code>ACTIVE</code> before asking the
// campaign for recommendations.</p> </note> <p class="title"> <b>Related APIs</b>
// </p> <ul> <li> <p> <a>ListCampaigns</a> </p> </li> <li> <p>
// <a>DescribeCampaign</a> </p> </li> <li> <p> <a>UpdateCampaign</a> </p> </li>
// <li> <p> <a>DeleteCampaign</a> </p> </li> </ul>
func (c *Client) CreateCampaign(ctx context.Context, params *CreateCampaignInput, optFns ...func(*Options)) (*CreateCampaignOutput, error) {
stack := middleware.NewStack("CreateCampaign", smithyhttp.NewStackRequest)
options := c.options.Copy()
for _, fn := range optFns {
fn(&options)
}
addawsAwsjson11_serdeOpCreateCampaignMiddlewares(stack)
awsmiddleware.AddRequestInvocationIDMiddleware(stack)
smithyhttp.AddContentLengthMiddleware(stack)
AddResolveEndpointMiddleware(stack, options)
v4.AddComputePayloadSHA256Middleware(stack)
retry.AddRetryMiddlewares(stack, options)
addHTTPSignerV4Middleware(stack, options)
awsmiddleware.AddAttemptClockSkewMiddleware(stack)
addClientUserAgent(stack)
smithyhttp.AddErrorCloseResponseBodyMiddleware(stack)
smithyhttp.AddCloseResponseBodyMiddleware(stack)
addOpCreateCampaignValidationMiddleware(stack)
stack.Initialize.Add(newServiceMetadataMiddleware_opCreateCampaign(options.Region), middleware.Before)
addRequestIDRetrieverMiddleware(stack)
addResponseErrorMiddleware(stack)
for _, fn := range options.APIOptions {
if err := fn(stack); err != nil {
return nil, err
}
}
handler := middleware.DecorateHandler(smithyhttp.NewClientHandler(options.HTTPClient), stack)
result, metadata, err := handler.Handle(ctx, params)
if err != nil {
return nil, &smithy.OperationError{
ServiceID: ServiceID,
OperationName: "CreateCampaign",
Err: err,
}
}
out := result.(*CreateCampaignOutput)
out.ResultMetadata = metadata
return out, nil
}
type CreateCampaignInput struct {
// Specifies the requested minimum provisioned transactions (recommendations) per
// second that Amazon Personalize will support.
//
// This member is required.
MinProvisionedTPS *int32
// The Amazon Resource Name (ARN) of the solution version to deploy.
//
// This member is required.
SolutionVersionArn *string
// A name for the new campaign. The campaign name must be unique within your
// account.
//
// This member is required.
Name *string
}
type CreateCampaignOutput struct {
// The Amazon Resource Name (ARN) of the campaign.
CampaignArn *string
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
}
func addawsAwsjson11_serdeOpCreateCampaignMiddlewares(stack *middleware.Stack) {
stack.Serialize.Add(&awsAwsjson11_serializeOpCreateCampaign{}, middleware.After)
stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateCampaign{}, middleware.After)
}
func newServiceMetadataMiddleware_opCreateCampaign(region string) awsmiddleware.RegisterServiceMetadata {
return awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
SigningName: "personalize",
OperationName: "CreateCampaign",
}
}