public async stt::Task GetBackupResourceNamesAsync() { moq::Mock <DataprocMetastore.DataprocMetastoreClient> mockGrpcClient = new moq::Mock <DataprocMetastore.DataprocMetastoreClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetBackupRequest request = new GetBackupRequest { BackupName = BackupName.FromProjectLocationServiceBackup("[PROJECT]", "[LOCATION]", "[SERVICE]", "[BACKUP]"), }; Backup expectedResponse = new Backup { BackupName = BackupName.FromProjectLocationServiceBackup("[PROJECT]", "[LOCATION]", "[SERVICE]", "[BACKUP]"), CreateTime = new wkt::Timestamp(), EndTime = new wkt::Timestamp(), State = Backup.Types.State.Unspecified, ServiceRevision = new Service(), Description = "description2cf9da67", RestoringServices = { "restoring_servicese2c88107", }, }; mockGrpcClient.Setup(x => x.GetBackupAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Backup>(stt::Task.FromResult(expectedResponse), null, null, null, null)); DataprocMetastoreClient client = new DataprocMetastoreClientImpl(mockGrpcClient.Object, null); Backup responseCallSettings = await client.GetBackupAsync(request.BackupName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Backup responseCancellationToken = await client.GetBackupAsync(request.BackupName, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
/// <summary> /// Get information about the specified Backup /// </summary> /// <param name="request">The request object containing the details to send. Required.</param> /// <param name="retryConfiguration">The retry configuration that will be used by to send this request. Optional.</param> /// <param name="cancellationToken">The cancellation token to cancel this operation. Optional.</param> /// <returns>A response object containing details about the completed operation</returns> /// <example>Click <a href="https://docs.cloud.oracle.com/en-us/iaas/tools/dot-net-examples/latest/mysql/GetBackup.cs.html">here</a> to see an example of how to use GetBackup API.</example> public async Task <GetBackupResponse> GetBackup(GetBackupRequest request, RetryConfiguration retryConfiguration = null, CancellationToken cancellationToken = default) { logger.Trace("Called getBackup"); Uri uri = new Uri(this.restClient.GetEndpoint(), System.IO.Path.Combine(basePathWithoutHost, "/backups/{backupId}".Trim('/'))); HttpMethod method = new HttpMethod("GET"); HttpRequestMessage requestMessage = Converter.ToHttpRequestMessage(uri, method, request); requestMessage.Headers.Add("Accept", "application/json"); GenericRetrier retryingClient = Retrier.GetPreferredRetrier(retryConfiguration, this.retryConfiguration); HttpResponseMessage responseMessage; try { if (retryingClient != null) { responseMessage = await retryingClient.MakeRetryingCall(this.restClient.HttpSend, requestMessage, cancellationToken).ConfigureAwait(false); } else { responseMessage = await this.restClient.HttpSend(requestMessage).ConfigureAwait(false); } this.restClient.CheckHttpResponseMessage(requestMessage, responseMessage); return(Converter.FromHttpResponseMessage <GetBackupResponse>(responseMessage)); } catch (Exception e) { logger.Error($"GetBackup failed with error: {e.Message}"); throw; } }
public void GetBackupResourceNames() { moq::Mock <DataprocMetastore.DataprocMetastoreClient> mockGrpcClient = new moq::Mock <DataprocMetastore.DataprocMetastoreClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetBackupRequest request = new GetBackupRequest { BackupName = BackupName.FromProjectLocationServiceBackup("[PROJECT]", "[LOCATION]", "[SERVICE]", "[BACKUP]"), }; Backup expectedResponse = new Backup { BackupName = BackupName.FromProjectLocationServiceBackup("[PROJECT]", "[LOCATION]", "[SERVICE]", "[BACKUP]"), CreateTime = new wkt::Timestamp(), EndTime = new wkt::Timestamp(), State = Backup.Types.State.Unspecified, ServiceRevision = new Service(), Description = "description2cf9da67", RestoringServices = { "restoring_servicese2c88107", }, }; mockGrpcClient.Setup(x => x.GetBackup(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); DataprocMetastoreClient client = new DataprocMetastoreClientImpl(mockGrpcClient.Object, null); Backup response = client.GetBackup(request.BackupName); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <summary> /// Creates a waiter using the provided configuration. /// </summary> /// <param name="request">Request to send.</param> /// <param name="config">Wait Configuration</param> /// <param name="targetStates">Desired resource states. If multiple states are provided then the waiter will return once the resource reaches any of the provided states</param> /// <returns>a new Oci.common.Waiter instance</returns> public Waiter <GetBackupRequest, GetBackupResponse> ForBackup(GetBackupRequest request, WaiterConfiguration config, params Backup.LifecycleStateEnum[] targetStates) { var agent = new WaiterAgent <GetBackupRequest, GetBackupResponse>( request, request => client.GetBackup(request), response => targetStates.Contains(response.Backup.LifecycleState.Value), targetStates.Contains(Backup.LifecycleStateEnum.Deleted) ); return(new Waiter <GetBackupRequest, GetBackupResponse>(config, agent)); }
/// <summary>Snippet for GetBackup</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void GetBackupRequestObject() { // Create client BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create(); // Initialize request argument(s) GetBackupRequest request = new GetBackupRequest { BackupName = BackupName.FromProjectInstanceClusterBackup("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[BACKUP]"), }; // Make the request Backup response = bigtableTableAdminClient.GetBackup(request); }
private void HandleOutput(GetBackupRequest request) { var waiterConfig = new WaiterConfiguration { MaxAttempts = MaxWaitAttempts, GetNextDelayInSeconds = (_) => WaitIntervalSeconds }; switch (ParameterSetName) { case LifecycleStateParamSet: response = client.Waiters.ForBackup(request, waiterConfig, WaitForLifecycleState).Execute(); break; case Default: response = client.GetBackup(request).GetAwaiter().GetResult(); break; } WriteOutput(response, response.Backup); }
protected override void ProcessRecord() { base.ProcessRecord(); GetBackupRequest request; try { request = new GetBackupRequest { BackupId = BackupId }; HandleOutput(request); FinishProcessing(response); } catch (Exception ex) { TerminatingErrorDuringExecution(ex); } }
public async stt::Task GetBackupResourceNamesAsync() { moq::Mock <CloudFilestoreManager.CloudFilestoreManagerClient> mockGrpcClient = new moq::Mock <CloudFilestoreManager.CloudFilestoreManagerClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetBackupRequest request = new GetBackupRequest { BackupName = BackupName.FromProjectLocationBackup("[PROJECT]", "[LOCATION]", "[BACKUP]"), }; Backup expectedResponse = new Backup { BackupName = BackupName.FromProjectLocationBackup("[PROJECT]", "[LOCATION]", "[BACKUP]"), Description = "description2cf9da67", State = Backup.Types.State.Ready, CreateTime = new wkt::Timestamp(), Labels = { { "key8a0b6e3c", "value60c16320" }, }, CapacityGb = -8715396619027832166L, StorageBytes = 8453704516828373557L, SourceInstanceAsInstanceName = InstanceName.FromProjectLocationInstance("[PROJECT]", "[LOCATION]", "[INSTANCE]"), SourceFileShare = "source_file_shareeecce468", SourceInstanceTier = Instance.Types.Tier.Premium, DownloadBytes = -6512123273633363558L, SatisfiesPzs = false, }; mockGrpcClient.Setup(x => x.GetBackupAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Backup>(stt::Task.FromResult(expectedResponse), null, null, null, null)); CloudFilestoreManagerClient client = new CloudFilestoreManagerClientImpl(mockGrpcClient.Object, null); Backup responseCallSettings = await client.GetBackupAsync(request.BackupName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Backup responseCancellationToken = await client.GetBackupAsync(request.BackupName, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
partial void Modify_GetBackupRequest(ref GetBackupRequest request, ref CallSettings settings) => ApplyResourcePrefixHeaderFromBackup(ref settings, request.Name);
/// <summary> /// Creates a waiter using default wait configuration. /// </summary> /// <param name="request">Request to send.</param> /// <param name="targetStates">Desired resource states. If multiple states are provided then the waiter will return once the resource reaches any of the provided states</param> /// <returns>a new Oci.common.Waiter instance</returns> public Waiter <GetBackupRequest, GetBackupResponse> ForBackup(GetBackupRequest request, params Backup.LifecycleStateEnum[] targetStates) { return(this.ForBackup(request, WaiterConfiguration.DefaultWaiterConfiguration, targetStates)); }