Connections to MIMIQ
MimiqLink.MimiqLink
— Modulemodule MimiqLink end
This module contains convenience tools to establish and keep up a connection to the QPerfect MIMIQ services, both remote or on premises.
It allows for three different connection modes: via login page, via token, via credentials.
Login Page
This method will open a browser pointing to a login page. The user will be asked to insert username/email and password.
julia> using MimiqLink
julia> connection = MimiqLink.connect()
optionally an address for the MIMIQ services can be specified
julia> connection = MimiqLink.connect(url = "http://127.0.0.1/api")
Token
This method will allow the user to save a token file (by login via a login page), and then load it also from another julia session.
julia> using MimiqLink
julia> MimiqLink.savetoken(url = "http://127.0.0.1/api")
this will save a token in the qperfect.json
file in the current directory. In another julia session is then possible to do:
julia> using MimiqLink
julia> connection = MimiqLink.loadtoken("path/to/my/qperfect.json")
Credentials
This method will allow users to access by directly use their own credentials.
It is strongly discuraged to use this method. If files with credentials will be shared the access to the qperfect account might be compromised.
julia> using MimiqLink
julia> connection = MimiqLink.connect("me@mymail.com", "myweakpassword")
julia> MimiqLink.connect("me@mymail.com", "myweakpassword"; url = "http://127.0.0.1/api")
MimiqLink.QPERFECT_CLOUD
— Constantconst QPERFECT_CLOUD
Address for the QPerfect Cloud services
MimiqLink.QPERFECT_CLOUD2
— Constantconst QPERFECT_CLOUD2
Addressfor secondary QPerfect Cloud services
MimiqLink.connect
— Functionconnect([; url=QPREFECT_CLOUD])
connect(token[; url=QPREFECT_CLOUD])
connect(username, password[; url=QPREFECT_CLOUD])
Establish a connection to the MIMIQ Services.
A refresh process will be spawned in the background to refresh the access credentials. An active connection can be closed by using the close(connection)
method. As an example:
connection = connect("john.doe@example.com", "johnspassword")
close(connection)
The first method will open a login page in the default browser and ask for your email and password. This method is encouraged, as it will avoid saving your password as plain text in your scripts or notebooks.
There are two main servers for the MIMIQ Services: the main one and a secondary one. Users are supposed to use the main one.
julia> QPERFECT_CLOUD
URI("https://mimiq.qperfect.io/api")
julia> QPERFECT_CLOUD2
URI("https://mimiqfast.qperfect.io/api")
MimiqLink.isjobcanceled
— Methodisjobcanceled(conn, execution)
Check if a job has been canceled.
MimiqLink.isjobdone
— Methodisjobdone(conn, execution)
Check if a job is done.
Will return true
if the job finished successfully or with an error and false
otherwise.
MimiqLink.isjobfailed
— Methodisjobfailed(conn, execution)
Check if a job failed.
MimiqLink.isjobstarted
— Methodisjobstarted(conn, execution)
Check if a job has started executing.
MimiqLink.loadtoken
— Functionloadtoken([filename])
Establish a connection to the MIMIQ Services by loading the credentials from a JSON file.
Arguments
filename
: file where to load the credentials (default:qperfect.json
)
The credentials are usually valid only for a small amount of time, so you may need to regenerate them from time to time.
Examples
julia> savetoken("myqperfectcredentials.json")
julia> connection = loadtoken("myqperfectcredentials.json")
MimiqLink.requestinfo
— Methodrequestinfo(conn, req)
Retrieve information about an execution request.
MimiqLink.savetoken
— Functionsavetoken([filename][; url=QPERFECT_CLOUD)
Establish a connection to the MIMIQ Services and save the credentials in a JSON file.
Arguments
filename
: file where to save the credentials (default:qperfect.json
)
Keyword arguments
url
: the uri of the MIMIQ Services (default:QPERFECT_CLOUD
value)
Examples
julia> savetoken("myqperfectcredentials.json")
julia> connection = loadtoken("myqperfectcredentials.json")