Пример #1
0
        public void UpdateLogMetricResourceNames()
        {
            moq::Mock <MetricsServiceV2.MetricsServiceV2Client> mockGrpcClient = new moq::Mock <MetricsServiceV2.MetricsServiceV2Client>(moq::MockBehavior.Strict);
            UpdateLogMetricRequest request = new UpdateLogMetricRequest
            {
                MetricNameAsMetricName = MetricName.FromProjectMetric("[PROJECT]", "[METRIC]"),
                Metric = new LogMetric(),
            };
            LogMetric expectedResponse = new LogMetric
            {
                MetricName       = MetricName.FromProjectMetric("[PROJECT]", "[METRIC]"),
                Description      = "description2cf9da67",
                Filter           = "filtere47ac9b2",
                MetricDescriptor = new ga::MetricDescriptor(),
                ValueExtractor   = "value_extractor09b994a6",
                LabelExtractors  =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                BucketOptions = new ga::Distribution.Types.BucketOptions(),
                CreateTime    = new wkt::Timestamp(),
                UpdateTime    = new wkt::Timestamp(),
            };

            mockGrpcClient.Setup(x => x.UpdateLogMetric(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            MetricsServiceV2Client client = new MetricsServiceV2ClientImpl(mockGrpcClient.Object, null);
            LogMetric response            = client.UpdateLogMetric(request.MetricNameAsMetricName, request.Metric);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Пример #2
0
 /// <summary>Snippet for GetLogMetric</summary>
 public void GetLogMetricResourceNames()
 {
     // Snippet: GetLogMetric(MetricName, CallSettings)
     // Create client
     MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.Create();
     // Initialize request argument(s)
     MetricName metricName = MetricName.FromProjectMetric("[PROJECT]", "[METRIC]");
     // Make the request
     LogMetric response = metricsServiceV2Client.GetLogMetric(metricName);
     // End snippet
 }
Пример #3
0
 /// <summary>Snippet for CreateLogMetric</summary>
 public void CreateLogMetricResourceNames()
 {
     // Snippet: CreateLogMetric(MetricName, LogMetric, CallSettings)
     // Create client
     MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.Create();
     // Initialize request argument(s)
     MetricName parent = MetricName.FromProjectMetric("[PROJECT]", "[METRIC]");
     LogMetric  metric = new LogMetric();
     // Make the request
     LogMetric response = metricsServiceV2Client.CreateLogMetric(parent, metric);
     // End snippet
 }
Пример #4
0
        /// <summary>Snippet for DeleteLogMetricAsync</summary>
        public async Task DeleteLogMetricResourceNamesAsync()
        {
            // Snippet: DeleteLogMetricAsync(MetricName, CallSettings)
            // Additional: DeleteLogMetricAsync(MetricName, CancellationToken)
            // Create client
            MetricsServiceV2Client metricsServiceV2Client = await MetricsServiceV2Client.CreateAsync();

            // Initialize request argument(s)
            MetricName metricName = MetricName.FromProjectMetric("[PROJECT]", "[METRIC]");
            // Make the request
            await metricsServiceV2Client.DeleteLogMetricAsync(metricName);

            // End snippet
        }
Пример #5
0
 /// <summary>Snippet for GetLogMetric</summary>
 public void GetLogMetricRequestObject()
 {
     // Snippet: GetLogMetric(GetLogMetricRequest, CallSettings)
     // Create client
     MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.Create();
     // Initialize request argument(s)
     GetLogMetricRequest request = new GetLogMetricRequest
     {
         MetricNameAsMetricName = MetricName.FromProjectMetric("[PROJECT]", "[METRIC]"),
     };
     // Make the request
     LogMetric response = metricsServiceV2Client.GetLogMetric(request);
     // End snippet
 }
Пример #6
0
        /// <summary>Snippet for CreateLogMetricAsync</summary>
        public async Task CreateLogMetricResourceNamesAsync()
        {
            // Snippet: CreateLogMetricAsync(MetricName, LogMetric, CallSettings)
            // Additional: CreateLogMetricAsync(MetricName, LogMetric, CancellationToken)
            // Create client
            MetricsServiceV2Client metricsServiceV2Client = await MetricsServiceV2Client.CreateAsync();

            // Initialize request argument(s)
            MetricName parent = MetricName.FromProjectMetric("[PROJECT]", "[METRIC]");
            LogMetric  metric = new LogMetric();
            // Make the request
            LogMetric response = await metricsServiceV2Client.CreateLogMetricAsync(parent, metric);

            // End snippet
        }
Пример #7
0
        public void DeleteLogMetricResourceNames()
        {
            moq::Mock <MetricsServiceV2.MetricsServiceV2Client> mockGrpcClient = new moq::Mock <MetricsServiceV2.MetricsServiceV2Client>(moq::MockBehavior.Strict);
            DeleteLogMetricRequest request = new DeleteLogMetricRequest
            {
                MetricNameAsMetricName = MetricName.FromProjectMetric("[PROJECT]", "[METRIC]"),
            };
            wkt::Empty expectedResponse = new wkt::Empty {
            };

            mockGrpcClient.Setup(x => x.DeleteLogMetric(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            MetricsServiceV2Client client = new MetricsServiceV2ClientImpl(mockGrpcClient.Object, null);

            client.DeleteLogMetric(request.MetricNameAsMetricName);
            mockGrpcClient.VerifyAll();
        }
Пример #8
0
        /// <summary>Snippet for DeleteLogMetricAsync</summary>
        public async Task DeleteLogMetricRequestObjectAsync()
        {
            // Snippet: DeleteLogMetricAsync(DeleteLogMetricRequest, CallSettings)
            // Additional: DeleteLogMetricAsync(DeleteLogMetricRequest, CancellationToken)
            // Create client
            MetricsServiceV2Client metricsServiceV2Client = await MetricsServiceV2Client.CreateAsync();

            // Initialize request argument(s)
            DeleteLogMetricRequest request = new DeleteLogMetricRequest
            {
                MetricNameAsMetricName = MetricName.FromProjectMetric("[PROJECT]", "[METRIC]"),
            };
            // Make the request
            await metricsServiceV2Client.DeleteLogMetricAsync(request);

            // End snippet
        }
Пример #9
0
        public async stt::Task DeleteLogMetricResourceNamesAsync()
        {
            moq::Mock <MetricsServiceV2.MetricsServiceV2Client> mockGrpcClient = new moq::Mock <MetricsServiceV2.MetricsServiceV2Client>(moq::MockBehavior.Strict);
            DeleteLogMetricRequest request = new DeleteLogMetricRequest
            {
                MetricNameAsMetricName = MetricName.FromProjectMetric("[PROJECT]", "[METRIC]"),
            };
            wkt::Empty expectedResponse = new wkt::Empty {
            };

            mockGrpcClient.Setup(x => x.DeleteLogMetricAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <wkt::Empty>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            MetricsServiceV2Client client = new MetricsServiceV2ClientImpl(mockGrpcClient.Object, null);
            await client.DeleteLogMetricAsync(request.MetricNameAsMetricName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            await client.DeleteLogMetricAsync(request.MetricNameAsMetricName, st::CancellationToken.None);

            mockGrpcClient.VerifyAll();
        }
Пример #10
0
        public async stt::Task UpdateLogMetricResourceNamesAsync()
        {
            moq::Mock <MetricsServiceV2.MetricsServiceV2Client> mockGrpcClient = new moq::Mock <MetricsServiceV2.MetricsServiceV2Client>(moq::MockBehavior.Strict);
            UpdateLogMetricRequest request = new UpdateLogMetricRequest
            {
                MetricNameAsMetricName = MetricName.FromProjectMetric("[PROJECT]", "[METRIC]"),
                Metric = new LogMetric(),
            };
            LogMetric expectedResponse = new LogMetric
            {
                MetricName  = MetricName.FromProjectMetric("[PROJECT]", "[METRIC]"),
                Description = "description2cf9da67",
                Filter      = "filtere47ac9b2",
#pragma warning disable CS0612
                Version = LogMetric.Types.ApiVersion.V2,
#pragma warning restore CS0612
                MetricDescriptor = new ga::MetricDescriptor(),
                ValueExtractor   = "value_extractor09b994a6",
                LabelExtractors  =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                BucketOptions = new ga::Distribution.Types.BucketOptions(),
                CreateTime    = new wkt::Timestamp(),
                UpdateTime    = new wkt::Timestamp(),
            };

            mockGrpcClient.Setup(x => x.UpdateLogMetricAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <LogMetric>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            MetricsServiceV2Client client  = new MetricsServiceV2ClientImpl(mockGrpcClient.Object, null);
            LogMetric responseCallSettings = await client.UpdateLogMetricAsync(request.MetricNameAsMetricName, request.Metric, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            LogMetric responseCancellationToken = await client.UpdateLogMetricAsync(request.MetricNameAsMetricName, request.Metric, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }