Esempio n. 1
0
        /// <summary>
        /// Synchronously creates a <see cref="MetricsServiceV2Client"/>, applying defaults for all unspecified settings.
        /// </summary>
        /// <param name="endpoint">Optional <see cref="ServiceEndpoint"/>.</param>
        /// <param name="settings">Optional <see cref="MetricsServiceV2Settings"/>.</param>
        /// <param name="credentials">Optional <see cref="ChannelCredentials"/>.</param>
        /// <returns>The created <see cref="MetricsServiceV2Client"/>.</returns>
        public static MetricsServiceV2Client Create(
            ServiceEndpoint endpoint          = null,
            MetricsServiceV2Settings settings = null,
            ChannelCredentials credentials    = null)
        {
            Channel channel = ClientHelper.CreateChannel(endpoint ?? DefaultEndpoint, credentials);

            MetricsServiceV2.MetricsServiceV2Client grpcClient = new MetricsServiceV2.MetricsServiceV2Client(channel);
            return(new MetricsServiceV2ClientImpl(grpcClient, settings));
        }
Esempio n. 2
0
        // Note: we could have parameterless overloads of Create and CreateAsync,
        // documented to just use the default endpoint, settings and credentials.
        // Pros:
        // - Might be more reassuring on first use
        // - Allows method group conversions
        // Con: overloads!

        /// <summary>
        /// Asynchronously creates a <see cref="MetricsServiceV2Client"/>, applying defaults for all unspecified settings.
        /// </summary>
        /// <param name="endpoint">Optional <see cref="ServiceEndpoint"/>.</param>
        /// <param name="settings">Optional <see cref="MetricsServiceV2Settings"/>.</param>
        /// <param name="credentials">Optional <see cref="ChannelCredentials"/>.</param>
        /// <returns>The task representing the created <see cref="MetricsServiceV2Client"/>.</returns>
        public static async Task <MetricsServiceV2Client> CreateAsync(
            ServiceEndpoint endpoint          = null,
            MetricsServiceV2Settings settings = null,
            ChannelCredentials credentials    = null)
        {
            Channel channel = await ClientHelper.CreateChannelAsync(endpoint ?? DefaultEndpoint, credentials).ConfigureAwait(false);

            MetricsServiceV2.MetricsServiceV2Client grpcClient = new MetricsServiceV2.MetricsServiceV2Client(channel);
            return(new MetricsServiceV2ClientImpl(grpcClient, settings));
        }
        public MetricsServiceV2ClientImpl(MetricsServiceV2.MetricsServiceV2Client grpcClient, MetricsServiceV2Settings settings)
        {
            this.GrpcClient = grpcClient;
            MetricsServiceV2Settings effectiveSettings = settings ?? MetricsServiceV2Settings.GetDefault();

            _clientHelper       = new ClientHelper(effectiveSettings);
            _callListLogMetrics = _clientHelper.BuildApiCall <ListLogMetricsRequest, ListLogMetricsResponse>(
                GrpcClient.ListLogMetricsAsync, GrpcClient.ListLogMetrics, effectiveSettings.ListLogMetricsSettings);
            _callGetLogMetric = _clientHelper.BuildApiCall <GetLogMetricRequest, LogMetric>(
                GrpcClient.GetLogMetricAsync, GrpcClient.GetLogMetric, effectiveSettings.GetLogMetricSettings);
            _callCreateLogMetric = _clientHelper.BuildApiCall <CreateLogMetricRequest, LogMetric>(
                GrpcClient.CreateLogMetricAsync, GrpcClient.CreateLogMetric, effectiveSettings.CreateLogMetricSettings);
            _callUpdateLogMetric = _clientHelper.BuildApiCall <UpdateLogMetricRequest, LogMetric>(
                GrpcClient.UpdateLogMetricAsync, GrpcClient.UpdateLogMetric, effectiveSettings.UpdateLogMetricSettings);
            _callDeleteLogMetric = _clientHelper.BuildApiCall <DeleteLogMetricRequest, Empty>(
                GrpcClient.DeleteLogMetricAsync, GrpcClient.DeleteLogMetric, effectiveSettings.DeleteLogMetricSettings);
        }
 /// <summary>
 /// Creates a <see cref="MetricsServiceV2Client"/> which uses the specified channel for remote operations.
 /// </summary>
 /// <param name="channel">The <see cref="Channel"/> for remote operations. Must not be null.</param>
 /// <param name="settings">Optional <see cref="MetricsServiceV2Settings"/>.</param>
 /// <returns>The created <see cref="MetricsServiceV2Client"/>.</returns>
 public static MetricsServiceV2Client Create(Channel channel, MetricsServiceV2Settings settings = null)
 {
     GaxPreconditions.CheckNotNull(channel, nameof(channel));
     MetricsServiceV2.MetricsServiceV2Client grpcClient = new MetricsServiceV2.MetricsServiceV2Client(channel);
     return(new MetricsServiceV2ClientImpl(grpcClient, settings));
 }
 /// <summary>
 /// Wrap a GRPC MetricsServiceV2 client for more convenient use.
 /// </summary>
 /// <param name="grpcClient">A GRPC client to wrap.</param>
 /// <param name="settings">
 /// An optional <see cref="MetricsServiceV2Settings"/> to configure this wrapper.
 /// If null or not specified, then the default settings are used.
 /// </param>
 /// <returns>A <see cref="MetricsServiceV2Client"/> that wraps the specified GRPC client.</returns>
 public static MetricsServiceV2Client ToClient(
     this MetricsServiceV2.MetricsServiceV2Client grpcClient,
     MetricsServiceV2Settings settings = null
     ) => new MetricsServiceV2ClientImpl(grpcClient, settings);