|
| 1 | +package oss |
| 2 | + |
| 3 | +import ( |
| 4 | + "context" |
| 5 | +) |
| 6 | + |
| 7 | +type BucketAntiDDOSConfiguration struct { |
| 8 | + // The custom domain names that you want to protect. |
| 9 | + Domains []string `xml:"Cnames>Domain"` |
| 10 | +} |
| 11 | + |
| 12 | +type BucketAntiDDOSInfo struct { |
| 13 | + // The ID of the bucket owner. |
| 14 | + Owner *string `xml:"Owner"` |
| 15 | + |
| 16 | + // The time when the Anti-DDoS instance was created. The value is a timestamp. |
| 17 | + Ctime *int64 `xml:"Ctime"` |
| 18 | + |
| 19 | + // The status of the Anti-DDoS instance. Valid values:* Init* Defending* HaltDefending |
| 20 | + Status *string `xml:"Status"` |
| 21 | + |
| 22 | + // The custom domain names. |
| 23 | + Domains []string `xml:"Cnames>Domain"` |
| 24 | + |
| 25 | + // The ID of the Anti-DDoS instance. |
| 26 | + InstanceId *string `xml:"InstanceId"` |
| 27 | + |
| 28 | + // The name of the bucket for which the Anti-DDoS instance is created. |
| 29 | + Bucket *string `xml:"Bucket"` |
| 30 | + |
| 31 | + // The time when the Anti-DDoS instance was last updated. The value is a timestamp. |
| 32 | + Mtime *int64 `xml:"Mtime"` |
| 33 | + |
| 34 | + // The time when the Anti-DDoS instance was activated. The value is a timestamp. |
| 35 | + ActiveTime *int64 `xml:"ActiveTime"` |
| 36 | + |
| 37 | + // The type of the Anti-DDoS instance. Valid value: AntiDDos Premimum. |
| 38 | + Type *string `xml:"Type"` |
| 39 | +} |
| 40 | + |
| 41 | +type UserAntiDDOSInfo struct { |
| 42 | + // The time when the Anti-DDoS instance was created. The value is a timestamp. |
| 43 | + Ctime *int64 `xml:"Ctime"` |
| 44 | + |
| 45 | + // The time when the Anti-DDoS instance was last updated. The value is a timestamp. |
| 46 | + Mtime *int64 `xml:"Mtime"` |
| 47 | + |
| 48 | + // The time when the Anti-DDoS instance was activated. The value is a timestamp. |
| 49 | + ActiveTime *int64 `xml:"ActiveTime"` |
| 50 | + |
| 51 | + // The status of the Anti-DDoS instance. Valid values:* Init* Defending* HaltDefending |
| 52 | + Status *string `xml:"Status"` |
| 53 | + |
| 54 | + // The ID of the Anti-DDoS instance. |
| 55 | + InstanceId *string `xml:"InstanceId"` |
| 56 | + |
| 57 | + // The ID of the owner of the Anti-DDoS instance. |
| 58 | + Owner *string `xml:"Owner"` |
| 59 | +} |
| 60 | + |
| 61 | +type AntiDDOSListConfiguration struct { |
| 62 | + // The Anti-DDoS instances whose names are alphabetically after the specified marker. |
| 63 | + Marker *string `xml:"Marker"` |
| 64 | + |
| 65 | + // Indicates whether all Anti-DDoS instances are returned.- true: All Anti-DDoS instances are returned.- false: Not all Anti-DDoS instances are returned. |
| 66 | + IsTruncated *bool `xml:"IsTruncated"` |
| 67 | + |
| 68 | + // The container that stores information about the Anti-DDoS instance. |
| 69 | + AntiDDOSConfigurations []BucketAntiDDOSInfo `xml:"AntiDDOSConfiguration"` |
| 70 | +} |
| 71 | + |
| 72 | +type UpdateUserAntiDDosInfoRequest struct { |
| 73 | + // The Anti-DDoS instance ID. |
| 74 | + DefenderInstance *string `input:"header,x-oss-defender-instance,required"` |
| 75 | + |
| 76 | + // The new status of the Anti-DDoS instance. Set the value to HaltDefending, which indicates that the Anti-DDos protection is disabled for a bucket. |
| 77 | + DefenderStatus *string `input:"header,x-oss-defender-status,required"` |
| 78 | + |
| 79 | + RequestCommon |
| 80 | +} |
| 81 | + |
| 82 | +type UpdateUserAntiDDosInfoResult struct { |
| 83 | + ResultCommon |
| 84 | +} |
| 85 | + |
| 86 | +// UpdateUserAntiDDosInfo Modifies the status of an Anti-DDoS instance. |
| 87 | +func (c *Client) UpdateUserAntiDDosInfo(ctx context.Context, request *UpdateUserAntiDDosInfoRequest, optFns ...func(*Options)) (*UpdateUserAntiDDosInfoResult, error) { |
| 88 | + var err error |
| 89 | + if request == nil { |
| 90 | + request = &UpdateUserAntiDDosInfoRequest{} |
| 91 | + } |
| 92 | + input := &OperationInput{ |
| 93 | + OpName: "UpdateUserAntiDDosInfo", |
| 94 | + Method: "POST", |
| 95 | + Headers: map[string]string{ |
| 96 | + HTTPHeaderContentType: contentTypeXML, |
| 97 | + }, |
| 98 | + Parameters: map[string]string{ |
| 99 | + "antiDDos": "", |
| 100 | + }, |
| 101 | + } |
| 102 | + if err = c.marshalInput(request, input, updateContentMd5); err != nil { |
| 103 | + return nil, err |
| 104 | + } |
| 105 | + output, err := c.invokeOperation(ctx, input, optFns) |
| 106 | + if err != nil { |
| 107 | + return nil, err |
| 108 | + } |
| 109 | + |
| 110 | + result := &UpdateUserAntiDDosInfoResult{} |
| 111 | + |
| 112 | + if err = c.unmarshalOutput(result, output, unmarshalBodyXmlMix); err != nil { |
| 113 | + return nil, c.toClientError(err, "UnmarshalOutputFail", output) |
| 114 | + } |
| 115 | + |
| 116 | + return result, err |
| 117 | +} |
| 118 | + |
| 119 | +type UpdateBucketAntiDDosInfoRequest struct { |
| 120 | + // The name of the bucket. |
| 121 | + Bucket *string `input:"host,bucket,required"` |
| 122 | + |
| 123 | + // The Anti-DDoS instance ID. |
| 124 | + DefenderInstance *string `input:"header,x-oss-defender-instance,required"` |
| 125 | + |
| 126 | + // The new status of the Anti-DDoS instance. Valid values:* Init: You must specify the custom domain name that you want to protect.* Defending: You can select whether to specify the custom domain name that you want to protect.* HaltDefending: You do not need to specify the custom domain name that you want to protect. |
| 127 | + DefenderStatus *string `input:"header,x-oss-defender-status,required"` |
| 128 | + |
| 129 | + // The request body schema. |
| 130 | + BucketAntiDDOSConfiguration *BucketAntiDDOSConfiguration `input:"body,AntiDDOSConfiguration,xml"` |
| 131 | + |
| 132 | + RequestCommon |
| 133 | +} |
| 134 | + |
| 135 | +type UpdateBucketAntiDDosInfoResult struct { |
| 136 | + ResultCommon |
| 137 | +} |
| 138 | + |
| 139 | +// UpdateBucketAntiDDosInfo Updates the status of an Anti-DDoS instance of a bucket. |
| 140 | +func (c *Client) UpdateBucketAntiDDosInfo(ctx context.Context, request *UpdateBucketAntiDDosInfoRequest, optFns ...func(*Options)) (*UpdateBucketAntiDDosInfoResult, error) { |
| 141 | + var err error |
| 142 | + if request == nil { |
| 143 | + request = &UpdateBucketAntiDDosInfoRequest{} |
| 144 | + } |
| 145 | + input := &OperationInput{ |
| 146 | + OpName: "UpdateBucketAntiDDosInfo", |
| 147 | + Method: "POST", |
| 148 | + Headers: map[string]string{ |
| 149 | + HTTPHeaderContentType: contentTypeXML, |
| 150 | + }, |
| 151 | + Parameters: map[string]string{ |
| 152 | + "antiDDos": "", |
| 153 | + }, |
| 154 | + Bucket: request.Bucket, |
| 155 | + } |
| 156 | + if err = c.marshalInput(request, input, updateContentMd5); err != nil { |
| 157 | + return nil, err |
| 158 | + } |
| 159 | + output, err := c.invokeOperation(ctx, input, optFns) |
| 160 | + if err != nil { |
| 161 | + return nil, err |
| 162 | + } |
| 163 | + |
| 164 | + result := &UpdateBucketAntiDDosInfoResult{} |
| 165 | + |
| 166 | + if err = c.unmarshalOutput(result, output, unmarshalBodyXmlMix); err != nil { |
| 167 | + return nil, c.toClientError(err, "UnmarshalOutputFail", output) |
| 168 | + } |
| 169 | + |
| 170 | + return result, err |
| 171 | +} |
| 172 | + |
| 173 | +type ListBucketAntiDDosInfoRequest struct { |
| 174 | + // The name of the Anti-DDoS instance from which the list starts. The Anti-DDoS instances whose names are alphabetically after the value of marker are returned. You can set marker to an empty string in the first request. If IsTruncated is returned in the response and the value of IsTruncated is true, you must use the value of Marker in the response as the value of marker in the next request. |
| 175 | + Marker *string `input:"query,marker"` |
| 176 | + |
| 177 | + // The maximum number of Anti-DDoS instances that can be returned.Valid values: 1 to 100.Default value: 100. |
| 178 | + MaxKeys *string `input:"query,max-keys"` |
| 179 | + |
| 180 | + RequestCommon |
| 181 | +} |
| 182 | + |
| 183 | +type ListBucketAntiDDosInfoResult struct { |
| 184 | + // The container that stores the protection list of an Anti-DDoS instance of a bucket. |
| 185 | + AntiDDOSListConfiguration *AntiDDOSListConfiguration `output:"body,AntiDDOSListConfiguration,xml"` |
| 186 | + |
| 187 | + ResultCommon |
| 188 | +} |
| 189 | + |
| 190 | +// ListBucketAntiDDosInfo Queries the protection list of an Anti-DDoS instance of a bucket. |
| 191 | +func (c *Client) ListBucketAntiDDosInfo(ctx context.Context, request *ListBucketAntiDDosInfoRequest, optFns ...func(*Options)) (*ListBucketAntiDDosInfoResult, error) { |
| 192 | + var err error |
| 193 | + if request == nil { |
| 194 | + request = &ListBucketAntiDDosInfoRequest{} |
| 195 | + } |
| 196 | + input := &OperationInput{ |
| 197 | + OpName: "ListBucketAntiDDosInfo", |
| 198 | + Method: "GET", |
| 199 | + Headers: map[string]string{ |
| 200 | + HTTPHeaderContentType: contentTypeXML, |
| 201 | + }, |
| 202 | + Parameters: map[string]string{ |
| 203 | + "bucketAntiDDos": "", |
| 204 | + }, |
| 205 | + } |
| 206 | + if err = c.marshalInput(request, input, updateContentMd5); err != nil { |
| 207 | + return nil, err |
| 208 | + } |
| 209 | + output, err := c.invokeOperation(ctx, input, optFns) |
| 210 | + if err != nil { |
| 211 | + return nil, err |
| 212 | + } |
| 213 | + |
| 214 | + result := &ListBucketAntiDDosInfoResult{} |
| 215 | + |
| 216 | + if err = c.unmarshalOutput(result, output, unmarshalBodyXmlMix); err != nil { |
| 217 | + return nil, c.toClientError(err, "UnmarshalOutputFail", output) |
| 218 | + } |
| 219 | + |
| 220 | + return result, err |
| 221 | +} |
| 222 | + |
| 223 | +type InitUserAntiDDosInfoRequest struct { |
| 224 | + RequestCommon |
| 225 | +} |
| 226 | + |
| 227 | +type InitUserAntiDDosInfoResult struct { |
| 228 | + // The ID of the Anti-DDoS instance. |
| 229 | + DefenderInstance *string `output:"header,x-oss-defender-instance"` |
| 230 | + |
| 231 | + ResultCommon |
| 232 | +} |
| 233 | + |
| 234 | +// InitUserAntiDDosInfo Creates an Anti-DDoS instance. |
| 235 | +func (c *Client) InitUserAntiDDosInfo(ctx context.Context, request *InitUserAntiDDosInfoRequest, optFns ...func(*Options)) (*InitUserAntiDDosInfoResult, error) { |
| 236 | + var err error |
| 237 | + if request == nil { |
| 238 | + request = &InitUserAntiDDosInfoRequest{} |
| 239 | + } |
| 240 | + input := &OperationInput{ |
| 241 | + OpName: "InitUserAntiDDosInfo", |
| 242 | + Method: "PUT", |
| 243 | + Headers: map[string]string{ |
| 244 | + HTTPHeaderContentType: contentTypeXML, |
| 245 | + }, |
| 246 | + Parameters: map[string]string{ |
| 247 | + "antiDDos": "", |
| 248 | + }, |
| 249 | + } |
| 250 | + if err = c.marshalInput(request, input, updateContentMd5); err != nil { |
| 251 | + return nil, err |
| 252 | + } |
| 253 | + output, err := c.invokeOperation(ctx, input, optFns) |
| 254 | + if err != nil { |
| 255 | + return nil, err |
| 256 | + } |
| 257 | + |
| 258 | + result := &InitUserAntiDDosInfoResult{} |
| 259 | + |
| 260 | + if err = c.unmarshalOutput(result, output, unmarshalHeader, unmarshalBodyXmlMix); err != nil { |
| 261 | + return nil, c.toClientError(err, "UnmarshalOutputFail", output) |
| 262 | + } |
| 263 | + |
| 264 | + return result, err |
| 265 | +} |
| 266 | + |
| 267 | +type InitBucketAntiDDosInfoRequest struct { |
| 268 | + // The name of the bucket. |
| 269 | + Bucket *string `input:"host,bucket,required"` |
| 270 | + |
| 271 | + // The ID of the Anti-DDoS instance. |
| 272 | + DefenderInstance *string `input:"header,x-oss-defender-instance,required"` |
| 273 | + |
| 274 | + // The type of the Anti-DDoS instance. Set the value to AntiDDos Premimum. |
| 275 | + DefenderType *string `input:"header,x-oss-defender-type,required"` |
| 276 | + |
| 277 | + // The request body schema. |
| 278 | + BucketAntiDDOSConfiguration *BucketAntiDDOSConfiguration `input:"body,AntiDDOSConfiguration,xml"` |
| 279 | + |
| 280 | + RequestCommon |
| 281 | +} |
| 282 | + |
| 283 | +type InitBucketAntiDDosInfoResult struct { |
| 284 | + // The ID of the Anti-DDoS instance. |
| 285 | + DefenderInstance *string `output:"header,x-oss-defender-instance"` |
| 286 | + |
| 287 | + ResultCommon |
| 288 | +} |
| 289 | + |
| 290 | +// InitBucketAntiDDosInfo Initializes an Anti-DDoS instance for a bucket. |
| 291 | +func (c *Client) InitBucketAntiDDosInfo(ctx context.Context, request *InitBucketAntiDDosInfoRequest, optFns ...func(*Options)) (*InitBucketAntiDDosInfoResult, error) { |
| 292 | + var err error |
| 293 | + if request == nil { |
| 294 | + request = &InitBucketAntiDDosInfoRequest{} |
| 295 | + } |
| 296 | + input := &OperationInput{ |
| 297 | + OpName: "InitBucketAntiDDosInfo", |
| 298 | + Method: "PUT", |
| 299 | + Headers: map[string]string{ |
| 300 | + HTTPHeaderContentType: contentTypeXML, |
| 301 | + }, |
| 302 | + Parameters: map[string]string{ |
| 303 | + "antiDDos": "", |
| 304 | + }, |
| 305 | + Bucket: request.Bucket, |
| 306 | + } |
| 307 | + if err = c.marshalInput(request, input, updateContentMd5); err != nil { |
| 308 | + return nil, err |
| 309 | + } |
| 310 | + output, err := c.invokeOperation(ctx, input, optFns) |
| 311 | + if err != nil { |
| 312 | + return nil, err |
| 313 | + } |
| 314 | + |
| 315 | + result := &InitBucketAntiDDosInfoResult{} |
| 316 | + |
| 317 | + if err = c.unmarshalOutput(result, output, unmarshalHeader, unmarshalBodyXmlMix); err != nil { |
| 318 | + return nil, c.toClientError(err, "UnmarshalOutputFail", output) |
| 319 | + } |
| 320 | + |
| 321 | + return result, err |
| 322 | +} |
| 323 | + |
| 324 | +type GetUserAntiDDosInfoRequest struct { |
| 325 | + RequestCommon |
| 326 | +} |
| 327 | + |
| 328 | +type GetUserAntiDDosInfoResult struct { |
| 329 | + // The container that stores information about the Anti-DDoS instance. |
| 330 | + AntiDDOSConfigurations []UserAntiDDOSInfo `xml:"AntiDDOSConfiguration"` |
| 331 | + |
| 332 | + ResultCommon |
| 333 | +} |
| 334 | + |
| 335 | +// GetUserAntiDDosInfo Queries the information about an Anti-DDoS instance of an Alibaba Cloud account. |
| 336 | +func (c *Client) GetUserAntiDDosInfo(ctx context.Context, request *GetUserAntiDDosInfoRequest, optFns ...func(*Options)) (*GetUserAntiDDosInfoResult, error) { |
| 337 | + var err error |
| 338 | + if request == nil { |
| 339 | + request = &GetUserAntiDDosInfoRequest{} |
| 340 | + } |
| 341 | + input := &OperationInput{ |
| 342 | + OpName: "GetUserAntiDDosInfo", |
| 343 | + Method: "GET", |
| 344 | + Headers: map[string]string{ |
| 345 | + HTTPHeaderContentType: contentTypeXML, |
| 346 | + }, |
| 347 | + Parameters: map[string]string{ |
| 348 | + "antiDDos": "", |
| 349 | + }, |
| 350 | + } |
| 351 | + if err = c.marshalInput(request, input, updateContentMd5); err != nil { |
| 352 | + return nil, err |
| 353 | + } |
| 354 | + output, err := c.invokeOperation(ctx, input, optFns) |
| 355 | + if err != nil { |
| 356 | + return nil, err |
| 357 | + } |
| 358 | + |
| 359 | + result := &GetUserAntiDDosInfoResult{} |
| 360 | + |
| 361 | + if err = c.unmarshalOutput(result, output, unmarshalBodyXmlMix); err != nil { |
| 362 | + return nil, c.toClientError(err, "UnmarshalOutputFail", output) |
| 363 | + } |
| 364 | + |
| 365 | + return result, err |
| 366 | +} |
0 commit comments