Skip to content

update_api_cache

update_api_cache(
    api_id: String,
    ttl: Long,
    api_caching_behavior: ApiCachingBehavior,
    type: ApiCacheType,
    *,
    config_overrides: Optional[AppSyncClientConfig] = None,
    health_metrics_config: Optional[CacheHealthMetricsConfig] = None,
) -> UpdateApiCacheResponse

Updates the cache for the GraphQL API.

Parameters:

  • api_id (String) –

    The GraphQL API ID.

  • ttl (Long) –

    TTL in seconds for cache entries.

    Valid values are 1–3,600 seconds.

  • api_caching_behavior (ApiCachingBehavior) –

    Caching behavior.

    • FULL_REQUEST_CACHING: All requests from the same user are cached. Individual resolvers are automatically cached. All API calls will try to return responses from the cache.

    • PER_RESOLVER_CACHING: Individual resolvers that you specify are cached.

    • OPERATION_LEVEL_CACHING: Full requests are cached together and returned without executing resolvers.

  • type (ApiCacheType) –

    The cache instance type. Valid values are

    • SMALL

    • MEDIUM

    • LARGE

    • XLARGE

    • LARGE_2X

    • LARGE_4X

    • LARGE_8X (not available in all regions)

    • LARGE_12X

    Historically, instance types were identified by an EC2-style value. As of July 2020, this is deprecated, and the generic identifiers above should be used.

    The following legacy instance types are available, but their use is discouraged:

    • T2_SMALL: A t2.small instance type.

    • T2_MEDIUM: A t2.medium instance type.

    • R4_LARGE: A r4.large instance type.

    • R4_XLARGE: A r4.xlarge instance type.

    • R4_2XLARGE: A r4.2xlarge instance type.

    • R4_4XLARGE: A r4.4xlarge instance type.

    • R4_8XLARGE: A r4.8xlarge instance type.

  • health_metrics_config (Optional[CacheHealthMetricsConfig], default: None ) –

    Controls how cache health metrics will be emitted to CloudWatch. Cache health metrics include:

    • NetworkBandwidthOutAllowanceExceeded: The network packets dropped because the throughput exceeded the aggregated bandwidth limit. This is useful for diagnosing bottlenecks in a cache configuration.

    • EngineCPUUtilization: The CPU utilization (percentage) allocated to the Redis process. This is useful for diagnosing bottlenecks in a cache configuration.

    Metrics will be recorded by API ID. You can set the value to ENABLED or DISABLED.

Raises:

  • BadRequestException –

    The request is not well formed. For example, a value is invalid or a required field is missing. Check the field values, and then try again.

  • ConcurrentModificationException –

    Another modification is in progress at this time and it must complete before you can make your change.

  • InternalFailureException –

    An internal AppSync error occurred. Try your request again.

  • NotFoundException –

    The resource specified in the request was not found. Check the resource, and then try again.

  • UnauthorizedException –

    You aren't authorized to perform this operation.

  • UnknownServiceError –

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

