Annotation Type RestDelete
RestServlet
implementation class.
This is a specialized subtype of @RestOp
(method=
See Also:
-
Optional Element Summary
Modifier and TypeOptional ElementDescriptionSpecifies whether this method can be called based on the client version.Enable debug mode.DefaultAccept header.Default character encoding.String[]
Default request attributes.String[]
Default request headers.String[]
Specifies default values for query parameters.String[]
Default response headers.String[]
Optional description for the exposed API.Specifies the compression encoders for this method.Method-level guards.Class<? extends RestMatcher>[]
Method matchers.String[]
Dynamically apply this annotation to the specified methods.String[]
Optional path pattern for the specified method.Role guard.Declared roles.Optional summary for the exposed API.Provides swagger-specific metadata on this method.REST method path.
-
Element Details
-
clientVersion
Specifies whether this method can be called based on the client version.The client version is identified via the HTTP request header identified by
@Rest(clientVersionHeader)
which by default is"Client-Version" .This is a specialized kind of
RestMatcher
that allows you to invoke different Java methods for the same method/path based on the client version.The format of the client version range is similar to that of OSGi versions.
In the following example, the Java methods are mapped to the same HTTP method and URL
"/foobar" .// Call this method if Client-Version is at least 2.0. // Note that this also matches 2.0.1. @RestDelete (path="/foobar" , clientVersion="2.0" )public Object method1() {...}// Call this method if Client-Version is at least 1.1, but less than 2.0. @RestDelete (path="/foobar" , clientVersion="[1.1,2.0)" )public Object method2() {...}// Call this method if Client-Version is less than 1.1. @RestDelete (path="/foobar" , clientVersion="[0,1.1)" )public Object method3() {...}It's common to combine the client version with transforms that will convert new POJOs into older POJOs for backwards compatibility.
// Call this method if Client-Version is at least 2.0. @RestDelete (path="/foobar" , clientVersion="2.0" )public void newMethod() {...}// Call this method if Client-Version is at least 1.1, but less than 2.0. @RestDelete (path="/foobar" , clientVersion="[1.1,2.0)" })public void oldMethod() {...}Note that in the previous example, we're returning the exact same POJO, but using a transform to convert it into an older form. The old method could also just return back a completely different object. The range can be any of the following:
"[0,1.0)" = Less than 1.0. 1.0 and 1.0.0 does not match."[0,1.0]" = Less than or equal to 1.0. Note that 1.0.1 will match."1.0" = At least 1.0. 1.0 and 2.0 will match.
See Also:
- Returns:
- The annotation value.
- Default:
- ""
-
debug
Enable debug mode.Enables the following:
- HTTP request/response bodies are cached in memory for logging purposes.
- Request/response messages are automatically logged.
"true" - Debug is enabled for all requests."false" - Debug is disabled for all requests."conditional" - Debug is enabled only for requests that have aDebug: true header."" (or anything else) - Debug mode is inherited from class.
Notes:
-
Supports SVL Variables
(e.g.
"$L{my.localized.variable}" ).
See Also:
- Returns:
- The annotation value.
- Default:
- ""
-
defaultAccept
DefaultAccept header.The default value for the
Accept header if not specified on a request.This is a shortcut for using
defaultRequestHeaders()
for just this specific header.- Returns:
- The annotation value.
- Default:
- ""
-
defaultCharset
Default character encoding.The default character encoding for the request and response if not specified on the request.
Notes:
-
Supports SVL Variables
(e.g.
"$S{mySystemProperty}" ).
See Also:
- Returns:
- The annotation value.
- Default:
- ""
-
Supports SVL Variables
(e.g.
-
defaultRequestQueryData
Specifies default values for query parameters.Strings are of the format
"name=value" .Affects values returned by
RestRequest.getQueryParam(String)
when the parameter is not present on the request.Example:
@RestDelete (path="/*" , defaultRequestQueryData={"foo=bar" })public String doDelete(@Query ("foo" ) Stringfoo ) {...}Notes:
-
You can use either
':' or'=' as the key/value delimiter. - Key and value is trimmed of whitespace.
-
Supports SVL Variables
(e.g.
"$S{mySystemProperty}" ).
- Returns:
- The annotation value.
- Default:
- {}
-
You can use either
-
defaultRequestAttributes
Default request attributes.Specifies default values for request attributes if they're not already set on the request.
Affects values returned by the following methods:
Example:
// Defined via annotation resolving to a config file setting with default value. @Rest (defaultRequestAttributes={"Foo=bar" ,"Baz: $C{REST/myAttributeValue}" })public class MyResource {// Override at the method level. @RestGet (defaultRequestAttributes={"Foo: bar" })public Object myMethod() {...} }Notes:
-
Supports SVL Variables
(e.g.
"$L{my.localized.variable}" ).
See Also:
- Returns:
- The annotation value.
- Default:
- {}
-
Supports SVL Variables
(e.g.
-
defaultRequestHeaders
Default request headers.Specifies default values for request headers if they're not passed in through the request.
Example:
// Assume "text/json" Accept value when Accept not specified @RestDelete (path="/*" , defaultRequestHeaders={"Accept: text/json" })public String doDelete() {...}Notes:
-
Supports SVL Variables
(e.g.
"$S{mySystemProperty}" ).
See Also:
- Returns:
- The annotation value.
- Default:
- {}
-
Supports SVL Variables
(e.g.
-
defaultResponseHeaders
Default response headers.Specifies default values for response headers if they're not overwritten during the request.
Example:
// Assume "text/json" Accept value when Accept not specified @RestDelete (path="/*" , defaultResponseHeaders={"Content-Type: text/json" })public String doDelete() {...}Notes:
-
Supports SVL Variables
(e.g.
"$S{mySystemProperty}" ).
See Also:
- Returns:
- The annotation value.
- Default:
- {}
-
Supports SVL Variables
(e.g.
-
description
Optional description for the exposed API.This description is used in the following locations:
-
The value returned by
Operation.getDescription()
in the auto-generated swagger. -
The
"$RS{operationDescription}" variable. - The description of the method in the Swagger page.
Notes:
-
Corresponds to the swagger field
/paths/{path}/{method}/description . -
Supports SVL Variables
(e.g.
"$L{my.localized.variable}" ).
- Returns:
- The annotation value.
- Default:
- {}
-
The value returned by
-
encoders
Specifies the compression encoders for this method.Encoders are used to enable various kinds of compression (e.g.
"gzip" ) on requests and responses.This value overrides encoders specified at the class level using
Rest.encoders()
. TheEncoderSet.Inherit
class can be used to include values from the parent class.Example:
// Define a REST resource that handles GZIP compression. @Rest ( encoders={ GzipEncoder.class } )public class MyResource {// Define a REST method that can also use a custom encoder. @RestDelete ( encoders={ EncoderSet.Inherit.class , MyEncoder.class } )public String doDelete() { ... } }The programmatic equivalent to this annotation is:
RestOpContext.Builder
builder = RestOpContext.create (method ,restContext );builder .getEncoders().set(classes );See Also:
- Returns:
- The annotation value.
- Default:
- {}
-
guards
Method-level guards.Associates one or more
RestGuards
with this method.See Also:
- Returns:
- The annotation value.
- Default:
- {}
-
matchers
Class<? extends RestMatcher>[] matchersMethod matchers.Associates one more more
RestMatchers
with this method.Matchers are used to allow multiple Java methods to handle requests assigned to the same URL path pattern, but differing based on some request attribute, such as a specific header value.
See Also:
- Returns:
- The annotation value.
- Default:
- {}
-
on
Dynamically apply this annotation to the specified methods.See Also:
- Returns:
- The annotation value.
- Default:
- {}
-
path
Optional path pattern for the specified method.Appending
"/*" to the end of the path pattern will make it match any remainder too.
Not appending"/*" to the end of the pattern will cause a 404 (Not found) error to occur if the exact pattern is not found.The path can contain variables that get resolved to
@Path
parameters.Examples:
@RestDelete (path="/myurl/{foo}/{bar}/{baz}/*" )@RestDelete (path="/myurl/{0}/{1}/{2}/*" )Note that you can also use
value()
to specify the path.See Also:
- Returns:
- The annotation value.
- Default:
- {}
-
roleGuard
Role guard.An expression defining if a user with the specified roles are allowed to access this method.
Example:
public class MyResourceextends BasicRestServlet {@RestDelete ( path="/foo" , roleGuard="ROLE_ADMIN || (ROLE_READ_WRITE && ROLE_SPECIAL)" )public Object doDelete() { } }Notes:
-
Supports any of the following expression constructs:
"foo" - Single arguments."foo,bar,baz" - Multiple OR'ed arguments."foo | bar | baz" - Multiple OR'ed arguments, pipe syntax."foo || bar || baz" - Multiple OR'ed arguments, Java-OR syntax."fo*" - Patterns including'*' and'?' ."fo* & *oo" - Multiple AND'ed arguments, ampersand syntax."fo* && *oo" - Multiple AND'ed arguments, Java-AND syntax."fo* || (*oo || bar)" - Parenthesis.
- AND operations take precedence over OR operations (as expected).
- Whitespace is ignored.
-
null or empty expressions always match asfalse . -
If patterns are used, you must specify the list of declared roles using
rolesDeclared()
orRestOpContext.Builder.rolesDeclared(String...)
. -
Supports SVL Variables
(e.g.
"$L{my.localized.variable}" ). - When defined on parent/child classes and methods, ALL guards within the hierarchy must pass.
See Also:
- Returns:
- The annotation value.
- Default:
- ""
-
Supports any of the following expression constructs:
-
rolesDeclared
Declared roles.A comma-delimited list of all possible user roles.
Used in conjunction with
roleGuard()
is used with patterns.Example:
public class MyResourceextends BasicRestServlet {@RestDelete ( path="/foo" , rolesDeclared="ROLE_ADMIN,ROLE_READ_WRITE,ROLE_READ_ONLY,ROLE_SPECIAL" , roleGuard="ROLE_ADMIN || (ROLE_READ_WRITE && ROLE_SPECIAL)" )public Object doDelete() { } }See Also:
- Returns:
- The annotation value.
- Default:
- ""
-
summary
Optional summary for the exposed API.This summary is used in the following locations:
-
The value returned by
Operation.getSummary()
in the auto-generated swagger. -
The
"$RS{operationSummary}" variable. - The summary of the method in the Swagger page.
Notes:
-
Corresponds to the swagger field
/paths/{path}/{method}/summary . -
Supports SVL Variables
(e.g.
"$L{my.localized.variable}" ).
- Returns:
- The annotation value.
- Default:
- ""
-
The value returned by
-
swagger
Provides swagger-specific metadata on this method.Used to populate the auto-generated OPTIONS swagger documentation.
The format of this annotation is JSON when all individual parts are concatenated.
The starting and ending'{' /'}' characters around the entire value are optional.Example:
@RestDelete ( path="/{propertyName}" ,// Swagger info. swagger={"parameters:[" ,"{name:'propertyName',in:'path',description:'The system property name.'}," ,"{in:'body',description:'The new system property value.'}" ,"]," ,"responses:{" ,"302: {headers:{Location:{description:'The root URL of this resource.'}}}," ,"403: {description:'User is not an admin.'}" ,"}" } )Notes:
-
The format is Swagger.
Multiple lines are concatenated with newlines. -
The starting and ending
'{' /'}' characters around the entire value are optional. - These values are superimposed on top of any Swagger JSON file present for the resource in the classpath.
-
Supports SVL Variables
(e.g.
"$L{my.localized.variable}" ).
See Also:
- Returns:
- The annotation value.
- Default:
- @org.apache.juneau.rest.annotation.OpSwagger
-
The format is Swagger.
-
value
REST method path.Can be used to provide a shortened form for the
path()
value.The following examples are considered equivalent.
// Normal form @RestDelete (path="/{propertyName}" )// Shortened form @RestDelete ("/{propertyName}" )- Returns:
- The annotation value.
- Default:
- ""
-