private AdServiceSettings(AdServiceSettings existing) : base(existing) { gax::GaxPreconditions.CheckNotNull(existing, nameof(existing)); GetAdSettings = existing.GetAdSettings; MutateAdsSettings = existing.MutateAdsSettings; OnCopy(existing); }
/// <summary> /// Creates a <see cref="AdServiceClient"/> which uses the specified call invoker for remote operations. /// </summary> /// <param name="callInvoker">The <see cref="grpccore::CallInvoker"/> for remote operations. Must not be null.</param> /// <param name="settings">Optional <see cref="AdServiceSettings"/>.</param> /// <returns>The created <see cref="AdServiceClient"/>.</returns> public static AdServiceClient Create(grpccore::CallInvoker callInvoker, AdServiceSettings settings = null) { gax::GaxPreconditions.CheckNotNull(callInvoker, nameof(callInvoker)); grpccore::Interceptors.Interceptor interceptor = settings?.Interceptor; if (interceptor != null) { callInvoker = grpccore::Interceptors.CallInvokerExtensions.Intercept(callInvoker, interceptor); } AdService.AdServiceClient grpcClient = new AdService.AdServiceClient(callInvoker); return(new AdServiceClientImpl(grpcClient, settings)); }
/// <summary> /// Constructs a client wrapper for the AdService service, with the specified gRPC client and settings. /// </summary> /// <param name="grpcClient">The underlying gRPC client.</param> /// <param name="settings">The base <see cref="AdServiceSettings"/> used within this client.</param> public AdServiceClientImpl(AdService.AdServiceClient grpcClient, AdServiceSettings settings) { GrpcClient = grpcClient; AdServiceSettings effectiveSettings = settings ?? AdServiceSettings.GetDefault(); gaxgrpc::ClientHelper clientHelper = new gaxgrpc::ClientHelper(effectiveSettings); _callGetAd = clientHelper.BuildApiCall <GetAdRequest, gagvr::Ad>(grpcClient.GetAdAsync, grpcClient.GetAd, effectiveSettings.GetAdSettings).WithGoogleRequestParam("resource_name", request => request.ResourceName); Modify_ApiCall(ref _callGetAd); Modify_GetAdApiCall(ref _callGetAd); _callMutateAds = clientHelper.BuildApiCall <MutateAdsRequest, MutateAdsResponse>(grpcClient.MutateAdsAsync, grpcClient.MutateAds, effectiveSettings.MutateAdsSettings).WithGoogleRequestParam("customer_id", request => request.CustomerId); Modify_ApiCall(ref _callMutateAds); Modify_MutateAdsApiCall(ref _callMutateAds); OnConstruction(grpcClient, effectiveSettings, clientHelper); }
/// <summary> /// Constructs a client wrapper for the AdService service, with the specified gRPC client and settings. /// </summary> /// <param name="grpcClient">The underlying gRPC client.</param> /// <param name="settings">The base <see cref="AdServiceSettings"/> used within this client </param> public AdServiceClientImpl(AdService.AdServiceClient grpcClient, AdServiceSettings settings) { GrpcClient = grpcClient; AdServiceSettings effectiveSettings = settings ?? AdServiceSettings.GetDefault(); gaxgrpc::ClientHelper clientHelper = new gaxgrpc::ClientHelper(effectiveSettings); _callGetAd = clientHelper.BuildApiCall <GetAdRequest, gagvr::Ad>( GrpcClient.GetAdAsync, GrpcClient.GetAd, effectiveSettings.GetAdSettings) .WithCallSettingsOverlay(request => gaxgrpc::CallSettings.FromHeader("x-goog-request-params", $"resource_name={request.ResourceName}")); _callMutateAds = clientHelper.BuildApiCall <MutateAdsRequest, MutateAdsResponse>( GrpcClient.MutateAdsAsync, GrpcClient.MutateAds, effectiveSettings.MutateAdsSettings) .WithCallSettingsOverlay(request => gaxgrpc::CallSettings.FromHeader("x-goog-request-params", $"customer_id={request.CustomerId}")); Modify_ApiCall(ref _callGetAd); Modify_GetAdApiCall(ref _callGetAd); Modify_ApiCall(ref _callMutateAds); Modify_MutateAdsApiCall(ref _callMutateAds); OnConstruction(grpcClient, effectiveSettings, clientHelper); }
partial void OnCopy(AdServiceSettings existing);
partial void OnConstruction(AdService.AdServiceClient grpcClient, AdServiceSettings effectiveSettings, gaxgrpc::ClientHelper clientHelper);
/// <summary> /// Creates a <see cref="AdServiceClient"/> which uses the specified channel for remote operations. /// </summary> /// <param name="channel">The <see cref="grpccore::Channel"/> for remote operations. Must not be null.</param> /// <param name="settings">Optional <see cref="AdServiceSettings"/>.</param> /// <returns>The created <see cref="AdServiceClient"/>.</returns> public static AdServiceClient Create(grpccore::Channel channel, AdServiceSettings settings = null) { gax::GaxPreconditions.CheckNotNull(channel, nameof(channel)); return(Create(new grpccore::DefaultCallInvoker(channel), settings)); }
/// <summary> /// Synchronously creates a <see cref="AdServiceClient"/>, applying defaults for all unspecified settings, /// and creating a channel connecting to the given endpoint with application default credentials where /// necessary. See the example for how to use custom credentials. /// </summary> /// <example> /// This sample shows how to create a client using default credentials: /// <code> /// using Google.Ads.GoogleAds.V3.Services; /// ... /// // When running on Google Cloud Platform this will use the project Compute Credential. /// // Or set the GOOGLE_APPLICATION_CREDENTIALS environment variable to the path of a JSON /// // credential file to use that credential. /// AdServiceClient client = AdServiceClient.Create(); /// </code> /// This sample shows how to create a client using credentials loaded from a JSON file: /// <code> /// using Google.Ads.GoogleAds.V3.Services; /// using Google.Apis.Auth.OAuth2; /// using Grpc.Auth; /// using Grpc.Core; /// ... /// GoogleCredential cred = GoogleCredential.FromFile("/path/to/credentials.json"); /// Channel channel = new Channel( /// AdServiceClient.DefaultEndpoint.Host, AdServiceClient.DefaultEndpoint.Port, cred.ToChannelCredentials()); /// AdServiceClient client = AdServiceClient.Create(channel); /// ... /// // Shutdown the channel when it is no longer required. /// channel.ShutdownAsync().Wait(); /// </code> /// </example> /// <param name="endpoint">Optional <see cref="gaxgrpc::ServiceEndpoint"/>.</param> /// <param name="settings">Optional <see cref="AdServiceSettings"/>.</param> /// <returns>The created <see cref="AdServiceClient"/>.</returns> public static AdServiceClient Create(gaxgrpc::ServiceEndpoint endpoint = null, AdServiceSettings settings = null) { grpccore::Channel channel = s_channelPool.GetChannel(endpoint ?? DefaultEndpoint); return(Create(channel, settings)); }
/// <summary> /// Asynchronously creates a <see cref="AdServiceClient"/>, applying defaults for all unspecified settings, /// and creating a channel connecting to the given endpoint with application default credentials where /// necessary. See the example for how to use custom credentials. /// </summary> /// <example> /// This sample shows how to create a client using default credentials: /// <code> /// using Google.Ads.GoogleAds.V3.Services; /// ... /// // When running on Google Cloud Platform this will use the project Compute Credential. /// // Or set the GOOGLE_APPLICATION_CREDENTIALS environment variable to the path of a JSON /// // credential file to use that credential. /// AdServiceClient client = await AdServiceClient.CreateAsync(); /// </code> /// This sample shows how to create a client using credentials loaded from a JSON file: /// <code> /// using Google.Ads.GoogleAds.V3.Services; /// using Google.Apis.Auth.OAuth2; /// using Grpc.Auth; /// using Grpc.Core; /// ... /// GoogleCredential cred = GoogleCredential.FromFile("/path/to/credentials.json"); /// Channel channel = new Channel( /// AdServiceClient.DefaultEndpoint.Host, AdServiceClient.DefaultEndpoint.Port, cred.ToChannelCredentials()); /// AdServiceClient client = AdServiceClient.Create(channel); /// ... /// // Shutdown the channel when it is no longer required. /// await channel.ShutdownAsync(); /// </code> /// </example> /// <param name="endpoint">Optional <see cref="gaxgrpc::ServiceEndpoint"/>.</param> /// <param name="settings">Optional <see cref="AdServiceSettings"/>.</param> /// <returns>The task representing the created <see cref="AdServiceClient"/>.</returns> public static async stt::Task <AdServiceClient> CreateAsync(gaxgrpc::ServiceEndpoint endpoint = null, AdServiceSettings settings = null) { grpccore::Channel channel = await s_channelPool.GetChannelAsync(endpoint ?? DefaultEndpoint).ConfigureAwait(false); return(Create(channel, settings)); }