Skip to content

Commit 0d26a36

Browse files
feat(api): api update
1 parent 5c1c281 commit 0d26a36

5 files changed

Lines changed: 50 additions & 122 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 1777
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9b887cd7c10651d6035399ac0cac40f37b53b4c9b2e287a23ea7352eca49c052.yml
3-
openapi_spec_hash: 3882002006ca3245b0bfc9dbcc66d0e0
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-395fd6e5cc7e27dbdb13689d4d35df1ab79a1341ff126182164b06c91cdd5c37.yml
3+
openapi_spec_hash: 0f73e4a572d51862942a5c0342121887
44
config_hash: bafeb7666d2b7868c9d4ab8f0cc686e1

src/cloudflare/types/shared/token_policy.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
from typing import Dict, List, Optional
3+
from typing import Dict, List, Union, Optional
44
from typing_extensions import Literal
55

66
from ..._models import BaseModel
77

8-
__all__ = ["TokenPolicy", "PermissionGroup", "PermissionGroupMeta", "Resources"]
8+
__all__ = ["TokenPolicy", "PermissionGroup", "PermissionGroupMeta"]
99

1010

1111
class PermissionGroupMeta(BaseModel):
@@ -25,14 +25,6 @@ class PermissionGroup(BaseModel):
2525
"""Name of the permission group."""
2626

2727

28-
class Resources(BaseModel):
29-
nested: Optional[Dict[str, Dict[str, str]]] = None
30-
"""Nested resource permissions for hierarchical scoping."""
31-
32-
simple: Optional[Dict[str, str]] = None
33-
"""Simple resource permissions where each resource maps to a permission string."""
34-
35-
3628
class TokenPolicy(BaseModel):
3729
id: str
3830
"""Policy identifier."""
@@ -43,5 +35,5 @@ class TokenPolicy(BaseModel):
4335
permission_groups: List[PermissionGroup]
4436
"""A set of permission groups that are specified to the policy."""
4537

46-
resources: Resources
47-
"""Resource permissions for the policy. Use either simple or nested permissions."""
38+
resources: Dict[str, Union[str, Dict[str, str]]]
39+
"""A list of resource names that the policy applies to."""

src/cloudflare/types/shared_params/token_policy.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
from __future__ import annotations
44

5-
from typing import Dict, Iterable
5+
from typing import Dict, Union, Iterable
66
from typing_extensions import Literal, Required, TypedDict
77

8-
__all__ = ["TokenPolicy", "PermissionGroup", "PermissionGroupMeta", "Resources"]
8+
__all__ = ["TokenPolicy", "PermissionGroup", "PermissionGroupMeta"]
99

1010

1111
class PermissionGroupMeta(TypedDict, total=False):
@@ -22,20 +22,12 @@ class PermissionGroup(TypedDict, total=False):
2222
"""Attributes associated to the permission group."""
2323

2424

25-
class Resources(TypedDict, total=False):
26-
nested: Dict[str, Dict[str, str]]
27-
"""Nested resource permissions for hierarchical scoping."""
28-
29-
simple: Dict[str, str]
30-
"""Simple resource permissions where each resource maps to a permission string."""
31-
32-
3325
class TokenPolicy(TypedDict, total=False):
3426
effect: Required[Literal["allow", "deny"]]
3527
"""Allow or deny operations against the resources."""
3628

3729
permission_groups: Required[Iterable[PermissionGroup]]
3830
"""A set of permission groups that are specified to the policy."""
3931

40-
resources: Required[Resources]
41-
"""Resource permissions for the policy. Use either simple or nested permissions."""
32+
resources: Required[Dict[str, Union[str, Dict[str, str]]]]
33+
"""A list of resource names that the policy applies to."""

tests/api_resources/accounts/test_tokens.py

