text: ﻿/**
   * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
   * SPDX-License-Identifier: Apache-2.0.
   */
  
  #include <aws/core/utils/Outcome.h>
  #include <aws/core/auth/AWSAuthSigner.h>
  #include <aws/core/client/CoreErrors.h>
  #include <aws/core/client/RetryStrategy.h>
  #include <aws/core/http/HttpClient.h>
  #include <aws/core/http/HttpResponse.h>
  #include <aws/core/http/HttpClientFactory.h>
  #include <aws/core/auth/AWSCredentialsProviderChain.h>
  #include <aws/core/utils/json/JsonSerializer.h>
  #include <aws/core/utils/memory/stl/AWSStringStream.h>
  #include <aws/core/utils/threading/Executor.h>
  #include <aws/core/utils/DNS.h>
  #include <aws/core/utils/logging/LogMacros.h>
  
  #include <aws/connect-contact-lens/ConnectContactLensClient.h>
  #include <aws/connect-contact-lens/ConnectContactLensEndpoint.h>
  #include <aws/connect-contact-lens/ConnectContactLensErrorMarshaller.h>
  #include <aws/connect-contact-lens/model/ListRealtimeContactAnalysisSegmentsRequest.h>
  
  using namespace Aws;
  using namespace Aws::Auth;
  using namespace Aws::Client;
  using namespace Aws::ConnectContactLens;
  using namespace Aws::ConnectContactLens::Model;
  using namespace Aws::Http;
  using namespace Aws::Utils::Json;
  
  static const char* SERVICE_NAME = "connect";
  static const char* ALLOCATION_TAG = "ConnectContactLensClient";
  
  
  ConnectContactLensClient::ConnectContactLensClient(const Client::ClientConfiguration& clientConfiguration) :
    BASECLASS(clientConfiguration,
      Aws::MakeShared<AWSAuthV4Signer>(ALLOCATION_TAG, Aws::MakeShared<DefaultAWSCredentialsProviderChain>(ALLOCATION_TAG),
          SERVICE_NAME, Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
      Aws::MakeShared<ConnectContactLensErrorMarshaller>(ALLOCATION_TAG)),
      m_executor(clientConfiguration.executor)
  {
    init(clientConfiguration);
  }
  
  ConnectContactLensClient::ConnectContactLensClient(const AWSCredentials& credentials, const Client::ClientConfiguration& clientConfiguration) :
    BASECLASS(clientConfiguration,
      Aws::MakeShared<AWSAuthV4Signer>(ALLOCATION_TAG, Aws::MakeShared<SimpleAWSCredentialsProvider>(ALLOCATION_TAG, credentials),
           SERVICE_NAME, Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
      Aws::MakeShared<ConnectContactLensErrorMarshaller>(ALLOCATION_TAG)),
      m_executor(clientConfiguration.executor)
  {
    init(clientConfiguration);
  }
  
  ConnectContactLensClient::ConnectContactLensClient(const std::shared_ptr<AWSCredentialsProvider>& credentialsProvider,
    const Client::ClientConfiguration& clientConfiguration) :
    BASECLASS(clientConfiguration,
      Aws::MakeShared<AWSAuthV4Signer>(ALLOCATION_TAG, credentialsProvider,
           SERVICE_NAME, Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
      Aws::MakeShared<ConnectContactLensErrorMarshaller>(ALLOCATION_TAG)),
      m_executor(clientConfiguration.executor)
  {
    init(clientConfiguration);
  }
  
  ConnectContactLensClient::~ConnectContactLensClient()
  {
  }
  
  void ConnectContactLensClient::init(const Client::ClientConfiguration& config)
  {
    SetServiceClientName("Connect Contact Lens");
    m_configScheme = SchemeMapper::ToString(config.scheme);
    if (config.endpointOverride.empty())
    {
        m_uri = m_configScheme + "://" + ConnectContactLensEndpoint::ForRegion(config.region, config.useDualStack);
    }
    else
    {
        OverrideEndpoint(config.endpointOverride);
    }
  }
  
  void ConnectContactLensClient::OverrideEndpoint(const Aws::String& endpoint)
  {
    if (endpoint.compare(0, 7, "http://") == 0 || endpoint.compare(0, 8, "https://") == 0)
    {
        m_uri = endpoint;
    }
    else
    {
        m_uri = m_configScheme + "://" + endpoint;
    }
  }
  
  ListRealtimeContactAnalysisSegmentsOutcome ConnectContactLensClient::ListRealtimeContactAnalysisSegments(const ListRealtimeContactAnalysisSegmentsRequest& request) const
  {
    Aws::Http::URI uri = m_uri;
    uri.AddPathSegments("/realtime-contact-analysis/analysis-segments");
    return ListRealtimeContactAnalysisSegmentsOutcome(MakeRequest(uri, request, Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER));
  }
  
  ListRealtimeContactAnalysisSegmentsOutcomeCallable ConnectContactLensClient::ListRealtimeContactAnalysisSegmentsCallable(const ListRealtimeContactAnalysisSegmentsRequest& request) const
  {
    auto task = Aws::MakeShared< std::packaged_task< ListRealtimeContactAnalysisSegmentsOutcome() > >(ALLOCATION_TAG, [this, request](){ return this->ListRealtimeContactAnalysisSegments(request); } );
    auto packagedFunction = [task]() { (*task)(); };
    m_executor->Submit(packagedFunction);
    return task->get_future();
  }
  
  void ConnectContactLensClient::ListRealtimeContactAnalysisSegmentsAsync(const ListRealtimeContactAnalysisSegmentsRequest& request, const ListRealtimeContactAnalysisSegmentsResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
  {
    m_executor->Submit( [this, request, handler, context](){ this->ListRealtimeContactAnalysisSegmentsAsyncHelper( request, handler, context ); } );
  }
  
  void ConnectContactLensClient::ListRealtimeContactAnalysisSegmentsAsyncHelper(const ListRealtimeContactAnalysisSegmentsRequest& request, const ListRealtimeContactAnalysisSegmentsResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
  {
    handler(this, request, ListRealtimeContactAnalysisSegments(request), context);
  }
  
  