-
Notifications
You must be signed in to change notification settings - Fork 597
/
api_op_CreateFilter.go
350 lines (305 loc) · 10.2 KB
/
api_op_CreateFilter.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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
package guardduty
import (
"context"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/internal/awsutil"
"github.com/aws/aws-sdk-go-v2/private/protocol"
)
type CreateFilterInput struct {
_ struct{} `type:"structure"`
// Specifies the action that is to be applied to the findings that match the
// filter.
Action FilterAction `locationName:"action" min:"1" type:"string" enum:"true"`
// The idempotency token for the create request.
ClientToken *string `locationName:"clientToken" type:"string" idempotencyToken:"true"`
// The description of the filter.
Description *string `locationName:"description" type:"string"`
// The unique ID of the detector of the GuardDuty account that you want to create
// a filter for.
//
// DetectorId is a required field
DetectorId *string `location:"uri" locationName:"detectorId" min:"1" type:"string" required:"true"`
// Represents the criteria to be used in the filter for querying findings.
//
// You can only use the following attributes to query findings:
//
// * accountId
//
// * region
//
// * confidence
//
// * id
//
// * resource.accessKeyDetails.accessKeyId
//
// * resource.accessKeyDetails.principalId
//
// * resource.accessKeyDetails.userName
//
// * resource.accessKeyDetails.userType
//
// * resource.instanceDetails.iamInstanceProfile.id
//
// * resource.instanceDetails.imageId
//
// * resource.instanceDetails.instanceId
//
// * resource.instanceDetails.outpostArn
//
// * resource.instanceDetails.networkInterfaces.ipv6Addresses
//
// * resource.instanceDetails.networkInterfaces.privateIpAddresses.privateIpAddress
//
// * resource.instanceDetails.networkInterfaces.publicDnsName
//
// * resource.instanceDetails.networkInterfaces.publicIp
//
// * resource.instanceDetails.networkInterfaces.securityGroups.groupId
//
// * resource.instanceDetails.networkInterfaces.securityGroups.groupName
//
// * resource.instanceDetails.networkInterfaces.subnetId
//
// * resource.instanceDetails.networkInterfaces.vpcId
//
// * resource.instanceDetails.tags.key
//
// * resource.instanceDetails.tags.value
//
// * resource.resourceType
//
// * service.action.actionType
//
// * service.action.awsApiCallAction.api
//
// * service.action.awsApiCallAction.callerType
//
// * service.action.awsApiCallAction.remoteIpDetails.city.cityName
//
// * service.action.awsApiCallAction.remoteIpDetails.country.countryName
//
// * service.action.awsApiCallAction.remoteIpDetails.ipAddressV4
//
// * service.action.awsApiCallAction.remoteIpDetails.organization.asn
//
// * service.action.awsApiCallAction.remoteIpDetails.organization.asnOrg
//
// * service.action.awsApiCallAction.serviceName
//
// * service.action.dnsRequestAction.domain
//
// * service.action.networkConnectionAction.blocked
//
// * service.action.networkConnectionAction.connectionDirection
//
// * service.action.networkConnectionAction.localPortDetails.port
//
// * service.action.networkConnectionAction.protocol
//
// * service.action.networkConnectionAction.remoteIpDetails.city.cityName
//
// * service.action.networkConnectionAction.remoteIpDetails.country.countryName
//
// * service.action.networkConnectionAction.remoteIpDetails.ipAddressV4
//
// * service.action.networkConnectionAction.remoteIpDetails.organization.asn
//
// * service.action.networkConnectionAction.remoteIpDetails.organization.asnOrg
//
// * service.action.networkConnectionAction.remotePortDetails.port
//
// * service.additionalInfo.threatListName
//
// * service.archived When this attribute is set to TRUE, only archived findings
// are listed. When it's set to FALSE, only unarchived findings are listed.
// When this attribute is not set, all existing findings are listed.
//
// * service.resourceRole
//
// * severity
//
// * type
//
// * updatedAt Type: ISO 8601 string format: YYYY-MM-DDTHH:MM:SS.SSSZ or
// YYYY-MM-DDTHH:MM:SSZ depending on whether the value contains milliseconds.
//
// FindingCriteria is a required field
FindingCriteria *FindingCriteria `locationName:"findingCriteria" type:"structure" required:"true"`
// The name of the filter.
//
// Name is a required field
Name *string `locationName:"name" min:"3" type:"string" required:"true"`
// Specifies the position of the filter in the list of current filters. Also
// specifies the order in which this filter is applied to the findings.
Rank *int64 `locationName:"rank" min:"1" type:"integer"`
// The tags to be added to a new filter resource.
Tags map[string]string `locationName:"tags" min:"1" type:"map"`
}
// String returns the string representation
func (s CreateFilterInput) String() string {
return awsutil.Prettify(s)
}
// Validate inspects the fields of the type to determine if they are valid.
func (s *CreateFilterInput) Validate() error {
invalidParams := aws.ErrInvalidParams{Context: "CreateFilterInput"}
if s.DetectorId == nil {
invalidParams.Add(aws.NewErrParamRequired("DetectorId"))
}
if s.DetectorId != nil && len(*s.DetectorId) < 1 {
invalidParams.Add(aws.NewErrParamMinLen("DetectorId", 1))
}
if s.FindingCriteria == nil {
invalidParams.Add(aws.NewErrParamRequired("FindingCriteria"))
}
if s.Name == nil {
invalidParams.Add(aws.NewErrParamRequired("Name"))
}
if s.Name != nil && len(*s.Name) < 3 {
invalidParams.Add(aws.NewErrParamMinLen("Name", 3))
}
if s.Rank != nil && *s.Rank < 1 {
invalidParams.Add(aws.NewErrParamMinValue("Rank", 1))
}
if s.Tags != nil && len(s.Tags) < 1 {
invalidParams.Add(aws.NewErrParamMinLen("Tags", 1))
}
if invalidParams.Len() > 0 {
return invalidParams
}
return nil
}
// MarshalFields encodes the AWS API shape using the passed in protocol encoder.
func (s CreateFilterInput) MarshalFields(e protocol.FieldEncoder) error {
e.SetValue(protocol.HeaderTarget, "Content-Type", protocol.StringValue("application/json"), protocol.Metadata{})
if len(s.Action) > 0 {
v := s.Action
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "action", protocol.QuotedValue{ValueMarshaler: v}, metadata)
}
var ClientToken string
if s.ClientToken != nil {
ClientToken = *s.ClientToken
} else {
ClientToken = protocol.GetIdempotencyToken()
}
{
v := ClientToken
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "clientToken", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)
}
if s.Description != nil {
v := *s.Description
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "description", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)
}
if s.FindingCriteria != nil {
v := s.FindingCriteria
metadata := protocol.Metadata{}
e.SetFields(protocol.BodyTarget, "findingCriteria", v, metadata)
}
if s.Name != nil {
v := *s.Name
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "name", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)
}
if s.Rank != nil {
v := *s.Rank
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "rank", protocol.Int64Value(v), metadata)
}
if s.Tags != nil {
v := s.Tags
metadata := protocol.Metadata{}
ms0 := e.Map(protocol.BodyTarget, "tags", metadata)
ms0.Start()
for k1, v1 := range v {
ms0.MapSetValue(k1, protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v1)})
}
ms0.End()
}
if s.DetectorId != nil {
v := *s.DetectorId
metadata := protocol.Metadata{}
e.SetValue(protocol.PathTarget, "detectorId", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)
}
return nil
}
type CreateFilterOutput struct {
_ struct{} `type:"structure"`
// The name of the successfully created filter.
//
// Name is a required field
Name *string `locationName:"name" min:"3" type:"string" required:"true"`
}
// String returns the string representation
func (s CreateFilterOutput) String() string {
return awsutil.Prettify(s)
}
// MarshalFields encodes the AWS API shape using the passed in protocol encoder.
func (s CreateFilterOutput) MarshalFields(e protocol.FieldEncoder) error {
if s.Name != nil {
v := *s.Name
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "name", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)
}
return nil
}
const opCreateFilter = "CreateFilter"
// CreateFilterRequest returns a request value for making API operation for
// Amazon GuardDuty.
//
// Creates a filter using the specified finding criteria.
//
// // Example sending a request using CreateFilterRequest.
// req := client.CreateFilterRequest(params)
// resp, err := req.Send(context.TODO())
// if err == nil {
// fmt.Println(resp)
// }
//
// Please also see https://docs.aws.amazon.com/goto/WebAPI/guardduty-2017-11-28/CreateFilter
func (c *Client) CreateFilterRequest(input *CreateFilterInput) CreateFilterRequest {
op := &aws.Operation{
Name: opCreateFilter,
HTTPMethod: "POST",
HTTPPath: "/detector/{detectorId}/filter",
}
if input == nil {
input = &CreateFilterInput{}
}
req := c.newRequest(op, input, &CreateFilterOutput{})
return CreateFilterRequest{Request: req, Input: input, Copy: c.CreateFilterRequest}
}
// CreateFilterRequest is the request type for the
// CreateFilter API operation.
type CreateFilterRequest struct {
*aws.Request
Input *CreateFilterInput
Copy func(*CreateFilterInput) CreateFilterRequest
}
// Send marshals and sends the CreateFilter API request.
func (r CreateFilterRequest) Send(ctx context.Context) (*CreateFilterResponse, error) {
r.Request.SetContext(ctx)
err := r.Request.Send()
if err != nil {
return nil, err
}
resp := &CreateFilterResponse{
CreateFilterOutput: r.Request.Data.(*CreateFilterOutput),
response: &aws.Response{Request: r.Request},
}
return resp, nil
}
// CreateFilterResponse is the response type for the
// CreateFilter API operation.
type CreateFilterResponse struct {
*CreateFilterOutput
response *aws.Response
}
// SDKResponseMetdata returns the response metadata for the
// CreateFilter request.
func (r *CreateFilterResponse) SDKResponseMetdata() *aws.Response {
return r.response
}