private MetricsServiceV2Settings(MetricsServiceV2Settings existing) : base(existing)
 {
     GaxPreconditions.CheckNotNull(existing, nameof(existing));
     ListLogMetricsSettings  = existing.ListLogMetricsSettings?.Clone();
     GetLogMetricSettings    = existing.GetLogMetricSettings?.Clone();
     CreateLogMetricSettings = existing.CreateLogMetricSettings?.Clone();
     UpdateLogMetricSettings = existing.UpdateLogMetricSettings?.Clone();
     DeleteLogMetricSettings = existing.DeleteLogMetricSettings?.Clone();
 }
Exemple #2
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));
        }
Exemple #3
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);
        }
Exemple #5
0
        public MetricsServiceV2ClientImpl(MetricsServiceV2.IMetricsServiceV2Client grpcClient, MetricsServiceV2Settings settings)
        {
            this.GrpcClient = grpcClient;
            MetricsServiceV2Settings effectiveSettings = settings ?? MetricsServiceV2Settings.GetDefault();
            IClock effectiveClock = effectiveSettings.Clock ?? SystemClock.Instance;

            _clientHelper       = new ClientHelper(effectiveSettings);
            _callListLogMetrics = _clientHelper.BuildApiCall <ListLogMetricsRequest, ListLogMetricsResponse>(GrpcClient.ListLogMetricsAsync, GrpcClient.ListLogMetrics)
                                  .WithRetry(effectiveSettings.ListLogMetricsRetry, effectiveClock, null);
            _callGetLogMetric = _clientHelper.BuildApiCall <GetLogMetricRequest, LogMetric>(GrpcClient.GetLogMetricAsync, GrpcClient.GetLogMetric)
                                .WithRetry(effectiveSettings.GetLogMetricRetry, effectiveClock, null);
            _callCreateLogMetric = _clientHelper.BuildApiCall <CreateLogMetricRequest, LogMetric>(GrpcClient.CreateLogMetricAsync, GrpcClient.CreateLogMetric)
                                   .WithRetry(effectiveSettings.CreateLogMetricRetry, effectiveClock, null);
            _callUpdateLogMetric = _clientHelper.BuildApiCall <UpdateLogMetricRequest, LogMetric>(GrpcClient.UpdateLogMetricAsync, GrpcClient.UpdateLogMetric)
                                   .WithRetry(effectiveSettings.UpdateLogMetricRetry, effectiveClock, null);
            _callDeleteLogMetric = _clientHelper.BuildApiCall <DeleteLogMetricRequest, Empty>(GrpcClient.DeleteLogMetricAsync, GrpcClient.DeleteLogMetric)
                                   .WithRetry(effectiveSettings.DeleteLogMetricRetry, effectiveClock, null);
        }
 /// <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>
        /// Synchronously creates a <see cref="MetricsServiceV2Client"/>, applying defaults for all unspecified settings,
        /// and creating a channel connecting to the given endpoint with application default credentials where
        /// necessary.
        /// </summary>
        /// <param name="endpoint">Optional <see cref="ServiceEndpoint"/>.</param>
        /// <param name="settings">Optional <see cref="MetricsServiceV2Settings"/>.</param>
        /// <returns>The created <see cref="MetricsServiceV2Client"/>.</returns>
        public static MetricsServiceV2Client Create(ServiceEndpoint endpoint = null, MetricsServiceV2Settings settings = null)
        {
            Channel channel = s_channelPool.GetChannel(endpoint ?? DefaultEndpoint);

            return(Create(channel, 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);
        // 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,
        /// and creating a channel connecting to the given endpoint with application default credentials where
        /// necessary.
        /// </summary>
        /// <param name="endpoint">Optional <see cref="ServiceEndpoint"/>.</param>
        /// <param name="settings">Optional <see cref="MetricsServiceV2Settings"/>.</param>
        /// <returns>The task representing the created <see cref="MetricsServiceV2Client"/>.</returns>
        public static async Task <MetricsServiceV2Client> CreateAsync(ServiceEndpoint endpoint = null, MetricsServiceV2Settings settings = null)
        {
            Channel channel = await s_channelPool.GetChannelAsync(endpoint ?? DefaultEndpoint).ConfigureAwait(false);

            return(Create(channel, settings));
        }