Skip to content

put_method async

put_method(
    rest_api_id: String,
    resource_id: String,
    http_method: String,
    authorization_type: String,
    *,
    config_overrides: Optional[AsyncAPIGatewayClientConfig] = None,
    authorizer_id: Optional[String] = None,
    api_key_required: Optional[Boolean] = None,
    operation_name: Optional[String] = None,
    request_parameters: Optional[MapOfStringToBoolean] = None,
    request_models: Optional[MapOfStringToString] = None,
    request_validator_id: Optional[String] = None,
    authorization_scopes: Optional[ListOfString] = None,
) -> Method

Add a method to an existing Resource resource.

Parameters:

  • rest_api_id (String) –

    The string identifier of the associated RestApi.

  • resource_id (String) –

    The Resource identifier for the new Method resource.

  • http_method (String) –

    Specifies the method request's HTTP method type.

  • authorization_type (String) –

    The method's authorization type. Valid values are NONE for open access, AWS_IAM for using AWS IAM permissions, CUSTOM for using a custom authorizer, or COGNITO_USER_POOLS for using a Cognito user pool.

  • authorizer_id (Optional[String], default: None ) –

    Specifies the identifier of an Authorizer to use on this Method, if the type is CUSTOM or COGNITO_USER_POOLS. The authorizer identifier is generated by API Gateway when you created the authorizer.

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

    Specifies whether the method required a valid ApiKey.

  • operation_name (Optional[String], default: None ) –

    A human-friendly operation identifier for the method. For example, you can assign the operationName of ListPets for the GET /pets method in the PetStore example.

  • request_parameters (Optional[MapOfStringToBoolean], default: None ) –

    A key-value map defining required or optional method request parameters that can be accepted by API Gateway. A key defines a method request parameter name matching the pattern of method.request.{location}.{name}, where location is querystring, path, or header and name is a valid and unique parameter name. The value associated with the key is a Boolean flag indicating whether the parameter is required (true) or optional (false). The method request parameter names defined here are available in Integration to be mapped to integration request parameters or body-mapping templates.

  • request_models (Optional[MapOfStringToString], default: None ) –

    Specifies the Model resources used for the request's content type. Request models are represented as a key/value map, with a content type as the key and a Model name as the value.

  • request_validator_id (Optional[String], default: None ) –

    The identifier of a RequestValidator for validating the method request.

  • authorization_scopes (Optional[ListOfString], default: None ) –

    A list of authorization scopes configured on the method. The scopes are used with a COGNITO_USER_POOLS authorizer to authorize the method invocation. The authorization works by matching the method scopes against the scopes parsed from the access token in the incoming request. The method invocation is authorized if any method scopes matches a claimed scope in the access token. Otherwise, the invocation is not authorized. When the method scope is configured, the client must provide an access token instead of an identity token for authorization purposes.

Raises:

  • BadRequestException –

    The submitted request is not valid, for example, the input is incomplete or incorrect. See the accompanying error message for details.

  • ConflictException –

    The request configuration has conflicts. For details, see the accompanying error message.

  • LimitExceededException –

    The request exceeded the rate limit. Retry after the specified time period.

  • NotFoundException –

    The requested resource is not found. Make sure that the request URI is correct.

  • TooManyRequestsException –

    The request has reached its throttling limit. Retry after the specified time period.

  • UnauthorizedException –

    The request is denied because the caller has insufficient permissions.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_api_gateway/_services/async_api_gateway.py
