22
33from __future__ import annotations
44
5- import typing_extensions
6-
75import httpx
86
97from ..._types import NOT_GIVEN , Body , Query , Headers , NotGiven
8+ from ..._utils import maybe_transform
109from ..._compat import cached_property
1110from ..._resource import SyncAPIResource , AsyncAPIResource
1211from ..._response import (
1514 async_to_raw_response_wrapper ,
1615 async_to_streamed_response_wrapper ,
1716)
18- from ..._base_client import make_request_options
19- from ...types .storage .location_list_response import LocationListResponse
17+ from ...pagination import SyncOffsetPage , AsyncOffsetPage
18+ from ..._base_client import AsyncPaginator , make_request_options
19+ from ...types .storage import location_list_params
20+ from ...types .storage .location import Location
2021
2122__all__ = ["LocationsResource" , "AsyncLocationsResource" ]
2223
@@ -41,30 +42,51 @@ def with_streaming_response(self) -> LocationsResourceWithStreamingResponse:
4142 """
4243 return LocationsResourceWithStreamingResponse (self )
4344
44- @typing_extensions .deprecated ("deprecated" )
4545 def list (
4646 self ,
4747 * ,
48+ limit : int | NotGiven = NOT_GIVEN ,
49+ offset : int | NotGiven = NOT_GIVEN ,
4850 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
4951 # The extra values given here take precedence over values defined on the client or passed to this method.
5052 extra_headers : Headers | None = None ,
5153 extra_query : Query | None = None ,
5254 extra_body : Body | None = None ,
5355 timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
54- ) -> LocationListResponse :
56+ ) -> SyncOffsetPage [ Location ] :
5557 """Returns available storage locations where you can create storages.
5658
5759 Each location
5860 represents a geographic region with specific data center facilities.
61+
62+ Args:
63+ extra_headers: Send extra headers
64+
65+ extra_query: Add additional query parameters to the request
66+
67+ extra_body: Add additional JSON properties to the request
68+
69+ timeout: Override the client-level default timeout for this request, in seconds
5970 """
60- return self ._get (
61- "/storage/provisioning/v1/location "
71+ return self ._get_api_list (
72+ "/storage/provisioning/v2/locations "
6273 if self ._client ._base_url_overridden
63- else "https://api.gcore.com//storage/provisioning/v1/location" ,
74+ else "https://api.gcore.com//storage/provisioning/v2/locations" ,
75+ page = SyncOffsetPage [Location ],
6476 options = make_request_options (
65- extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
77+ extra_headers = extra_headers ,
78+ extra_query = extra_query ,
79+ extra_body = extra_body ,
80+ timeout = timeout ,
81+ query = maybe_transform (
82+ {
83+ "limit" : limit ,
84+ "offset" : offset ,
85+ },
86+ location_list_params .LocationListParams ,
87+ ),
6688 ),
67- cast_to = LocationListResponse ,
89+ model = Location ,
6890 )
6991
7092
@@ -88,72 +110,85 @@ def with_streaming_response(self) -> AsyncLocationsResourceWithStreamingResponse
88110 """
89111 return AsyncLocationsResourceWithStreamingResponse (self )
90112
91- @typing_extensions .deprecated ("deprecated" )
92- async def list (
113+ def list (
93114 self ,
94115 * ,
116+ limit : int | NotGiven = NOT_GIVEN ,
117+ offset : int | NotGiven = NOT_GIVEN ,
95118 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
96119 # The extra values given here take precedence over values defined on the client or passed to this method.
97120 extra_headers : Headers | None = None ,
98121 extra_query : Query | None = None ,
99122 extra_body : Body | None = None ,
100123 timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
101- ) -> LocationListResponse :
124+ ) -> AsyncPaginator [ Location , AsyncOffsetPage [ Location ]] :
102125 """Returns available storage locations where you can create storages.
103126
104127 Each location
105128 represents a geographic region with specific data center facilities.
129+
130+ Args:
131+ extra_headers: Send extra headers
132+
133+ extra_query: Add additional query parameters to the request
134+
135+ extra_body: Add additional JSON properties to the request
136+
137+ timeout: Override the client-level default timeout for this request, in seconds
106138 """
107- return await self ._get (
108- "/storage/provisioning/v1/location "
139+ return self ._get_api_list (
140+ "/storage/provisioning/v2/locations "
109141 if self ._client ._base_url_overridden
110- else "https://api.gcore.com//storage/provisioning/v1/location" ,
142+ else "https://api.gcore.com//storage/provisioning/v2/locations" ,
143+ page = AsyncOffsetPage [Location ],
111144 options = make_request_options (
112- extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
145+ extra_headers = extra_headers ,
146+ extra_query = extra_query ,
147+ extra_body = extra_body ,
148+ timeout = timeout ,
149+ query = maybe_transform (
150+ {
151+ "limit" : limit ,
152+ "offset" : offset ,
153+ },
154+ location_list_params .LocationListParams ,
155+ ),
113156 ),
114- cast_to = LocationListResponse ,
157+ model = Location ,
115158 )
116159
117160
118161class LocationsResourceWithRawResponse :
119162 def __init__ (self , locations : LocationsResource ) -> None :
120163 self ._locations = locations
121164
122- self .list = ( # pyright: ignore[reportDeprecated]
123- to_raw_response_wrapper (
124- locations .list , # pyright: ignore[reportDeprecated],
125- )
165+ self .list = to_raw_response_wrapper (
166+ locations .list ,
126167 )
127168
128169
129170class AsyncLocationsResourceWithRawResponse :
130171 def __init__ (self , locations : AsyncLocationsResource ) -> None :
131172 self ._locations = locations
132173
133- self .list = ( # pyright: ignore[reportDeprecated]
134- async_to_raw_response_wrapper (
135- locations .list , # pyright: ignore[reportDeprecated],
136- )
174+ self .list = async_to_raw_response_wrapper (
175+ locations .list ,
137176 )
138177
139178
140179class LocationsResourceWithStreamingResponse :
141180 def __init__ (self , locations : LocationsResource ) -> None :
142181 self ._locations = locations
143182
144- self .list = ( # pyright: ignore[reportDeprecated]
145- to_streamed_response_wrapper (
146- locations .list , # pyright: ignore[reportDeprecated],
147- )
183+ self .list = to_streamed_response_wrapper (
184+ locations .list ,
148185 )
149186
150187
151188class AsyncLocationsResourceWithStreamingResponse :
152189 def __init__ (self , locations : AsyncLocationsResource ) -> None :
153190 self ._locations = locations
154191
155- self .list = ( # pyright: ignore[reportDeprecated]
156- async_to_streamed_response_wrapper (
157- locations .list , # pyright: ignore[reportDeprecated],
158- )
192+ self .list = async_to_streamed_response_wrapper (
193+ locations .list ,
159194 )
0 commit comments