# Class HttpJsonCallContext (2.81.0)

2.81.0 (latest) 2.80.0 2.79.0 2.76.0 2.75.0 2.74.1 2.73.1 2.72.2 2.71.0 2.70.3 2.69.0 2.68.2 2.67.0 2.66.0 2.65.0 2.63.1 2.62.0 2.61.0 2.60.0 2.59.1 2.58.0 2.57.0 2.55.0 2.54.1 2.53.0 2.52.0 2.51.0 2.50.0 2.49.0 2.48.1 2.47.0 2.46.1 2.45.0 2.43.0 2.42.0 2.41.0 2.39.0 2.38.0 2.37.0 2.36.0 2.35.0 2.34.1 2.33.0 2.32.1 2.31.1 2.30.1 2.24.0 2.23.3 2.22.0 2.21.0 2.20.1 2.19.6 2.18.7 2.17.0 2.16.0 2.15.0 2.14.0 2.13.0 2.12.2 2.11.0 2.10.0 2.9.0 2.8.1 2.7.1

    public final class HttpJsonCallContext implements ApiCallContext

HttpJsonCallContext encapsulates context data used to make an http-json call.

HttpJsonCallContext is immutable in the sense that none of its methods modifies the
HttpJsonCallContext itself or the underlying data. Methods of the form `withX` return
copies of the object, but with one field changed. The immutability and thread safety of the
arguments solely depends on the arguments themselves.

## Inheritance

[Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> HttpJsonCallContext

## Implements

[ApiCallContext](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.ApiCallContext)

## Inherited Members

[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) [Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) [Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) [Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) [Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) [Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) [Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) [Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) [Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) [Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) [Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)

## Static Methods

### createDefault()

    public static HttpJsonCallContext createDefault()

Returns an empty instance.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.httpjson.HttpJsonCallContext` |   |

### of(HttpJsonChannel channel, HttpJsonCallOptions options)

    public static HttpJsonCallContext of(HttpJsonChannel channel, HttpJsonCallOptions options)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `channel` | `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.httpjson.HttpJsonChannel` |
| `options` | `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.httpjson.HttpJsonCallOptions` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.httpjson.HttpJsonCallContext` |   |

## Methods

### \<T\>getOption(ApiCallContext.Key\<T\> key)

    public T <T>getOption(ApiCallContext.Key<T> key)

Return the api call context option set for this context.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `key` | `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.ApiCallContext.Key<T>` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `T` |   |

### \<T\>withOption(ApiCallContext.Key\<T\> key, T value)

    public ApiCallContext <T>withOption(ApiCallContext.Key<T> key, T value)

Return a new ApiCallContext with additional option merged into the present instance. Any
existing value of the key is overwritten.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `key` | `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.ApiCallContext.Key<T>` |
| `value` | `T` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.ApiCallContext` |   |

### equals(Object o)

    public boolean equals(Object o)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `o` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

**Overrides** [Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-)

### getCallOptions()

    public HttpJsonCallOptions getCallOptions()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.httpjson.HttpJsonCallOptions` |   |

### getChannel()

    public HttpJsonChannel getChannel()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.httpjson.HttpJsonChannel` |   |

### getCredentials() (deprecated)

    public Credentials getCredentials()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `com.google.auth.Credentials` |   |

### getDeadline() (deprecated)

    public Instant getDeadline()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `org.threeten.bp.Instant` |   |

### getExtraHeaders()

    public Map<String,List<String>> getExtraHeaders()

> [!WARNING]
> **Beta**
>
> *The surface for extra headers is not stable yet and may change in the future.*
>
> This feature is covered by the [Pre-GA Offerings Terms](https://docs.cloud.google.com/terms/service-terms#1) of the Terms of Service. Pre-GA libraries might have limited support, and changes to pre-GA libraries might not be compatible with other pre-GA versions. For more information, see the launch stage descriptions.

Return the extra headers set for this context.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/Map.html<https://docs.oracle.com/javase/8/docs/api/java/lang/String.html,https://docs.oracle.com/javase/8/docs/api/java/util/List.html<https://docs.oracle.com/javase/8/docs/api/java/lang/String.html>>` |   |

### getRetrySettings()

    public RetrySettings getRetrySettings()

Returns the [RetrySettings](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.retrying.RetrySettings) to use with this context, or `null` if the default
[RetrySettings](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.retrying.RetrySettings) should be used.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.retrying.RetrySettings` |   |

### getRetryableCodes()

    public Set<StatusCode.Code> getRetryableCodes()

Returns the retryable codes to use with this context, or `null` if the default
retryable codes should be used.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/Set.html<https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.StatusCode.Code>` |   |

### getStreamIdleTimeout()

    public Duration getStreamIdleTimeout()

> [!WARNING]
> **Obsolete**
>
> *Use getStreamIdleTimeoutDuration() instead*
>
> This feature is stable for usage in this major version, but may be deprecated in a future release.

This method is obsolete. Use [#getStreamIdleTimeoutDuration()](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.httpjson.HttpJsonCallContext#com_google_api_gax_httpjson_HttpJsonCallContext_getStreamIdleTimeoutDuration__) instead.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `org.threeten.bp.Duration` |   |

### getStreamIdleTimeoutDuration()

    public Duration getStreamIdleTimeoutDuration()

The stream idle timeout set for this context.
See Also: [ApiCallContext#withStreamIdleTimeoutDuration(java.time.Duration)](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.ApiCallContext#com_google_api_gax_rpc_ApiCallContext_withStreamIdleTimeoutDuration_java_time_Duration_)

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/time/Duration.html` |   |

### getStreamWaitTimeout()

    public Duration getStreamWaitTimeout()

> [!WARNING]
> **Obsolete**
>
> *Use getStreamWaitTimeoutDuration() instead*
>
> This feature is stable for usage in this major version, but may be deprecated in a future release.

This method is obsolete. Use [#getStreamWaitTimeoutDuration()](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.httpjson.HttpJsonCallContext#com_google_api_gax_httpjson_HttpJsonCallContext_getStreamWaitTimeoutDuration__) instead.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `org.threeten.bp.Duration` |   |

### getStreamWaitTimeoutDuration()

    public Duration getStreamWaitTimeoutDuration()

The stream wait timeout set for this context.
See Also: [ApiCallContext#withStreamWaitTimeoutDuration(java.time.Duration)](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.ApiCallContext#com_google_api_gax_rpc_ApiCallContext_withStreamWaitTimeoutDuration_java_time_Duration_)

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/time/Duration.html` |   |

### getTimeout()

    public Duration getTimeout()

> [!WARNING]
> **Obsolete**
>
> *Use getTimeoutDuration instead*
>
> This feature is stable for usage in this major version, but may be deprecated in a future release.

This method is obsolete. Use [#getTimeoutDuration()](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.httpjson.HttpJsonCallContext#com_google_api_gax_httpjson_HttpJsonCallContext_getTimeoutDuration__) instead.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `org.threeten.bp.Duration` |   |

### getTimeoutDuration()

    public Duration getTimeoutDuration()

Returns the configured per-RPC timeout.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/time/Duration.html` |   |

### getTracer()

    public ApiTracer getTracer()

The [ApiTracer](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.tracing.ApiTracer) that was previously set for this context.

The [ApiTracer](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.tracing.ApiTracer) will be used to trace the current operation and to annotate various
events like retries.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.tracing.ApiTracer` |   |

### hashCode()

    public int hashCode()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

**Overrides** [Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--)

### merge(ApiCallContext inputCallContext)

    public HttpJsonCallContext merge(ApiCallContext inputCallContext)

For any values in `inputCallContext` that are not null, override the corresponding values
in the present instance.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `inputCallContext` | `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.ApiCallContext` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.httpjson.HttpJsonCallContext` |   |

### nullToSelf(ApiCallContext inputContext)

    public HttpJsonCallContext nullToSelf(ApiCallContext inputContext)

Returns inputContext cast to [HttpJsonCallContext](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.httpjson.HttpJsonCallContext), or an empty [HttpJsonCallContext](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.httpjson.HttpJsonCallContext) if inputContext is null.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `inputContext` | `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.ApiCallContext` the [ApiCallContext](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.ApiCallContext) to cast if it is not null |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.httpjson.HttpJsonCallContext` |   |

### validateUniverseDomain()

    public void validateUniverseDomain()

> [!WARNING]
> **Internal Only**: This feature is not stable for application use.

Validate the Universe Domain to ensure that the user configured Universe Domain and the
Credentials' Universe Domain match. An exception will be raised if there are any issues when
trying to validate (i.e. unable to access the universe domain).

### withCallOptions(HttpJsonCallOptions newCallOptions)

    public HttpJsonCallContext withCallOptions(HttpJsonCallOptions newCallOptions)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `newCallOptions` | `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.httpjson.HttpJsonCallOptions` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.httpjson.HttpJsonCallContext` |   |

### withChannel(HttpJsonChannel newChannel)

    public HttpJsonCallContext withChannel(HttpJsonChannel newChannel)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `newChannel` | `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.httpjson.HttpJsonChannel` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.httpjson.HttpJsonCallContext` |   |

### withCredentials(Credentials newCredentials)

    public HttpJsonCallContext withCredentials(Credentials newCredentials)

Returns a new ApiCallContext with the given credentials set.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `newCredentials` | `com.google.auth.Credentials` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.httpjson.HttpJsonCallContext` |   |

### withDeadline(Instant newDeadline) (deprecated)

    public HttpJsonCallContext withDeadline(Instant newDeadline)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `newDeadline` | `org.threeten.bp.Instant` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.httpjson.HttpJsonCallContext` |   |

### withEndpointContext(EndpointContext endpointContext)

    public HttpJsonCallContext withEndpointContext(EndpointContext endpointContext)

Returns a new ApiCallContext with the given Endpoint Context.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `endpointContext` | `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.EndpointContext` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.httpjson.HttpJsonCallContext` |   |

### withExtraHeaders(Map\<String,List\<String\>\> extraHeaders)

    public ApiCallContext withExtraHeaders(Map<String,List<String>> extraHeaders)

> [!WARNING]
> **Beta**
>
> *The surface for extra headers is not stable yet and may change in the future.*
>
> This feature is covered by the [Pre-GA Offerings Terms](https://docs.cloud.google.com/terms/service-terms#1) of the Terms of Service. Pre-GA libraries might have limited support, and changes to pre-GA libraries might not be compatible with other pre-GA versions. For more information, see the launch stage descriptions.

Return a new ApiCallContext with the extraHeaders merged into the present instance.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `extraHeaders` | `https://docs.oracle.com/javase/8/docs/api/java/util/Map.html<https://docs.oracle.com/javase/8/docs/api/java/lang/String.html,https://docs.oracle.com/javase/8/docs/api/java/util/List.html<https://docs.oracle.com/javase/8/docs/api/java/lang/String.html>>` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.ApiCallContext` |   |

### withRetrySettings(RetrySettings retrySettings)

    public HttpJsonCallContext withRetrySettings(RetrySettings retrySettings)

Returns a new ApiCallContext with the given [RetrySettings](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.retrying.RetrySettings) set.

This sets the [RetrySettings](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.retrying.RetrySettings) to use for the RPC. These settings will work in
combination with either the default retryable codes for the RPC, or the retryable codes
supplied through [#withRetryableCodes(Set)](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.httpjson.HttpJsonCallContext#com_google_api_gax_httpjson_HttpJsonCallContext_withRetryableCodes_java_util_Set_com_google_api_gax_rpc_StatusCode_Code__). Calling [#withRetrySettings(RetrySettings)](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.httpjson.HttpJsonCallContext#com_google_api_gax_httpjson_HttpJsonCallContext_withRetrySettings_com_google_api_gax_retrying_RetrySettings_) on an RPC that does not include [Code#DEADLINE_EXCEEDED](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.StatusCode.Code#com_google_api_gax_rpc_StatusCode_Code_DEADLINE_EXCEEDED) as one of its retryable codes (or without calling [#withRetryableCodes(Set)](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.httpjson.HttpJsonCallContext#com_google_api_gax_httpjson_HttpJsonCallContext_withRetryableCodes_java_util_Set_com_google_api_gax_rpc_StatusCode_Code__) with a set that includes at least [Code#DEADLINE_EXCEEDED](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.StatusCode.Code#com_google_api_gax_rpc_StatusCode_Code_DEADLINE_EXCEEDED))
will effectively only set a single timeout that is equal to [RetrySettings#getInitialRpcTimeout()](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.retrying.RetrySettings#com_google_api_gax_retrying_RetrySettings_getInitialRpcTimeout__). If this timeout is exceeded, the RPC will not be retried
and will fail with [Code#DEADLINE_EXCEEDED](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.StatusCode.Code#com_google_api_gax_rpc_StatusCode_Code_DEADLINE_EXCEEDED).

Example usage:


     ApiCallContext context = GrpcCallContext.createDefault()
       .withRetrySettings(RetrySettings.newBuilder()
         .setInitialRetryDelay(Duration.ofMillis(10L))
         .setInitialRpcTimeout(Duration.ofMillis(100L))
         .setMaxAttempts(10)
         .setMaxRetryDelay(Duration.ofSeconds(10L))
         .setMaxRpcTimeout(Duration.ofSeconds(30L))
         .setRetryDelayMultiplier(1.4)
         .setRpcTimeoutMultiplier(1.5)
         .setTotalTimeout(Duration.ofMinutes(10L))
         .build())
       .withRetryableCodes(Sets.newSet(
         StatusCode.Code.UNAVAILABLE,
         StatusCode.Code.DEADLINE_EXCEEDED));
     
Setting a logical call timeout for the context can be done similarly with RetrySettings.Builder#setLogicalTimeout(java.time.Duration timeout).

Example usage:


     ApiCallContext context = GrpcCallContext.createDefault()
       .withRetrySettings(RetrySettings.newBuilder()
         .setInitialRetryDelay(Duration.ofMillis(10L))
         .setMaxRetryDelay(Duration.ofSeconds(10L))
         .setRetryDelayMultiplier(1.4)
         .setMaxAttempts(10)
         .setLogicalTimeout(Duration.ofSeconds(30L))
         .build());
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `retrySettings` | `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.retrying.RetrySettings` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.httpjson.HttpJsonCallContext` |   |

### withRetryableCodes(Set\<StatusCode.Code\> retryableCodes)

    public HttpJsonCallContext withRetryableCodes(Set<StatusCode.Code> retryableCodes)

Returns a new ApiCallContext with the given retryable codes set.

This sets the retryable codes to use for the RPC. These settings will work in combination
with either the default [RetrySettings](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.retrying.RetrySettings) for the RPC, or the [RetrySettings](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.retrying.RetrySettings)
supplied through [#withRetrySettings(RetrySettings)](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.httpjson.HttpJsonCallContext#com_google_api_gax_httpjson_HttpJsonCallContext_withRetrySettings_com_google_api_gax_retrying_RetrySettings_).

Setting a non-empty set of retryable codes for an RPC that is not already retryable by
default, will not have any effect and the RPC will NOT be retried. This option can only be used
to change which codes are considered retryable for an RPC that already has at least one
retryable code in its default settings.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `retryableCodes` | `https://docs.oracle.com/javase/8/docs/api/java/util/Set.html<https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.StatusCode.Code>` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.httpjson.HttpJsonCallContext` |   |

### withStreamIdleTimeout(Duration streamIdleTimeout)

    public HttpJsonCallContext withStreamIdleTimeout(Duration streamIdleTimeout)

> [!WARNING]
> **Obsolete**
>
> *Use withStreamIdleTimeoutDuration(java.time.Duration) instead*
>
> This feature is stable for usage in this major version, but may be deprecated in a future release.

This method is obsolete. Use [#withStreamIdleTimeoutDuration(java.time.Duration)](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.httpjson.HttpJsonCallContext#com_google_api_gax_httpjson_HttpJsonCallContext_withStreamIdleTimeoutDuration_java_time_Duration_)
instead.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `streamIdleTimeout` | `org.threeten.bp.Duration` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.httpjson.HttpJsonCallContext` |   |

### withStreamIdleTimeoutDuration(Duration streamIdleTimeout)

    public HttpJsonCallContext withStreamIdleTimeoutDuration(Duration streamIdleTimeout)

Returns a new ApiCallContext with the given stream idle timeout set.

This timeout only applies to a [ServerStreamingCallable](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.ServerStreamingCallable)s. It limits the maximum
amount of timeout that can pass between a message being received by [ResponseObserver#onResponse(Object)](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.ResponseObserver#com_google_api_gax_rpc_ResponseObserver_onResponse_) and demand being signaled via [StreamController#request(int)](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.StreamController#com_google_api_gax_rpc_StreamController_request_int_). Please note that this timeout is best effort and the maximum
resolution configured in [StubSettings#getStreamWatchdogCheckIntervalDuration()](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.StubSettings#com_google_api_gax_rpc_StubSettings_getStreamWatchdogCheckIntervalDuration__). This is
useful to clean up streams that were partially read but never closed. When the timeout has been
reached, the stream will be closed with a nonretryable [WatchdogTimeoutException](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.WatchdogTimeoutException) and a
status of [StatusCode.Code#ABORTED](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.StatusCode.Code#com_google_api_gax_rpc_StatusCode_Code_ABORTED).

A value of java.time.Duration#ZERO, disables the streaming idle timeout and a null
value will use the default in the callable.

Please note that this timeout is best effort and the maximum resolution is configured in
[StubSettings#getStreamWatchdogCheckIntervalDuration()](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.StubSettings#com_google_api_gax_rpc_StubSettings_getStreamWatchdogCheckIntervalDuration__).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `streamIdleTimeout` | `https://docs.oracle.com/javase/8/docs/api/java/time/Duration.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.httpjson.HttpJsonCallContext` |   |

### withStreamWaitTimeout(Duration streamWaitTimeout)

    public HttpJsonCallContext withStreamWaitTimeout(Duration streamWaitTimeout)

> [!WARNING]
> **Obsolete**
>
> *Use withStreamWaitTimeoutDuration(java.time.Duration) instead*
>
> This feature is stable for usage in this major version, but may be deprecated in a future release.

This method is obsolete. Use [#withStreamWaitTimeoutDuration(java.time.Duration)](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.httpjson.HttpJsonCallContext#com_google_api_gax_httpjson_HttpJsonCallContext_withStreamWaitTimeoutDuration_java_time_Duration_)
instead.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `streamWaitTimeout` | `org.threeten.bp.Duration` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.httpjson.HttpJsonCallContext` |   |

### withStreamWaitTimeoutDuration(Duration streamWaitTimeout)

    public HttpJsonCallContext withStreamWaitTimeoutDuration(Duration streamWaitTimeout)

Returns a new ApiCallContext with the given stream timeout set.

This timeout only applies to a [ServerStreamingCallable](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.ServerStreamingCallable)s. It limits the maximum
amount of time that can pass between demand being signaled via [StreamController#request(int)](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.StreamController#com_google_api_gax_rpc_StreamController_request_int_) and actual message delivery to [ResponseObserver#onResponse(Object)](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.ResponseObserver#com_google_api_gax_rpc_ResponseObserver_onResponse_). Or, in the case of automatic flow control, since the last
message was delivered to [ResponseObserver#onResponse(Object)](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.ResponseObserver#com_google_api_gax_rpc_ResponseObserver_onResponse_). This is useful to detect
server or connection stalls. When the timeout has been reached, the stream will be closed with
a retryable [WatchdogTimeoutException](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.WatchdogTimeoutException) and a status of [StatusCode.Code#ABORTED](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.StatusCode.Code#com_google_api_gax_rpc_StatusCode_Code_ABORTED).

A value of java.time.Duration#ZERO, disables the streaming wait timeout and a null
value will use the default in the callable.

Please note that this timeout is best effort and the maximum resolution is configured in
[StubSettings#getStreamWatchdogCheckIntervalDuration()](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.StubSettings#com_google_api_gax_rpc_StubSettings_getStreamWatchdogCheckIntervalDuration__).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `streamWaitTimeout` | `https://docs.oracle.com/javase/8/docs/api/java/time/Duration.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.httpjson.HttpJsonCallContext` |   |

### withTimeout(Duration timeout)

    public HttpJsonCallContext withTimeout(Duration timeout)

> [!WARNING]
> **Obsolete**
>
> *Use withTimeoutDuration(java.time.Duration) instead*
>
> This feature is stable for usage in this major version, but may be deprecated in a future release.

This method is obsolete. Use [#withTimeoutDuration(java.time.Duration)](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.httpjson.HttpJsonCallContext#com_google_api_gax_httpjson_HttpJsonCallContext_withTimeoutDuration_java_time_Duration_) instead.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `timeout` | `org.threeten.bp.Duration` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.httpjson.HttpJsonCallContext` |   |

### withTimeoutDuration(Duration timeout)

    public HttpJsonCallContext withTimeoutDuration(Duration timeout)

Returns a new ApiCallContext with the given timeout set.

This sets the maximum amount of time a single unary RPC attempt can take. If retries are
enabled, then this can take much longer, as each RPC attempt will have the same constant
timeout. Unlike a deadline, timeouts are relative durations that are measure from the beginning
of each RPC attempt. Please note that this limits the duration of a server streaming RPC as
well.

If a method has default [com.google.api.gax.retrying.RetrySettings](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.retrying.RetrySettings), the max attempts
and/or total timeout is still respected when scheduling each RPC attempt.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `timeout` | `https://docs.oracle.com/javase/8/docs/api/java/time/Duration.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.httpjson.HttpJsonCallContext` |   |

### withTracer(ApiTracer newTracer)

    public HttpJsonCallContext withTracer(ApiTracer newTracer)

Returns a new [ApiCallContext](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.ApiCallContext) with the given [ApiTracer](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.tracing.ApiTracer).

The [ApiTracer](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.tracing.ApiTracer) will be used to trace the current operation and to annotate various
events like retries.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `newTracer` | `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.tracing.ApiTracer` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.httpjson.HttpJsonCallContext` |   |

### withTransportChannel(TransportChannel inputChannel)

    public HttpJsonCallContext withTransportChannel(TransportChannel inputChannel)

Returns a new ApiCallContext with the given channel set.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `inputChannel` | `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.TransportChannel` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.httpjson.HttpJsonCallContext` |   |