HTTP Support Package
Subsystem Engee.Integrations provides the user with the ability to act as an HTTP client to communicate with external services via the REST API.
#
Main.EngeeDeviceManager.Devices.HTTP.Http — Type
#
Main.EngeeDeviceManager.Devices.HTTP.close_session — Method
function close_session(device::HttpType)::Nothing
De-initialization of a previously created HTTP client.
Arguments
device::HttpType: an object of the HTTP.Http() type.
#
Main.EngeeDeviceManager.Devices.HTTP.close_session — Method
#
Main.EngeeDeviceManager.Devices.HTTP.delete — Function
function delete(device::HttpType, endpoint::String, request_data::HTTPRequestData, headers::Dict{String, String}=Dict(), timeout::Union{Int64, Nothing}=nothing)::HTTPResponse
DELETE is a REST API request. Returns HTTPResponse — an object with the server response containing:
-
text_content: HTTP response in text representation; -
bytes_content: HTTP response in byte representation; -
elapsed: request completion time; -
status_code: status code of the HTTP request.
Server response example
Base.@kwdef struct HTTPResponse
text_content::Union{String, Nothing} = nothing
bytes_content::Union{Vector{UInt8}, Nothing} = nothing
elapsed::Union{HTTPTimedelta, Nothing} = nothing
status_code::Union{Int64, Nothing} = nothing
end
Arguments
-
device::HttpType: an object of the HTTP.Http() type. -
endpoint::String: the endpoint for accessing an HTTP resource. -
request_data::HTTPRequestData: request data (an HTTPRequestData object). -
headers::Dict{String, String}: additional headings. For example, setting up connection headers and MIME-type requests:headers = Dict{String, String}() headers["connection"] = "keep-alive" headers["Accept"] = "application/json" -
timeout::Union{Int64, Nothing}: timeout for waiting for a response in seconds.
#
Main.EngeeDeviceManager.Devices.HTTP.get — Function
function get(device::HttpType, endpoint::String, request_data::HTTPRequestData, headers::Dict{String, String}=Dict(), timeout::Union{Int64, Nothing}=nothing)::HTTPResponse
A REST API GET request. Returns HTTPResponse — an object with the server response containing:
-
text_content: HTTP response in text representation; -
bytes_content: HTTP response in byte representation; -
elapsed: request completion time; -
status_code: status code of the HTTP request.
Server response example
Base.@kwdef struct HTTPResponse
text_content::Union{String, Nothing} = nothing
bytes_content::Union{Vector{UInt8}, Nothing} = nothing
elapsed::Union{HTTPTimedelta, Nothing} = nothing
status_code::Union{Int64, Nothing} = nothing
end
Arguments
-
device::HttpType: an object of the HTTP.Http() type. -
endpoint::String: the endpoint for accessing an HTTP resource. -
request_data::HTTPRequestData: an HTTPRequestData object. -
headers::Dict{String, String}: additional headings. For example, setting up connection headers and MIME-type requests:headers = Dict{String, String}() headers["connection"] = "keep-alive" headers["Accept"] = "application/json" -
timeout::Union{Int64, Nothing}: timeout for waiting for a response in seconds.
#
Main.EngeeDeviceManager.Devices.HTTP.init_session — Function
function init_session(device::HttpType, base_url::String="", auth::Union{Tuple{String}, String, Nothing}=nothing, auth_type::String="bearer", headers::Dict{String, String}=Dict(), timeout::Int64=30, verify_ssl::Bool=true)::Bool
Initializing the HTTP client to communicate with the HTTP server.
Arguments
-
device::HttpType: an object of the HTTP.Http() type. -
base_url::String: the base URL for all requests. -
auth::Union{Tuple{String}: authorization data, either a tuple (username, password), or a string with a token. -
auth_type::String: authentication type (basic,digest, orbearer). -
headers::Dict{String, String}: default headers to include in each request. -
timeout::Int64: default response timeout in seconds. -
verify_ssl::Bool: verification of SSL certificates (true— enabled,false— disabled).
#
Main.EngeeDeviceManager.Devices.HTTP.patch — Function
function patch(device::HttpType, endpoint::String, request_data::HTTPRequestData, headers::Dict{String, String}=Dict(), timeout::Union{Int64, Nothing}=nothing)::HTTPResponse
A PATCH request for the REST API. Returns HTTPResponse — an object with the server response containing:
-
text_content: HTTP response in text representation; -
bytes_content: HTTP response in byte representation; -
elapsed: request completion time; -
status_code: status code of the HTTP request.
Server response example
Base.@kwdef struct HTTPResponse
text_content::Union{String, Nothing} = nothing
bytes_content::Union{Vector{UInt8}, Nothing} = nothing
elapsed::Union{HTTPTimedelta, Nothing} = nothing
status_code::Union{Int64, Nothing} = nothing
end
Arguments
-
device::HttpType: an object of the HTTP.Http() type. -
endpoint::String: the endpoint for accessing an HTTP resource. -
request_data::HTTPRequestData: an HTTPRequestData object. -
headers::Dict{String, String}: additional headings. For example, setting up connection headers and MIME-type requests:headers = Dict{String, String}() headers["connection"] = "keep-alive" headers["Accept"] = "application/json" -
timeout::Union{Int64, Nothing}: timeout for waiting for a response in seconds.
#
Main.EngeeDeviceManager.Devices.HTTP.post — Function
function post(device::HttpType, endpoint::String, request_data::HTTPRequestData, headers::Dict{String, String}=Dict(), timeout::Union{Int64, Nothing}=nothing)::HTTPResponse
A POST request to the REST API. Returns HTTPResponse — an object with the server response containing:
-
text_content: HTTP response in text representation; -
bytes_content: HTTP response in byte representation; -
elapsed: request completion time; -
status_code: status code of the HTTP request.
Server response example
Base.@kwdef struct HTTPResponse
text_content::Union{String, Nothing} = nothing
bytes_content::Union{Vector{UInt8}, Nothing} = nothing
elapsed::Union{HTTPTimedelta, Nothing} = nothing
status_code::Union{Int64, Nothing} = nothing
end
Arguments
-
device::HttpType: an object of the HTTP.Http() type. -
endpoint::String: the endpoint for accessing an HTTP resource. -
request_data::HTTPRequestData: an HTTPRequestData object. -
headers::Dict{String, String}: additional headings. For example, setting up connection headers and MIME-type requests:headers = Dict{String, String}() headers["connection"] = "keep-alive" headers["Accept"] = "application/json" -
timeout::Union{Int64, Nothing}: timeout for waiting for a response in seconds.
#
Main.EngeeDeviceManager.Devices.HTTP.put — Function
function put(device::HttpType, endpoint::String, request_data::HTTPRequestData, headers::Dict{String, String}=Dict(), timeout::Union{Int64, Nothing}=nothing)::HTTPResponse
A REST API PUT request. Returns HTTPResponse — an object with the server response containing:
-
text_content: HTTP response in text representation; -
bytes_content: HTTP response in byte representation; -
elapsed: request completion time; -
status_code: status code of the HTTP request.
Server response example
Base.@kwdef struct HTTPResponse
text_content::Union{String, Nothing} = nothing
bytes_content::Union{Vector{UInt8}, Nothing} = nothing
elapsed::Union{HTTPTimedelta, Nothing} = nothing
status_code::Union{Int64, Nothing} = nothing
end
Arguments
-
device::HttpType: an object of the HTTP.Http() type. -
endpoint::String: the endpoint for accessing an HTTP resource. -
request_data::HTTPRequestData: an HTTPRequestData object. -
headers::Dict{String, String}: additional headings. For example, setting up connection headers and MIME-type requests:headers = Dict{String, String}() headers["connection"] = "keep-alive" headers["Accept"] = "application/json" -
timeout::Union{Int64, Nothing}: timeout for waiting for a response in seconds.
#
Main.EngeeDeviceManager.Devices.HTTP.remove_header — Method
function remove_header(device::HttpType, key::String)::Nothing
A function to remove specified request headers from existing headers.
Arguments
-
device::HttpType: an object of the HTTP.Http() type. -
key::String: the key of the request header to be set.
#
Main.EngeeDeviceManager.Devices.HTTP.remove_header — Method
Deletes the header from all subsequent requests.
#
Main.EngeeDeviceManager.Devices.HTTP.set_header — Method
function set_header(device::HttpType, key::String, value::String)::Nothing
A function for setting request headers to already existing headers.
Arguments
-
device::HttpType: an object of the HTTP.Http() type. -
key::String: the key of the request header to be set.
#
Main.EngeeDeviceManager.Devices.HTTP.set_header — Method
Sets the header for all subsequent requests.