AWSApiJobConfig.cpp 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <AzFramework/AzFramework_Traits_Platform.h>
  9. #include <Framework/AWSApiJobConfig.h>
  10. #include <AWSCoreBus.h>
  11. #include <Credential/AWSCredentialBus.h>
  12. namespace AWSCore
  13. {
  14. void AwsApiJobConfig::ApplySettings()
  15. {
  16. m_jobContext = nullptr;
  17. Visit<AwsApiJobConfig>(
  18. [this](const AwsApiJobConfig& config) {
  19. CheckAndSet(config.jobContext, m_jobContext);
  20. }
  21. );
  22. if (!m_jobContext)
  23. {
  24. AWSCoreRequestBus::BroadcastResult(m_jobContext, &AWSCoreRequests::GetDefaultJobContext);
  25. }
  26. if (!credentialsProvider)
  27. {
  28. AWSCredentialResult credentialResult;
  29. AWSCredentialRequestBus::BroadcastResult(credentialResult, &AWSCredentialRequests::GetCredentialsProvider);
  30. if (credentialResult.result)
  31. {
  32. credentialsProvider = credentialResult.result;
  33. }
  34. }
  35. m_settingsApplied = true;
  36. }
  37. Aws::Client::ClientConfiguration AwsApiJobConfig::GetClientConfiguration() const
  38. {
  39. Aws::Client::ClientConfiguration target;
  40. target.enableTcpKeepAlive = AZ_TRAIT_AZFRAMEWORK_AWS_ENABLE_TCP_KEEP_ALIVE_SUPPORTED;
  41. Visit<AwsApiJobConfig>(
  42. [&target](const AwsApiJobConfig& config) {
  43. CheckAndSet(config.userAgent, target.userAgent);
  44. CheckAndSet(config.scheme, target.scheme);
  45. CheckAndSet(config.region, target.region);
  46. CheckAndSet(config.maxConnections, target.maxConnections);
  47. CheckAndSet(config.requestTimeoutMs, target.requestTimeoutMs);
  48. CheckAndSet(config.connectTimeoutMs, target.connectTimeoutMs);
  49. CheckAndSet(config.retryStrategy, target.retryStrategy);
  50. CheckAndSet(config.endpointOverride, target.endpointOverride);
  51. CheckAndSet(config.proxyHost, target.proxyHost);
  52. CheckAndSet(config.proxyPort, target.proxyPort);
  53. CheckAndSet(config.proxyUserName, target.proxyUserName);
  54. CheckAndSet(config.proxyPassword, target.proxyPassword);
  55. CheckAndSet(config.executor, target.executor);
  56. CheckAndSet(config.verifySSL, target.verifySSL);
  57. CheckAndSet(config.writeRateLimiter, target.writeRateLimiter);
  58. CheckAndSet(config.readRateLimiter, target.readRateLimiter);
  59. CheckAndSet(config.httpLibOverride, target.httpLibOverride);
  60. CheckAndSet(config.followRedirects, target.followRedirects);
  61. CheckAndSet(config.caFile, target.caFile);
  62. }
  63. );
  64. return target;
  65. }
  66. AZ::JobContext* AwsApiJobConfig::GetJobContext()
  67. {
  68. EnsureSettingsApplied();
  69. return m_jobContext;
  70. }
  71. std::shared_ptr<Aws::Auth::AWSCredentialsProvider> AwsApiJobConfig::GetCredentialsProvider() const
  72. {
  73. std::shared_ptr<Aws::Auth::AWSCredentialsProvider> target;
  74. Visit<AwsApiJobConfig>([&target](const AwsApiJobConfig& config) { CheckAndSet(config.credentialsProvider, target); });
  75. return target;
  76. }
  77. } // namespace AWSCore