Lines changed: 22 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def test_method_create(self, client: Cloudflare) -> None:
3737
{"id": "c8fed203ed3043cba015a93ad1616f1f"},
3838
{"id": "82e64a83756745bbbb1c9c2701bf816b"},
3939
],
40-
"resources": {},
40+
"resources": {"foo": "string"},
4141
}
4242
],
4343
)
@@ -68,14 +68,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None:
6868
},
6969
},
7070
],
71-
"resources": {
72-
"nested": {
73-
"com.cloudflare.api.account.472e41d66440f10635de39c7ffaf6080": {
74-
"com.cloudflare.api.account.zone.*": "*"
75-
}
76-
},
77-
"simple": {"com.cloudflare.api.account.472e41d66440f10635de39c7ffaf6080": "*"},
78-
},
71+
"resources": {"foo": "string"},
7972
}
8073
],
8174
condition={
@@ -102,7 +95,7 @@ def test_raw_response_create(self, client: Cloudflare) -> None:
10295
{"id": "c8fed203ed3043cba015a93ad1616f1f"},
10396
{"id": "82e64a83756745bbbb1c9c2701bf816b"},
10497
],
105-
"resources": {},
98+
"resources": {"foo": "string"},
10699
}
107100
],
108101
)
@@ -125,7 +118,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None:
125118
{"id": "c8fed203ed3043cba015a93ad1616f1f"},
126119
{"id": "82e64a83756745bbbb1c9c2701bf816b"},
127120
],
128-
"resources": {},
121+
"resources": {"foo": "string"},
129122
}
130123
],
131124
) as response:
@@ -151,7 +144,7 @@ def test_path_params_create(self, client: Cloudflare) -> None:
151144
{"id": "c8fed203ed3043cba015a93ad1616f1f"},
152145
{"id": "82e64a83756745bbbb1c9c2701bf816b"},
153146
],
154-
"resources": {},
147+
"resources": {"foo": "string"},
155148
}
156149
],
157150
)
@@ -170,7 +163,7 @@ def test_method_update(self, client: Cloudflare) -> None:
170163
{"id": "c8fed203ed3043cba015a93ad1616f1f"},
171164
{"id": "82e64a83756745bbbb1c9c2701bf816b"},
172165
],
173-
"resources": {},
166+
"resources": {"foo": "string"},
174167
}
175168
],
176169
)
@@ -202,14 +195,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None:
202195
},
203196
},
204197
],
205-
"resources": {
206-
"nested": {
207-
"com.cloudflare.api.account.472e41d66440f10635de39c7ffaf6080": {
208-
"com.cloudflare.api.account.zone.*": "*"
209-
}
210-
},
211-
"simple": {"com.cloudflare.api.account.472e41d66440f10635de39c7ffaf6080": "*"},
212-
},
198+
"resources": {"foo": "string"},
213199
}
214200
],
215201
condition={
@@ -238,7 +224,7 @@ def test_raw_response_update(self, client: Cloudflare) -> None:
238224
{"id": "c8fed203ed3043cba015a93ad1616f1f"},
239225
{"id": "82e64a83756745bbbb1c9c2701bf816b"},
240226
],
241-
"resources": {},
227+
"resources": {"foo": "string"},
242228
}
243229
],
244230
)
@@ -262,7 +248,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None:
262248
{"id": "c8fed203ed3043cba015a93ad1616f1f"},
263249
{"id": "82e64a83756745bbbb1c9c2701bf816b"},
264250
],
265-
"resources": {},
251+
"resources": {"foo": "string"},
266252
}
267253
],
268254
) as response:
@@ -289,7 +275,7 @@ def test_path_params_update(self, client: Cloudflare) -> None:
289275
{"id": "c8fed203ed3043cba015a93ad1616f1f"},
290276
{"id": "82e64a83756745bbbb1c9c2701bf816b"},
291277
],
292-
"resources": {},
278+
"resources": {"foo": "string"},
293279
}
294280
],
295281
)
@@ -306,7 +292,7 @@ def test_path_params_update(self, client: Cloudflare) -> None:
306292
{"id": "c8fed203ed3043cba015a93ad1616f1f"},
307293
{"id": "82e64a83756745bbbb1c9c2701bf816b"},
308294
],
309-
"resources": {},
295+
"resources": {"foo": "string"},
310296
}
311297
],
312298
)
@@ -529,7 +515,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None:
529515
{"id": "c8fed203ed3043cba015a93ad1616f1f"},
530516
{"id": "82e64a83756745bbbb1c9c2701bf816b"},
531517
],
532-
"resources": {},
518+
"resources": {"foo": "string"},
533519
}
534520
],
535521
)
@@ -560,14 +546,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare
560546
},
561547
},
562548
],
563-
"resources": {
564-
"nested": {
565-
"com.cloudflare.api.account.472e41d66440f10635de39c7ffaf6080": {
566-
"com.cloudflare.api.account.zone.*": "*"
567-
}
568-
},
569-
"simple": {"com.cloudflare.api.account.472e41d66440f10635de39c7ffaf6080": "*"},
570-
},
549+
"resources": {"foo": "string"},
571550
}
572551
],
573552
condition={
@@ -594,7 +573,7 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None:
594573
{"id": "c8fed203ed3043cba015a93ad1616f1f"},
595574
{"id": "82e64a83756745bbbb1c9c2701bf816b"},
596575
],
597-
"resources": {},
576+
"resources": {"foo": "string"},
598577
}
599578
],
600579
)
@@ -617,7 +596,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) ->
617596
{"id": "c8fed203ed3043cba015a93ad1616f1f"},
618597
{"id": "82e64a83756745bbbb1c9c2701bf816b"},
619598
],
620-
"resources": {},
599+
"resources": {"foo": "string"},
621600
}
622601
],
623602
) as response:
@@ -643,7 +622,7 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None:
643622
{"id": "c8fed203ed3043cba015a93ad1616f1f"},
644623
{"id": "82e64a83756745bbbb1c9c2701bf816b"},
645624
],
646-
"resources": {},
625+
"resources": {"foo": "string"},
647626
}
648627
],
649628
)
@@ -662,7 +641,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None:
662641
{"id": "c8fed203ed3043cba015a93ad1616f1f"},
663642
{"id": "82e64a83756745bbbb1c9c2701bf816b"},
664643
],
665-
"resources": {},
644+
"resources": {"foo": "string"},
666645
}
667646
],
668647
)
@@ -694,14 +673,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare
694673
},
695674
},
696675
],
697-
"resources": {
698-
"nested": {
699-
"com.cloudflare.api.account.472e41d66440f10635de39c7ffaf6080": {
700-
"com.cloudflare.api.account.zone.*": "*"
701-
}
702-
},
703-
"simple": {"com.cloudflare.api.account.472e41d66440f10635de39c7ffaf6080": "*"},
704-
},
676+
"resources": {"foo": "string"},
705677
}
706678
],
707679
condition={
@@ -730,7 +702,7 @@ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None:
730702
{"id": "c8fed203ed3043cba015a93ad1616f1f"},
731703
{"id": "82e64a83756745bbbb1c9c2701bf816b"},
732704
],
733-
"resources": {},
705+
"resources": {"foo": "string"},
734706
}
735707
],
736708
)
@@ -754,7 +726,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) ->
754726
{"id": "c8fed203ed3043cba015a93ad1616f1f"},
755727
{"id": "82e64a83756745bbbb1c9c2701bf816b"},
756728
],
757-
"resources": {},
729+
"resources": {"foo": "string"},
758730
}
759731
],
760732
) as response:
@@ -781,7 +753,7 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None:
781753
{"id": "c8fed203ed3043cba015a93ad1616f1f"},
782754
{"id": "82e64a83756745bbbb1c9c2701bf816b"},
783755
],
784-
"resources": {},
756+
"resources": {"foo": "string"},
785757
}
786758
],
787759
)
@@ -798,7 +770,7 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None:
798770
{"id": "c8fed203ed3043cba015a93ad1616f1f"},
799771
{"id": "82e64a83756745bbbb1c9c2701bf816b"},
800772
],
801-
"resources": {},
773+
"resources": {"foo": "string"},
802774
}
803775
],
804776
)

0 commit comments

Comments
 (0)