-
Notifications
You must be signed in to change notification settings - Fork 623
/
api_op_SendSSHPublicKey.go
164 lines (134 loc) · 4.63 KB
/
api_op_SendSSHPublicKey.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
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
package ec2instanceconnect
import (
"context"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/internal/awsutil"
)
type SendSSHPublicKeyInput struct {
_ struct{} `type:"structure"`
// The availability zone the EC2 instance was launched in.
//
// AvailabilityZone is a required field
AvailabilityZone *string `min:"6" type:"string" required:"true"`
// The EC2 instance you wish to publish the SSH key to.
//
// InstanceId is a required field
InstanceId *string `min:"10" type:"string" required:"true"`
// The OS user on the EC2 instance whom the key may be used to authenticate
// as.
//
// InstanceOSUser is a required field
InstanceOSUser *string `min:"1" type:"string" required:"true"`
// The public key to be published to the instance. To use it after publication
// you must have the matching private key.
//
// SSHPublicKey is a required field
SSHPublicKey *string `min:"256" type:"string" required:"true"`
}
// String returns the string representation
func (s SendSSHPublicKeyInput) String() string {
return awsutil.Prettify(s)
}
// Validate inspects the fields of the type to determine if they are valid.
func (s *SendSSHPublicKeyInput) Validate() error {
invalidParams := aws.ErrInvalidParams{Context: "SendSSHPublicKeyInput"}
if s.AvailabilityZone == nil {
invalidParams.Add(aws.NewErrParamRequired("AvailabilityZone"))
}
if s.AvailabilityZone != nil && len(*s.AvailabilityZone) < 6 {
invalidParams.Add(aws.NewErrParamMinLen("AvailabilityZone", 6))
}
if s.InstanceId == nil {
invalidParams.Add(aws.NewErrParamRequired("InstanceId"))
}
if s.InstanceId != nil && len(*s.InstanceId) < 10 {
invalidParams.Add(aws.NewErrParamMinLen("InstanceId", 10))
}
if s.InstanceOSUser == nil {
invalidParams.Add(aws.NewErrParamRequired("InstanceOSUser"))
}
if s.InstanceOSUser != nil && len(*s.InstanceOSUser) < 1 {
invalidParams.Add(aws.NewErrParamMinLen("InstanceOSUser", 1))
}
if s.SSHPublicKey == nil {
invalidParams.Add(aws.NewErrParamRequired("SSHPublicKey"))
}
if s.SSHPublicKey != nil && len(*s.SSHPublicKey) < 256 {
invalidParams.Add(aws.NewErrParamMinLen("SSHPublicKey", 256))
}
if invalidParams.Len() > 0 {
return invalidParams
}
return nil
}
type SendSSHPublicKeyOutput struct {
_ struct{} `type:"structure"`
// The request ID as logged by EC2 Connect. Please provide this when contacting
// AWS Support.
RequestId *string `type:"string"`
// Indicates request success.
Success *bool `type:"boolean"`
}
// String returns the string representation
func (s SendSSHPublicKeyOutput) String() string {
return awsutil.Prettify(s)
}
const opSendSSHPublicKey = "SendSSHPublicKey"
// SendSSHPublicKeyRequest returns a request value for making API operation for
// AWS EC2 Instance Connect.
//
// Pushes an SSH public key to a particular OS user on a given EC2 instance
// for 60 seconds.
//
// // Example sending a request using SendSSHPublicKeyRequest.
// req := client.SendSSHPublicKeyRequest(params)
// resp, err := req.Send(context.TODO())
// if err == nil {
// fmt.Println(resp)
// }
//
// Please also see https://docs.aws.amazon.com/goto/WebAPI/ec2-instance-connect-2018-04-02/SendSSHPublicKey
func (c *Client) SendSSHPublicKeyRequest(input *SendSSHPublicKeyInput) SendSSHPublicKeyRequest {
op := &aws.Operation{
Name: opSendSSHPublicKey,
HTTPMethod: "POST",
HTTPPath: "/",
}
if input == nil {
input = &SendSSHPublicKeyInput{}
}
req := c.newRequest(op, input, &SendSSHPublicKeyOutput{})
return SendSSHPublicKeyRequest{Request: req, Input: input, Copy: c.SendSSHPublicKeyRequest}
}
// SendSSHPublicKeyRequest is the request type for the
// SendSSHPublicKey API operation.
type SendSSHPublicKeyRequest struct {
*aws.Request
Input *SendSSHPublicKeyInput
Copy func(*SendSSHPublicKeyInput) SendSSHPublicKeyRequest
}
// Send marshals and sends the SendSSHPublicKey API request.
func (r SendSSHPublicKeyRequest) Send(ctx context.Context) (*SendSSHPublicKeyResponse, error) {
r.Request.SetContext(ctx)
err := r.Request.Send()
if err != nil {
return nil, err
}
resp := &SendSSHPublicKeyResponse{
SendSSHPublicKeyOutput: r.Request.Data.(*SendSSHPublicKeyOutput),
response: &aws.Response{Request: r.Request},
}
return resp, nil
}
// SendSSHPublicKeyResponse is the response type for the
// SendSSHPublicKey API operation.
type SendSSHPublicKeyResponse struct {
*SendSSHPublicKeyOutput
response *aws.Response
}
// SDKResponseMetdata returns the response metadata for the
// SendSSHPublicKey request.
func (r *SendSSHPublicKeyResponse) SDKResponseMetdata() *aws.Response {
return r.response
}