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

De-initialization of a previously created HTTP client.

Arguments

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

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.

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.

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, or bearer).

  • 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).

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.

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.

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.

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.

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.