Engee documentation

HTTP Software Management

This page contains all the available HTTP software management functions in Engee.

To work with HTTP software management functions in Engee, follow the instructions given in article.

function close_session(device::HttpType)::Nothing

Deinitialisation of a previously created HTTP client.

Arguments

  • device::HttpType: an object of type HTTP.Http().

function delete(device::HttpType, endpoint::String, request_data::HTTPRequestData, headers::Dict{String, String}=Dict(), timeout::Union{Int64, Nothing}=nothing)::HTTPResponse

A DELETE request to the REST API. Returns a HTTPResponse — an object containing the server’s response, comprising:

  • text_content : the HTTP response in text format;

  • bytes_content : the HTTP response in byte format;

  • elapsed : the request execution time;

  • status_code : the HTTP request status code.

Example of a server response

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 type HTTP.Http().

  • endpoint::String : the endpoint for accessing the HTTP resource.

  • request_data::HTTPRequestData : request data (an object of type HTTPRequestData).

  • headers::Dict{String, String}: additional headers. For example, configuring connection headers and MIME types for requests:

julia-repl headers = Dict{String, String}() headers["connection"] = "keep-alive" headers["Accept"] = "application/json"

  • timeout::Union{Int64, Nothing} : timeout for waiting for a response, in seconds.

function get(device::HttpType, endpoint::String, request_data::HTTPRequestData, headers::Dict{String, String}=Dict(), timeout::Union{Int64, Nothing}=nothing)::HTTPResponse

REST API GET request. Returns a HTTPResponse — an object containing the server’s response, comprising:

  • text_content : HTTP response in text format;

  • bytes_content : HTTP response in byte format;

  • elapsed : request execution time;

  • status_code : HTTP request status code.

Example of a server response

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 type HTTP.Http().

  • endpoint::String : the endpoint for accessing the HTTP resource.

  • request_data::HTTPRequestData : an object of type HTTPRequestData.

  • headers::Dict{String, String}: additional headers. For example, configuring connection headers and MIME types for requests:

julia-repl headers = Dict{String, String}() headers["connection"] = "keep-alive" headers["Accept"] = "application/json"

  • timeout::Union{Int64, Nothing} : timeout for waiting for a response, in seconds.

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

Initialising an HTTP client to communicate with an HTTP server.

Arguments

  • device::HttpType : an object of type HTTP.Http().

  • base_url::String : the base URL for all requests.

  • auth::Union{Tuple{String} : authorisation credentials, either a tuple (username, password) or a string containing a token.

  • auth_type::String : authentication type (basic, digest, or bearer).

  • headers::Dict{String, String} : by default, headers to include in every request.

  • timeout::Int64 : by default, response timeout in seconds.

  • verify_ssl::Bool : SSL certificate verification (true-- enabled, false — disabled).

function patch(device::HttpType, endpoint::String, request_data::HTTPRequestData, headers::Dict{String, String}=Dict(), timeout::Union{Int64, Nothing}=nothing)::HTTPResponse

REST API PATCH request. Returns HTTPResponse-- an object containing the server’s response, comprising: `

  • `text_content: HTTP response in text representation;

`

  • `bytes_content: HTTP response in byte representation;

`

  • `elapsed: request execution time;

`

  • `status_code: HTTP request status code.

Example of a server response

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 type HTTP.Http().

  • endpoint::String : the endpoint for accessing the HTTP resource.

  • request_data::HTTPRequestData : an object of type HTTPRequestData.

  • headers::Dict{String, String}: additional headers. For example, configuring connection headers and MIME types for requests:

julia-repl headers = Dict{String, String}() headers["connection"] = "keep-alive" headers["Accept"] = "application/json"

  • timeout::Union{Int64, Nothing} : timeout for waiting for a response, in seconds.

function post(device::HttpType, endpoint::String, request_data::HTTPRequestData, headers::Dict{String, String}=Dict(), timeout::Union{Int64, Nothing}=nothing)::HTTPResponse

REST API POST request. Returns HTTPResponse — an object containing the server’s response, comprising:

  • text_content : the HTTP response in text format;

  • bytes_content : the HTTP response in byte format;

  • elapsed : the request execution time;

  • status_code : the HTTP request status code.

Example of a server response

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 type HTTP.Http().

  • endpoint::String : the endpoint for accessing the HTTP resource.

  • request_data::HTTPRequestData : an object of type HTTPRequestData.

  • headers::Dict{String, String}: additional headers. For example, configuring connection headers and MIME types for requests:

julia-repl headers = Dict{String, String}() headers["connection"] = "keep-alive" headers["Accept"] = "application/json"

  • timeout::Union{Int64, Nothing} : response wait timeout in seconds.

function put(device::HttpType, endpoint::String, request_data::HTTPRequestData, headers::Dict{String, String}=Dict(), timeout::Union{Int64, Nothing}=nothing)::HTTPResponse

PUT request to the REST API. Returns HTTPResponse — an object containing the server’s response, comprising:

  • text_content : HTTP response in text representation;

  • bytes_content : HTTP response in byte representation;

  • elapsed : request execution time;

  • status_code : HTTP request status code.

Example of a server response

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 type HTTP.Http().

  • endpoint::String : endpoint for accessing the HTTP resource.

  • request_data::HTTPRequestData : an object of type HTTPRequestData.

  • headers::Dict{String, String}: additional headers. For example, configuring connection headers and MIME types for requests:

julia-repl headers = Dict{String, String}() headers["connection"] = "keep-alive" headers["Accept"] = "application/json"

  • timeout::Union{Int64, Nothing} : timeout for waiting for a response, in seconds.

function remove_header(device::HttpType, key::String)::Nothing

A function to remove the specified request headers from the existing headers.

Arguments

  • device::HttpType : an object of type HTTP.Http().

  • key::String : the key of the request header to be set.

function set_header(device::HttpType, key::String, value::String)::Nothing

A function for setting request headers alongside existing ones.

Arguments

  • device::HttpType : an object of type HTTP.Http().

  • key::String : the key of the request header to be set.