Source code in docs_src/capo_appsync/_services/app_sync.py
def update_api_cache(
    self,
    api_id: "capo_appsync.types.string.String",
    ttl: "capo_appsync.types.long.Long",
    api_caching_behavior: "capo_appsync.types.api_caching_behavior.ApiCachingBehavior",
    type: "capo_appsync.types.api_cache_type.ApiCacheType",
    *,
    config_overrides: Optional[AppSyncClientConfig] = None,
    health_metrics_config: Optional[
        "capo_appsync.types.cache_health_metrics_config.CacheHealthMetricsConfig"
    ] = None,
) -> "capo_appsync.types.update_api_cache_response.UpdateApiCacheResponse":
    """<p>Updates the cache for the GraphQL API.</p>

    Args:
        api_id: <p>The GraphQL API ID.</p>
        ttl: <p>TTL in seconds for cache entries.</p> <p>Valid values are 1–3,600 seconds.</p>
        api_caching_behavior: <p>Caching behavior.</p> <ul> <li> <p> <b>FULL_REQUEST_CACHING</b>: All requests from the same user are cached. Individual resolvers are automatically cached. All API calls will try to return responses from the cache.</p> </li> <li> <p> <b>PER_RESOLVER_CACHING</b>: Individual resolvers that you specify are cached.</p> </li> <li> <p> <b>OPERATION_LEVEL_CACHING</b>: Full requests are cached together and returned without executing resolvers.</p> </li> </ul>
        type: <p>The cache instance type. Valid values are </p> <ul> <li> <p> <code>SMALL</code> </p> </li> <li> <p> <code>MEDIUM</code> </p> </li> <li> <p> <code>LARGE</code> </p> </li> <li> <p> <code>XLARGE</code> </p> </li> <li> <p> <code>LARGE_2X</code> </p> </li> <li> <p> <code>LARGE_4X</code> </p> </li> <li> <p> <code>LARGE_8X</code> (not available in all regions)</p> </li> <li> <p> <code>LARGE_12X</code> </p> </li> </ul> <p>Historically, instance types were identified by an EC2-style value. As of July 2020, this is deprecated, and the generic identifiers above should be used.</p> <p>The following legacy instance types are available, but their use is discouraged:</p> <ul> <li> <p> <b>T2_SMALL</b>: A t2.small instance type.</p> </li> <li> <p> <b>T2_MEDIUM</b>: A t2.medium instance type.</p> </li> <li> <p> <b>R4_LARGE</b>: A r4.large instance type.</p> </li> <li> <p> <b>R4_XLARGE</b>: A r4.xlarge instance type.</p> </li> <li> <p> <b>R4_2XLARGE</b>: A r4.2xlarge instance type.</p> </li> <li> <p> <b>R4_4XLARGE</b>: A r4.4xlarge instance type.</p> </li> <li> <p> <b>R4_8XLARGE</b>: A r4.8xlarge instance type.</p> </li> </ul>
        health_metrics_config: <p>Controls how cache health metrics will be emitted to CloudWatch. Cache health metrics include:</p> <ul> <li> <p>NetworkBandwidthOutAllowanceExceeded: The network packets dropped because the throughput exceeded the aggregated bandwidth limit. This is useful for diagnosing bottlenecks in a cache configuration.</p> </li> <li> <p>EngineCPUUtilization: The CPU utilization (percentage) allocated to the Redis process. This is useful for diagnosing bottlenecks in a cache configuration.</p> </li> </ul> <p>Metrics will be recorded by API ID. You can set the value to <code>ENABLED</code> or <code>DISABLED</code>.</p>

    Raises:
        capo_appsync.errors.bad_request_exception.BadRequestException: <p>The request is not well formed. For example, a value is invalid or a required field is missing. Check the field values, and then try again.</p>
        capo_appsync.errors.concurrent_modification_exception.ConcurrentModificationException: <p>Another modification is in progress at this time and it must complete before you can make your change.</p>
        capo_appsync.errors.internal_failure_exception.InternalFailureException: <p>An internal AppSync error occurred. Try your request again.</p>
        capo_appsync.errors.not_found_exception.NotFoundException: <p>The resource specified in the request was not found. Check the resource, and then try again.</p>
        capo_appsync.errors.unauthorized_exception.UnauthorizedException: <p>You aren't authorized to perform this operation.</p>
        capo_appsync.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_appsync.types.update_api_cache_request.UpdateApiCacheRequest]",
    ) -> OperationResponse[
        "capo_appsync.types.update_api_cache_response.UpdateApiCacheResponse"
    ]:
        import capo_appsync._operations.aws_deepdish_control_plane_service.update_api_cache

        output, http_response = (
            capo_appsync._operations.aws_deepdish_control_plane_service.update_api_cache.update_api_cache(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateApiCache")
    )
    input_: capo_appsync.types.update_api_cache_request.UpdateApiCacheRequest = {
        "api_id": api_id,
        "ttl": ttl,
        "api_caching_behavior": api_caching_behavior,
        "type": type,
    }
    if health_metrics_config is not None:
        input_["health_metrics_config"] = health_metrics_config

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