Quaero.REST.Agent
Quaero.REST.Agent Class
public class Quaero.REST.Agent;
Quaero Archive REST API user agent.
quaero_ca_create() Method
Quaero.REST.Agent.quaero_ca_create();
Build Quaero Certificate Authority object, if it isn't already built.
ca_create() Method
Quaero.REST.Agent.ca_create(System.IO.Stream stream);
Create a cert from a stream.
Parameters
- stream
-
Stream to read the certificate from
[System.IO.Stream]
ca_create() Method
Quaero.REST.Agent.ca_create(System.Byte[] raw);
Create a cert from a byte array.
Parameters
- raw
-
The raw certificate data.
[System.Byte[]]
ca_create() Method
Quaero.REST.Agent.ca_create(System.String filename);
Create a cert from a file.
Parameters
- filename
-
Name of the file to load the cert from.
[System.String]
set_credentials() Method
void Quaero.REST.Agent.set_credentials(System.String tokenID, System.String secret);
Set the credentials used for authentication. The credentials are provided by the adminstrative tools, under Users.
Parameters
- tokenID
-
Your user token.
[System.String]
- secret
-
Your user secret.
[System.String]
set_endpoint() Method
void Quaero.REST.Agent.set_endpoint(System.String ep);
Set the base URL for all REST endpoints. For example "http://quaero.local.lan:33133/dw/v1"
Parameters
- ep
-
Full text URL.
[System.String]
link_for() Method
System.String Quaero.REST.Agent.link_for(System.String rel, System.String name);
Get a HATEOAS link for a given object relationship. If you want the link for the TIFF format, you'd call
link_for with rel="formats" and name="tif". See
JSON rel for a list of all
the possible relationships.
Parameters
- rel
-
Name of the relationship.
[System.String]
- name
-
Name of the object.
[System.String]
Returns
link_for() Method
System.String Quaero.REST.Agent.link_for(System.String rel, Quaero.DW.UCriteria criteria);
Get a HATEOAS link for a given object relationship.
Parameters
- rel
-
Name of the relationship. Currently only "documents" makes sense.
[System.String]
- criteria
-
Criteria to search for.
[Quaero.DW.UCriteria]
Returns
Example
DW.UCriteria crit = new DW.UCriteria { { "invoice", "FF-123312" }, { "type", "01-invoices" } };
String url = agent.link_for( "documents", crit );
have_authorization() Method
System.Boolean Quaero.REST.Agent.have_authorization();
Returns true if the agent has been authenticated and authorized to access the REST API.
Returns
is_expired Property
System.Boolean (Quaero.REST.Agent)agent.is_expired;
Will be true if the agent's authorisation is expired.
is_authorized Property
System.Boolean (Quaero.REST.Agent)agent.is_authorized;
Will be true if the agent has authorisation and it is not expired.
fetch() Method
T Quaero.REST.Agent.fetch<T, PT>(PT aggregate, System.String amember, System.String member, System.String name);
Fetch a details about an object from a endpoint that returns aggregate objects.
Generic parameters
- T
The type of the object you are fetching. Must be a sub-class of [
Quaero.DW.Links].
- PT
Parameters
- aggregate
-
Aggregate object
[PT]
- amember
-
Name of a member of the aggregate object that is an array of T.
[System.String]
- member
-
Name of a member of the object to match against.
[System.String]
- name
-
What you are looking for.
[System.String]
Returns
fetch() Method
T Quaero.REST.Agent.fetch<T, PT>(System.String amember, System.String name);
Fetch the details of one REST object, using known HATEOAS links.
Generic parameters
- T
The type of the object you are fetching. Must be a sub-class of [
Quaero.DW.Links].
- PT
Parameters
- amember
-
Relationship you want
[System.String]
- name
-
The object name
[System.String]
Returns
do_req() Method
T Quaero.REST.Agent.do_req<T, PT>(System.Net.Http.HttpRequestMessage req, System.String amember);
Fetch one object via the REST API. Fetching an object will return an aggregate object that only has
a single object. In other words, (PT)reply.amember[0] is a of type T.
Generic parameters
- T
Class of the object you are fetching.
- PT
Class of the aggregate object in the reply.
Parameters
- req
-
An HTTP request.
[System.Net.Http.HttpRequestMessage]
- amember
-
Name of the data field in the aggregate object that is the reply.
[System.String]
Returns
connect() Method
System.Boolean Quaero.REST.Agent.connect();
Get a REST access token
Returns
search_req() Method
System.Net.Http.HttpRequestMessage Quaero.REST.Agent.search_req(Quaero.DW.Search search);
Build an HTTP request that will search Quaero Archive for your documents.
See
REST API searches.
Parameters
- search
-
This is what you are searching for.
[Quaero.DW.Search]
Returns
Example
using Quaero;
using System.Net.Http;
DW.Search search = new DW.Search ();
search.criteria.words = "hello world";
search.criteria.type = "contract";
HttpRequestMessage req = agent.search_req( search );
// Criteria can be implicitly cast to Search.
DW.Criteria crit = new DW.Criteria ();
crit.words = "pill box";
crit.type = "contract";
HttpRequestMessage req2 = agent.search_req( crit );
document_req() Method
System.Net.Http.HttpRequestMessage Quaero.REST.Agent.document_req(System.String NUM);
Build an HTTP request that will fetch the named document from Quaero Archive.
See
REST API documents.
Parameters
- NUM
-
The unique document number.
[System.String]
Returns
Example
using Quaero;
using System.Net.Http;
HttpRequestMessage req = agent.document_req( "TG00100" );
// You can may now access req as you would any other HTTP request.
document_req() Method
System.Net.Http.HttpRequestMessage Quaero.REST.Agent.document_req(Quaero.DW.UCriteria criteria);
Build an HTTP request that will fetch a single document from Quaero Archive based on your search criteria
See
REST API documents.
Parameters
- criteria
-
Search criteria that will find a single document.
[Quaero.DW.UCriteria]
Returns
Example
DW.UCriteria crit = new DW.UCriteria { { "invoice", "FF-123312" }, { "type", "01-invoices" } };
HttpRequestMessage req = agent.document_req( crit );
fetch_req() Method
System.Net.Http.HttpRequestMessage Quaero.REST.Agent.fetch_req(System.String rel, System.String name);
Build an HTTP request that will fetch a named object. If you want the link for the TIFF format, you'd call
link_for with rel="formats" and name="tif".
Parameters
- rel
-
Name of the HATEOAS relationship for this object. See
JSON rel for a list of possible relationships.
[System.String]
- name
-
The name of the object.
[System.String]
Returns
Example
using Quaero;
using System.Net.Http;
HttpRequestMessage req = agent.fetch_req( "formats", "tif" );
// You can may now access req as you would any other HTTP request.
fetch_req() Method
System.Net.Http.HttpRequestMessage Quaero.REST.Agent.fetch_req(System.String rel, Quaero.DW.UCriteria criteria);
Build an HTTP request that will fetch document based on simple search criteria.
Parameters
- rel
-
Name of the HATEOAS relationship for this object. Currently only "documents" makes sense.
[System.String]
- criteria
-
Simple search criteria.
[Quaero.DW.UCriteria]
Returns
Example
using Quaero;
using System.Net.Http;
DW.UCriteria crit = new DW.UCriteria { { "invoice", "FF-123312" }, { "type", "01-invoices" } };
HttpRequestMessage req = agent.fetch_req( "documents", crit );
// You can may now access req as you would any other HTTP request.
close() Method
void Quaero.REST.Agent.close();
Close a batch