Total Lines | 56 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | package pinpoint |
||
2 | |||
3 | import ( |
||
4 | "context" |
||
5 | |||
6 | SDK "github.com/aws/aws-sdk-go-v2/service/pinpoint" |
||
7 | |||
8 | "github.com/evalphobia/aws-sdk-go-v2-wrapper/errors" |
||
9 | "github.com/evalphobia/aws-sdk-go-v2-wrapper/private/pointers" |
||
10 | ) |
||
11 | |||
12 | // CreateApp executes `CreateApp` operation. |
||
13 | func (svc *Pinpoint) CreateApp(ctx context.Context, r CreateAppRequest) (*CreateAppResult, error) { |
||
14 | out, err := svc.RawCreateApp(ctx, r.ToInput()) |
||
15 | if err != nil { |
||
16 | err = svc.errWrap(errors.ErrorData{ |
||
17 | Err: err, |
||
18 | AWSOperation: "CreateApp", |
||
19 | }) |
||
20 | svc.Errorf(err.Error()) |
||
|
|||
21 | return nil, err |
||
22 | } |
||
23 | return NewCreateAppResult(out), nil |
||
24 | } |
||
25 | |||
26 | // CreateAppRequest has parameters for `CreateApp` operation. |
||
27 | type CreateAppRequest struct { |
||
28 | Name string |
||
29 | |||
30 | // optional |
||
31 | Tags map[string]string |
||
32 | } |
||
33 | |||
34 | func (r CreateAppRequest) ToInput() *SDK.CreateAppInput { |
||
35 | in := &SDK.CreateAppInput{ |
||
36 | CreateApplicationRequest: &SDK.CreateApplicationRequest{}, |
||
37 | } |
||
38 | if r.Name != "" { |
||
39 | in.CreateApplicationRequest.Name = pointers.String(r.Name) |
||
40 | } |
||
41 | in.CreateApplicationRequest.Tags = r.Tags |
||
42 | return in |
||
43 | } |
||
44 | |||
45 | type CreateAppResult struct { |
||
46 | ApplicationResponse |
||
47 | } |
||
48 | |||
49 | func NewCreateAppResult(o *SDK.CreateAppResponse) *CreateAppResult { |
||
50 | result := &CreateAppResult{} |
||
51 | if o == nil { |
||
52 | return result |
||
53 | } |
||
54 | |||
55 | result.ApplicationResponse = newApplicationResponse(o.ApplicationResponse) |
||
56 | return result |
||
57 | } |
||
58 |