12
12
from azure .core .exceptions import ClientAuthenticationError , HttpResponseError , ResourceExistsError , ResourceNotFoundError , map_error
13
13
from azure .core .pipeline import PipelineResponse
14
14
from azure .core .pipeline .transport import AsyncHttpResponse , HttpRequest
15
+ from azure .core .polling import AsyncLROPoller , AsyncNoPolling , AsyncPollingMethod
15
16
from azure .mgmt .core .exceptions import ARMErrorFormat
17
+ from azure .mgmt .core .polling .async_arm_polling import AsyncARMPolling
16
18
17
19
from ... import models as _models
18
20
@@ -108,7 +110,7 @@ async def get(
108
110
return deserialized
109
111
get .metadata = {'url' : '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}' } # type: ignore
110
112
111
- async def create_or_update (
113
+ async def _create_or_update_initial (
112
114
self ,
113
115
resource_group_name : str ,
114
116
server_name : str ,
@@ -117,25 +119,6 @@ async def create_or_update(
117
119
parameters : "_models.LedgerDigestUploads" ,
118
120
** kwargs : Any
119
121
) -> Optional ["_models.LedgerDigestUploads" ]:
120
- """Enables upload ledger digests to an Azure Storage account or an Azure Confidential Ledger
121
- instance.
122
-
123
- :param resource_group_name: The name of the resource group that contains the resource. You can
124
- obtain this value from the Azure Resource Manager API or the portal.
125
- :type resource_group_name: str
126
- :param server_name: The name of the server.
127
- :type server_name: str
128
- :param database_name: The name of the database.
129
- :type database_name: str
130
- :param ledger_digest_uploads:
131
- :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.LedgerDigestUploadsName
132
- :param parameters:
133
- :type parameters: ~azure.mgmt.sql.models.LedgerDigestUploads
134
- :keyword callable cls: A custom type or function that will be passed the direct response
135
- :return: LedgerDigestUploads, or the result of cls(response)
136
- :rtype: ~azure.mgmt.sql.models.LedgerDigestUploads or None
137
- :raises: ~azure.core.exceptions.HttpResponseError
138
- """
139
122
cls = kwargs .pop ('cls' , None ) # type: ClsType[Optional["_models.LedgerDigestUploads"]]
140
123
error_map = {
141
124
401 : ClientAuthenticationError , 404 : ResourceNotFoundError , 409 : ResourceExistsError
@@ -146,7 +129,7 @@ async def create_or_update(
146
129
accept = "application/json"
147
130
148
131
# Construct URL
149
- url = self .create_or_update .metadata ['url' ] # type: ignore
132
+ url = self ._create_or_update_initial .metadata ['url' ] # type: ignore
150
133
path_format_arguments = {
151
134
'resourceGroupName' : self ._serialize .url ("resource_group_name" , resource_group_name , 'str' ),
152
135
'serverName' : self ._serialize .url ("server_name" , server_name , 'str' ),
@@ -184,7 +167,90 @@ async def create_or_update(
184
167
return cls (pipeline_response , deserialized , {})
185
168
186
169
return deserialized
187
- create_or_update .metadata = {'url' : '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}' } # type: ignore
170
+ _create_or_update_initial .metadata = {'url' : '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}' } # type: ignore
171
+
172
+ async def begin_create_or_update (
173
+ self ,
174
+ resource_group_name : str ,
175
+ server_name : str ,
176
+ database_name : str ,
177
+ ledger_digest_uploads : Union [str , "_models.LedgerDigestUploadsName" ],
178
+ parameters : "_models.LedgerDigestUploads" ,
179
+ ** kwargs : Any
180
+ ) -> AsyncLROPoller ["_models.LedgerDigestUploads" ]:
181
+ """Enables upload ledger digests to an Azure Storage account or an Azure Confidential Ledger
182
+ instance.
183
+
184
+ :param resource_group_name: The name of the resource group that contains the resource. You can
185
+ obtain this value from the Azure Resource Manager API or the portal.
186
+ :type resource_group_name: str
187
+ :param server_name: The name of the server.
188
+ :type server_name: str
189
+ :param database_name: The name of the database.
190
+ :type database_name: str
191
+ :param ledger_digest_uploads:
192
+ :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.LedgerDigestUploadsName
193
+ :param parameters:
194
+ :type parameters: ~azure.mgmt.sql.models.LedgerDigestUploads
195
+ :keyword callable cls: A custom type or function that will be passed the direct response
196
+ :keyword str continuation_token: A continuation token to restart a poller from a saved state.
197
+ :keyword polling: By default, your polling method will be AsyncARMPolling.
198
+ Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.
199
+ :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
200
+ :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
201
+ :return: An instance of AsyncLROPoller that returns either LedgerDigestUploads or the result of cls(response)
202
+ :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LedgerDigestUploads]
203
+ :raises ~azure.core.exceptions.HttpResponseError:
204
+ """
205
+ polling = kwargs .pop ('polling' , True ) # type: Union[bool, AsyncPollingMethod]
206
+ cls = kwargs .pop ('cls' , None ) # type: ClsType["_models.LedgerDigestUploads"]
207
+ lro_delay = kwargs .pop (
208
+ 'polling_interval' ,
209
+ self ._config .polling_interval
210
+ )
211
+ cont_token = kwargs .pop ('continuation_token' , None ) # type: Optional[str]
212
+ if cont_token is None :
213
+ raw_result = await self ._create_or_update_initial (
214
+ resource_group_name = resource_group_name ,
215
+ server_name = server_name ,
216
+ database_name = database_name ,
217
+ ledger_digest_uploads = ledger_digest_uploads ,
218
+ parameters = parameters ,
219
+ cls = lambda x ,y ,z : x ,
220
+ ** kwargs
221
+ )
222
+
223
+ kwargs .pop ('error_map' , None )
224
+ kwargs .pop ('content_type' , None )
225
+
226
+ def get_long_running_output (pipeline_response ):
227
+ deserialized = self ._deserialize ('LedgerDigestUploads' , pipeline_response )
228
+
229
+ if cls :
230
+ return cls (pipeline_response , deserialized , {})
231
+ return deserialized
232
+
233
+ path_format_arguments = {
234
+ 'resourceGroupName' : self ._serialize .url ("resource_group_name" , resource_group_name , 'str' ),
235
+ 'serverName' : self ._serialize .url ("server_name" , server_name , 'str' ),
236
+ 'databaseName' : self ._serialize .url ("database_name" , database_name , 'str' ),
237
+ 'ledgerDigestUploads' : self ._serialize .url ("ledger_digest_uploads" , ledger_digest_uploads , 'str' ),
238
+ 'subscriptionId' : self ._serialize .url ("self._config.subscription_id" , self ._config .subscription_id , 'str' ),
239
+ }
240
+
241
+ if polling is True : polling_method = AsyncARMPolling (lro_delay , path_format_arguments = path_format_arguments , ** kwargs )
242
+ elif polling is False : polling_method = AsyncNoPolling ()
243
+ else : polling_method = polling
244
+ if cont_token :
245
+ return AsyncLROPoller .from_continuation_token (
246
+ polling_method = polling_method ,
247
+ continuation_token = cont_token ,
248
+ client = self ._client ,
249
+ deserialization_callback = get_long_running_output
250
+ )
251
+ else :
252
+ return AsyncLROPoller (self ._client , raw_result , get_long_running_output , polling_method )
253
+ begin_create_or_update .metadata = {'url' : '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}' } # type: ignore
188
254
189
255
def list_by_database (
190
256
self ,
@@ -265,31 +331,14 @@ async def get_next(next_link=None):
265
331
)
266
332
list_by_database .metadata = {'url' : '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads' } # type: ignore
267
333
268
- async def disable (
334
+ async def _disable_initial (
269
335
self ,
270
336
resource_group_name : str ,
271
337
server_name : str ,
272
338
database_name : str ,
273
339
ledger_digest_uploads : Union [str , "_models.LedgerDigestUploadsName" ],
274
340
** kwargs : Any
275
341
) -> Optional ["_models.LedgerDigestUploads" ]:
276
- """Disables uploading ledger digests to an Azure Storage account or an Azure Confidential Ledger
277
- instance.
278
-
279
- :param resource_group_name: The name of the resource group that contains the resource. You can
280
- obtain this value from the Azure Resource Manager API or the portal.
281
- :type resource_group_name: str
282
- :param server_name: The name of the server.
283
- :type server_name: str
284
- :param database_name: The name of the database.
285
- :type database_name: str
286
- :param ledger_digest_uploads:
287
- :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.LedgerDigestUploadsName
288
- :keyword callable cls: A custom type or function that will be passed the direct response
289
- :return: LedgerDigestUploads, or the result of cls(response)
290
- :rtype: ~azure.mgmt.sql.models.LedgerDigestUploads or None
291
- :raises: ~azure.core.exceptions.HttpResponseError
292
- """
293
342
cls = kwargs .pop ('cls' , None ) # type: ClsType[Optional["_models.LedgerDigestUploads"]]
294
343
error_map = {
295
344
401 : ClientAuthenticationError , 404 : ResourceNotFoundError , 409 : ResourceExistsError
@@ -299,7 +348,7 @@ async def disable(
299
348
accept = "application/json"
300
349
301
350
# Construct URL
302
- url = self .disable .metadata ['url' ] # type: ignore
351
+ url = self ._disable_initial .metadata ['url' ] # type: ignore
303
352
path_format_arguments = {
304
353
'resourceGroupName' : self ._serialize .url ("resource_group_name" , resource_group_name , 'str' ),
305
354
'serverName' : self ._serialize .url ("server_name" , server_name , 'str' ),
@@ -333,4 +382,83 @@ async def disable(
333
382
return cls (pipeline_response , deserialized , {})
334
383
335
384
return deserialized
336
- disable .metadata = {'url' : '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}/disable' } # type: ignore
385
+ _disable_initial .metadata = {'url' : '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}/disable' } # type: ignore
386
+
387
+ async def begin_disable (
388
+ self ,
389
+ resource_group_name : str ,
390
+ server_name : str ,
391
+ database_name : str ,
392
+ ledger_digest_uploads : Union [str , "_models.LedgerDigestUploadsName" ],
393
+ ** kwargs : Any
394
+ ) -> AsyncLROPoller ["_models.LedgerDigestUploads" ]:
395
+ """Disables uploading ledger digests to an Azure Storage account or an Azure Confidential Ledger
396
+ instance.
397
+
398
+ :param resource_group_name: The name of the resource group that contains the resource. You can
399
+ obtain this value from the Azure Resource Manager API or the portal.
400
+ :type resource_group_name: str
401
+ :param server_name: The name of the server.
402
+ :type server_name: str
403
+ :param database_name: The name of the database.
404
+ :type database_name: str
405
+ :param ledger_digest_uploads:
406
+ :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.LedgerDigestUploadsName
407
+ :keyword callable cls: A custom type or function that will be passed the direct response
408
+ :keyword str continuation_token: A continuation token to restart a poller from a saved state.
409
+ :keyword polling: By default, your polling method will be AsyncARMPolling.
410
+ Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.
411
+ :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
412
+ :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
413
+ :return: An instance of AsyncLROPoller that returns either LedgerDigestUploads or the result of cls(response)
414
+ :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LedgerDigestUploads]
415
+ :raises ~azure.core.exceptions.HttpResponseError:
416
+ """
417
+ polling = kwargs .pop ('polling' , True ) # type: Union[bool, AsyncPollingMethod]
418
+ cls = kwargs .pop ('cls' , None ) # type: ClsType["_models.LedgerDigestUploads"]
419
+ lro_delay = kwargs .pop (
420
+ 'polling_interval' ,
421
+ self ._config .polling_interval
422
+ )
423
+ cont_token = kwargs .pop ('continuation_token' , None ) # type: Optional[str]
424
+ if cont_token is None :
425
+ raw_result = await self ._disable_initial (
426
+ resource_group_name = resource_group_name ,
427
+ server_name = server_name ,
428
+ database_name = database_name ,
429
+ ledger_digest_uploads = ledger_digest_uploads ,
430
+ cls = lambda x ,y ,z : x ,
431
+ ** kwargs
432
+ )
433
+
434
+ kwargs .pop ('error_map' , None )
435
+ kwargs .pop ('content_type' , None )
436
+
437
+ def get_long_running_output (pipeline_response ):
438
+ deserialized = self ._deserialize ('LedgerDigestUploads' , pipeline_response )
439
+
440
+ if cls :
441
+ return cls (pipeline_response , deserialized , {})
442
+ return deserialized
443
+
444
+ path_format_arguments = {
445
+ 'resourceGroupName' : self ._serialize .url ("resource_group_name" , resource_group_name , 'str' ),
446
+ 'serverName' : self ._serialize .url ("server_name" , server_name , 'str' ),
447
+ 'databaseName' : self ._serialize .url ("database_name" , database_name , 'str' ),
448
+ 'ledgerDigestUploads' : self ._serialize .url ("ledger_digest_uploads" , ledger_digest_uploads , 'str' ),
449
+ 'subscriptionId' : self ._serialize .url ("self._config.subscription_id" , self ._config .subscription_id , 'str' ),
450
+ }
451
+
452
+ if polling is True : polling_method = AsyncARMPolling (lro_delay , path_format_arguments = path_format_arguments , ** kwargs )
453
+ elif polling is False : polling_method = AsyncNoPolling ()
454
+ else : polling_method = polling
455
+ if cont_token :
456
+ return AsyncLROPoller .from_continuation_token (
457
+ polling_method = polling_method ,
458
+ continuation_token = cont_token ,
459
+ client = self ._client ,
460
+ deserialization_callback = get_long_running_output
461
+ )
462
+ else :
463
+ return AsyncLROPoller (self ._client , raw_result , get_long_running_output , polling_method )
464
+ begin_disable .metadata = {'url' : '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}/disable' } # type: ignore
0 commit comments