com.azure.core.annotation.HeaderParam Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-core Show documentation
Show all versions of azure-core Show documentation
This package contains core types for Azure Java clients.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.core.annotation;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* Replaces the header with the value of its target. The value specified here replaces headers specified statically in
* the {@link Headers}. If the parameter this annotation is attached to is a Map type, then this will be treated as a
* header collection. In that case each of the entries in the argument's map will be individual header values that use
* the value of this annotation as a prefix to their key/header name.
*
* Example 1:
*
*
*
* @Put("{functionId}")
* Mono<ResponseBase<ResponseHeaders, ResponseBody>> createOrReplace(
* @PathParam(value = "functionId", encoded = true) String functionId,
* @BodyParam("application/json") RequestBody function,
* @HeaderParam("If-Match") String ifMatch);
*
* // "If-Match: user passed value" will show up as one of the headers.
*
*
*
* Example 2:
*
*
*
* @Get("subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces")
* Mono<ResponseBase<ResponseHeaders, ResponseBody>> list(@PathParam("subscriptionId") String subscriptionId,
* @HeaderParam("accept-language") String acceptLanguage,
* @HeaderParam("User-Agent") String userAgent);
*
* // "accept-language" generated by the HTTP client will be overwritten by the user passed value.
*
*
*
* Example 3:
*
*
*
* @Get("subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces")
* Mono<ResponseBase<ResponseHeaders, ResponseBody>> list(@PathParam("subscriptionId") String subscriptionId,
* @HeaderParam("Authorization") String token);
*
* // The token parameter will replace the effect of any credentials in the HttpPipeline.
*
*
*
* Example 4:
*
*
*
* @Put("{containerName}/{blob}")
* @ExpectedResponses({200})
* Mono<ResponseBase<ResponseHeaders, Void>> setMetadata(@PathParam("containerName") String containerName,
* @PathParam("blob") String blob,
* @HeaderParam("x-ms-meta-") Map<String, String> metadata);
*
* // The metadata parameter will be expanded out so that each entry becomes
* // "x-ms-meta-{@literal <entryKey>}: {@literal <entryValue>}".
*
*
*/
@Retention(RUNTIME)
@Target(PARAMETER)
public @interface HeaderParam {
/**
* The name of the variable in the endpoint uri template which will be replaced with the value of the parameter
* annotated with this annotation.
*
* @return The name of the variable in the endpoint uri template which will be replaced with the value of the
* parameter annotated with this annotation.
*/
String value();
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy