SIGN IN SIGN UP

Welcome to the AWS Code Examples Repository. This repo contains code examples used in the AWS documentation, AWS SDK Developer Guides, and more. For more information, see the Readme.md file below.

0 0 16 Java
<?php
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
2019-01-30 18:35:51 -08:00
// snippet-start:[apigateway.php.update_base_path_mapping.complete]
// snippet-start:[apigateway.php.update_base_path_mapping.import]
require 'vendor/autoload.php';
use Aws\ApiGateway\ApiGatewayClient;
use Aws\Exception\AwsException;
2019-01-30 18:35:51 -08:00
// snippet-end:[apigateway.php.update_base_path_mapping.import]
/* ////////////////////////////////////////////////////////////////////////////
*
* Purpose: Updates the base path mapping for a custom domain name
* in Amazon API Gateway.
*
* Inputs:
2020-04-17 16:11:47 -07:00
* - $apiGatewayClient: An initialized AWS SDK for PHP API client for
* API Gateway.
* - $basePath: The base path name that callers must provide as part of the
* URL after the domain name.
* - $domainName: The custom domain name for the base path mapping.
2020-04-17 16:11:47 -07:00
* - $patchOperations: The base path update operations to apply.
*
2020-04-17 16:11:47 -07:00
* Returns: Information about the updated base path mapping, if available;
* otherwise, the error message.
* ///////////////////////////////////////////////////////////////////////// */
2019-01-30 18:35:51 -08:00
// snippet-start:[apigateway.php.update_base_path_mapping.main]
function updateBasePathMapping(
$apiGatewayClient,
$basePath,
$domainName,
$patchOperations
) {
try {
$result = $apiGatewayClient->updateBasePathMapping([
'basePath' => $basePath,
'domainName' => $domainName,
'patchOperations' => $patchOperations
]);
return 'The updated base path\'s URI is: ' .
$result['@metadata']['effectiveUri'];
} catch (AwsException $e) {
return 'Error: ' . $e['message'];
}
}
function updateTheBasePathMapping()
{
$patchOperations = array([
'op' => 'replace',
'path' => '/stage',
'value' => 'stage2'
]);
$apiGatewayClient = new ApiGatewayClient([
'profile' => 'default',
'region' => 'us-east-1',
'version' => '2015-07-09'
]);
echo updateBasePathMapping(
$apiGatewayClient,
'(none)',
'example.com',
$patchOperations
);
}
// Uncomment the following line to run this code in an AWS account.
// updateTheBasePathMapping();
// snippet-end:[apigateway.php.update_base_path_mapping.main]
// snippet-end:[apigateway.php.update_base_path_mapping.complete]