CloudFrontClient.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <?php
  2. namespace Aws\CloudFront;
  3. use Aws\AwsClient;
  4. /**
  5. * This client is used to interact with the **Amazon CloudFront** service.
  6. *
  7. * @method \Aws\Result createCloudFrontOriginAccessIdentity(array $args = [])
  8. * @method \GuzzleHttp\Promise\Promise createCloudFrontOriginAccessIdentityAsync(array $args = [])
  9. * @method \Aws\Result createDistribution(array $args = [])
  10. * @method \GuzzleHttp\Promise\Promise createDistributionAsync(array $args = [])
  11. * @method \Aws\Result createInvalidation(array $args = [])
  12. * @method \GuzzleHttp\Promise\Promise createInvalidationAsync(array $args = [])
  13. * @method \Aws\Result createStreamingDistribution(array $args = [])
  14. * @method \GuzzleHttp\Promise\Promise createStreamingDistributionAsync(array $args = [])
  15. * @method \Aws\Result deleteCloudFrontOriginAccessIdentity(array $args = [])
  16. * @method \GuzzleHttp\Promise\Promise deleteCloudFrontOriginAccessIdentityAsync(array $args = [])
  17. * @method \Aws\Result deleteDistribution(array $args = [])
  18. * @method \GuzzleHttp\Promise\Promise deleteDistributionAsync(array $args = [])
  19. * @method \Aws\Result deleteStreamingDistribution(array $args = [])
  20. * @method \GuzzleHttp\Promise\Promise deleteStreamingDistributionAsync(array $args = [])
  21. * @method \Aws\Result getCloudFrontOriginAccessIdentity(array $args = [])
  22. * @method \GuzzleHttp\Promise\Promise getCloudFrontOriginAccessIdentityAsync(array $args = [])
  23. * @method \Aws\Result getCloudFrontOriginAccessIdentityConfig(array $args = [])
  24. * @method \GuzzleHttp\Promise\Promise getCloudFrontOriginAccessIdentityConfigAsync(array $args = [])
  25. * @method \Aws\Result getDistribution(array $args = [])
  26. * @method \GuzzleHttp\Promise\Promise getDistributionAsync(array $args = [])
  27. * @method \Aws\Result getDistributionConfig(array $args = [])
  28. * @method \GuzzleHttp\Promise\Promise getDistributionConfigAsync(array $args = [])
  29. * @method \Aws\Result getInvalidation(array $args = [])
  30. * @method \GuzzleHttp\Promise\Promise getInvalidationAsync(array $args = [])
  31. * @method \Aws\Result getStreamingDistribution(array $args = [])
  32. * @method \GuzzleHttp\Promise\Promise getStreamingDistributionAsync(array $args = [])
  33. * @method \Aws\Result getStreamingDistributionConfig(array $args = [])
  34. * @method \GuzzleHttp\Promise\Promise getStreamingDistributionConfigAsync(array $args = [])
  35. * @method \Aws\Result listCloudFrontOriginAccessIdentities(array $args = [])
  36. * @method \GuzzleHttp\Promise\Promise listCloudFrontOriginAccessIdentitiesAsync(array $args = [])
  37. * @method \Aws\Result listDistributions(array $args = [])
  38. * @method \GuzzleHttp\Promise\Promise listDistributionsAsync(array $args = [])
  39. * @method \Aws\Result listDistributionsByWebACLId(array $args = [])
  40. * @method \GuzzleHttp\Promise\Promise listDistributionsByWebACLIdAsync(array $args = [])
  41. * @method \Aws\Result listInvalidations(array $args = [])
  42. * @method \GuzzleHttp\Promise\Promise listInvalidationsAsync(array $args = [])
  43. * @method \Aws\Result listStreamingDistributions(array $args = [])
  44. * @method \GuzzleHttp\Promise\Promise listStreamingDistributionsAsync(array $args = [])
  45. * @method \Aws\Result updateCloudFrontOriginAccessIdentity(array $args = [])
  46. * @method \GuzzleHttp\Promise\Promise updateCloudFrontOriginAccessIdentityAsync(array $args = [])
  47. * @method \Aws\Result updateDistribution(array $args = [])
  48. * @method \GuzzleHttp\Promise\Promise updateDistributionAsync(array $args = [])
  49. * @method \Aws\Result updateStreamingDistribution(array $args = [])
  50. * @method \GuzzleHttp\Promise\Promise updateStreamingDistributionAsync(array $args = [])
  51. * @method \Aws\Result createDistributionWithTags(array $args = []) (supported in versions 2016-08-01, 2016-08-20, 2016-09-07, 2016-09-29, 2016-11-25, 2017-03-25, 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  52. * @method \GuzzleHttp\Promise\Promise createDistributionWithTagsAsync(array $args = []) (supported in versions 2016-08-01, 2016-08-20, 2016-09-07, 2016-09-29, 2016-11-25, 2017-03-25, 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  53. * @method \Aws\Result createStreamingDistributionWithTags(array $args = []) (supported in versions 2016-08-01, 2016-08-20, 2016-09-07, 2016-09-29, 2016-11-25, 2017-03-25, 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  54. * @method \GuzzleHttp\Promise\Promise createStreamingDistributionWithTagsAsync(array $args = []) (supported in versions 2016-08-01, 2016-08-20, 2016-09-07, 2016-09-29, 2016-11-25, 2017-03-25, 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  55. * @method \Aws\Result listTagsForResource(array $args = []) (supported in versions 2016-08-01, 2016-08-20, 2016-09-07, 2016-09-29, 2016-11-25, 2017-03-25, 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  56. * @method \GuzzleHttp\Promise\Promise listTagsForResourceAsync(array $args = []) (supported in versions 2016-08-01, 2016-08-20, 2016-09-07, 2016-09-29, 2016-11-25, 2017-03-25, 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  57. * @method \Aws\Result tagResource(array $args = []) (supported in versions 2016-08-01, 2016-08-20, 2016-09-07, 2016-09-29, 2016-11-25, 2017-03-25, 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  58. * @method \GuzzleHttp\Promise\Promise tagResourceAsync(array $args = []) (supported in versions 2016-08-01, 2016-08-20, 2016-09-07, 2016-09-29, 2016-11-25, 2017-03-25, 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  59. * @method \Aws\Result untagResource(array $args = []) (supported in versions 2016-08-01, 2016-08-20, 2016-09-07, 2016-09-29, 2016-11-25, 2017-03-25, 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  60. * @method \GuzzleHttp\Promise\Promise untagResourceAsync(array $args = []) (supported in versions 2016-08-01, 2016-08-20, 2016-09-07, 2016-09-29, 2016-11-25, 2017-03-25, 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  61. * @method \Aws\Result deleteServiceLinkedRole(array $args = []) (supported in versions 2017-03-25)
  62. * @method \GuzzleHttp\Promise\Promise deleteServiceLinkedRoleAsync(array $args = []) (supported in versions 2017-03-25)
  63. * @method \Aws\Result createFieldLevelEncryptionConfig(array $args = []) (supported in versions 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  64. * @method \GuzzleHttp\Promise\Promise createFieldLevelEncryptionConfigAsync(array $args = []) (supported in versions 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  65. * @method \Aws\Result createFieldLevelEncryptionProfile(array $args = []) (supported in versions 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  66. * @method \GuzzleHttp\Promise\Promise createFieldLevelEncryptionProfileAsync(array $args = []) (supported in versions 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  67. * @method \Aws\Result createPublicKey(array $args = []) (supported in versions 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  68. * @method \GuzzleHttp\Promise\Promise createPublicKeyAsync(array $args = []) (supported in versions 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  69. * @method \Aws\Result deleteFieldLevelEncryptionConfig(array $args = []) (supported in versions 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  70. * @method \GuzzleHttp\Promise\Promise deleteFieldLevelEncryptionConfigAsync(array $args = []) (supported in versions 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  71. * @method \Aws\Result deleteFieldLevelEncryptionProfile(array $args = []) (supported in versions 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  72. * @method \GuzzleHttp\Promise\Promise deleteFieldLevelEncryptionProfileAsync(array $args = []) (supported in versions 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  73. * @method \Aws\Result deletePublicKey(array $args = []) (supported in versions 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  74. * @method \GuzzleHttp\Promise\Promise deletePublicKeyAsync(array $args = []) (supported in versions 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  75. * @method \Aws\Result getFieldLevelEncryption(array $args = []) (supported in versions 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  76. * @method \GuzzleHttp\Promise\Promise getFieldLevelEncryptionAsync(array $args = []) (supported in versions 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  77. * @method \Aws\Result getFieldLevelEncryptionConfig(array $args = []) (supported in versions 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  78. * @method \GuzzleHttp\Promise\Promise getFieldLevelEncryptionConfigAsync(array $args = []) (supported in versions 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  79. * @method \Aws\Result getFieldLevelEncryptionProfile(array $args = []) (supported in versions 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  80. * @method \GuzzleHttp\Promise\Promise getFieldLevelEncryptionProfileAsync(array $args = []) (supported in versions 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  81. * @method \Aws\Result getFieldLevelEncryptionProfileConfig(array $args = []) (supported in versions 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  82. * @method \GuzzleHttp\Promise\Promise getFieldLevelEncryptionProfileConfigAsync(array $args = []) (supported in versions 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  83. * @method \Aws\Result getPublicKey(array $args = []) (supported in versions 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  84. * @method \GuzzleHttp\Promise\Promise getPublicKeyAsync(array $args = []) (supported in versions 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  85. * @method \Aws\Result getPublicKeyConfig(array $args = []) (supported in versions 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  86. * @method \GuzzleHttp\Promise\Promise getPublicKeyConfigAsync(array $args = []) (supported in versions 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  87. * @method \Aws\Result listFieldLevelEncryptionConfigs(array $args = []) (supported in versions 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  88. * @method \GuzzleHttp\Promise\Promise listFieldLevelEncryptionConfigsAsync(array $args = []) (supported in versions 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  89. * @method \Aws\Result listFieldLevelEncryptionProfiles(array $args = []) (supported in versions 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  90. * @method \GuzzleHttp\Promise\Promise listFieldLevelEncryptionProfilesAsync(array $args = []) (supported in versions 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  91. * @method \Aws\Result listPublicKeys(array $args = []) (supported in versions 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  92. * @method \GuzzleHttp\Promise\Promise listPublicKeysAsync(array $args = []) (supported in versions 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  93. * @method \Aws\Result updateFieldLevelEncryptionConfig(array $args = []) (supported in versions 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  94. * @method \GuzzleHttp\Promise\Promise updateFieldLevelEncryptionConfigAsync(array $args = []) (supported in versions 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  95. * @method \Aws\Result updateFieldLevelEncryptionProfile(array $args = []) (supported in versions 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  96. * @method \GuzzleHttp\Promise\Promise updateFieldLevelEncryptionProfileAsync(array $args = []) (supported in versions 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  97. * @method \Aws\Result updatePublicKey(array $args = []) (supported in versions 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  98. * @method \GuzzleHttp\Promise\Promise updatePublicKeyAsync(array $args = []) (supported in versions 2017-10-30, 2018-06-18, 2018-11-05, 2019-03-26, 2020-05-31)
  99. * @method \Aws\Result createCachePolicy(array $args = []) (supported in versions 2020-05-31)
  100. * @method \GuzzleHttp\Promise\Promise createCachePolicyAsync(array $args = []) (supported in versions 2020-05-31)
  101. * @method \Aws\Result createKeyGroup(array $args = []) (supported in versions 2020-05-31)
  102. * @method \GuzzleHttp\Promise\Promise createKeyGroupAsync(array $args = []) (supported in versions 2020-05-31)
  103. * @method \Aws\Result createMonitoringSubscription(array $args = []) (supported in versions 2020-05-31)
  104. * @method \GuzzleHttp\Promise\Promise createMonitoringSubscriptionAsync(array $args = []) (supported in versions 2020-05-31)
  105. * @method \Aws\Result createOriginRequestPolicy(array $args = []) (supported in versions 2020-05-31)
  106. * @method \GuzzleHttp\Promise\Promise createOriginRequestPolicyAsync(array $args = []) (supported in versions 2020-05-31)
  107. * @method \Aws\Result createRealtimeLogConfig(array $args = []) (supported in versions 2020-05-31)
  108. * @method \GuzzleHttp\Promise\Promise createRealtimeLogConfigAsync(array $args = []) (supported in versions 2020-05-31)
  109. * @method \Aws\Result deleteCachePolicy(array $args = []) (supported in versions 2020-05-31)
  110. * @method \GuzzleHttp\Promise\Promise deleteCachePolicyAsync(array $args = []) (supported in versions 2020-05-31)
  111. * @method \Aws\Result deleteKeyGroup(array $args = []) (supported in versions 2020-05-31)
  112. * @method \GuzzleHttp\Promise\Promise deleteKeyGroupAsync(array $args = []) (supported in versions 2020-05-31)
  113. * @method \Aws\Result deleteMonitoringSubscription(array $args = []) (supported in versions 2020-05-31)
  114. * @method \GuzzleHttp\Promise\Promise deleteMonitoringSubscriptionAsync(array $args = []) (supported in versions 2020-05-31)
  115. * @method \Aws\Result deleteOriginRequestPolicy(array $args = []) (supported in versions 2020-05-31)
  116. * @method \GuzzleHttp\Promise\Promise deleteOriginRequestPolicyAsync(array $args = []) (supported in versions 2020-05-31)
  117. * @method \Aws\Result deleteRealtimeLogConfig(array $args = []) (supported in versions 2020-05-31)
  118. * @method \GuzzleHttp\Promise\Promise deleteRealtimeLogConfigAsync(array $args = []) (supported in versions 2020-05-31)
  119. * @method \Aws\Result getCachePolicy(array $args = []) (supported in versions 2020-05-31)
  120. * @method \GuzzleHttp\Promise\Promise getCachePolicyAsync(array $args = []) (supported in versions 2020-05-31)
  121. * @method \Aws\Result getCachePolicyConfig(array $args = []) (supported in versions 2020-05-31)
  122. * @method \GuzzleHttp\Promise\Promise getCachePolicyConfigAsync(array $args = []) (supported in versions 2020-05-31)
  123. * @method \Aws\Result getKeyGroup(array $args = []) (supported in versions 2020-05-31)
  124. * @method \GuzzleHttp\Promise\Promise getKeyGroupAsync(array $args = []) (supported in versions 2020-05-31)
  125. * @method \Aws\Result getKeyGroupConfig(array $args = []) (supported in versions 2020-05-31)
  126. * @method \GuzzleHttp\Promise\Promise getKeyGroupConfigAsync(array $args = []) (supported in versions 2020-05-31)
  127. * @method \Aws\Result getMonitoringSubscription(array $args = []) (supported in versions 2020-05-31)
  128. * @method \GuzzleHttp\Promise\Promise getMonitoringSubscriptionAsync(array $args = []) (supported in versions 2020-05-31)
  129. * @method \Aws\Result getOriginRequestPolicy(array $args = []) (supported in versions 2020-05-31)
  130. * @method \GuzzleHttp\Promise\Promise getOriginRequestPolicyAsync(array $args = []) (supported in versions 2020-05-31)
  131. * @method \Aws\Result getOriginRequestPolicyConfig(array $args = []) (supported in versions 2020-05-31)
  132. * @method \GuzzleHttp\Promise\Promise getOriginRequestPolicyConfigAsync(array $args = []) (supported in versions 2020-05-31)
  133. * @method \Aws\Result getRealtimeLogConfig(array $args = []) (supported in versions 2020-05-31)
  134. * @method \GuzzleHttp\Promise\Promise getRealtimeLogConfigAsync(array $args = []) (supported in versions 2020-05-31)
  135. * @method \Aws\Result listCachePolicies(array $args = []) (supported in versions 2020-05-31)
  136. * @method \GuzzleHttp\Promise\Promise listCachePoliciesAsync(array $args = []) (supported in versions 2020-05-31)
  137. * @method \Aws\Result listDistributionsByCachePolicyId(array $args = []) (supported in versions 2020-05-31)
  138. * @method \GuzzleHttp\Promise\Promise listDistributionsByCachePolicyIdAsync(array $args = []) (supported in versions 2020-05-31)
  139. * @method \Aws\Result listDistributionsByKeyGroup(array $args = []) (supported in versions 2020-05-31)
  140. * @method \GuzzleHttp\Promise\Promise listDistributionsByKeyGroupAsync(array $args = []) (supported in versions 2020-05-31)
  141. * @method \Aws\Result listDistributionsByOriginRequestPolicyId(array $args = []) (supported in versions 2020-05-31)
  142. * @method \GuzzleHttp\Promise\Promise listDistributionsByOriginRequestPolicyIdAsync(array $args = []) (supported in versions 2020-05-31)
  143. * @method \Aws\Result listDistributionsByRealtimeLogConfig(array $args = []) (supported in versions 2020-05-31)
  144. * @method \GuzzleHttp\Promise\Promise listDistributionsByRealtimeLogConfigAsync(array $args = []) (supported in versions 2020-05-31)
  145. * @method \Aws\Result listKeyGroups(array $args = []) (supported in versions 2020-05-31)
  146. * @method \GuzzleHttp\Promise\Promise listKeyGroupsAsync(array $args = []) (supported in versions 2020-05-31)
  147. * @method \Aws\Result listOriginRequestPolicies(array $args = []) (supported in versions 2020-05-31)
  148. * @method \GuzzleHttp\Promise\Promise listOriginRequestPoliciesAsync(array $args = []) (supported in versions 2020-05-31)
  149. * @method \Aws\Result listRealtimeLogConfigs(array $args = []) (supported in versions 2020-05-31)
  150. * @method \GuzzleHttp\Promise\Promise listRealtimeLogConfigsAsync(array $args = []) (supported in versions 2020-05-31)
  151. * @method \Aws\Result updateCachePolicy(array $args = []) (supported in versions 2020-05-31)
  152. * @method \GuzzleHttp\Promise\Promise updateCachePolicyAsync(array $args = []) (supported in versions 2020-05-31)
  153. * @method \Aws\Result updateKeyGroup(array $args = []) (supported in versions 2020-05-31)
  154. * @method \GuzzleHttp\Promise\Promise updateKeyGroupAsync(array $args = []) (supported in versions 2020-05-31)
  155. * @method \Aws\Result updateOriginRequestPolicy(array $args = []) (supported in versions 2020-05-31)
  156. * @method \GuzzleHttp\Promise\Promise updateOriginRequestPolicyAsync(array $args = []) (supported in versions 2020-05-31)
  157. * @method \Aws\Result updateRealtimeLogConfig(array $args = []) (supported in versions 2020-05-31)
  158. * @method \GuzzleHttp\Promise\Promise updateRealtimeLogConfigAsync(array $args = []) (supported in versions 2020-05-31)
  159. */
  160. class CloudFrontClient extends AwsClient
  161. {
  162. /**
  163. * Create a signed Amazon CloudFront URL.
  164. *
  165. * This method accepts an array of configuration options:
  166. *
  167. * - url: (string) URL of the resource being signed (can include query
  168. * string and wildcards). For example: rtmp://s5c39gqb8ow64r.cloudfront.net/videos/mp3_name.mp3
  169. * http://d111111abcdef8.cloudfront.net/images/horizon.jpg?size=large&license=yes
  170. * - policy: (string) JSON policy. Use this option when creating a signed
  171. * URL for a custom policy.
  172. * - expires: (int) UTC Unix timestamp used when signing with a canned
  173. * policy. Not required when passing a custom 'policy' option.
  174. * - key_pair_id: (string) The ID of the key pair used to sign CloudFront
  175. * URLs for private distributions.
  176. * - private_key: (string) The filepath ot the private key used to sign
  177. * CloudFront URLs for private distributions.
  178. *
  179. * @param array $options Array of configuration options used when signing
  180. *
  181. * @return string Signed URL with authentication parameters
  182. * @throws \InvalidArgumentException if url, key_pair_id, or private_key
  183. * were not specified.
  184. * @link http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/WorkingWithStreamingDistributions.html
  185. */
  186. public function getSignedUrl(array $options)
  187. {
  188. foreach (['url', 'key_pair_id', 'private_key'] as $required) {
  189. if (!isset($options[$required])) {
  190. throw new \InvalidArgumentException("$required is required");
  191. }
  192. }
  193. $urlSigner = new UrlSigner(
  194. $options['key_pair_id'],
  195. $options['private_key']
  196. );
  197. return $urlSigner->getSignedUrl(
  198. $options['url'],
  199. isset($options['expires']) ? $options['expires'] : null,
  200. isset($options['policy']) ? $options['policy'] : null
  201. );
  202. }
  203. /**
  204. * Create a signed Amazon CloudFront cookie.
  205. *
  206. * This method accepts an array of configuration options:
  207. *
  208. * - url: (string) URL of the resource being signed (can include query
  209. * string and wildcards). For example: http://d111111abcdef8.cloudfront.net/images/horizon.jpg?size=large&license=yes
  210. * - policy: (string) JSON policy. Use this option when creating a signed
  211. * URL for a custom policy.
  212. * - expires: (int) UTC Unix timestamp used when signing with a canned
  213. * policy. Not required when passing a custom 'policy' option.
  214. * - key_pair_id: (string) The ID of the key pair used to sign CloudFront
  215. * URLs for private distributions.
  216. * - private_key: (string) The filepath ot the private key used to sign
  217. * CloudFront URLs for private distributions.
  218. *
  219. * @param array $options Array of configuration options used when signing
  220. *
  221. * @return array Key => value pairs of signed cookies to set
  222. * @throws \InvalidArgumentException if url, key_pair_id, or private_key
  223. * were not specified.
  224. * @link http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/WorkingWithStreamingDistributions.html
  225. */
  226. public function getSignedCookie(array $options)
  227. {
  228. foreach (['key_pair_id', 'private_key'] as $required) {
  229. if (!isset($options[$required])) {
  230. throw new \InvalidArgumentException("$required is required");
  231. }
  232. }
  233. $cookieSigner = new CookieSigner(
  234. $options['key_pair_id'],
  235. $options['private_key']
  236. );
  237. return $cookieSigner->getSignedCookie(
  238. isset($options['url']) ? $options['url'] : null,
  239. isset($options['expires']) ? $options['expires'] : null,
  240. isset($options['policy']) ? $options['policy'] : null
  241. );
  242. }
  243. }