Package org.apache.camel.model.rest
Class RestDefinition
java.lang.Object
org.apache.camel.model.OptionalIdentifiedDefinition<RestDefinition>
org.apache.camel.model.rest.RestDefinition
- All Implemented Interfaces:
org.apache.camel.CamelContextAware,org.apache.camel.LineNumberAware,org.apache.camel.NamedNode,org.apache.camel.spi.HasCamelContext,org.apache.camel.spi.HasId,org.apache.camel.spi.IdAware,org.apache.camel.spi.ResourceAware
@Metadata(label="rest")
public class RestDefinition
extends OptionalIdentifiedDefinition<RestDefinition>
implements org.apache.camel.spi.ResourceAware
Defines a rest service using the rest-dsl
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionInclude or exclude the current Rest Definition in API documentation.static RouteDefinitionasRouteApiDefinition(org.apache.camel.CamelContext camelContext, org.apache.camel.spi.RestConfiguration configuration) Transforms the rest api configuration into aRouteDefinitionwhich Camel routing engine uses to service the rest api docs.asRouteDefinition(org.apache.camel.CamelContext camelContext) Transforms this REST definition into a list ofRouteDefinitionwhich Camel routing engine can add and run.protected StringasTypeName(Class<?> classType) bindingMode(String mode) bindingMode(RestBindingMode mode) buildFromUri(VerbDefinition verb) Build the from endpoint uri for the verbclientRequestValidation(boolean clientRequestValidation) delete()description(String description) Sets the description of this nodedisabled()Disables this REST service from the route during build time.disabled(boolean disabled) Whether to disable this REST service from the route during build time.Whether to disable this REST service from the route during build time.enableCORS(boolean enableCORS) enableNoContentResponse(boolean enableNoContentResponse) get()getLabel()getPath()org.apache.camel.spi.ResourcegetTag()getVerbs()head()Sets the id of this node.param()param(ParamDefinition param) param(VerbDefinition verb) params(List<ParamDefinition> params) patch()To set the base path of this REST servicepost()put()responseMessage(int code, String message) responseMessage(String code, String message) Sets the security setting for this verb.Sets the security setting for this verb.To configure security definitions.voidsetApiDocs(String apiDocs) Whether to include or exclude this rest operation in API documentation.voidsetBindingMode(String bindingMode) Sets the binding mode to use.voidsetClientRequestValidation(String clientRequestValidation) Whether to enable validation of the client request to check: 1) Content-Type header matches what the Rest DSL consumes; returns HTTP Status 415 if validation error.voidsetConsumes(String consumes) To define the content type what the REST service consumes (accept as input), such as application/xml or application/json.voidsetDisabled(String disabled) Whether to disable this REST service from the route during build time.voidsetEnableCORS(String enableCORS) Whether to enable CORS headers in the HTTP response.voidsetEnableNoContentResponse(String enableNoContentResponse) Whether to return HTTP 204 with an empty body when a response contains an empty JSON object or XML root object.voidPath of the rest service, such as "/foo"voidsetProduces(String produces) To define the content type what the REST service produces (uses for output), such as application/xml or application/json This option will override what may be configured on a parent levelvoidsetResource(org.apache.camel.spi.Resource resource) voidsetSecurityDefinitions(RestSecuritiesDefinition securityDefinitions) Sets the security definitions such as Basic, OAuth2 etc.voidsetSecurityRequirements(List<SecurityDefinition> securityRequirements) Sets the security requirement(s) for all endpoints.voidsetSkipBindingOnErrorCode(String skipBindingOnErrorCode) Whether to skip binding on output if there is a custom HTTP error code header.voidTo configure a special tag for the operations within this rest definition.voidsetVerbs(List<VerbDefinition> verbs) The HTTP verbs this REST service accepts and usesskipBindingOnErrorCode(boolean skipBindingOnErrorCode) To set the tag to use of this REST serviceThe Camel endpoint this REST service will call, such as a direct endpoint to link to an existing route that handles this REST call.protected voidvalidateUniqueDirects(List<VerbDefinition> verbs) protected voidvalidateUniquePaths(List<VerbDefinition> verbs) Methods inherited from class org.apache.camel.model.OptionalIdentifiedDefinition
getCamelContext, getCustomId, getDescription, getDescriptionText, getId, getLineNumber, getLocation, getNodePrefixId, getParent, hasCustomIdAssigned, idOrCreate, setCamelContext, setCustomId, setDescription, setGeneratedId, setId, setLineNumber, setLocation
-
Constructor Details
-
RestDefinition
public RestDefinition()
-
-
Method Details
-
getShortName
- Specified by:
getShortNamein interfaceorg.apache.camel.NamedNode
-
getLabel
- Specified by:
getLabelin interfaceorg.apache.camel.NamedNode
-
getPath
-
setPath
Path of the rest service, such as "/foo" -
getTag
-
setTag
To configure a special tag for the operations within this rest definition. -
getConsumes
-
setConsumes
To define the content type what the REST service consumes (accept as input), such as application/xml or application/json. This option will override what may be configured on a parent level -
getProduces
-
setProduces
To define the content type what the REST service produces (uses for output), such as application/xml or application/json This option will override what may be configured on a parent level -
getDisabled
-
setDisabled
Whether to disable this REST service from the route during build time. Once an REST service has been disabled then it cannot be enabled later at runtime. -
getBindingMode
-
setBindingMode
Sets the binding mode to use. This option will override what may be configured on a parent level The default value is auto -
getVerbs
-
getSecurityDefinitions
-
setSecurityDefinitions
Sets the security definitions such as Basic, OAuth2 etc. -
getSecurityRequirements
-
setSecurityRequirements
Sets the security requirement(s) for all endpoints. -
setVerbs
The HTTP verbs this REST service accepts and uses -
getSkipBindingOnErrorCode
-
setSkipBindingOnErrorCode
Whether to skip binding on output if there is a custom HTTP error code header. This allows to build custom error messages that do not bind to json / xml etc, as success messages otherwise will do. This option will override what may be configured on a parent level -
getClientRequestValidation
-
setClientRequestValidation
Whether to enable validation of the client request to check: 1) Content-Type header matches what the Rest DSL consumes; returns HTTP Status 415 if validation error. 2) Accept header matches what the Rest DSL produces; returns HTTP Status 406 if validation error. 3) Missing required data (query parameters, HTTP headers, body); returns HTTP Status 400 if validation error. 4) Parsing error of the message body (JSon, XML or Auto binding mode must be enabled); returns HTTP Status 400 if validation error. -
getEnableCORS
-
setEnableCORS
Whether to enable CORS headers in the HTTP response. This option will override what may be configured on a parent level The default value is false. -
getEnableNoContentResponse
-
setEnableNoContentResponse
Whether to return HTTP 204 with an empty body when a response contains an empty JSON object or XML root object. The default value is false. -
getApiDocs
-
setApiDocs
Whether to include or exclude this rest operation in API documentation. This option will override what may be configured on a parent level. The default value is true. -
getResource
public org.apache.camel.spi.Resource getResource()- Specified by:
getResourcein interfaceorg.apache.camel.spi.ResourceAware
-
setResource
public void setResource(org.apache.camel.spi.Resource resource) - Specified by:
setResourcein interfaceorg.apache.camel.spi.ResourceAware
-
path
To set the base path of this REST service -
disabled
Disables this REST service from the route during build time. Once an REST service has been disabled then it cannot be enabled later at runtime. -
disabled
Whether to disable this REST service from the route during build time. Once an REST service has been disabled then it cannot be enabled later at runtime. -
disabled
Whether to disable this REST service from the route during build time. Once an REST service has been disabled then it cannot be enabled later at runtime. -
tag
To set the tag to use of this REST service -
get
-
get
-
post
-
post
-
put
-
put
-
patch
-
patch
-
delete
-
delete
-
head
-
head
-
verb
-
verb
-
id
Description copied from class:OptionalIdentifiedDefinitionSets the id of this node. Important: If you want to set the id of the route, then you must use routeId(String) instead.- Overrides:
idin classOptionalIdentifiedDefinition<RestDefinition>- Parameters:
id- the id- Returns:
- the builder
-
routeId
-
deprecated
-
description
Description copied from class:OptionalIdentifiedDefinitionSets the description of this node- Overrides:
descriptionin classOptionalIdentifiedDefinition<RestDefinition>- Parameters:
description- sets the text description, use null to not set a text- Returns:
- the builder
-
consumes
-
param
-
param
-
params
-
param
-
responseMessage
-
responseMessage
-
responseMessage
-
responseMessages
-
responseMessage
-
responseMessage
-
securityDefinitions
To configure security definitions. -
produces
-
type
-
outType
-
bindingMode
-
bindingMode
-
skipBindingOnErrorCode
-
clientRequestValidation
-
enableCORS
-
enableNoContentResponse
-
apiDocs
Include or exclude the current Rest Definition in API documentation. The default value is true. -
security
Sets the security setting for this verb. -
security
Sets the security setting for this verb. -
to
The Camel endpoint this REST service will call, such as a direct endpoint to link to an existing route that handles this REST call.- Parameters:
uri- the uri of the endpoint- Returns:
- this builder
-
buildFromUri
Build the from endpoint uri for the verb -
asRouteDefinition
Transforms this REST definition into a list ofRouteDefinitionwhich Camel routing engine can add and run. This allows us to define REST services using this REST DSL and turn those into regular Camel routes.- Parameters:
camelContext- The Camel context
-
validateUniquePaths
-
validateUniqueDirects
-
asTypeName
-
asRouteApiDefinition
public static RouteDefinition asRouteApiDefinition(org.apache.camel.CamelContext camelContext, org.apache.camel.spi.RestConfiguration configuration) Transforms the rest api configuration into aRouteDefinitionwhich Camel routing engine uses to service the rest api docs.
-