-
Notifications
You must be signed in to change notification settings - Fork 598
/
api_op_CreateUser.go
199 lines (167 loc) · 6.52 KB
/
api_op_CreateUser.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
package transfer
import (
"context"
"fmt"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/internal/awsutil"
)
// Please also see https://docs.aws.amazon.com/goto/WebAPI/transfer-2018-11-05/CreateUserRequest
type CreateUserInput struct {
_ struct{} `type:"structure"`
// The landing directory (folder) for a user when they log in to the server
// using their SFTP client. An example is /home/username .
HomeDirectory *string `type:"string"`
// A scope-down policy for your user so you can use the same IAM role across
// multiple users. This policy scopes down user access to portions of their
// Amazon S3 bucket. Variables that you can use inside this policy include ${Transfer:UserName},
// ${Transfer:HomeDirectory}, and ${Transfer:HomeBucket}.
//
// For scope-down policies, AWS Transfer for SFTP stores the policy as a JSON
// blob, instead of the Amazon Resource Name (ARN) of the policy. You save the
// policy as a JSON blob and pass it in the Policy argument.
//
// For an example of a scope-down policy, see "https://docs.aws.amazon.com/transfer/latest/userguide/users.html#users-policies-scope-down">Creating
// a Scope-Down Policy.
//
// For more information, see "https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html"
// in the AWS Security Token Service API Reference.
Policy *string `type:"string"`
// The IAM role that controls your user's access to your Amazon S3 bucket. The
// policies attached to this role will determine the level of access you want
// to provide your users when transferring files into and out of your Amazon
// S3 bucket or buckets. The IAM role should also contain a trust relationship
// that allows the SFTP server to access your resources when servicing your
// SFTP user's transfer requests.
//
// Role is a required field
Role *string `type:"string" required:"true"`
// A system-assigned unique identifier for an SFTP server instance. This is
// the specific SFTP server that you added your user to.
//
// ServerId is a required field
ServerId *string `type:"string" required:"true"`
// The public portion of the Secure Shell (SSH) key used to authenticate the
// user to the SFTP server.
SshPublicKeyBody *string `type:"string"`
// Key-value pairs that can be used to group and search for users. Tags are
// metadata attached to users for any purpose.
Tags []Tag `min:"1" type:"list"`
// A unique string that identifies a user and is associated with a server as
// specified by the ServerId. This user name must be a minimum of 3 and a maximum
// of 32 characters long. The following are valid characters: a-z, A-Z, 0-9,
// underscore, and hyphen. The user name can't start with a hyphen.
//
// UserName is a required field
UserName *string `type:"string" required:"true"`
}
// String returns the string representation
func (s CreateUserInput) String() string {
return awsutil.Prettify(s)
}
// Validate inspects the fields of the type to determine if they are valid.
func (s *CreateUserInput) Validate() error {
invalidParams := aws.ErrInvalidParams{Context: "CreateUserInput"}
if s.Role == nil {
invalidParams.Add(aws.NewErrParamRequired("Role"))
}
if s.ServerId == nil {
invalidParams.Add(aws.NewErrParamRequired("ServerId"))
}
if s.Tags != nil && len(s.Tags) < 1 {
invalidParams.Add(aws.NewErrParamMinLen("Tags", 1))
}
if s.UserName == nil {
invalidParams.Add(aws.NewErrParamRequired("UserName"))
}
if s.Tags != nil {
for i, v := range s.Tags {
if err := v.Validate(); err != nil {
invalidParams.AddNested(fmt.Sprintf("%s[%v]", "Tags", i), err.(aws.ErrInvalidParams))
}
}
}
if invalidParams.Len() > 0 {
return invalidParams
}
return nil
}
// Please also see https://docs.aws.amazon.com/goto/WebAPI/transfer-2018-11-05/CreateUserResponse
type CreateUserOutput struct {
_ struct{} `type:"structure"`
// The ID of the SFTP server that the user is attached to.
//
// ServerId is a required field
ServerId *string `type:"string" required:"true"`
// A unique string that identifies a user account associated with an SFTP server.
//
// UserName is a required field
UserName *string `type:"string" required:"true"`
}
// String returns the string representation
func (s CreateUserOutput) String() string {
return awsutil.Prettify(s)
}
const opCreateUser = "CreateUser"
// CreateUserRequest returns a request value for making API operation for
// AWS Transfer for SFTP.
//
// Creates a user and associates them with an existing Secure File Transfer
// Protocol (SFTP) server. You can only create and associate users with SFTP
// servers that have the IdentityProviderType set to SERVICE_MANAGED. Using
// parameters for CreateUser, you can specify the user name, set the home directory,
// store the user's public key, and assign the user's AWS Identity and Access
// Management (IAM) role. You can also optionally add a scope-down policy, and
// assign metadata with tags that can be used to group and search for users.
//
// // Example sending a request using CreateUserRequest.
// req := client.CreateUserRequest(params)
// resp, err := req.Send(context.TODO())
// if err == nil {
// fmt.Println(resp)
// }
//
// Please also see https://docs.aws.amazon.com/goto/WebAPI/transfer-2018-11-05/CreateUser
func (c *Client) CreateUserRequest(input *CreateUserInput) CreateUserRequest {
op := &aws.Operation{
Name: opCreateUser,
HTTPMethod: "POST",
HTTPPath: "/",
}
if input == nil {
input = &CreateUserInput{}
}
req := c.newRequest(op, input, &CreateUserOutput{})
return CreateUserRequest{Request: req, Input: input, Copy: c.CreateUserRequest}
}
// CreateUserRequest is the request type for the
// CreateUser API operation.
type CreateUserRequest struct {
*aws.Request
Input *CreateUserInput
Copy func(*CreateUserInput) CreateUserRequest
}
// Send marshals and sends the CreateUser API request.
func (r CreateUserRequest) Send(ctx context.Context) (*CreateUserResponse, error) {
r.Request.SetContext(ctx)
err := r.Request.Send()
if err != nil {
return nil, err
}
resp := &CreateUserResponse{
CreateUserOutput: r.Request.Data.(*CreateUserOutput),
response: &aws.Response{Request: r.Request},
}
return resp, nil
}
// CreateUserResponse is the response type for the
// CreateUser API operation.
type CreateUserResponse struct {
*CreateUserOutput
response *aws.Response
}
// SDKResponseMetdata returns the response metadata for the
// CreateUser request.
func (r *CreateUserResponse) SDKResponseMetdata() *aws.Response {
return r.response
}