Skip to content

create_transit_gateway_metering_policy

create_transit_gateway_metering_policy(
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    transit_gateway_id: Optional[TransitGatewayId] = None,
    middlebox_attachment_ids: Optional[TransitGatewayAttachmentIdStringList] = None,
    tag_specifications: Optional[TagSpecificationList] = None,
    dry_run: Optional[Boolean] = None,
) -> CreateTransitGatewayMeteringPolicyResult

Creates a metering policy for a transit gateway to track and measure network traffic.

Parameters:

  • transit_gateway_id (Optional[TransitGatewayId], default: None ) –

    The ID of the transit gateway for which to create the metering policy.

  • middlebox_attachment_ids (Optional[TransitGatewayAttachmentIdStringList], default: None ) –

    The IDs of the middlebox attachments to include in the metering policy.

  • tag_specifications (Optional[TagSpecificationList], default: None ) –

    The tags to assign to the metering policy.

  • dry_run (Optional[Boolean], default: None ) –

    Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

Raises:

Source code in docs_src/capo_ec2/_services/ec2.py
def create_transit_gateway_metering_policy(
    self,
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    transit_gateway_id: Optional[
        "capo_ec2.types.transit_gateway_id.TransitGatewayId"
    ] = None,
    middlebox_attachment_ids: Optional[
        "capo_ec2.types.transit_gateway_attachment_id_string_list.TransitGatewayAttachmentIdStringList"
    ] = None,
    tag_specifications: Optional[
        "capo_ec2.types.tag_specification_list.TagSpecificationList"
    ] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
) -> "capo_ec2.types.create_transit_gateway_metering_policy_result.CreateTransitGatewayMeteringPolicyResult":
    """<p>Creates a metering policy for a transit gateway to track and measure network traffic.</p>

    Args:
        transit_gateway_id: <p>The ID of the transit gateway for which to create the metering policy.</p>
        middlebox_attachment_ids: <p>The IDs of the middlebox attachments to include in the metering policy.</p>
        tag_specifications: <p>The tags to assign to the metering policy.</p>
        dry_run: <p>Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is <code>DryRunOperation</code>. Otherwise, it is <code>UnauthorizedOperation</code>.</p>

    Raises:
        capo_ec2.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_ec2.types.create_transit_gateway_metering_policy_request.CreateTransitGatewayMeteringPolicyRequest]",
    ) -> OperationResponse[
        "capo_ec2.types.create_transit_gateway_metering_policy_result.CreateTransitGatewayMeteringPolicyResult"
    ]:
        import capo_ec2._operations.amazon_ec2.create_transit_gateway_metering_policy

        output, http_response = (
            capo_ec2._operations.amazon_ec2.create_transit_gateway_metering_policy.create_transit_gateway_metering_policy(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateTransitGatewayMeteringPolicy")
    )
    input_: capo_ec2.types.create_transit_gateway_metering_policy_request.CreateTransitGatewayMeteringPolicyRequest = {}
    if transit_gateway_id is not None:
        input_["transit_gateway_id"] = transit_gateway_id
    if middlebox_attachment_ids is not None:
        input_["middlebox_attachment_ids"] = middlebox_attachment_ids
    if tag_specifications is not None:
        input_["tag_specifications"] = tag_specifications
    if dry_run is not None:
        input_["dry_run"] = dry_run

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output