| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c1c6173 commit 2fda51f
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -26,3 +26,4 @@ Methods: | |||
| 26 | 26 | - <code title="put /zones/{zone_id}/snippets/snippet_rules">client.snippets.rules.<a href="./src/cloudflare/resources/snippets/rules.py">update</a>(\*, zone_id, \*\*<a href="src/cloudflare/types/snippets/rule_update_params.py">params</a>) -> object</code> | |
| 27 | 27 | - <code title="get /zones/{zone_id}/snippets/snippet_rules">client.snippets.rules.<a href="./src/cloudflare/resources/snippets/rules.py">list</a>(\*, zone_id) -> object</code> | |
| 28 | 28 | - <code title="delete /zones/{zone_id}/snippets/snippet_rules">client.snippets.rules.<a href="./src/cloudflare/resources/snippets/rules.py">delete</a>(\*, zone_id) -> object</code> | |
| 29 | + - <code title="get /zones/{zone_id}/snippets/snippet_rules">client.snippets.rules.<a href="./src/cloudflare/resources/snippets/rules.py">get</a>(\*, zone_id) -> object</code> | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -164,6 +164,45 @@ def delete( | |||
| 164 | 164 | cast_to=cast(Type[object], ResultWrapper[object]), | |
| 165 | 165 | ) | |
| 166 | 166 | ||
| 167 | + def get( | ||
| 168 | + self, | ||
| 169 | + *, | ||
| 170 | + zone_id: str, | ||
| 171 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. | ||
| 172 | + # The extra values given here take precedence over values defined on the client or passed to this method. | ||
| 173 | + extra_headers: Headers | None = None, | ||
| 174 | + extra_query: Query | None = None, | ||
| 175 | + extra_body: Body | None = None, | ||
| 176 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, | ||
| 177 | + ) -> object: | ||
| 178 | + """ | ||
| 179 | + Fetches all snippet rules belonging to the zone. | ||
| 180 | + | ||
| 181 | + Args: | ||
| 182 | + zone_id: Use this field to specify the unique ID of the zone. | ||
| 183 | + | ||
| 184 | + extra_headers: Send extra headers | ||
| 185 | + | ||
| 186 | + extra_query: Add additional query parameters to the request | ||
| 187 | + | ||
| 188 | + extra_body: Add additional JSON properties to the request | ||
| 189 | + | ||
| 190 | + timeout: Override the client-level default timeout for this request, in seconds | ||
| 191 | + """ | ||
| 192 | + if not zone_id: | ||
| 193 | + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") | ||
| 194 | + return self._get( | ||
| 195 | + path_template("/zones/{zone_id}/snippets/snippet_rules", zone_id=zone_id), | ||
| 196 | + options=make_request_options( | ||
| 197 | + extra_headers=extra_headers, | ||
| 198 | + extra_query=extra_query, | ||
| 199 | + extra_body=extra_body, | ||
| 200 | + timeout=timeout, | ||
| 201 | + post_parser=ResultWrapper[object]._unwrapper, | ||
| 202 | + ), | ||
| 203 | + cast_to=cast(Type[object], ResultWrapper[object]), | ||
| 204 | + ) | ||
| 205 | + | ||
| 167 | 206 | ||
| 168 | 207 | class AsyncRulesResource(AsyncAPIResource): | |
| 169 | 208 | @cached_property | |
@@ -306,6 +345,45 @@ async def delete( | |||
| 306 | 345 | cast_to=cast(Type[object], ResultWrapper[object]), | |
| 307 | 346 | ) | |
| 308 | 347 | ||
| 348 | + async def get( | ||
| 349 | + self, | ||
| 350 | + *, | ||
| 351 | + zone_id: str, | ||
| 352 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. | ||
| 353 | + # The extra values given here take precedence over values defined on the client or passed to this method. | ||
| 354 | + extra_headers: Headers | None = None, | ||
| 355 | + extra_query: Query | None = None, | ||
| 356 | + extra_body: Body | None = None, | ||
| 357 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, | ||
| 358 | + ) -> object: | ||
| 359 | + """ | ||
| 360 | + Fetches all snippet rules belonging to the zone. | ||
| 361 | + | ||
| 362 | + Args: | ||
| 363 | + zone_id: Use this field to specify the unique ID of the zone. | ||
| 364 | + | ||
| 365 | + extra_headers: Send extra headers | ||
| 366 | + | ||
| 367 | + extra_query: Add additional query parameters to the request | ||
| 368 | + | ||
| 369 | + extra_body: Add additional JSON properties to the request | ||
| 370 | + | ||
| 371 | + timeout: Override the client-level default timeout for this request, in seconds | ||
| 372 | + """ | ||
| 373 | + if not zone_id: | ||
| 374 | + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") | ||
| 375 | + return await self._get( | ||
| 376 | + path_template("/zones/{zone_id}/snippets/snippet_rules", zone_id=zone_id), | ||
| 377 | + options=make_request_options( | ||
| 378 | + extra_headers=extra_headers, | ||
| 379 | + extra_query=extra_query, | ||
| 380 | + extra_body=extra_body, | ||
| 381 | + timeout=timeout, | ||
| 382 | + post_parser=ResultWrapper[object]._unwrapper, | ||
| 383 | + ), | ||
| 384 | + cast_to=cast(Type[object], ResultWrapper[object]), | ||
| 385 | + ) | ||
| 386 | + | ||
| 309 | 387 | ||
| 310 | 388 | class RulesResourceWithRawResponse: | |
| 311 | 389 | def __init__(self, rules: RulesResource) -> None: | |
@@ -320,6 +398,9 @@ def __init__(self, rules: RulesResource) -> None: | |||
| 320 | 398 | self.delete = to_raw_response_wrapper( | |
| 321 | 399 | rules.delete, | |
| 322 | 400 | ) | |
| 401 | + self.get = to_raw_response_wrapper( | ||
| 402 | + rules.get, | ||
| 403 | + ) | ||
| 323 | 404 | ||
| 324 | 405 | ||
| 325 | 406 | class AsyncRulesResourceWithRawResponse: | |
@@ -335,6 +416,9 @@ def __init__(self, rules: AsyncRulesResource) -> None: | |||
| 335 | 416 | self.delete = async_to_raw_response_wrapper( | |
| 336 | 417 | rules.delete, | |
| 337 | 418 | ) | |
| 419 | + self.get = async_to_raw_response_wrapper( | ||
| 420 | + rules.get, | ||
| 421 | + ) | ||
| 338 | 422 | ||
| 339 | 423 | ||
| 340 | 424 | class RulesResourceWithStreamingResponse: | |
@@ -350,6 +434,9 @@ def __init__(self, rules: RulesResource) -> None: | |||
| 350 | 434 | self.delete = to_streamed_response_wrapper( | |
| 351 | 435 | rules.delete, | |
| 352 | 436 | ) | |
| 437 | + self.get = to_streamed_response_wrapper( | ||
| 438 | + rules.get, | ||
| 439 | + ) | ||
| 353 | 440 | ||
| 354 | 441 | ||
| 355 | 442 | class AsyncRulesResourceWithStreamingResponse: | |
@@ -365,3 +452,6 @@ def __init__(self, rules: AsyncRulesResource) -> None: | |||
| 365 | 452 | self.delete = async_to_streamed_response_wrapper( | |
| 366 | 453 | rules.delete, | |
| 367 | 454 | ) | |
| 455 | + self.get = async_to_streamed_response_wrapper( | ||
| 456 | + rules.get, | ||
| 457 | + ) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -154,6 +154,44 @@ def test_path_params_delete(self, client: Cloudflare) -> None: | |||
| 154 | 154 | zone_id="", | |
| 155 | 155 | ) | |
| 156 | 156 | ||
| 157 | + @parametrize | ||
| 158 | + def test_method_get(self, client: Cloudflare) -> None: | ||
| 159 | + rule = client.snippets.rules.get( | ||
| 160 | + zone_id="9f1839b6152d298aca64c4e906b6d074", | ||
| 161 | + ) | ||
| 162 | + assert_matches_type(object, rule, path=["response"]) | ||
| 163 | + | ||
| 164 | + @parametrize | ||
| 165 | + def test_raw_response_get(self, client: Cloudflare) -> None: | ||
| 166 | + response = client.snippets.rules.with_raw_response.get( | ||
| 167 | + zone_id="9f1839b6152d298aca64c4e906b6d074", | ||
| 168 | + ) | ||
| 169 | + | ||
| 170 | + assert response.is_closed is True | ||
| 171 | + assert response.http_request.headers.get("X-Stainless-Lang") == "python" | ||
| 172 | + rule = response.parse() | ||
| 173 | + assert_matches_type(object, rule, path=["response"]) | ||
| 174 | + | ||
| 175 | + @parametrize | ||
| 176 | + def test_streaming_response_get(self, client: Cloudflare) -> None: | ||
| 177 | + with client.snippets.rules.with_streaming_response.get( | ||
| 178 | + zone_id="9f1839b6152d298aca64c4e906b6d074", | ||
| 179 | + ) as response: | ||
| 180 | + assert not response.is_closed | ||
| 181 | + assert response.http_request.headers.get("X-Stainless-Lang") == "python" | ||
| 182 | + | ||
| 183 | + rule = response.parse() | ||
| 184 | + assert_matches_type(object, rule, path=["response"]) | ||
| 185 | + | ||
| 186 | + assert cast(Any, response.is_closed) is True | ||
| 187 | + | ||
| 188 | + @parametrize | ||
| 189 | + def test_path_params_get(self, client: Cloudflare) -> None: | ||
| 190 | + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): | ||
| 191 | + client.snippets.rules.with_raw_response.get( | ||
| 192 | + zone_id="", | ||
| 193 | + ) | ||
| 194 | + | ||
| 157 | 195 | ||
| 158 | 196 | class TestAsyncRules: | |
| 159 | 197 | parametrize = pytest.mark.parametrize( | |
@@ -297,3 +335,41 @@ async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: | |||
| 297 | 335 | await async_client.snippets.rules.with_raw_response.delete( | |
| 298 | 336 | zone_id="", | |
| 299 | 337 | ) | |
| 338 | + | ||
| 339 | + @parametrize | ||
| 340 | + async def test_method_get(self, async_client: AsyncCloudflare) -> None: | ||
| 341 | + rule = await async_client.snippets.rules.get( | ||
| 342 | + zone_id="9f1839b6152d298aca64c4e906b6d074", | ||
| 343 | + ) | ||
| 344 | + assert_matches_type(object, rule, path=["response"]) | ||
| 345 | + | ||
| 346 | + @parametrize | ||
| 347 | + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: | ||
| 348 | + response = await async_client.snippets.rules.with_raw_response.get( | ||
| 349 | + zone_id="9f1839b6152d298aca64c4e906b6d074", | ||
| 350 | + ) | ||
| 351 | + | ||
| 352 | + assert response.is_closed is True | ||
| 353 | + assert response.http_request.headers.get("X-Stainless-Lang") == "python" | ||
| 354 | + rule = await response.parse() | ||
| 355 | + assert_matches_type(object, rule, path=["response"]) | ||
| 356 | + | ||
| 357 | + @parametrize | ||
| 358 | + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: | ||
| 359 | + async with async_client.snippets.rules.with_streaming_response.get( | ||
| 360 | + zone_id="9f1839b6152d298aca64c4e906b6d074", | ||
| 361 | + ) as response: | ||
| 362 | + assert not response.is_closed | ||
| 363 | + assert response.http_request.headers.get("X-Stainless-Lang") == "python" | ||
| 364 | + | ||
| 365 | + rule = await response.parse() | ||
| 366 | + assert_matches_type(object, rule, path=["response"]) | ||
| 367 | + | ||
| 368 | + assert cast(Any, response.is_closed) is True | ||
| 369 | + | ||
| 370 | + @parametrize | ||
| 371 | + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: | ||
| 372 | + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): | ||
| 373 | + await async_client.snippets.rules.with_raw_response.get( | ||
| 374 | + zone_id="", | ||
| 375 | + ) | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments