ACMPCA
10 months ago
ARCZonalShift
10 months ago
AccessAnalyzer
10 months ago
Account
10 months ago
Acm
10 months ago
AlexaForBusiness
10 months ago
Amplify
10 months ago
AmplifyBackend
10 months ago
AmplifyUIBuilder
10 months ago
Api
10 months ago
ApiGateway
10 months ago
ApiGatewayManagementApi
10 months ago
ApiGatewayV2
10 months ago
AppConfig
10 months ago
AppConfigData
10 months ago
AppFabric
10 months ago
AppIntegrationsService
10 months ago
AppMesh
10 months ago
AppRegistry
10 months ago
AppRunner
10 months ago
AppSync
10 months ago
Appflow
10 months ago
ApplicationAutoScaling
10 months ago
ApplicationCostProfiler
10 months ago
ApplicationDiscoveryService
10 months ago
ApplicationInsights
10 months ago
Appstream
10 months ago
Arn
10 months ago
Athena
10 months ago
AuditManager
10 months ago
AugmentedAIRuntime
10 months ago
AutoScaling
10 months ago
AutoScalingPlans
10 months ago
B2bi
10 months ago
BCMDataExports
10 months ago
Backup
10 months ago
BackupGateway
10 months ago
BackupStorage
10 months ago
Batch
10 months ago
Bedrock
10 months ago
BedrockAgent
10 months ago
BedrockAgentRuntime
10 months ago
BedrockRuntime
10 months ago
BillingConductor
10 months ago
Braket
10 months ago
Budgets
10 months ago
Chime
10 months ago
ChimeSDKIdentity
10 months ago
ChimeSDKMediaPipelines
10 months ago
ChimeSDKMeetings
10 months ago
ChimeSDKMessaging
10 months ago
ChimeSDKVoice
10 months ago
CleanRooms
10 months ago
CleanRoomsML
10 months ago
ClientSideMonitoring
10 months ago
Cloud9
10 months ago
CloudControlApi
10 months ago
CloudDirectory
10 months ago
CloudFormation
10 months ago
CloudFront
10 months ago
CloudFrontKeyValueStore
10 months ago
CloudHSMV2
10 months ago
CloudHsm
10 months ago
CloudSearch
10 months ago
CloudSearchDomain
10 months ago
CloudTrail
10 months ago
CloudTrailData
10 months ago
CloudWatch
10 months ago
CloudWatchEvents
10 months ago
CloudWatchEvidently
10 months ago
CloudWatchLogs
10 months ago
CloudWatchRUM
10 months ago
CodeArtifact
10 months ago
CodeBuild
10 months ago
CodeCatalyst
10 months ago
CodeCommit
10 months ago
CodeDeploy
10 months ago
CodeGuruProfiler
10 months ago
CodeGuruReviewer
10 months ago
CodeGuruSecurity
10 months ago
CodePipeline
10 months ago
CodeStar
10 months ago
CodeStarNotifications
10 months ago
CodeStarconnections
10 months ago
CognitoIdentity
10 months ago
CognitoIdentityProvider
10 months ago
CognitoSync
10 months ago
Comprehend
10 months ago
ComprehendMedical
10 months ago
ComputeOptimizer
10 months ago
ConfigService
10 months ago
Configuration
10 months ago
Connect
10 months ago
ConnectCampaignService
10 months ago
ConnectCases
10 months ago
ConnectContactLens
10 months ago
ConnectParticipant
10 months ago
ConnectWisdomService
10 months ago
ControlTower
10 months ago
CostExplorer
10 months ago
CostOptimizationHub
10 months ago
CostandUsageReportService
10 months ago
Credentials
10 months ago
Crypto
10 months ago
CustomerProfiles
10 months ago
DAX
10 months ago
DLM
10 months ago
DataExchange
10 months ago
DataPipeline
10 months ago
DataSync
10 months ago
DataZone
10 months ago
DatabaseMigrationService
10 months ago
DefaultsMode
10 months ago
Detective
10 months ago
DevOpsGuru
10 months ago
DeviceFarm
10 months ago
DirectConnect
10 months ago
DirectoryService
10 months ago
DocDB
10 months ago
DocDBElastic
10 months ago
DynamoDb
10 months ago
DynamoDbStreams
10 months ago
EBS
10 months ago
EC2InstanceConnect
10 months ago
ECRPublic
10 months ago
EKS
10 months ago
EKSAuth
10 months ago
EMRContainers
10 months ago
EMRServerless
10 months ago
Ec2
10 months ago
Ecr
10 months ago
Ecs
10 months ago
Efs
10 months ago
ElastiCache
10 months ago
ElasticBeanstalk
10 months ago
ElasticInference
10 months ago
ElasticLoadBalancing
10 months ago
ElasticLoadBalancingV2
10 months ago
ElasticTranscoder
10 months ago
ElasticsearchService
10 months ago
Emr
10 months ago
Endpoint
10 months ago
EndpointDiscovery
10 months ago
EndpointV2
10 months ago
EntityResolution
10 months ago
EventBridge
10 months ago
Exception
10 months ago
FIS
10 months ago
FMS
10 months ago
FSx
10 months ago
FinSpaceData
10 months ago
Firehose
10 months ago
ForecastQueryService
10 months ago
ForecastService
10 months ago
FraudDetector
10 months ago
FreeTier
10 months ago
GameLift
10 months ago
Glacier
10 months ago
GlobalAccelerator
10 months ago
Glue
10 months ago
GlueDataBrew
10 months ago
Greengrass
10 months ago
GreengrassV2
10 months ago
GroundStation
10 months ago
GuardDuty
10 months ago
Handler
10 months ago
Health
10 months ago
HealthLake
10 months ago
Honeycode
10 months ago
IVS
10 months ago
IVSRealTime
10 months ago
Iam
10 months ago
Identity
10 months ago
IdentityStore
10 months ago
ImportExport
10 months ago
Inspector
10 months ago
Inspector2
10 months ago
InspectorScan
10 months ago
InternetMonitor
10 months ago
IoT1ClickDevicesService
10 months ago
IoT1ClickProjects
10 months ago
IoTAnalytics
10 months ago
IoTDeviceAdvisor
10 months ago
IoTEvents
10 months ago
IoTEventsData
10 months ago
IoTFleetHub
10 months ago
IoTFleetWise
10 months ago
IoTJobsDataPlane
10 months ago
IoTRoboRunner
10 months ago
IoTSecureTunneling
10 months ago
IoTSiteWise
10 months ago
IoTThingsGraph
10 months ago
IoTTwinMaker
10 months ago
IoTWireless
10 months ago
Iot
10 months ago
IotDataPlane
10 months ago
Kafka
10 months ago
KafkaConnect
10 months ago
KendraRanking
10 months ago
Keyspaces
10 months ago
Kinesis
10 months ago
KinesisAnalytics
10 months ago
KinesisAnalyticsV2
10 months ago
KinesisVideo
10 months ago
KinesisVideoArchivedMedia
10 months ago
KinesisVideoMedia
10 months ago
KinesisVideoSignalingChannels
10 months ago
KinesisVideoWebRTCStorage
10 months ago
Kms
10 months ago
LakeFormation
10 months ago
Lambda
10 months ago
LaunchWizard
10 months ago
LexModelBuildingService
10 months ago
LexModelsV2
10 months ago
LexRuntimeService
10 months ago
LexRuntimeV2
10 months ago
LicenseManager
10 months ago
LicenseManagerLinuxSubscriptions
10 months ago
LicenseManagerUserSubscriptions
10 months ago
Lightsail
10 months ago
LocationService
10 months ago
LookoutEquipment
10 months ago
LookoutMetrics
10 months ago
LookoutforVision
10 months ago
MQ
10 months ago
MTurk
10 months ago
MWAA
10 months ago
MachineLearning
10 months ago
Macie2
10 months ago
MainframeModernization
10 months ago
ManagedBlockchain
10 months ago
ManagedBlockchainQuery
10 months ago
ManagedGrafana
10 months ago
MarketplaceAgreement
10 months ago
MarketplaceCatalog
10 months ago
MarketplaceCommerceAnalytics
10 months ago
MarketplaceDeployment
10 months ago
MarketplaceEntitlementService
10 months ago
MarketplaceMetering
10 months ago
MediaConnect
10 months ago
MediaConvert
10 months ago
MediaLive
10 months ago
MediaPackage
10 months ago
MediaPackageV2
10 months ago
MediaPackageVod
10 months ago
MediaStore
10 months ago
MediaStoreData
10 months ago
MediaTailor
10 months ago
MedicalImaging
10 months ago
MemoryDB
10 months ago
MigrationHub
10 months ago
MigrationHubConfig
10 months ago
MigrationHubOrchestrator
10 months ago
MigrationHubRefactorSpaces
10 months ago
MigrationHubStrategyRecommendations
10 months ago
Mobile
10 months ago
Multipart
10 months ago
Neptune
10 months ago
Neptunedata
10 months ago
NetworkFirewall
10 months ago
NetworkManager
10 months ago
NimbleStudio
10 months ago
OAM
10 months ago
OSIS
10 months ago
Omics
10 months ago
OpenSearchServerless
10 months ago
OpenSearchService
10 months ago
OpsWorks
10 months ago
OpsWorksCM
10 months ago
Organizations
10 months ago
Outposts
10 months ago
PI
10 months ago
Panorama
10 months ago
PaymentCryptography
10 months ago
PaymentCryptographyData
10 months ago
PcaConnectorAd
10 months ago
Personalize
10 months ago
PersonalizeEvents
10 months ago
PersonalizeRuntime
10 months ago
Pinpoint
10 months ago
PinpointEmail
10 months ago
PinpointSMSVoice
10 months ago
PinpointSMSVoiceV2
10 months ago
Pipes
10 months ago
Polly
10 months ago
Pricing
10 months ago
PrivateNetworks
10 months ago
PrometheusService
10 months ago
Proton
10 months ago
QBusiness
10 months ago
QConnect
10 months ago
QLDB
10 months ago
QLDBSession
10 months ago
QuickSight
10 months ago
RAM
10 months ago
RDSDataService
10 months ago
Rds
10 months ago
RecycleBin
10 months ago
Redshift
10 months ago
RedshiftDataAPIService
10 months ago
RedshiftServerless
10 months ago
Rekognition
10 months ago
Repostspace
10 months ago
ResilienceHub
10 months ago
ResourceExplorer2
10 months ago
ResourceGroups
10 months ago
ResourceGroupsTaggingAPI
10 months ago
Retry
10 months ago
RoboMaker
10 months ago
RolesAnywhere
10 months ago
Route53
10 months ago
Route53Domains
10 months ago
Route53RecoveryCluster
10 months ago
Route53RecoveryControlConfig
10 months ago
Route53RecoveryReadiness
10 months ago
Route53Resolver
10 months ago
S3
10 months ago
S3Control
10 months ago
S3Outposts
10 months ago
SSMContacts
10 months ago
SSMIncidents
10 months ago
SSO
10 months ago
SSOAdmin
10 months ago
SSOOIDC
10 months ago
SageMaker
10 months ago
SageMakerFeatureStoreRuntime
10 months ago
SageMakerGeospatial
10 months ago
SageMakerMetrics
10 months ago
SageMakerRuntime
10 months ago
SagemakerEdgeManager
10 months ago
SavingsPlans
10 months ago
Scheduler
10 months ago
Schemas
10 months ago
Script
10 months ago
SecretsManager
10 months ago
SecurityHub
10 months ago
SecurityLake
10 months ago
ServerlessApplicationRepository
10 months ago
ServiceCatalog
10 months ago
ServiceDiscovery
10 months ago
ServiceQuotas
10 months ago
Ses
10 months ago
SesV2
10 months ago
Sfn
10 months ago
Shield
10 months ago
Signature
10 months ago
SimSpaceWeaver
10 months ago
Sms
10 months ago
SnowBall
10 months ago
SnowDeviceManagement
10 months ago
Sns
10 months ago
Sqs
10 months ago
Ssm
10 months ago
SsmSap
10 months ago
StorageGateway
10 months ago
Sts
10 months ago
Support
10 months ago
SupportApp
10 months ago
Swf
10 months ago
Synthetics
10 months ago
Textract
10 months ago
TimestreamQuery
10 months ago
TimestreamWrite
10 months ago
Tnb
10 months ago
Token
10 months ago
TranscribeService
10 months ago
Transfer
10 months ago
Translate
10 months ago
TrustedAdvisor
10 months ago
VPCLattice
10 months ago
VerifiedPermissions
10 months ago
VoiceID
10 months ago
WAFV2
10 months ago
Waf
10 months ago
WafRegional
10 months ago
WellArchitected
10 months ago
WorkDocs
10 months ago
WorkLink
10 months ago
WorkMail
10 months ago
WorkMailMessageFlow
10 months ago
WorkSpaces
10 months ago
WorkSpacesThinClient
10 months ago
WorkSpacesWeb
10 months ago
XRay
10 months ago
data
10 months ago
drs
10 months ago
finspace
10 months ago
imagebuilder
10 months ago
ivschat
10 months ago
kendra
10 months ago
mgn
10 months ago
signer
10 months ago
AbstractConfigurationProvider.php
10 months ago
AwsClient.php
10 months ago
AwsClientInterface.php
10 months ago
AwsClientTrait.php
10 months ago
CacheInterface.php
10 months ago
ClientResolver.php
10 months ago
Command.php
10 months ago
CommandInterface.php
10 months ago
CommandPool.php
10 months ago
ConfigurationProviderInterface.php
10 months ago
DoctrineCacheAdapter.php
10 months ago
EndpointParameterMiddleware.php
10 months ago
HandlerList.php
10 months ago
HasDataTrait.php
10 months ago
HasMonitoringEventsTrait.php
10 months ago
HashInterface.php
10 months ago
HashingStream.php
10 months ago
History.php
10 months ago
IdempotencyTokenMiddleware.php
10 months ago
InputValidationMiddleware.php
10 months ago
JsonCompiler.php
10 months ago
LruArrayCache.php
10 months ago
Middleware.php
10 months ago
MockHandler.php
10 months ago
MonitoringEventsInterface.php
10 months ago
MultiRegionClient.php
10 months ago
PhpHash.php
10 months ago
PresignUrlMiddleware.php
10 months ago
Psr16CacheAdapter.php
10 months ago
PsrCacheAdapter.php
10 months ago
QueryCompatibleInputMiddleware.php
10 months ago
RequestCompressionMiddleware.php
10 months ago
ResponseContainerInterface.php
10 months ago
Result.php
10 months ago
ResultInterface.php
10 months ago
ResultPaginator.php
10 months ago
RetryMiddleware.php
10 months ago
RetryMiddlewareV2.php
10 months ago
Sdk.php
10 months ago
StreamRequestPayloadMiddleware.php
10 months ago
TraceMiddleware.php
10 months ago
Waiter.php
10 months ago
WrappedHttpHandler.php
10 months ago
functions.php
10 months ago
ClientResolver.php
1299 lines
| 1 | <?php |
| 2 | namespace Aws; |
| 3 | |
| 4 | use Aws\Api\ApiProvider; |
| 5 | use Aws\Api\Service; |
| 6 | use Aws\Api\Validator; |
| 7 | use Aws\ClientSideMonitoring\ApiCallAttemptMonitoringMiddleware; |
| 8 | use Aws\ClientSideMonitoring\ApiCallMonitoringMiddleware; |
| 9 | use Aws\ClientSideMonitoring\Configuration; |
| 10 | use Aws\Configuration\ConfigurationResolver; |
| 11 | use Aws\Credentials\CredentialProvider; |
| 12 | use Aws\Credentials\Credentials; |
| 13 | use Aws\Credentials\CredentialsInterface; |
| 14 | use Aws\DefaultsMode\ConfigurationInterface as ConfigModeInterface; |
| 15 | use Aws\DefaultsMode\ConfigurationProvider as ConfigModeProvider; |
| 16 | use Aws\Endpoint\EndpointProvider; |
| 17 | use Aws\Endpoint\PartitionEndpointProvider; |
| 18 | use Aws\Endpoint\UseDualstackEndpoint\Configuration as UseDualStackEndpointConfiguration; |
| 19 | use Aws\Endpoint\UseDualstackEndpoint\ConfigurationInterface as UseDualStackEndpointConfigurationInterface; |
| 20 | use Aws\Endpoint\UseDualstackEndpoint\ConfigurationProvider as UseDualStackConfigProvider; |
| 21 | use Aws\Endpoint\UseFipsEndpoint\Configuration as UseFipsEndpointConfiguration; |
| 22 | use Aws\Endpoint\UseFipsEndpoint\ConfigurationInterface as UseFipsEndpointConfigurationInterface; |
| 23 | use Aws\Endpoint\UseFipsEndpoint\ConfigurationProvider as UseFipsConfigProvider; |
| 24 | use Aws\EndpointDiscovery\ConfigurationInterface; |
| 25 | use Aws\EndpointDiscovery\ConfigurationProvider; |
| 26 | use Aws\EndpointV2\EndpointDefinitionProvider; |
| 27 | use Aws\Exception\AwsException; |
| 28 | use Aws\Exception\InvalidRegionException; |
| 29 | use Aws\Retry\ConfigurationInterface as RetryConfigInterface; |
| 30 | use Aws\Retry\ConfigurationProvider as RetryConfigProvider; |
| 31 | use Aws\Signature\SignatureProvider; |
| 32 | use Aws\Token\Token; |
| 33 | use Aws\Token\TokenInterface; |
| 34 | use Aws\Token\TokenProvider; |
| 35 | use GuzzleHttp\Promise\PromiseInterface; |
| 36 | use InvalidArgumentException as IAE; |
| 37 | use Psr\Http\Message\RequestInterface; |
| 38 | |
| 39 | /** |
| 40 | * @internal Resolves a hash of client arguments to construct a client. |
| 41 | */ |
| 42 | class ClientResolver |
| 43 | { |
| 44 | /** @var array */ |
| 45 | private $argDefinitions; |
| 46 | |
| 47 | /** @var array Map of types to a corresponding function */ |
| 48 | private static $typeMap = [ |
| 49 | 'resource' => 'is_resource', |
| 50 | 'callable' => 'is_callable', |
| 51 | 'int' => 'is_int', |
| 52 | 'bool' => 'is_bool', |
| 53 | 'boolean' => 'is_bool', |
| 54 | 'string' => 'is_string', |
| 55 | 'object' => 'is_object', |
| 56 | 'array' => 'is_array', |
| 57 | ]; |
| 58 | |
| 59 | private static $defaultArgs = [ |
| 60 | 'service' => [ |
| 61 | 'type' => 'value', |
| 62 | 'valid' => ['string'], |
| 63 | 'doc' => 'Name of the service to utilize. This value will be supplied by default when using one of the SDK clients (e.g., Aws\\S3\\S3Client).', |
| 64 | 'required' => true, |
| 65 | 'internal' => true |
| 66 | ], |
| 67 | 'exception_class' => [ |
| 68 | 'type' => 'value', |
| 69 | 'valid' => ['string'], |
| 70 | 'doc' => 'Exception class to create when an error occurs.', |
| 71 | 'default' => AwsException::class, |
| 72 | 'internal' => true |
| 73 | ], |
| 74 | 'scheme' => [ |
| 75 | 'type' => 'value', |
| 76 | 'valid' => ['string'], |
| 77 | 'default' => 'https', |
| 78 | 'doc' => 'URI scheme to use when connecting connect. The SDK will utilize "https" endpoints (i.e., utilize SSL/TLS connections) by default. You can attempt to connect to a service over an unencrypted "http" endpoint by setting ``scheme`` to "http".', |
| 79 | ], |
| 80 | 'disable_host_prefix_injection' => [ |
| 81 | 'type' => 'value', |
| 82 | 'valid' => ['bool'], |
| 83 | 'doc' => 'Set to true to disable host prefix injection logic for services that use it. This disables the entire prefix injection, including the portions supplied by user-defined parameters. Setting this flag will have no effect on services that do not use host prefix injection.', |
| 84 | 'default' => false, |
| 85 | ], |
| 86 | 'ignore_configured_endpoint_urls' => [ |
| 87 | 'type' => 'value', |
| 88 | 'valid' => ['bool'], |
| 89 | 'doc' => 'Set to true to disable endpoint urls configured using `AWS_ENDPOINT_URL` and `endpoint_url` shared config option.', |
| 90 | 'fn' => [__CLASS__, '_apply_ignore_configured_endpoint_urls'], |
| 91 | 'default' => [__CLASS__, '_default_ignore_configured_endpoint_urls'], |
| 92 | ], |
| 93 | 'endpoint' => [ |
| 94 | 'type' => 'value', |
| 95 | 'valid' => ['string'], |
| 96 | 'doc' => 'The full URI of the webservice. This is only required when connecting to a custom endpoint (e.g., a local version of S3).', |
| 97 | 'fn' => [__CLASS__, '_apply_endpoint'], |
| 98 | 'default' => [__CLASS__, '_default_endpoint'] |
| 99 | ], |
| 100 | 'region' => [ |
| 101 | 'type' => 'value', |
| 102 | 'valid' => ['string'], |
| 103 | 'doc' => 'Region to connect to. See http://docs.aws.amazon.com/general/latest/gr/rande.html for a list of available regions.', |
| 104 | 'fn' => [__CLASS__, '_apply_region'], |
| 105 | 'default' => [__CLASS__, '_default_region'] |
| 106 | ], |
| 107 | 'version' => [ |
| 108 | 'type' => 'value', |
| 109 | 'valid' => ['string'], |
| 110 | 'doc' => 'The version of the webservice to utilize (e.g., 2006-03-01).', |
| 111 | 'default' => 'latest', |
| 112 | ], |
| 113 | 'signature_provider' => [ |
| 114 | 'type' => 'value', |
| 115 | 'valid' => ['callable'], |
| 116 | 'doc' => 'A callable that accepts a signature version name (e.g., "v4"), a service name, and region, and returns a SignatureInterface object or null. This provider is used to create signers utilized by the client. See Aws\\Signature\\SignatureProvider for a list of built-in providers', |
| 117 | 'default' => [__CLASS__, '_default_signature_provider'], |
| 118 | ], |
| 119 | 'api_provider' => [ |
| 120 | 'type' => 'value', |
| 121 | 'valid' => ['callable'], |
| 122 | 'doc' => 'An optional PHP callable that accepts a type, service, and version argument, and returns an array of corresponding configuration data. The type value can be one of api, waiter, or paginator.', |
| 123 | 'fn' => [__CLASS__, '_apply_api_provider'], |
| 124 | 'default' => [ApiProvider::class, 'defaultProvider'], |
| 125 | ], |
| 126 | 'configuration_mode' => [ |
| 127 | 'type' => 'value', |
| 128 | 'valid' => [ConfigModeInterface::class, CacheInterface::class, 'string', 'closure'], |
| 129 | 'doc' => "Sets the default configuration mode. Otherwise provide an instance of Aws\DefaultsMode\ConfigurationInterface, an instance of Aws\CacheInterface, or a string containing a valid mode", |
| 130 | 'fn' => [__CLASS__, '_apply_defaults'], |
| 131 | 'default' => [ConfigModeProvider::class, 'defaultProvider'] |
| 132 | ], |
| 133 | 'use_fips_endpoint' => [ |
| 134 | 'type' => 'value', |
| 135 | 'valid' => ['bool', UseFipsEndpointConfiguration::class, CacheInterface::class, 'callable'], |
| 136 | 'doc' => 'Set to true to enable the use of FIPS pseudo regions', |
| 137 | 'fn' => [__CLASS__, '_apply_use_fips_endpoint'], |
| 138 | 'default' => [__CLASS__, '_default_use_fips_endpoint'], |
| 139 | ], |
| 140 | 'use_dual_stack_endpoint' => [ |
| 141 | 'type' => 'value', |
| 142 | 'valid' => ['bool', UseDualStackEndpointConfiguration::class, CacheInterface::class, 'callable'], |
| 143 | 'doc' => 'Set to true to enable the use of dual-stack endpoints', |
| 144 | 'fn' => [__CLASS__, '_apply_use_dual_stack_endpoint'], |
| 145 | 'default' => [__CLASS__, '_default_use_dual_stack_endpoint'], |
| 146 | ], |
| 147 | 'endpoint_provider' => [ |
| 148 | 'type' => 'value', |
| 149 | 'valid' => ['callable', EndpointV2\EndpointProviderV2::class], |
| 150 | 'fn' => [__CLASS__, '_apply_endpoint_provider'], |
| 151 | 'doc' => 'An optional PHP callable that accepts a hash of options including a "service" and "region" key and returns NULL or a hash of endpoint data, of which the "endpoint" key is required. See Aws\\Endpoint\\EndpointProvider for a list of built-in providers.', |
| 152 | 'default' => [__CLASS__, '_default_endpoint_provider'], |
| 153 | ], |
| 154 | 'serializer' => [ |
| 155 | 'default' => [__CLASS__, '_default_serializer'], |
| 156 | 'fn' => [__CLASS__, '_apply_serializer'], |
| 157 | 'internal' => true, |
| 158 | 'type' => 'value', |
| 159 | 'valid' => ['callable'], |
| 160 | ], |
| 161 | 'signature_version' => [ |
| 162 | 'type' => 'config', |
| 163 | 'valid' => ['string'], |
| 164 | 'doc' => 'A string representing a custom signature version to use with a service (e.g., v4). Note that per/operation signature version MAY override this requested signature version.', |
| 165 | 'default' => [__CLASS__, '_default_signature_version'], |
| 166 | ], |
| 167 | 'signing_name' => [ |
| 168 | 'type' => 'config', |
| 169 | 'valid' => ['string'], |
| 170 | 'doc' => 'A string representing a custom service name to be used when calculating a request signature.', |
| 171 | 'default' => [__CLASS__, '_default_signing_name'], |
| 172 | ], |
| 173 | 'signing_region' => [ |
| 174 | 'type' => 'config', |
| 175 | 'valid' => ['string'], |
| 176 | 'doc' => 'A string representing a custom region name to be used when calculating a request signature.', |
| 177 | 'default' => [__CLASS__, '_default_signing_region'], |
| 178 | ], |
| 179 | 'profile' => [ |
| 180 | 'type' => 'config', |
| 181 | 'valid' => ['string'], |
| 182 | 'doc' => 'Allows you to specify which profile to use when credentials are created from the AWS credentials file in your HOME directory. This setting overrides the AWS_PROFILE environment variable. Note: Specifying "profile" will cause the "credentials" and "use_aws_shared_config_files" keys to be ignored.', |
| 183 | 'fn' => [__CLASS__, '_apply_profile'], |
| 184 | ], |
| 185 | 'credentials' => [ |
| 186 | 'type' => 'value', |
| 187 | 'valid' => [CredentialsInterface::class, CacheInterface::class, 'array', 'bool', 'callable'], |
| 188 | 'doc' => 'Specifies the credentials used to sign requests. Provide an Aws\Credentials\CredentialsInterface object, an associative array of "key", "secret", and an optional "token" key, `false` to use null credentials, or a callable credentials provider used to create credentials or return null. See Aws\\Credentials\\CredentialProvider for a list of built-in credentials providers. If no credentials are provided, the SDK will attempt to load them from the environment.', |
| 189 | 'fn' => [__CLASS__, '_apply_credentials'], |
| 190 | 'default' => [__CLASS__, '_default_credential_provider'], |
| 191 | ], |
| 192 | 'token' => [ |
| 193 | 'type' => 'value', |
| 194 | 'valid' => [TokenInterface::class, CacheInterface::class, 'array', 'bool', 'callable'], |
| 195 | 'doc' => 'Specifies the token used to authorize requests. Provide an Aws\Token\TokenInterface object, an associative array of "token", and an optional "expiration" key, `false` to use a null token, or a callable token provider used to fetch a token or return null. See Aws\\Token\\TokenProvider for a list of built-in credentials providers. If no token is provided, the SDK will attempt to load one from the environment.', |
| 196 | 'fn' => [__CLASS__, '_apply_token'], |
| 197 | 'default' => [__CLASS__, '_default_token_provider'], |
| 198 | ], |
| 199 | 'endpoint_discovery' => [ |
| 200 | 'type' => 'value', |
| 201 | 'valid' => [ConfigurationInterface::class, CacheInterface::class, 'array', 'callable'], |
| 202 | 'doc' => 'Specifies settings for endpoint discovery. Provide an instance of Aws\EndpointDiscovery\ConfigurationInterface, an instance Aws\CacheInterface, a callable that provides a promise for a Configuration object, or an associative array with the following keys: enabled: (bool) Set to true to enable endpoint discovery, false to explicitly disable it. Defaults to false; cache_limit: (int) The maximum number of keys in the endpoints cache. Defaults to 1000.', |
| 203 | 'fn' => [__CLASS__, '_apply_endpoint_discovery'], |
| 204 | 'default' => [__CLASS__, '_default_endpoint_discovery_provider'] |
| 205 | ], |
| 206 | 'stats' => [ |
| 207 | 'type' => 'value', |
| 208 | 'valid' => ['bool', 'array'], |
| 209 | 'default' => false, |
| 210 | 'doc' => 'Set to true to gather transfer statistics on requests sent. Alternatively, you can provide an associative array with the following keys: retries: (bool) Set to false to disable reporting on retries attempted; http: (bool) Set to true to enable collecting statistics from lower level HTTP adapters (e.g., values returned in GuzzleHttp\TransferStats). HTTP handlers must support an http_stats_receiver option for this to have an effect; timer: (bool) Set to true to enable a command timer that reports the total wall clock time spent on an operation in seconds.', |
| 211 | 'fn' => [__CLASS__, '_apply_stats'], |
| 212 | ], |
| 213 | 'retries' => [ |
| 214 | 'type' => 'value', |
| 215 | 'valid' => ['int', RetryConfigInterface::class, CacheInterface::class, 'callable', 'array'], |
| 216 | 'doc' => "Configures the retry mode and maximum number of allowed retries for a client (pass 0 to disable retries). Provide an integer for 'legacy' mode with the specified number of retries. Otherwise provide an instance of Aws\Retry\ConfigurationInterface, an instance of Aws\CacheInterface, a callable function, or an array with the following keys: mode: (string) Set to 'legacy', 'standard' (uses retry quota management), or 'adapative' (an experimental mode that adds client-side rate limiting to standard mode); max_attempts: (int) The maximum number of attempts for a given request. ", |
| 217 | 'fn' => [__CLASS__, '_apply_retries'], |
| 218 | 'default' => [RetryConfigProvider::class, 'defaultProvider'] |
| 219 | ], |
| 220 | 'validate' => [ |
| 221 | 'type' => 'value', |
| 222 | 'valid' => ['bool', 'array'], |
| 223 | 'default' => true, |
| 224 | 'doc' => 'Set to false to disable client-side parameter validation. Set to true to utilize default validation constraints. Set to an associative array of validation options to enable specific validation constraints.', |
| 225 | 'fn' => [__CLASS__, '_apply_validate'], |
| 226 | ], |
| 227 | 'debug' => [ |
| 228 | 'type' => 'value', |
| 229 | 'valid' => ['bool', 'array'], |
| 230 | 'doc' => 'Set to true to display debug information when sending requests. Alternatively, you can provide an associative array with the following keys: logfn: (callable) Function that is invoked with log messages; stream_size: (int) When the size of a stream is greater than this number, the stream data will not be logged (set to "0" to not log any stream data); scrub_auth: (bool) Set to false to disable the scrubbing of auth data from the logged messages; http: (bool) Set to false to disable the "debug" feature of lower level HTTP adapters (e.g., verbose curl output).', |
| 231 | 'fn' => [__CLASS__, '_apply_debug'], |
| 232 | ], |
| 233 | 'disable_request_compression' => [ |
| 234 | 'type' => 'value', |
| 235 | 'valid' => ['bool', 'callable'], |
| 236 | 'doc' => 'Set to true to disable request compression for supported operations', |
| 237 | 'fn' => [__CLASS__, '_apply_disable_request_compression'], |
| 238 | 'default' => [__CLASS__, '_default_disable_request_compression'], |
| 239 | ], |
| 240 | 'request_min_compression_size_bytes' => [ |
| 241 | 'type' => 'value', |
| 242 | 'valid' => ['int', 'callable'], |
| 243 | 'doc' => 'Set to a value between between 0 and 10485760 bytes, inclusive. This value will be ignored if `disable_request_compression` is set to `true`', |
| 244 | 'fn' => [__CLASS__, '_apply_min_compression_size'], |
| 245 | 'default' => [__CLASS__, '_default_min_compression_size'], |
| 246 | ], |
| 247 | 'csm' => [ |
| 248 | 'type' => 'value', |
| 249 | 'valid' => [\Aws\ClientSideMonitoring\ConfigurationInterface::class, 'callable', 'array', 'bool'], |
| 250 | 'doc' => 'CSM options for the client. Provides a callable wrapping a promise, a boolean "false", an instance of ConfigurationInterface, or an associative array of "enabled", "host", "port", and "client_id".', |
| 251 | 'fn' => [__CLASS__, '_apply_csm'], |
| 252 | 'default' => [\Aws\ClientSideMonitoring\ConfigurationProvider::class, 'defaultProvider'] |
| 253 | ], |
| 254 | 'http' => [ |
| 255 | 'type' => 'value', |
| 256 | 'valid' => ['array'], |
| 257 | 'default' => [], |
| 258 | 'doc' => 'Set to an array of SDK request options to apply to each request (e.g., proxy, verify, etc.).', |
| 259 | ], |
| 260 | 'http_handler' => [ |
| 261 | 'type' => 'value', |
| 262 | 'valid' => ['callable'], |
| 263 | 'doc' => 'An HTTP handler is a function that accepts a PSR-7 request object and returns a promise that is fulfilled with a PSR-7 response object or rejected with an array of exception data. NOTE: This option supersedes any provided "handler" option.', |
| 264 | 'fn' => [__CLASS__, '_apply_http_handler'] |
| 265 | ], |
| 266 | 'handler' => [ |
| 267 | 'type' => 'value', |
| 268 | 'valid' => ['callable'], |
| 269 | 'doc' => 'A handler that accepts a command object, request object and returns a promise that is fulfilled with an Aws\ResultInterface object or rejected with an Aws\Exception\AwsException. A handler does not accept a next handler as it is terminal and expected to fulfill a command. If no handler is provided, a default Guzzle handler will be utilized.', |
| 270 | 'fn' => [__CLASS__, '_apply_handler'], |
| 271 | 'default' => [__CLASS__, '_default_handler'] |
| 272 | ], |
| 273 | 'ua_append' => [ |
| 274 | 'type' => 'value', |
| 275 | 'valid' => ['string', 'array'], |
| 276 | 'doc' => 'Provide a string or array of strings to send in the User-Agent header.', |
| 277 | 'fn' => [__CLASS__, '_apply_user_agent'], |
| 278 | 'default' => [], |
| 279 | ], |
| 280 | 'idempotency_auto_fill' => [ |
| 281 | 'type' => 'value', |
| 282 | 'valid' => ['bool', 'callable'], |
| 283 | 'doc' => 'Set to false to disable SDK to populate parameters that enabled \'idempotencyToken\' trait with a random UUID v4 value on your behalf. Using default value \'true\' still allows parameter value to be overwritten when provided. Note: auto-fill only works when cryptographically secure random bytes generator functions(random_bytes, openssl_random_pseudo_bytes or mcrypt_create_iv) can be found. You may also provide a callable source of random bytes.', |
| 284 | 'default' => true, |
| 285 | 'fn' => [__CLASS__, '_apply_idempotency_auto_fill'] |
| 286 | ], |
| 287 | 'use_aws_shared_config_files' => [ |
| 288 | 'type' => 'value', |
| 289 | 'valid' => ['bool'], |
| 290 | 'doc' => 'Set to false to disable checking for shared aws config files usually located in \'~/.aws/config\' and \'~/.aws/credentials\'. This will be ignored if you set the \'profile\' setting.', |
| 291 | 'default' => true, |
| 292 | ], |
| 293 | ]; |
| 294 | |
| 295 | /** |
| 296 | * Gets an array of default client arguments, each argument containing a |
| 297 | * hash of the following: |
| 298 | * |
| 299 | * - type: (string, required) option type described as follows: |
| 300 | * - value: The default option type. |
| 301 | * - config: The provided value is made available in the client's |
| 302 | * getConfig() method. |
| 303 | * - valid: (array, required) Valid PHP types or class names. Note: null |
| 304 | * is not an allowed type. |
| 305 | * - required: (bool, callable) Whether or not the argument is required. |
| 306 | * Provide a function that accepts an array of arguments and returns a |
| 307 | * string to provide a custom error message. |
| 308 | * - default: (mixed) The default value of the argument if not provided. If |
| 309 | * a function is provided, then it will be invoked to provide a default |
| 310 | * value. The function is provided the array of options and is expected |
| 311 | * to return the default value of the option. The default value can be a |
| 312 | * closure and can not be a callable string that is not part of the |
| 313 | * defaultArgs array. |
| 314 | * - doc: (string) The argument documentation string. |
| 315 | * - fn: (callable) Function used to apply the argument. The function |
| 316 | * accepts the provided value, array of arguments by reference, and an |
| 317 | * event emitter. |
| 318 | * |
| 319 | * Note: Order is honored and important when applying arguments. |
| 320 | * |
| 321 | * @return array |
| 322 | */ |
| 323 | public static function getDefaultArguments() |
| 324 | { |
| 325 | return self::$defaultArgs; |
| 326 | } |
| 327 | |
| 328 | /** |
| 329 | * @param array $argDefinitions Client arguments. |
| 330 | */ |
| 331 | public function __construct(array $argDefinitions) |
| 332 | { |
| 333 | $this->argDefinitions = $argDefinitions; |
| 334 | } |
| 335 | |
| 336 | /** |
| 337 | * Resolves client configuration options and attached event listeners. |
| 338 | * Check for missing keys in passed arguments |
| 339 | * |
| 340 | * @param array $args Provided constructor arguments. |
| 341 | * @param HandlerList $list Handler list to augment. |
| 342 | * |
| 343 | * @return array Returns the array of provided options. |
| 344 | * @throws \InvalidArgumentException |
| 345 | * @see Aws\AwsClient::__construct for a list of available options. |
| 346 | */ |
| 347 | public function resolve(array $args, HandlerList $list) |
| 348 | { |
| 349 | $args['config'] = []; |
| 350 | foreach ($this->argDefinitions as $key => $a) { |
| 351 | // Add defaults, validate required values, and skip if not set. |
| 352 | if (!isset($args[$key])) { |
| 353 | if (isset($a['default'])) { |
| 354 | // Merge defaults in when not present. |
| 355 | if (is_callable($a['default']) |
| 356 | && ( |
| 357 | is_array($a['default']) |
| 358 | || $a['default'] instanceof \Closure |
| 359 | ) |
| 360 | ) { |
| 361 | $args[$key] = $a['default']($args); |
| 362 | } else { |
| 363 | $args[$key] = $a['default']; |
| 364 | } |
| 365 | } elseif (empty($a['required'])) { |
| 366 | continue; |
| 367 | } else { |
| 368 | $this->throwRequired($args); |
| 369 | } |
| 370 | } |
| 371 | |
| 372 | // Validate the types against the provided value. |
| 373 | foreach ($a['valid'] as $check) { |
| 374 | if (isset(self::$typeMap[$check])) { |
| 375 | $fn = self::$typeMap[$check]; |
| 376 | if ($fn($args[$key])) { |
| 377 | goto is_valid; |
| 378 | } |
| 379 | } elseif ($args[$key] instanceof $check) { |
| 380 | goto is_valid; |
| 381 | } |
| 382 | } |
| 383 | |
| 384 | $this->invalidType($key, $args[$key]); |
| 385 | |
| 386 | // Apply the value |
| 387 | is_valid: |
| 388 | if (isset($a['fn'])) { |
| 389 | $a['fn']($args[$key], $args, $list); |
| 390 | } |
| 391 | |
| 392 | if ($a['type'] === 'config') { |
| 393 | $args['config'][$key] = $args[$key]; |
| 394 | } |
| 395 | } |
| 396 | $this->_apply_client_context_params($args); |
| 397 | |
| 398 | return $args; |
| 399 | } |
| 400 | |
| 401 | /** |
| 402 | * Creates a verbose error message for an invalid argument. |
| 403 | * |
| 404 | * @param string $name Name of the argument that is missing. |
| 405 | * @param array $args Provided arguments |
| 406 | * @param bool $useRequired Set to true to show the required fn text if |
| 407 | * available instead of the documentation. |
| 408 | * @return string |
| 409 | */ |
| 410 | private function getArgMessage($name, $args = [], $useRequired = false) |
| 411 | { |
| 412 | $arg = $this->argDefinitions[$name]; |
| 413 | $msg = ''; |
| 414 | $modifiers = []; |
| 415 | if (isset($arg['valid'])) { |
| 416 | $modifiers[] = implode('|', $arg['valid']); |
| 417 | } |
| 418 | if (isset($arg['choice'])) { |
| 419 | $modifiers[] = 'One of ' . implode(', ', $arg['choice']); |
| 420 | } |
| 421 | if ($modifiers) { |
| 422 | $msg .= '(' . implode('; ', $modifiers) . ')'; |
| 423 | } |
| 424 | $msg = wordwrap("{$name}: {$msg}", 75, "\n "); |
| 425 | |
| 426 | if ($useRequired && is_callable($arg['required'])) { |
| 427 | $msg .= "\n\n "; |
| 428 | $msg .= str_replace("\n", "\n ", call_user_func($arg['required'], $args)); |
| 429 | } elseif (isset($arg['doc'])) { |
| 430 | $msg .= wordwrap("\n\n {$arg['doc']}", 75, "\n "); |
| 431 | } |
| 432 | |
| 433 | return $msg; |
| 434 | } |
| 435 | |
| 436 | /** |
| 437 | * Throw when an invalid type is encountered. |
| 438 | * |
| 439 | * @param string $name Name of the value being validated. |
| 440 | * @param mixed $provided The provided value. |
| 441 | * @throws \InvalidArgumentException |
| 442 | */ |
| 443 | private function invalidType($name, $provided) |
| 444 | { |
| 445 | $expected = implode('|', $this->argDefinitions[$name]['valid']); |
| 446 | $msg = "Invalid configuration value " |
| 447 | . "provided for \"{$name}\". Expected {$expected}, but got " |
| 448 | . describe_type($provided) . "\n\n" |
| 449 | . $this->getArgMessage($name); |
| 450 | throw new IAE($msg); |
| 451 | } |
| 452 | |
| 453 | /** |
| 454 | * Throws an exception for missing required arguments. |
| 455 | * |
| 456 | * @param array $args Passed in arguments. |
| 457 | * @throws \InvalidArgumentException |
| 458 | */ |
| 459 | private function throwRequired(array $args) |
| 460 | { |
| 461 | $missing = []; |
| 462 | foreach ($this->argDefinitions as $k => $a) { |
| 463 | if (empty($a['required']) |
| 464 | || isset($a['default']) |
| 465 | || isset($args[$k]) |
| 466 | ) { |
| 467 | continue; |
| 468 | } |
| 469 | $missing[] = $this->getArgMessage($k, $args, true); |
| 470 | } |
| 471 | $msg = "Missing required client configuration options: \n\n"; |
| 472 | $msg .= implode("\n\n", $missing); |
| 473 | throw new IAE($msg); |
| 474 | } |
| 475 | |
| 476 | public static function _apply_retries($value, array &$args, HandlerList $list) |
| 477 | { |
| 478 | // A value of 0 for the config option disables retries |
| 479 | if ($value) { |
| 480 | $config = RetryConfigProvider::unwrap($value); |
| 481 | |
| 482 | if ($config->getMode() === 'legacy') { |
| 483 | // # of retries is 1 less than # of attempts |
| 484 | $decider = RetryMiddleware::createDefaultDecider( |
| 485 | $config->getMaxAttempts() - 1 |
| 486 | ); |
| 487 | $list->appendSign( |
| 488 | Middleware::retry($decider, null, $args['stats']['retries']), |
| 489 | 'retry' |
| 490 | ); |
| 491 | } else { |
| 492 | $list->appendSign( |
| 493 | RetryMiddlewareV2::wrap( |
| 494 | $config, |
| 495 | ['collect_stats' => $args['stats']['retries']] |
| 496 | ), |
| 497 | 'retry' |
| 498 | ); |
| 499 | } |
| 500 | } |
| 501 | } |
| 502 | |
| 503 | public static function _apply_defaults($value, array &$args, HandlerList $list) |
| 504 | { |
| 505 | $config = ConfigModeProvider::unwrap($value); |
| 506 | if ($config->getMode() !== 'legacy') { |
| 507 | if (!isset($args['retries']) && !is_null($config->getRetryMode())) { |
| 508 | $args['retries'] = ['mode' => $config->getRetryMode()]; |
| 509 | } |
| 510 | if ( |
| 511 | !isset($args['sts_regional_endpoints']) |
| 512 | && !is_null($config->getStsRegionalEndpoints()) |
| 513 | ) { |
| 514 | $args['sts_regional_endpoints'] = ['mode' => $config->getStsRegionalEndpoints()]; |
| 515 | } |
| 516 | if ( |
| 517 | !isset($args['s3_us_east_1_regional_endpoint']) |
| 518 | && !is_null($config->getS3UsEast1RegionalEndpoints()) |
| 519 | ) { |
| 520 | $args['s3_us_east_1_regional_endpoint'] = ['mode' => $config->getS3UsEast1RegionalEndpoints()]; |
| 521 | } |
| 522 | |
| 523 | if (!isset($args['http'])) { |
| 524 | $args['http'] = []; |
| 525 | } |
| 526 | if ( |
| 527 | !isset($args['http']['connect_timeout']) |
| 528 | && !is_null($config->getConnectTimeoutInMillis()) |
| 529 | ) { |
| 530 | $args['http']['connect_timeout'] = $config->getConnectTimeoutInMillis() / 1000; |
| 531 | } |
| 532 | if ( |
| 533 | !isset($args['http']['timeout']) |
| 534 | && !is_null($config->getHttpRequestTimeoutInMillis()) |
| 535 | ) { |
| 536 | $args['http']['timeout'] = $config->getHttpRequestTimeoutInMillis() / 1000; |
| 537 | } |
| 538 | } |
| 539 | } |
| 540 | |
| 541 | public static function _apply_disable_request_compression($value, array &$args) { |
| 542 | if (is_callable($value)) { |
| 543 | $value = $value(); |
| 544 | } |
| 545 | if (!is_bool($value)) { |
| 546 | throw new IAE( |
| 547 | "Invalid configuration value provided for 'disable_request_compression'." |
| 548 | . " value must be a bool." |
| 549 | ); |
| 550 | } |
| 551 | $args['config']['disable_request_compression'] = $value; |
| 552 | } |
| 553 | |
| 554 | public static function _default_disable_request_compression(array &$args) { |
| 555 | return ConfigurationResolver::resolve( |
| 556 | 'disable_request_compression', |
| 557 | false, |
| 558 | 'bool', |
| 559 | $args |
| 560 | ); |
| 561 | } |
| 562 | |
| 563 | public static function _apply_min_compression_size($value, array &$args) { |
| 564 | if (is_callable($value)) { |
| 565 | $value = $value(); |
| 566 | } |
| 567 | if (!is_int($value) |
| 568 | || (is_int($value) |
| 569 | && ($value < 0 || $value > 10485760)) |
| 570 | ) { |
| 571 | throw new IAE(" Invalid configuration value provided for 'min_compression_size_bytes'." |
| 572 | . " value must be an integer between 0 and 10485760, inclusive."); |
| 573 | } |
| 574 | $args['config']['request_min_compression_size_bytes'] = $value; |
| 575 | } |
| 576 | |
| 577 | public static function _default_min_compression_size(array &$args) { |
| 578 | return ConfigurationResolver::resolve( |
| 579 | 'request_min_compression_size_bytes', |
| 580 | 10240, |
| 581 | 'int', |
| 582 | $args |
| 583 | ); |
| 584 | } |
| 585 | |
| 586 | public static function _apply_credentials($value, array &$args) |
| 587 | { |
| 588 | if (is_callable($value)) { |
| 589 | return; |
| 590 | } |
| 591 | |
| 592 | if ($value instanceof CredentialsInterface) { |
| 593 | $args['credentials'] = CredentialProvider::fromCredentials($value); |
| 594 | } elseif (is_array($value) |
| 595 | && isset($value['key']) |
| 596 | && isset($value['secret']) |
| 597 | ) { |
| 598 | $args['credentials'] = CredentialProvider::fromCredentials( |
| 599 | new Credentials( |
| 600 | $value['key'], |
| 601 | $value['secret'], |
| 602 | isset($value['token']) ? $value['token'] : null, |
| 603 | isset($value['expires']) ? $value['expires'] : null |
| 604 | ) |
| 605 | ); |
| 606 | } elseif ($value === false) { |
| 607 | $args['credentials'] = CredentialProvider::fromCredentials( |
| 608 | new Credentials('', '') |
| 609 | ); |
| 610 | $args['config']['signature_version'] = 'anonymous'; |
| 611 | } elseif ($value instanceof CacheInterface) { |
| 612 | $args['credentials'] = CredentialProvider::defaultProvider($args); |
| 613 | } else { |
| 614 | throw new IAE('Credentials must be an instance of ' |
| 615 | . "'" . CredentialsInterface::class . ', an associative ' |
| 616 | . 'array that contains "key", "secret", and an optional "token" ' |
| 617 | . 'key-value pairs, a credentials provider function, or false.'); |
| 618 | } |
| 619 | } |
| 620 | |
| 621 | public static function _default_credential_provider(array $args) |
| 622 | { |
| 623 | return CredentialProvider::defaultProvider($args); |
| 624 | } |
| 625 | |
| 626 | public static function _apply_token($value, array &$args) |
| 627 | { |
| 628 | if (is_callable($value)) { |
| 629 | return; |
| 630 | } |
| 631 | |
| 632 | if ($value instanceof Token) { |
| 633 | $args['token'] = TokenProvider::fromToken($value); |
| 634 | } elseif (is_array($value) |
| 635 | && isset($value['token']) |
| 636 | ) { |
| 637 | $args['token'] = TokenProvider::fromToken( |
| 638 | new Token( |
| 639 | $value['token'], |
| 640 | isset($value['expires']) ? $value['expires'] : null |
| 641 | ) |
| 642 | ); |
| 643 | } elseif ($value instanceof CacheInterface) { |
| 644 | $args['token'] = TokenProvider::defaultProvider($args); |
| 645 | } else { |
| 646 | throw new IAE('Token must be an instance of ' |
| 647 | . TokenInterface::class . ', an associative ' |
| 648 | . 'array that contains "token" and an optional "expires" ' |
| 649 | . 'key-value pairs, a token provider function, or false.'); |
| 650 | } |
| 651 | } |
| 652 | |
| 653 | public static function _default_token_provider(array $args) |
| 654 | { |
| 655 | return TokenProvider::defaultProvider($args); |
| 656 | } |
| 657 | |
| 658 | public static function _apply_csm($value, array &$args, HandlerList $list) |
| 659 | { |
| 660 | if ($value === false) { |
| 661 | $value = new Configuration( |
| 662 | false, |
| 663 | \Aws\ClientSideMonitoring\ConfigurationProvider::DEFAULT_HOST, |
| 664 | \Aws\ClientSideMonitoring\ConfigurationProvider::DEFAULT_PORT, |
| 665 | \Aws\ClientSideMonitoring\ConfigurationProvider::DEFAULT_CLIENT_ID |
| 666 | ); |
| 667 | $args['csm'] = $value; |
| 668 | } |
| 669 | |
| 670 | $list->appendBuild( |
| 671 | ApiCallMonitoringMiddleware::wrap( |
| 672 | $args['credentials'], |
| 673 | $value, |
| 674 | $args['region'], |
| 675 | $args['api']->getServiceId() |
| 676 | ), |
| 677 | 'ApiCallMonitoringMiddleware' |
| 678 | ); |
| 679 | |
| 680 | $list->appendAttempt( |
| 681 | ApiCallAttemptMonitoringMiddleware::wrap( |
| 682 | $args['credentials'], |
| 683 | $value, |
| 684 | $args['region'], |
| 685 | $args['api']->getServiceId() |
| 686 | ), |
| 687 | 'ApiCallAttemptMonitoringMiddleware' |
| 688 | ); |
| 689 | } |
| 690 | |
| 691 | public static function _apply_api_provider(callable $value, array &$args) |
| 692 | { |
| 693 | $api = new Service( |
| 694 | ApiProvider::resolve( |
| 695 | $value, |
| 696 | 'api', |
| 697 | $args['service'], |
| 698 | $args['version'] |
| 699 | ), |
| 700 | $value |
| 701 | ); |
| 702 | |
| 703 | if ( |
| 704 | empty($args['config']['signing_name']) |
| 705 | && isset($api['metadata']['signingName']) |
| 706 | ) { |
| 707 | $args['config']['signing_name'] = $api['metadata']['signingName']; |
| 708 | } |
| 709 | |
| 710 | $args['api'] = $api; |
| 711 | $args['parser'] = Service::createParser($api); |
| 712 | $args['error_parser'] = Service::createErrorParser($api->getProtocol(), $api); |
| 713 | } |
| 714 | |
| 715 | public static function _apply_endpoint_provider($value, array &$args) |
| 716 | { |
| 717 | if (!isset($args['endpoint'])) { |
| 718 | if ($value instanceof \Aws\EndpointV2\EndpointProviderV2) { |
| 719 | $options = self::getEndpointProviderOptions($args); |
| 720 | $value = PartitionEndpointProvider::defaultProvider($options) |
| 721 | ->getPartition($args['region'], $args['service']); |
| 722 | } |
| 723 | |
| 724 | $endpointPrefix = isset($args['api']['metadata']['endpointPrefix']) |
| 725 | ? $args['api']['metadata']['endpointPrefix'] |
| 726 | : $args['service']; |
| 727 | |
| 728 | // Check region is a valid host label when it is being used to |
| 729 | // generate an endpoint |
| 730 | if (!self::isValidRegion($args['region'])) { |
| 731 | throw new InvalidRegionException('Region must be a valid RFC' |
| 732 | . ' host label.'); |
| 733 | } |
| 734 | $serviceEndpoints = |
| 735 | is_array($value) && isset($value['services'][$args['service']]['endpoints']) |
| 736 | ? $value['services'][$args['service']]['endpoints'] |
| 737 | : null; |
| 738 | if (isset($serviceEndpoints[$args['region']]['deprecated'])) { |
| 739 | trigger_error("The service " . $args['service'] . "has " |
| 740 | . " deprecated the region " . $args['region'] . ".", |
| 741 | E_USER_WARNING |
| 742 | ); |
| 743 | } |
| 744 | |
| 745 | $args['region'] = \Aws\strip_fips_pseudo_regions($args['region']); |
| 746 | |
| 747 | // Invoke the endpoint provider and throw if it does not resolve. |
| 748 | $result = EndpointProvider::resolve($value, [ |
| 749 | 'service' => $endpointPrefix, |
| 750 | 'region' => $args['region'], |
| 751 | 'scheme' => $args['scheme'], |
| 752 | 'options' => self::getEndpointProviderOptions($args), |
| 753 | ]); |
| 754 | |
| 755 | $args['endpoint'] = $result['endpoint']; |
| 756 | |
| 757 | if (empty($args['config']['signature_version'])) { |
| 758 | if ( |
| 759 | isset($args['api']) |
| 760 | && $args['api']->getSignatureVersion() == 'bearer' |
| 761 | ) { |
| 762 | $args['config']['signature_version'] = 'bearer'; |
| 763 | } elseif (isset($result['signatureVersion'])) { |
| 764 | $args['config']['signature_version'] = $result['signatureVersion']; |
| 765 | } |
| 766 | } |
| 767 | |
| 768 | if ( |
| 769 | empty($args['config']['signing_region']) |
| 770 | && isset($result['signingRegion']) |
| 771 | ) { |
| 772 | $args['config']['signing_region'] = $result['signingRegion']; |
| 773 | } |
| 774 | |
| 775 | if ( |
| 776 | empty($args['config']['signing_name']) |
| 777 | && isset($result['signingName']) |
| 778 | ) { |
| 779 | $args['config']['signing_name'] = $result['signingName']; |
| 780 | } |
| 781 | } |
| 782 | } |
| 783 | |
| 784 | public static function _apply_endpoint_discovery($value, array &$args) { |
| 785 | $args['endpoint_discovery'] = $value; |
| 786 | } |
| 787 | |
| 788 | public static function _default_endpoint_discovery_provider(array $args) |
| 789 | { |
| 790 | return ConfigurationProvider::defaultProvider($args); |
| 791 | } |
| 792 | |
| 793 | public static function _apply_use_fips_endpoint($value, array &$args) { |
| 794 | if ($value instanceof CacheInterface) { |
| 795 | $value = UseFipsConfigProvider::defaultProvider($args); |
| 796 | } |
| 797 | if (is_callable($value)) { |
| 798 | $value = $value(); |
| 799 | } |
| 800 | if ($value instanceof PromiseInterface) { |
| 801 | $value = $value->wait(); |
| 802 | } |
| 803 | if ($value instanceof UseFipsEndpointConfigurationInterface) { |
| 804 | $args['config']['use_fips_endpoint'] = $value; |
| 805 | } else { |
| 806 | // The Configuration class itself will validate other inputs |
| 807 | $args['config']['use_fips_endpoint'] = new UseFipsEndpointConfiguration($value); |
| 808 | } |
| 809 | } |
| 810 | |
| 811 | public static function _default_use_fips_endpoint(array &$args) { |
| 812 | return UseFipsConfigProvider::defaultProvider($args); |
| 813 | } |
| 814 | |
| 815 | public static function _apply_use_dual_stack_endpoint($value, array &$args) { |
| 816 | if ($value instanceof CacheInterface) { |
| 817 | $value = UseDualStackConfigProvider::defaultProvider($args); |
| 818 | } |
| 819 | if (is_callable($value)) { |
| 820 | $value = $value(); |
| 821 | } |
| 822 | if ($value instanceof PromiseInterface) { |
| 823 | $value = $value->wait(); |
| 824 | } |
| 825 | if ($value instanceof UseDualStackEndpointConfigurationInterface) { |
| 826 | $args['config']['use_dual_stack_endpoint'] = $value; |
| 827 | } else { |
| 828 | // The Configuration class itself will validate other inputs |
| 829 | $args['config']['use_dual_stack_endpoint'] = |
| 830 | new UseDualStackEndpointConfiguration($value, $args['region']); |
| 831 | } |
| 832 | } |
| 833 | |
| 834 | public static function _default_use_dual_stack_endpoint(array &$args) { |
| 835 | return UseDualStackConfigProvider::defaultProvider($args); |
| 836 | } |
| 837 | |
| 838 | public static function _apply_serializer($value, array &$args, HandlerList $list) |
| 839 | { |
| 840 | $list->prependBuild(Middleware::requestBuilder($value), 'builder'); |
| 841 | } |
| 842 | |
| 843 | public static function _apply_debug($value, array &$args, HandlerList $list) |
| 844 | { |
| 845 | if ($value !== false) { |
| 846 | $list->interpose( |
| 847 | new TraceMiddleware( |
| 848 | $value === true ? [] : $value, |
| 849 | $args['api']) |
| 850 | ); |
| 851 | } |
| 852 | } |
| 853 | |
| 854 | public static function _apply_stats($value, array &$args, HandlerList $list) |
| 855 | { |
| 856 | // Create an array of stat collectors that are disabled (set to false) |
| 857 | // by default. If the user has passed in true, enable all stat |
| 858 | // collectors. |
| 859 | $defaults = array_fill_keys( |
| 860 | ['http', 'retries', 'timer'], |
| 861 | $value === true |
| 862 | ); |
| 863 | $args['stats'] = is_array($value) |
| 864 | ? array_replace($defaults, $value) |
| 865 | : $defaults; |
| 866 | |
| 867 | if ($args['stats']['timer']) { |
| 868 | $list->prependInit(Middleware::timer(), 'timer'); |
| 869 | } |
| 870 | } |
| 871 | |
| 872 | public static function _apply_profile($_, array &$args) |
| 873 | { |
| 874 | $args['credentials'] = CredentialProvider::ini($args['profile']); |
| 875 | } |
| 876 | |
| 877 | public static function _apply_validate($value, array &$args, HandlerList $list) |
| 878 | { |
| 879 | if ($value === false) { |
| 880 | return; |
| 881 | } |
| 882 | |
| 883 | $validator = $value === true |
| 884 | ? new Validator() |
| 885 | : new Validator($value); |
| 886 | $list->appendValidate( |
| 887 | Middleware::validation($args['api'], $validator), |
| 888 | 'validation' |
| 889 | ); |
| 890 | } |
| 891 | |
| 892 | public static function _apply_handler($value, array &$args, HandlerList $list) |
| 893 | { |
| 894 | $list->setHandler($value); |
| 895 | } |
| 896 | |
| 897 | public static function _default_handler(array &$args) |
| 898 | { |
| 899 | return new WrappedHttpHandler( |
| 900 | default_http_handler(), |
| 901 | $args['parser'], |
| 902 | $args['error_parser'], |
| 903 | $args['exception_class'], |
| 904 | $args['stats']['http'] |
| 905 | ); |
| 906 | } |
| 907 | |
| 908 | public static function _apply_http_handler($value, array &$args, HandlerList $list) |
| 909 | { |
| 910 | $args['handler'] = new WrappedHttpHandler( |
| 911 | $value, |
| 912 | $args['parser'], |
| 913 | $args['error_parser'], |
| 914 | $args['exception_class'], |
| 915 | $args['stats']['http'] |
| 916 | ); |
| 917 | } |
| 918 | |
| 919 | public static function _apply_user_agent($inputUserAgent, array &$args, HandlerList $list) |
| 920 | { |
| 921 | //Add SDK version |
| 922 | $userAgent = ['aws-sdk-php/' . Sdk::VERSION]; |
| 923 | |
| 924 | //If on HHVM add the HHVM version |
| 925 | if (defined('HHVM_VERSION')) { |
| 926 | $userAgent []= 'HHVM/' . HHVM_VERSION; |
| 927 | } |
| 928 | |
| 929 | //Add OS version |
| 930 | $disabledFunctions = explode(',', ini_get('disable_functions')); |
| 931 | if (function_exists('php_uname') |
| 932 | && !in_array('php_uname', $disabledFunctions, true) |
| 933 | ) { |
| 934 | $osName = "OS/" . php_uname('s') . '#' . php_uname('r'); |
| 935 | if (!empty($osName)) { |
| 936 | $userAgent []= $osName; |
| 937 | } |
| 938 | } |
| 939 | |
| 940 | //Add the language version |
| 941 | $userAgent []= 'lang/php#' . phpversion(); |
| 942 | |
| 943 | //Add exec environment if present |
| 944 | if ($executionEnvironment = getenv('AWS_EXECUTION_ENV')) { |
| 945 | $userAgent []= $executionEnvironment; |
| 946 | } |
| 947 | |
| 948 | //Add endpoint discovery if set |
| 949 | if (isset($args['endpoint_discovery'])) { |
| 950 | if (($args['endpoint_discovery'] instanceof \Aws\EndpointDiscovery\Configuration |
| 951 | && $args['endpoint_discovery']->isEnabled()) |
| 952 | ) { |
| 953 | $userAgent []= 'cfg/endpoint-discovery'; |
| 954 | } elseif (is_array($args['endpoint_discovery']) |
| 955 | && isset($args['endpoint_discovery']['enabled']) |
| 956 | && $args['endpoint_discovery']['enabled'] |
| 957 | ) { |
| 958 | $userAgent []= 'cfg/endpoint-discovery'; |
| 959 | } |
| 960 | } |
| 961 | |
| 962 | //Add retry mode if set |
| 963 | if (isset($args['retries'])) { |
| 964 | if ($args['retries'] instanceof \Aws\Retry\Configuration) { |
| 965 | $userAgent []= 'cfg/retry-mode#' . $args["retries"]->getMode(); |
| 966 | } elseif (is_array($args['retries']) |
| 967 | && isset($args["retries"]["mode"]) |
| 968 | ) { |
| 969 | $userAgent []= 'cfg/retry-mode#' . $args["retries"]["mode"]; |
| 970 | } |
| 971 | } |
| 972 | //Add the input to the end |
| 973 | if ($inputUserAgent){ |
| 974 | if (!is_array($inputUserAgent)) { |
| 975 | $inputUserAgent = [$inputUserAgent]; |
| 976 | } |
| 977 | $inputUserAgent = array_map('strval', $inputUserAgent); |
| 978 | $userAgent = array_merge($userAgent, $inputUserAgent); |
| 979 | } |
| 980 | |
| 981 | $args['ua_append'] = $userAgent; |
| 982 | |
| 983 | $list->appendBuild(static function (callable $handler) use ($userAgent) { |
| 984 | return function ( |
| 985 | CommandInterface $command, |
| 986 | RequestInterface $request |
| 987 | ) use ($handler, $userAgent) { |
| 988 | return $handler( |
| 989 | $command, |
| 990 | $request->withHeader( |
| 991 | 'X-Amz-User-Agent', |
| 992 | implode(' ', array_merge( |
| 993 | $userAgent, |
| 994 | $request->getHeader('X-Amz-User-Agent') |
| 995 | )) |
| 996 | )->withHeader( |
| 997 | 'User-Agent', |
| 998 | implode(' ', array_merge( |
| 999 | $userAgent, |
| 1000 | $request->getHeader('User-Agent') |
| 1001 | )) |
| 1002 | ) |
| 1003 | ); |
| 1004 | }; |
| 1005 | }); |
| 1006 | } |
| 1007 | |
| 1008 | public static function _apply_endpoint($value, array &$args, HandlerList $list) |
| 1009 | { |
| 1010 | if (empty($value)) { |
| 1011 | unset($args['endpoint']); |
| 1012 | return; |
| 1013 | } |
| 1014 | |
| 1015 | $args['endpoint'] = $value; |
| 1016 | } |
| 1017 | |
| 1018 | public static function _apply_idempotency_auto_fill( |
| 1019 | $value, |
| 1020 | array &$args, |
| 1021 | HandlerList $list |
| 1022 | ) { |
| 1023 | $enabled = false; |
| 1024 | $generator = null; |
| 1025 | |
| 1026 | |
| 1027 | if (is_bool($value)) { |
| 1028 | $enabled = $value; |
| 1029 | } elseif (is_callable($value)) { |
| 1030 | $enabled = true; |
| 1031 | $generator = $value; |
| 1032 | } |
| 1033 | |
| 1034 | if ($enabled) { |
| 1035 | $list->prependInit( |
| 1036 | IdempotencyTokenMiddleware::wrap($args['api'], $generator), |
| 1037 | 'idempotency_auto_fill' |
| 1038 | ); |
| 1039 | } |
| 1040 | } |
| 1041 | |
| 1042 | public static function _default_endpoint_provider(array $args) |
| 1043 | { |
| 1044 | $service = isset($args['api']) ? $args['api'] : null; |
| 1045 | $serviceName = isset($service) ? $service->getServiceName() : null; |
| 1046 | $apiVersion = isset($service) ? $service->getApiVersion() : null; |
| 1047 | |
| 1048 | if (self::isValidService($serviceName) |
| 1049 | && self::isValidApiVersion($serviceName, $apiVersion) |
| 1050 | ) { |
| 1051 | $ruleset = EndpointDefinitionProvider::getEndpointRuleset( |
| 1052 | $service->getServiceName(), |
| 1053 | $service->getApiVersion() |
| 1054 | ); |
| 1055 | return new \Aws\EndpointV2\EndpointProviderV2( |
| 1056 | $ruleset, |
| 1057 | EndpointDefinitionProvider::getPartitions() |
| 1058 | ); |
| 1059 | } |
| 1060 | $options = self::getEndpointProviderOptions($args); |
| 1061 | return PartitionEndpointProvider::defaultProvider($options) |
| 1062 | ->getPartition($args['region'], $args['service']); |
| 1063 | } |
| 1064 | |
| 1065 | public static function _default_serializer(array $args) |
| 1066 | { |
| 1067 | return Service::createSerializer( |
| 1068 | $args['api'], |
| 1069 | $args['endpoint'] |
| 1070 | ); |
| 1071 | } |
| 1072 | |
| 1073 | public static function _default_signature_provider() |
| 1074 | { |
| 1075 | return SignatureProvider::defaultProvider(); |
| 1076 | } |
| 1077 | |
| 1078 | public static function _default_signature_version(array &$args) |
| 1079 | { |
| 1080 | if (isset($args['config']['signature_version'])) { |
| 1081 | return $args['config']['signature_version']; |
| 1082 | } |
| 1083 | |
| 1084 | $args['__partition_result'] = isset($args['__partition_result']) |
| 1085 | ? isset($args['__partition_result']) |
| 1086 | : call_user_func(PartitionEndpointProvider::defaultProvider(), [ |
| 1087 | 'service' => $args['service'], |
| 1088 | 'region' => $args['region'], |
| 1089 | ]); |
| 1090 | |
| 1091 | return isset($args['__partition_result']['signatureVersion']) |
| 1092 | ? $args['__partition_result']['signatureVersion'] |
| 1093 | : $args['api']->getSignatureVersion(); |
| 1094 | } |
| 1095 | |
| 1096 | public static function _default_signing_name(array &$args) |
| 1097 | { |
| 1098 | if (isset($args['config']['signing_name'])) { |
| 1099 | return $args['config']['signing_name']; |
| 1100 | } |
| 1101 | |
| 1102 | $args['__partition_result'] = isset($args['__partition_result']) |
| 1103 | ? isset($args['__partition_result']) |
| 1104 | : call_user_func(PartitionEndpointProvider::defaultProvider(), [ |
| 1105 | 'service' => $args['service'], |
| 1106 | 'region' => $args['region'], |
| 1107 | ]); |
| 1108 | |
| 1109 | if (isset($args['__partition_result']['signingName'])) { |
| 1110 | return $args['__partition_result']['signingName']; |
| 1111 | } |
| 1112 | |
| 1113 | if ($signingName = $args['api']->getSigningName()) { |
| 1114 | return $signingName; |
| 1115 | } |
| 1116 | |
| 1117 | return $args['service']; |
| 1118 | } |
| 1119 | |
| 1120 | public static function _default_signing_region(array &$args) |
| 1121 | { |
| 1122 | if (isset($args['config']['signing_region'])) { |
| 1123 | return $args['config']['signing_region']; |
| 1124 | } |
| 1125 | |
| 1126 | $args['__partition_result'] = isset($args['__partition_result']) |
| 1127 | ? isset($args['__partition_result']) |
| 1128 | : call_user_func(PartitionEndpointProvider::defaultProvider(), [ |
| 1129 | 'service' => $args['service'], |
| 1130 | 'region' => $args['region'], |
| 1131 | ]); |
| 1132 | |
| 1133 | return isset($args['__partition_result']['signingRegion']) |
| 1134 | ? $args['__partition_result']['signingRegion'] |
| 1135 | : $args['region']; |
| 1136 | } |
| 1137 | |
| 1138 | public static function _apply_ignore_configured_endpoint_urls($value, array &$args) |
| 1139 | { |
| 1140 | $args['config']['ignore_configured_endpoint_urls'] = $value; |
| 1141 | } |
| 1142 | |
| 1143 | public static function _default_ignore_configured_endpoint_urls(array &$args) |
| 1144 | { |
| 1145 | return ConfigurationResolver::resolve( |
| 1146 | 'ignore_configured_endpoint_urls', |
| 1147 | false, |
| 1148 | 'bool', |
| 1149 | $args |
| 1150 | ); |
| 1151 | } |
| 1152 | |
| 1153 | public static function _default_endpoint(array &$args) |
| 1154 | { |
| 1155 | if ($args['config']['ignore_configured_endpoint_urls'] |
| 1156 | || !self::isValidService($args['service']) |
| 1157 | ) { |
| 1158 | return ''; |
| 1159 | } |
| 1160 | |
| 1161 | $serviceIdentifier = \Aws\manifest($args['service'])['serviceIdentifier']; |
| 1162 | $value = ConfigurationResolver::resolve( |
| 1163 | 'endpoint_url_' . $serviceIdentifier, |
| 1164 | '', |
| 1165 | 'string', |
| 1166 | $args + [ |
| 1167 | 'ini_resolver_options' => [ |
| 1168 | 'section' => 'services', |
| 1169 | 'subsection' => $serviceIdentifier, |
| 1170 | 'key' => 'endpoint_url' |
| 1171 | ] |
| 1172 | ] |
| 1173 | ); |
| 1174 | |
| 1175 | if (empty($value)) { |
| 1176 | $value = ConfigurationResolver::resolve( |
| 1177 | 'endpoint_url', |
| 1178 | '', |
| 1179 | 'string', |
| 1180 | $args |
| 1181 | ); |
| 1182 | } |
| 1183 | |
| 1184 | return $value; |
| 1185 | } |
| 1186 | |
| 1187 | public static function _apply_region($value, array &$args) |
| 1188 | { |
| 1189 | if (empty($value)) { |
| 1190 | self::_missing_region($args); |
| 1191 | } |
| 1192 | $args['region'] = $value; |
| 1193 | } |
| 1194 | |
| 1195 | public static function _default_region(&$args) |
| 1196 | { |
| 1197 | return ConfigurationResolver::resolve('region', '', 'string'); |
| 1198 | } |
| 1199 | |
| 1200 | public static function _missing_region(array $args) |
| 1201 | { |
| 1202 | $service = isset($args['service']) ? $args['service'] : ''; |
| 1203 | |
| 1204 | $msg = <<<EOT |
| 1205 | Missing required client configuration options: |
| 1206 | |
| 1207 | region: (string) |
| 1208 | |
| 1209 | A "region" configuration value is required for the "{$service}" service |
| 1210 | (e.g., "us-west-2"). A list of available public regions and endpoints can be |
| 1211 | found at http://docs.aws.amazon.com/general/latest/gr/rande.html. |
| 1212 | EOT; |
| 1213 | throw new IAE($msg); |
| 1214 | } |
| 1215 | |
| 1216 | /** |
| 1217 | * Extracts client options for the endpoint provider to its own array |
| 1218 | * |
| 1219 | * @param array $args |
| 1220 | * @return array |
| 1221 | */ |
| 1222 | private static function getEndpointProviderOptions(array $args) |
| 1223 | { |
| 1224 | $options = []; |
| 1225 | $optionKeys = [ |
| 1226 | 'sts_regional_endpoints', |
| 1227 | 's3_us_east_1_regional_endpoint', |
| 1228 | ]; |
| 1229 | $configKeys = [ |
| 1230 | 'use_dual_stack_endpoint', |
| 1231 | 'use_fips_endpoint', |
| 1232 | ]; |
| 1233 | foreach ($optionKeys as $key) { |
| 1234 | if (isset($args[$key])) { |
| 1235 | $options[$key] = $args[$key]; |
| 1236 | } |
| 1237 | } |
| 1238 | foreach ($configKeys as $key) { |
| 1239 | if (isset($args['config'][$key])) { |
| 1240 | $options[$key] = $args['config'][$key]; |
| 1241 | } |
| 1242 | } |
| 1243 | return $options; |
| 1244 | } |
| 1245 | |
| 1246 | /** |
| 1247 | * Validates a region to be used for endpoint construction |
| 1248 | * |
| 1249 | * @param $region |
| 1250 | * @return bool |
| 1251 | */ |
| 1252 | private static function isValidRegion($region) |
| 1253 | { |
| 1254 | return is_valid_hostlabel($region); |
| 1255 | } |
| 1256 | |
| 1257 | private function _apply_client_context_params(array $args) |
| 1258 | { |
| 1259 | if (isset($args['api']) |
| 1260 | && !empty($args['api']->getClientContextParams())) |
| 1261 | { |
| 1262 | $clientContextParams = $args['api']->getClientContextParams(); |
| 1263 | foreach($clientContextParams as $paramName => $paramDefinition) { |
| 1264 | $definition = [ |
| 1265 | 'type' => 'value', |
| 1266 | 'valid' => [$paramDefinition['type']], |
| 1267 | 'doc' => isset($paramDefinition['documentation']) ? |
| 1268 | $paramDefinition['documentation'] : null |
| 1269 | ]; |
| 1270 | $this->argDefinitions[$paramName] = $definition; |
| 1271 | |
| 1272 | if (isset($args[$paramName])) { |
| 1273 | $fn = self::$typeMap[$paramDefinition['type']]; |
| 1274 | if (!$fn($args[$paramName])) { |
| 1275 | $this->invalidType($paramName, $args[$paramName]); |
| 1276 | } |
| 1277 | } |
| 1278 | } |
| 1279 | } |
| 1280 | } |
| 1281 | |
| 1282 | private static function isValidService($service) { |
| 1283 | if (is_null($service)) { |
| 1284 | return false; |
| 1285 | } |
| 1286 | $services = \Aws\manifest(); |
| 1287 | return isset($services[$service]); |
| 1288 | } |
| 1289 | |
| 1290 | private static function isValidApiVersion($service, $apiVersion) { |
| 1291 | if (is_null($apiVersion)) { |
| 1292 | return false; |
| 1293 | } |
| 1294 | return is_dir( |
| 1295 | __DIR__ . "/data/{$service}/$apiVersion" |
| 1296 | ); |
| 1297 | } |
| 1298 | } |
| 1299 |