public virtual Response <bool> CheckIfExists(RestoreDetailsName restoreDetailsName, CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("ManagedDatabaseRestoreDetailsResultCollection.CheckIfExists"); scope.Start(); try { var response = GetIfExists(restoreDetailsName, cancellationToken: cancellationToken); return(Response.FromValue(response.Value != null, response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual Response <bool> Exists(RestoreDetailsName restoreDetailsName, CancellationToken cancellationToken = default) { using var scope = _managedDatabaseRestoreDetailsResultManagedDatabaseRestoreDetailsClientDiagnostics.CreateScope("ManagedDatabaseRestoreDetailsResultCollection.Exists"); scope.Start(); try { var response = _managedDatabaseRestoreDetailsResultManagedDatabaseRestoreDetailsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, restoreDetailsName, cancellationToken: cancellationToken); return(Response.FromValue(response.Value != null, response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public async virtual Task <Response <bool> > ExistsAsync(RestoreDetailsName restoreDetailsName, CancellationToken cancellationToken = default) { using var scope = _managedDatabaseRestoreDetailsResultManagedDatabaseRestoreDetailsClientDiagnostics.CreateScope("ManagedDatabaseRestoreDetailsResultCollection.Exists"); scope.Start(); try { var response = await GetIfExistsAsync(restoreDetailsName, cancellationToken : cancellationToken).ConfigureAwait(false); return(Response.FromValue(response.Value != null, response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual Response <ManagedDatabaseRestoreDetailsResult> Get(RestoreDetailsName restoreDetailsName, CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("ManagedDatabaseRestoreDetailsResultCollection.Get"); scope.Start(); try { var response = _managedDatabaseRestoreDetailsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, restoreDetailsName, cancellationToken); if (response.Value == null) { throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse()); } return(Response.FromValue(new ManagedDatabaseRestoreDetailsResult(Parent, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public async Task <Response <ManagedDatabaseRestoreDetailsResultData> > GetAsync(string subscriptionId, string resourceGroupName, string managedInstanceName, string databaseName, RestoreDetailsName restoreDetailsName, CancellationToken cancellationToken = default) { if (subscriptionId == null) { throw new ArgumentNullException(nameof(subscriptionId)); } if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (managedInstanceName == null) { throw new ArgumentNullException(nameof(managedInstanceName)); } if (databaseName == null) { throw new ArgumentNullException(nameof(databaseName)); } using var message = CreateGetRequest(subscriptionId, resourceGroupName, managedInstanceName, databaseName, restoreDetailsName); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { ManagedDatabaseRestoreDetailsResultData value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); value = ManagedDatabaseRestoreDetailsResultData.DeserializeManagedDatabaseRestoreDetailsResultData(document.RootElement); return(Response.FromValue(value, message.Response)); }
internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string managedInstanceName, string databaseName, RestoreDetailsName restoreDetailsName) { var message = _pipeline.CreateMessage(); var request = message.Request; request.Method = RequestMethod.Get; var uri = new RawRequestUriBuilder(); uri.Reset(endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); uri.AppendPath("/resourceGroups/", false); uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.Sql/managedInstances/", false); uri.AppendPath(managedInstanceName, true); uri.AppendPath("/databases/", false); uri.AppendPath(databaseName, true); uri.AppendPath("/restoreDetails/", false); uri.AppendPath(restoreDetailsName.ToString(), true); uri.AppendQuery("api-version", "2020-11-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); message.SetProperty("UserAgentOverride", _userAgent); return(message); }
public async virtual Task <Response <ManagedDatabaseRestoreDetailsResult> > GetIfExistsAsync(RestoreDetailsName restoreDetailsName, CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("ManagedDatabaseRestoreDetailsResultCollection.GetIfExistsAsync"); scope.Start(); try { var response = await _managedDatabaseRestoreDetailsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, restoreDetailsName, cancellationToken : cancellationToken).ConfigureAwait(false); return(response.Value == null ? Response.FromValue <ManagedDatabaseRestoreDetailsResult>(null, response.GetRawResponse()) : Response.FromValue(new ManagedDatabaseRestoreDetailsResult(this, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual Response <ManagedDatabaseRestoreDetailsResult> Get(string resourceGroupName, string managedInstanceName, string databaseName, RestoreDetailsName restoreDetailsName, CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("ManagedDatabaseRestoreDetailsOperations.Get"); scope.Start(); try { return(RestClient.Get(resourceGroupName, managedInstanceName, databaseName, restoreDetailsName, cancellationToken)); } catch (Exception e) { scope.Failed(e); throw; } }
public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string managedInstanceName, string databaseName, RestoreDetailsName restoreDetailsName) { var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/restoreDetails/{restoreDetailsName}"; return(new ResourceIdentifier(resourceId)); }