Scalr\Service\Aws\Ec2\V20150415\Ec2Api::replaceRoute PHP Метод

replaceRoute() публичный Метод

Replaces an existing route within a route table in a VPC Condition:You must provide only one of the following: a GatewayId, InstanceId, or NetworkInterfaceId.
public replaceRoute ( string $routeTableId, string $destinationCidrBlock, string $gatewayId = null, string $instanceId = null, string $networkInterfaceId = null, string $vpcPeeringConnectionId = null ) : boolean
$routeTableId string The ID of the route table where the route will be added.
$destinationCidrBlock string The CIDR address block used for the destination match.
$gatewayId string optional The ID of a gataway attached to your VPC.
$instanceId string optional The ID of a NAT instance in your VPC.
$networkInterfaceId string optional Allows the routing of network interface IDs. Exactly one interface must be attached when specifying an instance ID or it fails.
$vpcPeeringConnectionId string optional The ID of a VPC peering connection.
Результат boolean Returns TRUE on success
    public function replaceRoute($routeTableId, $destinationCidrBlock, $gatewayId = null, $instanceId = null, $networkInterfaceId = null, $vpcPeeringConnectionId = null)
    {
        $result = false;
        $options = ['DestinationCidrBlock' => (string) $destinationCidrBlock, 'RouteTableId' => (string) $routeTableId];
        $f = 0;
        if ($gatewayId !== null) {
            $options['GatewayId'] = (string) $gatewayId;
            $f++;
        }
        if ($instanceId !== null) {
            $options['InstanceId'] = (string) $instanceId;
            $f++;
        }
        if ($networkInterfaceId !== null) {
            $options['NetworkInterfaceId'] = (string) $networkInterfaceId;
            $f++;
        }
        if ($vpcPeeringConnectionId !== null) {
            $options['VpcPeeringConnectionId'] = (string) $vpcPeeringConnectionId;
            $f++;
        }
        if ($f > 1) {
            throw new \InvalidArgumentException(sprintf('You must provide only one of the following: a GatewayId, InstanceId, VpcPeeringConnectionId or NetworkInterfaceId.'));
        }
        $action = ucfirst(__FUNCTION__);
        $response = $this->client->call($action, $options);
        if ($response->getError() === false) {
            $sxml = simplexml_load_string($response->getRawContent());
            if ((string) $sxml->return != 'true') {
                throw new Ec2Exception(sprintf('Amazon Ec2 could not %s RouteTableId:"%s". It returned "%s"', $action, $options['RouteTableId'], $sxml->return));
            }
            $result = true;
        }
        return $result;
    }
Ec2Api