async def put_method(
    self,
    rest_api_id: "capo_api_gateway.types.string.String",
    resource_id: "capo_api_gateway.types.string.String",
    http_method: "capo_api_gateway.types.string.String",
    authorization_type: "capo_api_gateway.types.string.String",
    *,
    config_overrides: Optional[AsyncAPIGatewayClientConfig] = None,
    authorizer_id: Optional["capo_api_gateway.types.string.String"] = None,
    api_key_required: Optional["capo_api_gateway.types.boolean.Boolean"] = None,
    operation_name: Optional["capo_api_gateway.types.string.String"] = None,
    request_parameters: Optional[
        "capo_api_gateway.types.map_of_string_to_boolean.MapOfStringToBoolean"
    ] = None,
    request_models: Optional[
        "capo_api_gateway.types.map_of_string_to_string.MapOfStringToString"
    ] = None,
    request_validator_id: Optional["capo_api_gateway.types.string.String"] = None,
    authorization_scopes: Optional[
        "capo_api_gateway.types.list_of_string.ListOfString"
    ] = None,
) -> "capo_api_gateway.types.method.Method":
    """<p>Add a method to an existing Resource resource.</p>

    Args:
        rest_api_id: <p>The string identifier of the associated RestApi.</p>
        resource_id: <p>The Resource identifier for the new Method resource.</p>
        http_method: <p>Specifies the method request's HTTP method type.</p>
        authorization_type: <p>The method's authorization type. Valid values are <code>NONE</code> for open access, <code>AWS_IAM</code> for using AWS IAM permissions, <code>CUSTOM</code> for using a custom authorizer, or <code>COGNITO_USER_POOLS</code> for using a Cognito user pool.</p>
        authorizer_id: <p>Specifies the identifier of an Authorizer to use on this Method, if the type is CUSTOM or COGNITO_USER_POOLS. The authorizer identifier is generated by API Gateway when you created the authorizer.</p>
        api_key_required: <p>Specifies whether the method required a valid ApiKey.</p>
        operation_name: <p>A human-friendly operation identifier for the method. For example, you can assign the <code>operationName</code> of <code>ListPets</code> for the <code>GET /pets</code> method in the <code>PetStore</code> example.</p>
        request_parameters: <p>A key-value map defining required or optional method request parameters that can be accepted by API Gateway. A key defines a method request parameter name matching the pattern of <code>method.request.{location}.{name}</code>, where <code>location</code> is <code>querystring</code>, <code>path</code>, or <code>header</code> and <code>name</code> is a valid and unique parameter name. The value associated with the key is a Boolean flag indicating whether the parameter is required (<code>true</code>) or optional (<code>false</code>). The method request parameter names defined here are available in Integration to be mapped to integration request parameters or body-mapping templates.</p>
        request_models: <p>Specifies the Model resources used for the request's content type. Request models are represented as a key/value map, with a content type as the key and a Model name as the value.</p>
        request_validator_id: <p>The identifier of a RequestValidator for validating the method request.</p>
        authorization_scopes: <p>A list of authorization scopes configured on the method. The scopes are used with a <code>COGNITO_USER_POOLS</code> authorizer to authorize the method invocation. The authorization works by matching the method scopes against the scopes parsed from the access token in the incoming request. The method invocation is authorized if any method scopes matches a claimed scope in the access token. Otherwise, the invocation is not authorized. When the method scope is configured, the client must provide an access token instead of an identity token for authorization purposes.</p>

    Raises:
        capo_api_gateway.errors.bad_request_exception.BadRequestException: <p>The submitted request is not valid, for example, the input is incomplete or incorrect. See the accompanying error message for details.</p>
        capo_api_gateway.errors.conflict_exception.ConflictException: <p>The request configuration has conflicts. For details, see the accompanying error message.</p>
        capo_api_gateway.errors.limit_exceeded_exception.LimitExceededException: <p>The request exceeded the rate limit. Retry after the specified time period.</p>
        capo_api_gateway.errors.not_found_exception.NotFoundException: <p>The requested resource is not found. Make sure that the request URI is correct.</p>
        capo_api_gateway.errors.too_many_requests_exception.TooManyRequestsException: <p>The request has reached its throttling limit. Retry after the specified time period.</p>
        capo_api_gateway.errors.unauthorized_exception.UnauthorizedException: <p>The request is denied because the caller has insufficient permissions.</p>
        capo_api_gateway.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_api_gateway.types.put_method_request.PutMethodRequest]",
    ) -> AsyncOperationResponse["capo_api_gateway.types.method.Method"]:
        import capo_api_gateway._operations.backplane_control_service.put_method

        (
            output,
            http_response,
        ) = await capo_api_gateway._operations.backplane_control_service.put_method.async_put_method(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("PutMethod")
    )
    input_: capo_api_gateway.types.put_method_request.PutMethodRequest = {
        "rest_api_id": rest_api_id,
        "resource_id": resource_id,
        "http_method": http_method,
        "authorization_type": authorization_type,
    }
    if authorizer_id is not None:
        input_["authorizer_id"] = authorizer_id
    if api_key_required is not None:
        input_["api_key_required"] = api_key_required
    if operation_name is not None:
        input_["operation_name"] = operation_name
    if request_parameters is not None:
        input_["request_parameters"] = request_parameters
    if request_models is not None:
        input_["request_models"] = request_models
    if request_validator_id is not None:
        input_["request_validator_id"] = request_validator_id
    if authorization_scopes is not None:
        input_["authorization_scopes"] = authorization_scopes

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output