|
1 |
| -<?php |
2 |
| -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
3 |
| -// SPDX-License-Identifier: Apache-2.0 |
4 |
| - |
5 |
| - |
6 |
| -// snippet-start:[apigateway.php.get_base_path_mapping.complete] |
7 |
| -// snippet-start:[apigateway.php.get_base_path_mapping.import] |
8 |
| -require 'vendor/autoload.php'; |
9 |
| - |
10 |
| -use Aws\ApiGateway\ApiGatewayClient; |
11 |
| -use Aws\Exception\AwsException; |
12 |
| -// snippet-end:[apigateway.php.get_base_path_mapping.import] |
13 |
| - |
14 |
| -/* //////////////////////////////////////////////////////////////////////////// |
15 |
| - * Purpose: Gets the base path mapping for a custom domain name in |
16 |
| - * Amazon API Gateway. |
17 |
| - * |
18 |
| - * Prerequisites: A custom domain name in API Gateway. For more information, |
19 |
| - * see "Custom Domain Names" in the Amazon API Gateway Developer Guide. |
20 |
| - * |
21 |
| - * Inputs: |
22 |
| - * - $apiGatewayClient: An initialized AWS SDK for PHP API client for |
23 |
| - * API Gateway. |
24 |
| - * - $basePath: The base path name that callers must provide as part of the |
25 |
| - * URL after the domain name. |
26 |
| - * - $domainName: The custom domain name for the base path mapping. |
27 |
| - * |
28 |
| - * Returns: The base path mapping, if available; otherwise, the error message. |
29 |
| - * ///////////////////////////////////////////////////////////////////////// */ |
30 |
| - |
31 |
| -// snippet-start:[apigateway.php.get_base_path_mapping.main] |
32 |
| -function getBasePathMapping($apiGatewayClient, $basePath, $domainName) |
33 |
| -{ |
34 |
| - try { |
35 |
| - $result = $apiGatewayClient->getBasePathMapping([ |
36 |
| - 'basePath' => $basePath, |
37 |
| - 'domainName' => $domainName, |
38 |
| - ]); |
39 |
| - return 'The base path mapping\'s effective URI is: ' . |
40 |
| - $result['@metadata']['effectiveUri']; |
41 |
| - } catch (AwsException $e) { |
42 |
| - return 'Error: ' . $e['message']; |
43 |
| - } |
44 |
| -} |
45 |
| - |
46 |
| -function getsTheBasePathMapping() |
47 |
| -{ |
48 |
| - $apiGatewayClient = new ApiGatewayClient([ |
49 |
| - 'profile' => 'default', |
50 |
| - 'region' => 'us-east-1', |
51 |
| - 'version' => '2015-07-09' |
52 |
| - ]); |
53 |
| - |
54 |
| - echo getBasePathMapping($apiGatewayClient, '(none)', 'example.com'); |
55 |
| -} |
56 |
| - |
57 |
| -// Uncomment the following line to run this code in an AWS account. |
58 |
| -// getsTheBasePathMapping(); |
59 |
| -// snippet-end:[apigateway.php.get_base_path_mapping.main] |
60 |
| -// snippet-end:[apigateway.php.get_base_path_mapping.complete] |
61 |
| -
|
| 1 | +<?php |
| 2 | +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 3 | +// SPDX-License-Identifier: Apache-2.0 |
| 4 | + |
| 5 | + |
| 6 | +// snippet-start:[apigateway.php.get_base_path_mapping.complete] |
| 7 | +// snippet-start:[apigateway.php.get_base_path_mapping.import] |
| 8 | +require 'vendor/autoload.php'; |
| 9 | + |
| 10 | +use Aws\ApiGateway\ApiGatewayClient; |
| 11 | +use Aws\Exception\AwsException; |
| 12 | + |
| 13 | +// snippet-end:[apigateway.php.get_base_path_mapping.import] |
| 14 | + |
| 15 | +/* //////////////////////////////////////////////////////////////////////////// |
| 16 | + * Purpose: Gets the base path mapping for a custom domain name in |
| 17 | + * Amazon API Gateway. |
| 18 | + * |
| 19 | + * Prerequisites: A custom domain name in API Gateway. For more information, |
| 20 | + * see "Custom Domain Names" in the Amazon API Gateway Developer Guide. |
| 21 | + * |
| 22 | + * Inputs: |
| 23 | + * - $apiGatewayClient: An initialized AWS SDK for PHP API client for |
| 24 | + * API Gateway. |
| 25 | + * - $basePath: The base path name that callers must provide as part of the |
| 26 | + * URL after the domain name. |
| 27 | + * - $domainName: The custom domain name for the base path mapping. |
| 28 | + * |
| 29 | + * Returns: The base path mapping, if available; otherwise, the error message. |
| 30 | + * ///////////////////////////////////////////////////////////////////////// */ |
| 31 | + |
| 32 | +// snippet-start:[apigateway.php.get_base_path_mapping.main] |
| 33 | +function getBasePathMapping($apiGatewayClient, $basePath, $domainName) |
| 34 | +{ |
| 35 | + try { |
| 36 | + $result = $apiGatewayClient->getBasePathMapping([ |
| 37 | + 'basePath' => $basePath, |
| 38 | + 'domainName' => $domainName, |
| 39 | + ]); |
| 40 | + return 'The base path mapping\'s effective URI is: ' . |
| 41 | + $result['@metadata']['effectiveUri']; |
| 42 | + } catch (AwsException $e) { |
| 43 | + return 'Error: ' . $e['message']; |
| 44 | + } |
| 45 | +} |
| 46 | + |
| 47 | +function getsTheBasePathMapping() |
| 48 | +{ |
| 49 | + $apiGatewayClient = new ApiGatewayClient([ |
| 50 | + 'profile' => 'default', |
| 51 | + 'region' => 'us-east-1', |
| 52 | + 'version' => '2015-07-09' |
| 53 | + ]); |
| 54 | + |
| 55 | + echo getBasePathMapping($apiGatewayClient, '(none)', 'example.com'); |
| 56 | +} |
| 57 | + |
| 58 | +// Uncomment the following line to run this code in an AWS account. |
| 59 | +// getsTheBasePathMapping(); |
| 60 | +// snippet-end:[apigateway.php.get_base_path_mapping.main] |
| 61 | +// snippet-end:[apigateway.php.get_base_path_mapping.complete] |
0 commit comments