Skip to content

Commit 6319ebd

Browse files
sabiurrsabiurrjirikuncar
authored
Add excluded_regions to POST/PUT AWS lib (#552)
* Add excluded_regions to POST/PUT AWS lib * Update AWS integration tests with excluded_regions * Assert excluded region in resp * Assert excluded region in resp v2 * Update cassette Co-authored-by: sabiurr <[email protected]> Co-authored-by: Jiri Kuncar <[email protected]>
1 parent ad72cac commit 6319ebd

File tree

3 files changed

+71
-61
lines changed

3 files changed

+71
-61
lines changed

datadog/api/aws_integration.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ def create(cls, **params):
6464
/v1/integration/aws/available_namespace_rules endpoint.
6565
:type account_specific_namespace_rules: dictionary
6666
67+
:param excluded_regions: An array of AWS regions to exclude \
68+
from metrics collection.
69+
:type excluded_regions: list of strings
70+
6771
:returns: Dictionary representing the API's JSON response
6872
6973
>>> account_id = "<AWS_ACCOUNT_ID>"
@@ -72,10 +76,12 @@ def create(cls, **params):
7276
>>> filter_tags = ["<KEY>:<VALUE>"]
7377
>>> host_tags = ["<KEY>:<VALUE>"]
7478
>>> account_specific_namespace_rules = {"namespace1":true/false, "namespace2":true/false}
79+
>>> excluded_regions = ["us-east-1", "us-west-1"]
7580
7681
>>> api.AwsIntegration.create(account_id=account_id, role_name=role_name, \
7782
filter_tags=filter_tags,host_tags=host_tags,\
78-
account_specific_namespace_rules=account_specific_namespace_rules)
83+
account_specific_namespace_rules=account_specific_namespace_rules \
84+
excluded_regions=excluded_regions)
7985
"""
8086
return super(AwsIntegration, cls).create(id=cls._resource_id, **params)
8187

@@ -142,6 +148,10 @@ def update(cls, **body):
142148
/v1/integration/aws/available_namespace_rules endpoint.
143149
:type account_specific_namespace_rules: dictionary
144150
151+
:param excluded_regions: An array of AWS regions to exclude \
152+
from metrics collection.
153+
:type excluded_regions: list of strings
154+
145155
:returns: Dictionary representing the API's JSON response
146156
147157
The following will depend on whether role delegation or access keys are being used.
@@ -166,11 +176,13 @@ def update(cls, **body):
166176
>>> filter_tags = ["<KEY>:<VALUE>"]
167177
>>> host_tags = ["<KEY>:<VALUE>"]
168178
>>> account_specific_namespace_rules = {"namespace1":true/false, "namespace2":true/false}
179+
>>> excluded_regions = ["us-east-1", "us-west-1"]
169180
170181
>>> api.AwsIntegration.update(account_id=account_id, role_name=role_name, \
171182
new_account_id=new_account_id, new_role_name=new_role_name, \
172183
filter_tags=filter_tags,host_tags=host_tags,\
173-
account_specific_namespace_rules=account_specific_namespace_rules)
184+
account_specific_namespace_rules=account_specific_namespace_rules, \
185+
excluded_regions=excluded_regions)
174186
"""
175187
params = {}
176188
if body.get('account_id') and body.get('role_name'):

tests/integration/api/cassettes/TestAwsIntegration.test_update.yaml

