Example #1
0
        private MarketplaceSaaSClientOptions GetOptions()
        {
            var options = new MarketplaceSaaSClientOptions()
            {
                Diagnostics = { IsLoggingEnabled = true },
                Retry       =
                {
                    Mode           = RetryMode.Exponential,
                    MaxRetries     =                                                                       10,
                    Delay          = TimeSpan.FromSeconds(this.Mode == RecordedTestMode.Playback ? 0.01 : 1),
                    MaxDelay       = TimeSpan.FromSeconds(this.Mode == RecordedTestMode.Playback ? 0.1 : 60),
                    NetworkTimeout = TimeSpan.FromSeconds(this.Mode == RecordedTestMode.Playback ? 100 : 400),
                },
                Transport = new HttpClientTransport(
                    new HttpClient()
                {
                    Timeout = TimeSpan.FromSeconds(1000),
                }),
            };

            if (this.Mode != RecordedTestMode.Live)
            {
                options.AddPolicy(new RecordedClientRequestIdPolicy(this.Recording, false), HttpPipelinePosition.PerCall);
            }

            return(this.InstrumentClientOptions(options));
        }
Example #2
0
        /// <summary>Initializes a new instance of the <see cref="MarketplaceSaaSClient"/> class. Initializes a new instance of SaaSManagementClient. </summary>
        /// <param name="endpoint"> server parameter. </param>
        /// <param name="tokenCredential"> The OAuth token for making client requests. </param>
        /// <param name="options"> The options for configuring the client. </param>
#pragma warning disable SA1202 // Elements should be ordered by access
        public MarketplaceSaaSClient(Uri endpoint, TokenCredential tokenCredential, MarketplaceSaaSClientOptions options = null)
#pragma warning restore SA1202 // Elements should be ordered by access
        {
            endpoint ??= new Uri("https://marketplaceapi.microsoft.com/api");

            options ??= new MarketplaceSaaSClientOptions();
            this.clientDiagnostics = new ClientDiagnostics(options);
            this.pipeline          = HttpPipelineBuilder.Build(options, new BearerTokenAuthenticationPolicy(tokenCredential, $"20e940b3-4c77-4b0b-9a53-9e16a1b010a7/.default"));
            this.endpoint          = endpoint;
        }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MarketplaceSaaSClient"/> class.
 /// </summary>
 /// <param name="tokenCredential">Token credential.</param>
 /// <param name="options">Client options.</param>
 public MarketplaceSaaSClient(TokenCredential tokenCredential, MarketplaceSaaSClientOptions options = null)
     : this(null, tokenCredential, options)
 {
 }