private static CosmosClientOptions CreateOrCloneClientOptions(CosmosClientOptions clientOptions)
        {
            if (clientOptions == null)
            {
                return(new CosmosClientOptions());
            }

            return(clientOptions.Clone());
        }
        /// <summary>
        /// Create a new CosmosClient with the cosmosClientOption
        /// </summary>
        /// <param name="clientOptions">The <see cref="CosmosClientOptions"/> used to initialize the cosmos client.</param>
        /// <example>
        /// This example creates a CosmosClient through explicit CosmosClientOptions
        /// <code language="c#">
        /// <![CDATA[
        /// CosmosClientOptions clientOptions = new CosmosClientOptions("accountEndpoint", "accountkey");
        /// clientOptions.ApplicationRegion = "East US 2";
        /// clientOptions.ConnectionMode = ConnectionMode.Direct;
        /// clientOptions.RequestTimeout = TimeSpan.FromSeconds(5);
        ///
        /// using (CosmosClient client = new CosmosClient(clientOptions))
        /// {
        ///     // Create a database and other CosmosClient operations
        /// }
        /// ]]>
        /// </code>
        /// </example>
        /// <example>
        /// This example creates a CosmosClient through builder
        /// <code language="c#">
        /// <![CDATA[
        /// CosmosClientBuilder cosmosClientBuilder = new CosmosClientBuilder("accountEndpoint", "accountkey")
        /// .UseConsistencyLevel(ConsistencyLevel.Eventual)
        /// .WithApplicationRegion("East US 2");
        /// CosmosClient client = cosmosClientBuilder.Build();
        /// ]]>
        /// </code>
        /// </example>
        public CosmosClient(CosmosClientOptions clientOptions)
        {
            if (clientOptions == null)
            {
                throw new ArgumentNullException(nameof(clientOptions));
            }

            CosmosClientOptions clientOptionsClone = clientOptions.Clone();

            DocumentClient documentClient = new DocumentClient(
                clientOptionsClone.EndPoint,
                clientOptionsClone.AccountKey,
                apitype: clientOptionsClone.ApiType,
                sendingRequestEventArgs: clientOptionsClone.SendingRequestEventArgs,
                transportClientHandlerFactory: clientOptionsClone.TransportClientHandlerFactory,
                connectionPolicy: clientOptionsClone.GetConnectionPolicy(),
                enableCpuMonitor: clientOptionsClone.EnableCpuMonitor,
                storeClientFactory: clientOptionsClone.StoreClientFactory);

            this.Init(
                clientOptionsClone,
                documentClient);
        }