Lines changed: 53 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,15 @@ interactions:
1212
- '65'
1313
Content-Type:
1414
- application/json
15-
Cookie:
16-
- DD-PSHARD=233
1715
User-Agent:
1816
- python-requests/2.22.0
1917
method: POST
2018
uri: https://api.datadoghq.com/api/v1/integration/aws
2119
response:
2220
body:
2321
string: !!binary |
24-
H4sIAAAAAAAAA6tWSq0oSS3KS8yJz0xRslIyT0xNMk40SjVJNTcwMTczsjC3NDRJMzE1NLIwNUpK
25-
MVSqBQBSbkdpMgAAAA==
22+
H4sIAAAAAAAAA6tWSq0oSS3KS8yJz0xRslIyMkxJS00zS7E0MTY1MTG1TEyyMEq2tDQzTEmxNDIw
23+
MFaqBQCXVQ/zMgAAAA==
2624
headers:
2725
Cache-Control:
2826
- no-cache
@@ -37,11 +35,11 @@ interactions:
3735
DD-POOL:
3836
- dogweb
3937
Date:
40-
- Mon, 03 Feb 2020 16:21:59 GMT
38+
- Sat, 21 Mar 2020 08:44:10 GMT
4139
Pragma:
4240
- no-cache
4341
Set-Cookie:
44-
- DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 10-Feb-2020 16:21:58 GMT;
42+
- DD-PSHARD=233; Max-Age=604800; Path=/; expires=Sat, 28-Mar-2020 08:44:06 GMT;
4543
secure; HttpOnly
4644
Strict-Transport-Security:
4745
- max-age=15724800;
@@ -52,17 +50,17 @@ interactions:
5250
X-Content-Type-Options:
5351
- nosniff
5452
X-DD-Debug:
55-
- rk3iIRyevtXsTLLTMsm8PoHrVjRY2UIgJwOnYxasATpPihgg0ps3VPSw7zz+6jrL
53+
- WatxAL43AyqgfI4tyA152NzYM3DLdjL7IWr0SzhldiWriTsbw9vUaRZnaqhOCdUk
5654
X-DD-VERSION:
57-
- '35.2134903'
55+
- '35.2303403'
5856
X-Frame-Options:
5957
- SAMEORIGIN
6058
status:
6159
code: 200
6260
message: OK
6361
- request:
64-
body: '{"account_id": "123456789104", "host_tags": ["api:test2"], "role_name":
65-
"DatadogApiTestRolo"}'
62+
body: '{"account_id": "123456789104", "excluded_regions": ["us-east-1", "us-west-1"],
63+
"host_tags": ["api:test2"], "role_name": "DatadogApiTestRolo"}'
6664
headers:
6765
Accept:
6866
- '*/*'
@@ -71,7 +69,7 @@ interactions:
7169
Connection:
7270
- keep-alive
7371
Content-Length:
74-
- '93'
72+
- '141'
7573
Content-Type:
7674
- application/json
7775
Cookie:
@@ -97,20 +95,20 @@ interactions:
9795
DD-POOL:
9896
- dogweb
9997
Date:
100-
- Mon, 03 Feb 2020 16:22:00 GMT
98+
- Sat, 21 Mar 2020 08:44:11 GMT
10199
Pragma:
102100
- no-cache
103101
Set-Cookie:
104-
- DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 10-Feb-2020 16:21:59 GMT;
102+
- DD-PSHARD=233; Max-Age=604800; Path=/; expires=Sat, 28-Mar-2020 08:44:10 GMT;
105103
secure; HttpOnly
106104
Strict-Transport-Security:
107105
- max-age=15724800;
108106
X-Content-Type-Options:
109107
- nosniff
110108
X-DD-Debug:
111-
- u2B27rQjtu8TuEjzrroc8ae3xeJMLmsxU6SiAszW1tH+EI3X0cOP819eGNRqlxzl
109+
- QpzDmIoaO5Hufx014PqM5BuLw+G9k75nLqy12TEr4Iab1Fl7hIFT5DrERoBer8OF
112110
X-DD-VERSION:
113-
- '35.2134903'
111+
- '35.2303403'
114112
X-Frame-Options:
115113
- SAMEORIGIN
116114
status:
@@ -134,12 +132,10 @@ interactions:
134132
response:
135133
body:
136134
string: !!binary |
137-
H4sIAAAAAAAAA82SMU/DMBCF/8vNGZrSlNQbgoWFASoxoMg6udfUEHKRfSFCVf47dmlplUJgZDv7
138-
Tuf3Pr8toDHc1uJBPW2BnGMXyyI5NLRdgYJnfEO9SOfZLJtDAhv2ogXLwahvyNi1NbrGV/INGtKu
139-
rShMbfsEHFe06xz2CXm5D5d38S6Bta2E3NfaPhnRU7JOZ9M0z+aTbKBnv0dxfVwqHcOJpRGdwI3v
140-
2L0EzeJaGsi+QcEVl1ePD7e1UOlQLNfRwpl8iOaWWIZGrFQop1CMetoxTqcXAfHlf2B8oicfMo69
141-
YGkPOZ6Ub40h7//KGRurSxTq8P1b1LvXRxMCK67lmquKjKg4/gvfPdp8kU5mQz9BjYqPhT86Jn8k
142-
Jj/korHLz0zzWSCKvug/AL5ErxtuAwAA
135+
H4sIAAAAAAAAA02OywqDQAxF/yVrhWrty12hX1C6KzKEmWgHpmaYBy2I/94oCN1dyD0ndwLUmvOY
136+
IrTPCQI7UiO+CVq4YULDw9XbB8V0Z8dQAH21y4aMCjRYHhcKciwJYyoruUv+SFtyV2xqZY3oqnrf
137+
HI6n86XaNVJ8cUwq4bAa0Ns2CVb/U9GTtr3V657oUZMK2ZEA0yxDQuCwwPKnty5R2Gzd3M0/Jtmz
138+
DdcAAAA=
143139
headers:
144140
Cache-Control:
145141
- no-cache
@@ -154,11 +150,11 @@ interactions:
154150
DD-POOL:
155151
- dogweb
156152
Date:
157-
- Mon, 03 Feb 2020 16:22:01 GMT
153+
- Sat, 21 Mar 2020 08:44:12 GMT
158154
Pragma:
159155
- no-cache
160156
Set-Cookie:
161-
- DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 10-Feb-2020 16:22:01 GMT;
157+
- DD-PSHARD=233; Max-Age=604800; Path=/; expires=Sat, 28-Mar-2020 08:44:11 GMT;
162158
secure; HttpOnly
163159
Strict-Transport-Security:
164160
- max-age=15724800;
@@ -169,9 +165,9 @@ interactions:
169165
X-Content-Type-Options:
170166
- nosniff
171167
X-DD-Debug:
172-
- +0e88dcOoH2a7qrZ5zz4PnubdrAKvSl+k8YKr4bhBQyArPBFiYg3oXWqeVKLPB1I
168+
- EbXB0e7cF4uDRViRvI+w6qPg1YzykoJqZiw5SbqL/81VRQW4a286h09eTGyIVvXJ
173169
X-DD-VERSION:
174-
- '35.2134903'
170+
- '35.2303403'
175171
X-Frame-Options:
176172
- SAMEORIGIN
177173
status:
@@ -213,20 +209,20 @@ interactions:
213209
DD-POOL:
214210
- dogweb
215211
Date:
216-
- Mon, 03 Feb 2020 16:22:02 GMT
212+
- Sat, 21 Mar 2020 08:44:13 GMT
217213
Pragma:
218214
- no-cache
219215
Set-Cookie:
220-
- DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 10-Feb-2020 16:22:01 GMT;
216+
- DD-PSHARD=233; Max-Age=604800; Path=/; expires=Sat, 28-Mar-2020 08:44:12 GMT;
221217
secure; HttpOnly
222218
Strict-Transport-Security:
223219
- max-age=15724800;
224220
X-Content-Type-Options:
225221
- nosniff
226222
X-DD-Debug:
227-
- jety+2H6BA1H4x31+wzy5BjqI2NDwh54fgbjSYyrLU0p2tWQPCCTKspX7sHO7u1n
223+
- IkXBg4ZNMRmDsobzMjEa2v35+NuPiQI0gFmho/o6e7+hfyyJl3rjuklsE4uVJo7l
228224
X-DD-VERSION:
229-
- '35.2134903'
225+
- '35.2303403'
230226
X-Frame-Options:
231227
- SAMEORIGIN
232228
status:
@@ -268,20 +264,20 @@ interactions:
268264
DD-POOL:
269265
- dogweb
270266
Date:
271-
- Mon, 03 Feb 2020 16:22:03 GMT
267+
- Sat, 21 Mar 2020 08:44:14 GMT
272268
Pragma:
273269
- no-cache
274270
Set-Cookie:
275-
- DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 10-Feb-2020 16:22:03 GMT;
271+
- DD-PSHARD=233; Max-Age=604800; Path=/; expires=Sat, 28-Mar-2020 08:44:14 GMT;
276272
secure; HttpOnly
277273
Strict-Transport-Security:
278274
- max-age=15724800;
279275
X-Content-Type-Options:
280276
- nosniff
281277
X-DD-Debug:
282-
- /Lq4EjXKMzRKp9qa/TaJTTVqSY3uTwQpdi8SFIU3firYrLG0qdPC+ksTJBROerQS
278+
- RngFxOd8mVeT14auLfzsH/6kz142QLoKkYXZjfmXpXDkZ/eN6uoCM3cTScXuFEa0
283279
X-DD-VERSION:
284-
- '35.2134903'
280+
- '35.2303403'
285281
X-Frame-Options:
286282
- SAMEORIGIN
287283
status:
@@ -323,20 +319,20 @@ interactions:
323319
DD-POOL:
324320
- dogweb
325321
Date:
326-
- Mon, 03 Feb 2020 16:22:04 GMT
322+
- Sat, 21 Mar 2020 08:44:16 GMT
327323
Pragma:
328324
- no-cache
329325
Set-Cookie:
330-
- DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 10-Feb-2020 16:22:03 GMT;
326+
- DD-PSHARD=233; Max-Age=604800; Path=/; expires=Sat, 28-Mar-2020 08:44:15 GMT;
331327
secure; HttpOnly
332328
Strict-Transport-Security:
333329
- max-age=15724800;
334330
X-Content-Type-Options:
335331
- nosniff
336332
X-DD-Debug:
337-
- x4m73yTAj65OpCjnvpw3RBJyiFQpkDOBZ7rE/UM6Q4o0837nUb4ZsWFNJUD0Xh0e
333+
- EbXB0e7cF4uDRViRvI+w6qPg1YzykoJqZiw5SbqL/81VRQW4a286h09eTGyIVvXJ
338334
X-DD-VERSION:
339-
- '35.2134903'
335+
- '35.2303403'
340336
X-Frame-Options:
341337
- SAMEORIGIN
342338
status:
@@ -378,20 +374,20 @@ interactions:
378374
DD-POOL:
379375
- dogweb
380376
Date:
381-
- Mon, 03 Feb 2020 16:22:06 GMT
377+
- Sat, 21 Mar 2020 08:44:17 GMT
382378
Pragma:
383379
- no-cache
384380
Set-Cookie:
385-
- DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 10-Feb-2020 16:22:04 GMT;
381+
- DD-PSHARD=233; Max-Age=604800; Path=/; expires=Sat, 28-Mar-2020 08:44:16 GMT;
386382
secure; HttpOnly
387383
Strict-Transport-Security:
388384
- max-age=15724800;
389385
X-Content-Type-Options:
390386
- nosniff
391387
X-DD-Debug:
392-
- xKFgbVhCHArG4Y0sXMtZ5P8r3tuxi63adTKFxNzM7f4aJAAu82zS1Bp7ak9HjM4Y
388+
- NueLa2zkdBcl9S7BHrRuWyjAeR9iWgPFe330KTY6Cp0/yUhjUktbxu5rG2fG6gBk
393389
X-DD-VERSION:
394-
- '35.2134903'
390+
- '35.2303403'
395391
X-Frame-Options:
396392
- SAMEORIGIN
397393
status:
@@ -433,20 +429,20 @@ interactions:
433429
DD-POOL:
434430
- dogweb
435431
Date:
436-
- Mon, 03 Feb 2020 16:22:07 GMT
432+
- Sat, 21 Mar 2020 08:44:18 GMT
437433
Pragma:
438434
- no-cache
439435
Set-Cookie:
440-
- DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 10-Feb-2020 16:22:06 GMT;
436+
- DD-PSHARD=233; Max-Age=604800; Path=/; expires=Sat, 28-Mar-2020 08:44:17 GMT;
441437
secure; HttpOnly
442438
Strict-Transport-Security:
443439
- max-age=15724800;
444440
X-Content-Type-Options:
445441
- nosniff
446442
X-DD-Debug:
447-
- TAg/qKywM5rz/AUGkmt8+wB4wzGMJfSiHOrBzxBctPLsV/erSD5TChi/uo5ZlVXK
443+
- u9VEJv4YNx+Fl9tRGJNbGm0+76jyym0t+mec2t84PhoJYEedil3ajyEhP7U3EneZ
448444
X-DD-VERSION:
449-
- '35.2134903'
445+
- '35.2303403'
450446
X-Frame-Options:
451447
- SAMEORIGIN
452448
status:
@@ -488,20 +484,20 @@ interactions:
488484
DD-POOL:
489485
- dogweb
490486
Date:
491-
- Mon, 03 Feb 2020 16:22:10 GMT
487+
- Sat, 21 Mar 2020 08:44:18 GMT
492488
Pragma:
493489
- no-cache
494490
Set-Cookie:
495-
- DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 10-Feb-2020 16:22:07 GMT;
491+
- DD-PSHARD=233; Max-Age=604800; Path=/; expires=Sat, 28-Mar-2020 08:44:18 GMT;
496492
secure; HttpOnly
497493
Strict-Transport-Security:
498494
- max-age=15724800;
499495
X-Content-Type-Options:
500496
- nosniff
501497
X-DD-Debug:
502-
- xDB9TwFteerR1wCiwj8/TgXRHM8VsESQxiCQvltAxyn4fse47E64CquSvdpyvFXM
498+
- Z91NUpPIZnIQ9h7lBFWBkEPGVUEsn4/i71imPPwrChu4RPI5uNM5HGuodISK1HBR
503499
X-DD-VERSION:
504-
- '35.2134903'
500+
- '35.2303403'
505501
X-Frame-Options:
506502
- SAMEORIGIN
507503
status:
@@ -543,20 +539,20 @@ interactions:
543539
DD-POOL:
544540
- dogweb
545541
Date:
546-
- Mon, 03 Feb 2020 16:22:11 GMT
542+
- Sat, 21 Mar 2020 08:44:20 GMT
547543
Pragma:
548544
- no-cache
549545
Set-Cookie:
550-
- DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 10-Feb-2020 16:22:10 GMT;
546+
- DD-PSHARD=233; Max-Age=604800; Path=/; expires=Sat, 28-Mar-2020 08:44:18 GMT;
551547
secure; HttpOnly
552548
Strict-Transport-Security:
553549
- max-age=15724800;
554550
X-Content-Type-Options:
555551
- nosniff
556552
X-DD-Debug:
557-
- AZX6w/8zD+VN3BjlP7mTxsWKLW39bs6QmKw7eyNlBdxzsMsZp5eTFn4umzElZK4n
553+
- +6muH0vWWhHE6JfE/xHkdpoFSNgX/+wCvqEMuEDvglDKir3htwvCDYdHi0bPaPF0
558554
X-DD-VERSION:
559-
- '35.2134903'
555+
- '35.2303403'
560556
X-Frame-Options:
561557
- SAMEORIGIN
562558
status:
@@ -598,20 +594,20 @@ interactions:
598594
DD-POOL:
599595
- dogweb
600596
Date:
601-
- Mon, 03 Feb 2020 16:22:11 GMT
597+
- Sat, 21 Mar 2020 08:44:22 GMT
602598
Pragma:
603599
- no-cache
604600
Set-Cookie:
605-
- DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 10-Feb-2020 16:22:11 GMT;
601+
- DD-PSHARD=233; Max-Age=604800; Path=/; expires=Sat, 28-Mar-2020 08:44:20 GMT;
606602
secure; HttpOnly
607603
Strict-Transport-Security:
608604
- max-age=15724800;
609605
X-Content-Type-Options:
610606
- nosniff
611607
X-DD-Debug:
612-
- vwiIwb5QepaQFIQrmPfIwwVWkQ/z0inFQwNEDjqDDy4v3CsF5qbv9dnyfb7UGzLf
608+
- WyM4veckZw3QTGGZ+Ro8psXMR12RERTyuAWc4KNrn9Mfk0tQy+xf5Ofi04GlB+uh
613609
X-DD-VERSION:
614-
- '35.2134903'
610+
- '35.2303403'
615611
X-Frame-Options:
616612
- SAMEORIGIN
617613
status:

0 commit comments

Comments
 (0)