Class InvokeHTTP
java.lang.Object
org.apache.nifi.components.AbstractConfigurableComponent
org.apache.nifi.processor.AbstractSessionFactoryProcessor
org.apache.nifi.processor.AbstractProcessor
org.apache.nifi.processors.standard.InvokeHTTP
- All Implemented Interfaces:
org.apache.nifi.components.ConfigurableComponent,org.apache.nifi.processor.Processor
@SupportsSensitiveDynamicProperties
@SupportsBatching
@Tags({"http","https","rest","client"})
@InputRequirement(INPUT_ALLOWED)
@CapabilityDescription("An HTTP client processor which can interact with a configurable HTTP Endpoint. The destination URL and HTTP Method are configurable. When the HTTP Method is PUT, POST or PATCH, the FlowFile contents are included as the body of the request and FlowFile attributes are converted to HTTP headers, optionally, based on configuration properties.")
@WritesAttribute(attribute="invokehttp.status.code",description="The status code that is returned") @WritesAttribute(attribute="invokehttp.status.message",description="The status message that is returned") @WritesAttribute(attribute="invokehttp.response.body",description="In the instance where the status code received is not a success (2xx) then the response body will be put to the \'invokehttp.response.body\' attribute of the request FlowFile.") @WritesAttribute(attribute="invokehttp.request.url",description="The original request URL") @WritesAttribute(attribute="invokehttp.request.duration",description="Duration (in milliseconds) of the HTTP call to the external endpoint") @WritesAttribute(attribute="invokehttp.response.url",description="The URL that was ultimately requested after any redirects were followed") @WritesAttribute(attribute="invokehttp.tx.id",description="The transaction ID that is returned after reading the response") @WritesAttribute(attribute="invokehttp.remote.dn",description="The DN of the remote server") @WritesAttribute(attribute="invokehttp.java.exception.class",description="The Java exception class raised when the processor fails") @WritesAttribute(attribute="invokehttp.java.exception.message",description="The Java exception message raised when the processor fails") @WritesAttribute(attribute="user-defined",description="If the \'Put Response Body In Attribute\' property is set then whatever it is set to will become the attribute key and the value would be the body of the HTTP response.")
@DynamicProperty(name="Header Name",value="Attribute Expression Language",expressionLanguageScope=FLOWFILE_ATTRIBUTES,description="Send request header with a key matching the Dynamic Property Key and a value created by evaluating the Attribute Expression Language set in the value of the Dynamic Property.") @DynamicProperty(name="post:form:<NAME>",value="Attribute Expression Language",expressionLanguageScope=FLOWFILE_ATTRIBUTES,description="When the HTTP Method is POST, dynamic properties with the property name in the form of post:form:<NAME>, where the <NAME> will be the form data name, will be used to fill out the multipart form parts. If send message body is false, the flowfile will not be sent, but any other form data will be.")
public class InvokeHTTP
extends org.apache.nifi.processor.AbstractProcessor
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final org.apache.nifi.processor.Relationshipprotected static final Stringprivate static final Stringprivate static final Patternstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorprivate static final Stringstatic final org.apache.nifi.processor.Relationshipprivate Optional<OAuth2AccessTokenProvider> private final AtomicReference<okhttp3.OkHttpClient> static final org.apache.nifi.processor.Relationshipstatic final List<org.apache.nifi.components.PropertyDescriptor> private static final org.apache.nifi.components.PropertyDescriptorprivate static final ProxySpec[]static final Set<org.apache.nifi.processor.Relationship> static final Stringstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final Stringstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final Stringstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorprivate Patternstatic final org.apache.nifi.processor.Relationshipstatic final Stringstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final Stringstatic final org.apache.nifi.processor.Relationshipprivate static final DateTimeFormatterstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final Stringstatic final Stringstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate okhttp3.RequestconfigureRequest(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session, org.apache.nifi.flowfile.FlowFile requestFlowFile, String url) convertAttributesFromHeaders(okhttp3.Response responseHttp, String prefix) Returns a Map of flowfile attributes from the response http headers.protected Collection<org.apache.nifi.components.ValidationResult> customValidate(org.apache.nifi.components.ValidationContext validationContext) private Optional<HttpMethod> findRequestMethod(String method) private CharsetgetCharsetFromMediaType(okhttp3.MediaType contentType) private StringgetFileNameFromUrl(URL url) private FlowFileNamingStrategygetFlowFileNamingStrategy(org.apache.nifi.processor.ProcessContext context) Set<org.apache.nifi.processor.Relationship> private okhttp3.RequestBodygetRequestBodyToSend(org.apache.nifi.processor.ProcessSession session, org.apache.nifi.processor.ProcessContext context, org.apache.nifi.flowfile.FlowFile requestFlowFile, ContentEncodingStrategy contentEncodingStrategy) private StringgetRequestMethod(org.apache.nifi.context.PropertyContext context, org.apache.nifi.flowfile.FlowFile flowFile) private static Fileprotected org.apache.nifi.components.PropertyDescriptorgetSupportedDynamicPropertyDescriptor(String propertyDescriptorName) protected List<org.apache.nifi.components.PropertyDescriptor> voidinitOauth2AccessTokenProvider(org.apache.nifi.processor.ProcessContext context) private booleanisSuccess(int statusCode) voidvoidonPropertyModified(org.apache.nifi.components.PropertyDescriptor descriptor, String oldValue, String newValue) voidonTrigger(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session) private voidroute(org.apache.nifi.flowfile.FlowFile request, org.apache.nifi.flowfile.FlowFile response, org.apache.nifi.processor.ProcessSession session, org.apache.nifi.processor.ProcessContext context, int statusCode) private voidsetAuthenticator(okhttp3.OkHttpClient.Builder okHttpClientBuilder, org.apache.nifi.processor.ProcessContext context) private voidsetHeaderProperties(org.apache.nifi.processor.ProcessContext context, okhttp3.Request.Builder requestBuilder, org.apache.nifi.flowfile.FlowFile requestFlowFile) voidsetUpClient(org.apache.nifi.processor.ProcessContext context) Methods inherited from class org.apache.nifi.processor.AbstractProcessor
onTriggerMethods inherited from class org.apache.nifi.processor.AbstractSessionFactoryProcessor
getControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, init, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTrueMethods inherited from class org.apache.nifi.components.AbstractConfigurableComponent
equals, getPropertyDescriptor, getPropertyDescriptors, hashCode, validateMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.nifi.components.ConfigurableComponent
getPropertyDescriptor, getPropertyDescriptors, validateMethods inherited from interface org.apache.nifi.processor.Processor
isStateful, migrateRelationships
-
Field Details
-
STATUS_CODE
- See Also:
-
STATUS_MESSAGE
- See Also:
-
RESPONSE_BODY
- See Also:
-
REQUEST_URL
- See Also:
-
REQUEST_DURATION
- See Also:
-
RESPONSE_URL
- See Also:
-
TRANSACTION_ID
- See Also:
-
REMOTE_DN
- See Also:
-
EXCEPTION_CLASS
- See Also:
-
EXCEPTION_MESSAGE
- See Also:
-
DEFAULT_CONTENT_TYPE
- See Also:
-
FORM_DATA_NAME_BASE
- See Also:
-
FORM_DATA_NAME_PARAMETER_PATTERN
-
FORM_DATA_NAME_GROUP
- See Also:
-
IGNORED_REQUEST_ATTRIBUTES
-
HTTP_METHOD
public static final org.apache.nifi.components.PropertyDescriptor HTTP_METHOD -
HTTP_URL
public static final org.apache.nifi.components.PropertyDescriptor HTTP_URL -
HTTP2_DISABLED
public static final org.apache.nifi.components.PropertyDescriptor HTTP2_DISABLED -
SSL_CONTEXT_SERVICE
public static final org.apache.nifi.components.PropertyDescriptor SSL_CONTEXT_SERVICE -
SOCKET_CONNECT_TIMEOUT
public static final org.apache.nifi.components.PropertyDescriptor SOCKET_CONNECT_TIMEOUT -
SOCKET_READ_TIMEOUT
public static final org.apache.nifi.components.PropertyDescriptor SOCKET_READ_TIMEOUT -
SOCKET_WRITE_TIMEOUT
public static final org.apache.nifi.components.PropertyDescriptor SOCKET_WRITE_TIMEOUT -
SOCKET_IDLE_TIMEOUT
public static final org.apache.nifi.components.PropertyDescriptor SOCKET_IDLE_TIMEOUT -
SOCKET_IDLE_CONNECTIONS
public static final org.apache.nifi.components.PropertyDescriptor SOCKET_IDLE_CONNECTIONS -
REQUEST_OAUTH2_ACCESS_TOKEN_PROVIDER
public static final org.apache.nifi.components.PropertyDescriptor REQUEST_OAUTH2_ACCESS_TOKEN_PROVIDER -
REQUEST_OAUTH2_REFRESH_TOKEN
public static final org.apache.nifi.components.PropertyDescriptor REQUEST_OAUTH2_REFRESH_TOKEN -
REQUEST_USERNAME
public static final org.apache.nifi.components.PropertyDescriptor REQUEST_USERNAME -
REQUEST_PASSWORD
public static final org.apache.nifi.components.PropertyDescriptor REQUEST_PASSWORD -
REQUEST_DIGEST_AUTHENTICATION_ENABLED
public static final org.apache.nifi.components.PropertyDescriptor REQUEST_DIGEST_AUTHENTICATION_ENABLED -
REQUEST_FAILURE_PENALIZATION_ENABLED
public static final org.apache.nifi.components.PropertyDescriptor REQUEST_FAILURE_PENALIZATION_ENABLED -
REQUEST_BODY_ENABLED
public static final org.apache.nifi.components.PropertyDescriptor REQUEST_BODY_ENABLED -
REQUEST_FORM_DATA_NAME
public static final org.apache.nifi.components.PropertyDescriptor REQUEST_FORM_DATA_NAME -
REQUEST_FORM_DATA_FILENAME_ENABLED
public static final org.apache.nifi.components.PropertyDescriptor REQUEST_FORM_DATA_FILENAME_ENABLED -
REQUEST_CHUNKED_TRANSFER_ENCODING_ENABLED
public static final org.apache.nifi.components.PropertyDescriptor REQUEST_CHUNKED_TRANSFER_ENCODING_ENABLED -
REQUEST_CONTENT_ENCODING
public static final org.apache.nifi.components.PropertyDescriptor REQUEST_CONTENT_ENCODING -
REQUEST_CONTENT_TYPE
public static final org.apache.nifi.components.PropertyDescriptor REQUEST_CONTENT_TYPE -
REQUEST_DATE_HEADER_ENABLED
public static final org.apache.nifi.components.PropertyDescriptor REQUEST_DATE_HEADER_ENABLED -
REQUEST_HEADER_ATTRIBUTES_PATTERN
public static final org.apache.nifi.components.PropertyDescriptor REQUEST_HEADER_ATTRIBUTES_PATTERN -
REQUEST_USER_AGENT
public static final org.apache.nifi.components.PropertyDescriptor REQUEST_USER_AGENT -
RESPONSE_BODY_ATTRIBUTE_NAME
public static final org.apache.nifi.components.PropertyDescriptor RESPONSE_BODY_ATTRIBUTE_NAME -
RESPONSE_BODY_ATTRIBUTE_SIZE
public static final org.apache.nifi.components.PropertyDescriptor RESPONSE_BODY_ATTRIBUTE_SIZE -
RESPONSE_BODY_IGNORED
public static final org.apache.nifi.components.PropertyDescriptor RESPONSE_BODY_IGNORED -
RESPONSE_CACHE_ENABLED
public static final org.apache.nifi.components.PropertyDescriptor RESPONSE_CACHE_ENABLED -
RESPONSE_CACHE_SIZE
public static final org.apache.nifi.components.PropertyDescriptor RESPONSE_CACHE_SIZE -
RESPONSE_COOKIE_STRATEGY
public static final org.apache.nifi.components.PropertyDescriptor RESPONSE_COOKIE_STRATEGY -
RESPONSE_GENERATION_REQUIRED
public static final org.apache.nifi.components.PropertyDescriptor RESPONSE_GENERATION_REQUIRED -
RESPONSE_FLOW_FILE_NAMING_STRATEGY
public static final org.apache.nifi.components.PropertyDescriptor RESPONSE_FLOW_FILE_NAMING_STRATEGY -
RESPONSE_HEADER_REQUEST_ATTRIBUTES_ENABLED
public static final org.apache.nifi.components.PropertyDescriptor RESPONSE_HEADER_REQUEST_ATTRIBUTES_ENABLED -
RESPONSE_HEADER_REQUEST_ATTRIBUTES_PREFIX
public static final org.apache.nifi.components.PropertyDescriptor RESPONSE_HEADER_REQUEST_ATTRIBUTES_PREFIX -
RESPONSE_REDIRECTS_ENABLED
public static final org.apache.nifi.components.PropertyDescriptor RESPONSE_REDIRECTS_ENABLED -
PROXY_SPECS
-
PROXY_CONFIGURATION_SERVICE
private static final org.apache.nifi.components.PropertyDescriptor PROXY_CONFIGURATION_SERVICE -
PROPERTY_DESCRIPTORS
-
ORIGINAL
public static final org.apache.nifi.processor.Relationship ORIGINAL -
RESPONSE
public static final org.apache.nifi.processor.Relationship RESPONSE -
RETRY
public static final org.apache.nifi.processor.Relationship RETRY -
NO_RETRY
public static final org.apache.nifi.processor.Relationship NO_RETRY -
FAILURE
public static final org.apache.nifi.processor.Relationship FAILURE -
RELATIONSHIPS
-
RFC_2616_DATE_TIME
-
MULTIPLE_HEADER_DELIMITER
- See Also:
-
dynamicPropertyNames
-
requestHeaderAttributesPattern
-
oauth2AccessTokenProviderOptional
-
okHttpClientAtomicReference
-
-
Constructor Details
-
InvokeHTTP
public InvokeHTTP()
-
-
Method Details
-
getSupportedPropertyDescriptors
- Overrides:
getSupportedPropertyDescriptorsin classorg.apache.nifi.components.AbstractConfigurableComponent
-
getSupportedDynamicPropertyDescriptor
protected org.apache.nifi.components.PropertyDescriptor getSupportedDynamicPropertyDescriptor(String propertyDescriptorName) - Overrides:
getSupportedDynamicPropertyDescriptorin classorg.apache.nifi.components.AbstractConfigurableComponent
-
migrateProperties
-
getRelationships
- Specified by:
getRelationshipsin interfaceorg.apache.nifi.processor.Processor- Overrides:
getRelationshipsin classorg.apache.nifi.processor.AbstractSessionFactoryProcessor
-
onPropertyModified
public void onPropertyModified(org.apache.nifi.components.PropertyDescriptor descriptor, String oldValue, String newValue) - Specified by:
onPropertyModifiedin interfaceorg.apache.nifi.components.ConfigurableComponent- Overrides:
onPropertyModifiedin classorg.apache.nifi.components.AbstractConfigurableComponent
-
customValidate
protected Collection<org.apache.nifi.components.ValidationResult> customValidate(org.apache.nifi.components.ValidationContext validationContext) - Overrides:
customValidatein classorg.apache.nifi.components.AbstractConfigurableComponent
-
setUpClient
@OnScheduled public void setUpClient(org.apache.nifi.processor.ProcessContext context) throws IOException - Throws:
IOException
-
initOauth2AccessTokenProvider
@OnScheduled public void initOauth2AccessTokenProvider(org.apache.nifi.processor.ProcessContext context) -
setAuthenticator
private void setAuthenticator(okhttp3.OkHttpClient.Builder okHttpClientBuilder, org.apache.nifi.processor.ProcessContext context) -
onTrigger
public void onTrigger(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session) throws org.apache.nifi.processor.exception.ProcessException - Specified by:
onTriggerin classorg.apache.nifi.processor.AbstractProcessor- Throws:
org.apache.nifi.processor.exception.ProcessException
-
configureRequest
private okhttp3.Request configureRequest(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session, org.apache.nifi.flowfile.FlowFile requestFlowFile, String url) -
getRequestBodyToSend
private okhttp3.RequestBody getRequestBodyToSend(org.apache.nifi.processor.ProcessSession session, org.apache.nifi.processor.ProcessContext context, org.apache.nifi.flowfile.FlowFile requestFlowFile, ContentEncodingStrategy contentEncodingStrategy) -
setHeaderProperties
private void setHeaderProperties(org.apache.nifi.processor.ProcessContext context, okhttp3.Request.Builder requestBuilder, org.apache.nifi.flowfile.FlowFile requestFlowFile) -
route
private void route(org.apache.nifi.flowfile.FlowFile request, org.apache.nifi.flowfile.FlowFile response, org.apache.nifi.processor.ProcessSession session, org.apache.nifi.processor.ProcessContext context, int statusCode) -
isSuccess
private boolean isSuccess(int statusCode) -
convertAttributesFromHeaders
private Map<String,String> convertAttributesFromHeaders(okhttp3.Response responseHttp, String prefix) Returns a Map of flowfile attributes from the response http headers. Multivalue headers are naively converted to comma separated strings. Prefix is passed in to allow differentiation for these new attributes. -
getCharsetFromMediaType
-
getResponseCacheDirectory
- Throws:
IOException
-
getFlowFileNamingStrategy
private FlowFileNamingStrategy getFlowFileNamingStrategy(org.apache.nifi.processor.ProcessContext context) -
getFileNameFromUrl
-
findRequestMethod
-
getRequestMethod
private String getRequestMethod(org.apache.nifi.context.PropertyContext context, org.apache.nifi.flowfile.FlowFile flowFile)
-