Struct Client

Source
pub struct Client {
    pub client: Arc<Mutex<ClientEnum>>,
    pub inner: Arc<Mutex<ClientInner>>,
    pub config: Arc<Mutex<Option<Config>>>,
    pub auto_reconnect: Arc<Mutex<bool>>,
    pub url: Arc<Mutex<String>>,
    pub username: Arc<Mutex<String>>,
    pub password: Arc<Mutex<String>>,
    pub jwt: Arc<Mutex<String>>,
    pub state: Arc<Mutex<ClientState>>,
    pub msgcount: Arc<Mutex<i32>>,
    pub reconnect_ms: Arc<Mutex<i32>>,
    pub default_timeout: Arc<Mutex<Duration>>,
    /* private fields */
}
Expand description

The Client struct provides the client for the OpenIAP service. Initialize a new client, by calling the Client::new_connect method.

Fields§

§client: Arc<Mutex<ClientEnum>>

The inner client object

§inner: Arc<Mutex<ClientInner>>

The inner client.

§config: Arc<Mutex<Option<Config>>>

The Config struct provides the configuration for the OpenIAP service we are connecting to.

§auto_reconnect: Arc<Mutex<bool>>

Should client automatically reconnect, if disconnected?

§url: Arc<Mutex<String>>

URL used to connect to server, processed and without credentials

§username: Arc<Mutex<String>>

Username used to connect to server

§password: Arc<Mutex<String>>

Password used to connect to server

§jwt: Arc<Mutex<String>>

JWT token used to connect to server

§state: Arc<Mutex<ClientState>>

The client connection state.

§msgcount: Arc<Mutex<i32>>

Inceasing message count, used as unique id for messages.

§reconnect_ms: Arc<Mutex<i32>>

Reconnect interval in milliseconds, this will slowly increase if we keep getting disconnected.

§default_timeout: Arc<Mutex<Duration>>

The default timeout for requests

Implementations§

Source§

impl Client

Source

pub async fn setup_ws(&self, strurl: &str) -> Result<(), OpenIAPError>

Setup a websocket connection to the server

Source§

impl Client

Source

pub async fn connect_grpc( url: String, ) -> Result<FlowServiceClient<Channel>, Box<dyn Error>>

Connect to the server using gRPC protocol.

Source

pub async fn setup_grpc_stream(&self) -> Result<(), OpenIAPError>

internal function, used to setup gRPC stream used for communication with the server. This function is called by [connect] and should not be called directly. It will “pre” process stream, watch and queue events, and call future promises, when a response is received.

Source§

impl Client

Source

pub fn new() -> Self

Create a new client.

Source

pub fn connect(&self, dst: &str) -> Result<(), OpenIAPError>

Connect the client to the OpenIAP server.

Source

pub async fn load_config(&self, strurl: &str, url: &Url) -> Option<Config>

Load the configuration from the server.

Source

pub async fn connect_async(&self, dst: &str) -> Result<(), OpenIAPError>

Connect the client to the OpenIAP server.

Source

pub async fn new_connect(dst: &str) -> Result<Self, OpenIAPError>

Connect will initializes a new client and starts a connection to an OpenIAP server.
Use “” to autodetect the server from the environment variables (apiurl or grpcapiurl), or provide a URL.

You can add username and password, to login using local provider, or set them using OPENIAP_USERNAME and OPENIAP_PASSWORD environment variables. It is highly recommended to not user username and password, but instead use a JWT token, set using the OPENIAP_JWT (or jwt) environment variable. You can use the openiap vs.code extension to manage this, if you need to generate one your self, login to the OpenIAP server and then open the /jwtlong page. If credentials are not provided, the client will run as guest.
If credentials are found, it will call Client::signin after successfully connecting to the server.

To troubleshoot issues, call enable_tracing.

use openiap_client::{OpenIAPError, Client, QueryRequest};
#[tokio::main]
async fn main() -> Result<(), OpenIAPError> {
    let client = Client::new_connect("").await?;
    let q = client.query( QueryRequest::with_projection(
        "entities",
        "{}",
        "{\"name\":1}"
    )).await?;
    let items: serde_json::Value = serde_json::from_str(&q.results).unwrap();
    let items: &Vec<serde_json::Value> = items.as_array().unwrap();
    for item in items {
        println!("Item: {:?}", item);
    }
    Ok(())
}
Source

pub async fn post_connected(&self) -> Result<(), OpenIAPError>

Handle auto-signin after a connection has been established.

Source

pub async fn reconnect(&self) -> Result<(), OpenIAPError>

Reconnect will attempt to reconnect to the OpenIAP server.

Source

pub fn disconnect(&self)

Disconnect the client from the OpenIAP server.

Source

pub fn set_connected(&self, state: ClientState, message: Option<&str>)

Set the connected flag to true or false

Source

pub fn get_state(&self) -> ClientState

Get client state

Source

pub fn set_state(&self, state: ClientState)

Set client state

Source

pub fn set_msgcount(&self, msgcount: i32)

Set the msgcount value

Source

pub fn inc_msgcount(&self) -> i32

Increment the msgcount value

Source

pub fn get_reconnect_ms(&self) -> i32

Return value of reconnect_ms

Source

pub fn reset_reconnect_ms(&self)

Increment the reconnect_ms value

Source

pub fn inc_reconnect_ms(&self) -> i32

Increment the reconnect_ms value

Source

pub fn push_handle(&self, handle: JoinHandle<()>)

Push tokio task handle to the task_handles vector

Source

pub fn kill_handles(&self)

Kill all tokio task handles in the task_handles vector

Source

pub fn set_default_timeout(&self, timeout: Duration)

Set the default timeout for the client commands

Source

pub fn get_default_timeout(&self) -> Duration

Return the default timeout for the client commands

Source

pub fn set_connect_called(&self, connect_called: bool)

Set the connect_called flag to true or false

Source

pub fn set_auto_reconnect(&self, auto_reconnect: bool)

Set the auto_reconnect flag to true or false

Source

pub fn set_url(&self, url: &str)

Set the url flag to true or false

Source

pub fn set_username(&self, username: &str)

Set the username flag to true or false

Source

pub fn set_password(&self, password: &str)

Set the password value

Source

pub fn set_jwt(&self, jwt: &str)

Set the jwt flag to true or false

Source

pub fn set_service_name(&self, service_name: &str)

Set the service name

Source

pub fn get_service_name(&self) -> String

Return value of the service name string

Source

pub fn set_agent_name(&self, agent: &str)

Set the agent name

Source

pub fn get_agent_name(&self) -> String

Return value of the agent string

Source

pub fn set_agent_version(&self, version: &str)

Set the agent version number

Source

pub fn get_agent_version(&self) -> String

Return value of the agent version string

Source

pub fn set_config(&self, config: Option<Config>)

Set the config flag to true or false

Source

pub fn get_config(&self) -> Option<Config>

Return value of the config

Source

pub fn set_client(&self, client: ClientEnum)

Set the client flag to true or false

Source

pub fn set_user(&self, user: Option<User>)

Set the user flag to true or false

Source

pub fn get_user(&self) -> Option<User>

Return value of the user

Source

pub fn set_runtime(&self, runtime: Option<Runtime>)

Set the runtime flag to true or false

Source

pub fn get_runtime(&self) -> &Mutex<Option<Runtime>>

Return value of the runtime

Source

pub fn get_runtime_handle(&self) -> Handle

Return value of the runtime handle

Source

pub async fn on_event(&self, callback: Box<dyn Fn(ClientEvent) + Send + Sync>)

Method to allow the user to subscribe with a callback function

Source

pub fn get_uniqueid() -> String

Internal function, used to generate a unique id for each message sent to the server.

Source

pub async fn signin( &self, config: SigninRequest, ) -> Result<SigninResponse, OpenIAPError>

Sign in to the OpenIAP service.
If no username and password is provided, it will attempt to use environment variables.
if config is set to validateonly, it will only validate the credentials, but not sign in.
If no jwt, username and password is provided, it will attempt to use environment variables.
will prefere OPENIAP_JWT (or jwt) over OPENIAP_USERNAME and OPENIAP_PASSWORD.

Source

pub async fn list_collections( &self, includehist: bool, ) -> Result<String, OpenIAPError>

Return a list of collections in the database

  • includehist: include historical collections, default is false. please see create_collection for examples on how to create collections.
Source

pub async fn create_collection( &self, config: CreateCollectionRequest, ) -> Result<(), OpenIAPError>

Create a new collection in the database. You can create a collection by simply adding a new document to it using Client::insert_one. Or you can create a collecting using the following example:

use openiap_client::{Client, CreateCollectionRequest, DropCollectionRequest, OpenIAPError};
#[tokio::main]
async fn main() -> Result<(), OpenIAPError> {
    let client = Client::new_connect("").await?;
    //let collections = client.list_collections(false).await?;
    //println!("Collections: {}", collections);
    let config = CreateCollectionRequest::byname("rusttestcollection");
    client.create_collection(config).await?;
    let config = DropCollectionRequest::byname("rusttestcollection");
    client.drop_collection(config).await?;
    Ok(())
}

You can create a normal collection with a TTL index on the _created field, using the following example:

use openiap_client::{Client, CreateCollectionRequest, DropCollectionRequest, OpenIAPError};
#[tokio::main]
async fn main() -> Result<(), OpenIAPError> {
    let client = Client::new_connect("").await?;
    let config = CreateCollectionRequest::with_ttl(
        "rusttestttlcollection",
        60
    );
    client.create_collection(config).await?;
    let config = DropCollectionRequest::byname("rusttestttlcollection");
    client.drop_collection(config).await?;
    Ok(())
}

You can create a time series collection using the following example: granularity can be one of: seconds, minutes, hours

use openiap_client::{Client, CreateCollectionRequest, DropCollectionRequest, OpenIAPError};
#[tokio::main]
async fn main() -> Result<(), OpenIAPError> {
    let client = Client::new_connect("").await?;
    let config = CreateCollectionRequest::timeseries(
        "rusttesttscollection2",
        "_created",
        "minutes"
    );
    client.create_collection(config).await?;
    let config = DropCollectionRequest::byname("rusttesttscollection2");
    client.drop_collection(config).await?;
    Ok(())
}
Source

pub async fn drop_collection( &self, config: DropCollectionRequest, ) -> Result<(), OpenIAPError>

Drop a collection from the database, this will delete all data and indexes for the collection. See Client::create_collection for examples on how to create a collection.

Source

pub async fn get_indexes( &self, config: GetIndexesRequest, ) -> Result<String, OpenIAPError>

Return all indexes for a collection in the database

use openiap_client::{Client, GetIndexesRequest, OpenIAPError};
#[tokio::main]
async fn main() -> Result<(), OpenIAPError> {
    let client = Client::new_connect("").await?;
    let config = GetIndexesRequest::bycollectionname("rustindextestcollection");
    let indexes = client.get_indexes(config).await?;
    println!("Indexes: {}", indexes);
    Ok(())
}
Source

pub async fn create_index( &self, config: CreateIndexRequest, ) -> Result<(), OpenIAPError>

Create an index in the database. Example of creating an index on the name field in the rustindextestcollection collection, and then dropping it again:

use openiap_client::{Client, DropIndexRequest, CreateIndexRequest, OpenIAPError};
#[tokio::main]
async fn main() -> Result<(), OpenIAPError> {
    let client = Client::new_connect("").await?;
    let config = CreateIndexRequest::bycollectionname(
        "rustindextestcollection",
        "{\"name\": 1}"
    );
    client.create_index(config).await?;
    let config = DropIndexRequest::bycollectionname(
        "rustindextestcollection",
        "name_1"
    );
    client.drop_index(config).await?;
    Ok(())
}

Example of creating an unique index on the address field in the rustindextestcollection collection, and then dropping it again:

use openiap_client::{Client, DropIndexRequest, CreateIndexRequest, OpenIAPError};
#[tokio::main]
async fn main() -> Result<(), OpenIAPError> {
    let client = Client::new_connect("").await?;
    let mut config = CreateIndexRequest::bycollectionname(
        "rustindextestcollection",
        "{\"address\": 1}"
    );
    config.options = "{\"unique\": true}".to_string();
    client.create_index(config).await?;
    let config = DropIndexRequest::bycollectionname(
        "rustindextestcollection",
        "address_1"
    );
    client.drop_index(config).await?;
    Ok(())
}
Source

pub async fn drop_index( &self, config: DropIndexRequest, ) -> Result<(), OpenIAPError>

Drop an index from the database See Client::create_index for an example on how to create and drop an index.

Source

pub async fn query( &self, config: QueryRequest, ) -> Result<QueryResponse, OpenIAPError>

To query all documents in the entities collection where _type is test, you can use the following example:

use openiap_client::{OpenIAPError, Client, QueryRequest};
#[tokio::main]
async fn main() -> Result<(), OpenIAPError> {
    let client = Client::new_connect("").await?;
    let q = client.query( QueryRequest::with_query(
        "entities",
        "{\"_type\":\"test\"}"
    )).await?;
    let items: serde_json::Value = serde_json::from_str(&q.results).unwrap();
    let items: &Vec<serde_json::Value> = items.as_array().unwrap();
    for item in items {
        println!("Item: {:?}", item);
    }
    Ok(())
}

To query all documents in the entities collection, and only return the name and _id field for all documents, you can use the following example:

use openiap_client::{OpenIAPError, Client, QueryRequest};
#[tokio::main]
async fn main() -> Result<(), OpenIAPError> {
    let client = Client::new_connect("").await?;
    let q = client.query( QueryRequest::with_projection(
        "entities",
        "{}",
        "{\"name\":1}"
    )).await?;
    let items: serde_json::Value = serde_json::from_str(&q.results).unwrap();
    let items: &Vec<serde_json::Value> = items.as_array().unwrap();
    for item in items {
        println!("Item: {:?}", item);
    }
    Ok(())
}
Source

pub async fn get_one(&self, config: QueryRequest) -> Option<Value>

Try and get a single document from the database.
If no document is found, it will return None.

use openiap_client::{OpenIAPError, Client, QueryRequest};
#[tokio::main]
async fn main() -> Result<(), OpenIAPError> {
    let client = Client::new_connect("").await?;
    let config = QueryRequest::with_query(
        "users",
        "{\"username\":\"guest\"}"
    );
    let item = client.get_one(config).await;
    match item {
        Some(item) => {
            assert_eq!(item["username"], "guest");
            println!("Item: {:?}", item);
        }
        None => {
            println!("No item found");
            assert!(false, "No item found");
        }
    }
    Ok(())
}
Source

pub async fn get_document_version( &self, config: GetDocumentVersionRequest, ) -> Result<String, OpenIAPError>

Try and get a specefic version of a document from the database, reconstructing it from the history collection

use openiap_client::{OpenIAPError, Client, GetDocumentVersionRequest, InsertOneRequest, UpdateOneRequest};
#[tokio::main]
async fn main() -> Result<(), OpenIAPError> {
    let client = Client::new_connect("").await?;
    let item = "{\"name\": \"test from rust\", \"_type\": \"test\"}";
    let query = InsertOneRequest {
        collectionname: "entities".to_string(),
        item: item.to_string(),
        j: true,
        w: 2,
        ..Default::default()
    };
    let response = client.insert_one(query).await;
    let response = match response {
        Ok(r) => r,
        Err(e) => {
            println!("Error: {:?}", e);
            assert!(false, "insert_one failed with {:?}", e);
            return Ok(());
        }
    };
    let _obj: serde_json::Value = serde_json::from_str(&response.result).unwrap();
    let _id = _obj["_id"].as_str().unwrap();
    let item = format!("{{\"name\":\"updated from rust\", \"_id\": \"{}\"}}", _id);
    let query = UpdateOneRequest {
        collectionname: "entities".to_string(),
        item: item.to_string(),
        ..Default::default()
    };
    let response = client.update_one(query).await;
    _ = match response {
        Ok(r) => r,
        Err(e) => {
            println!("Error: {:?}", e);
            assert!(false, "update_one failed with {:?}", e);
            return Ok(());
        }
    };
    let query = GetDocumentVersionRequest {
        collectionname: "entities".to_string(),
        id: _id.to_string(),
        version: 0,
        ..Default::default()
    };
    let response = client.get_document_version(query).await;
    let response = match response {
        Ok(r) => r,
        Err(e) => {
            println!("Error: {:?}", e);
            assert!(false, "get_document_version failed with {:?}", e);
            return Ok(());
        }
    };
    let _obj = serde_json::from_str(&response);
    let _obj: serde_json::Value = match _obj {
        Ok(r) => r,
        Err(e) => {
            println!("Error: {:?}", e);
            assert!(
                false,
                "parse get_document_version result failed with {:?}",
                e
            );
            return Ok(());
        }
    };
    let name = _obj["name"].as_str().unwrap();
    let version = _obj["_version"].as_i64().unwrap();
    println!("version 0 Name: {}, Version: {}", name, version);
    assert_eq!(name, "test from rust");
    let query = GetDocumentVersionRequest {
        collectionname: "entities".to_string(),
        id: _id.to_string(),
        version: 1,
        ..Default::default()
    };
    let response = client.get_document_version(query).await;
    assert!(
        response.is_ok(),
        "test_get_document_version failed with {:?}",
        response.err().unwrap()
    );
    let _obj: serde_json::Value = serde_json::from_str(&response.unwrap()).unwrap();
    let name = _obj["name"].as_str().unwrap();
    let version = _obj["_version"].as_i64().unwrap();
    println!("version 1 Name: {}, Version: {}", name, version);
    assert_eq!(name, "updated from rust");
    let query = GetDocumentVersionRequest {
        collectionname: "entities".to_string(),
        id: _id.to_string(),
        version: -1,
        ..Default::default()
    };
    let response = client.get_document_version(query).await;
    assert!(
        response.is_ok(),
        "test_get_document_version failed with {:?}",
        response.err().unwrap()
    );
    let _obj: serde_json::Value = serde_json::from_str(&response.unwrap()).unwrap();
    let name = _obj["name"].as_str().unwrap();
    let version = _obj["_version"].as_i64().unwrap();
    println!("version -1 Name: {}, Version: {}", name, version);
    assert_eq!(name, "updated from rust");
    Ok(())
}
Source

pub async fn aggregate( &self, config: AggregateRequest, ) -> Result<AggregateResponse, OpenIAPError>

Run an aggregate pipeline towards the database Example of running an aggregate pipeline on the entities collection, counting the number of documents with _type=test, and grouping them by name:

use openiap_client::{OpenIAPError, Client, AggregateRequest};
#[tokio::main]
async fn main() -> Result<(), OpenIAPError> {
   let client = Client::new_connect("").await?;
    let config = AggregateRequest {
        collectionname: "entities".to_string(),
        aggregates: "[{\"$match\": {\"_type\": \"test\"}}, {\"$group\": {\"_id\": \"$name\", \"count\": {\"$sum\": 1}}}]".to_string(),
        ..Default::default()
    };
    let response = client.aggregate(config).await?;
    println!("Response: {:?}", response);
    Ok(())
}
Source

pub async fn count( &self, config: CountRequest, ) -> Result<CountResponse, OpenIAPError>

Count the number of documents in a collection, with an optional query

Source

pub async fn distinct( &self, config: DistinctRequest, ) -> Result<DistinctResponse, OpenIAPError>

Get distinct values for a field in a collection, with an optional query

Source

pub async fn insert_one( &self, config: InsertOneRequest, ) -> Result<InsertOneResponse, OpenIAPError>

Insert a document into a collection

Source

pub async fn insert_many( &self, config: InsertManyRequest, ) -> Result<InsertManyResponse, OpenIAPError>

Insert many documents into a collection

Source

pub async fn update_one( &self, config: UpdateOneRequest, ) -> Result<UpdateOneResponse, OpenIAPError>

Update ( replace ) a document in a collection

Source

pub async fn insert_or_update_one( &self, config: InsertOrUpdateOneRequest, ) -> Result<String, OpenIAPError>

Using a unique key, insert a document or update it if it already exists ( upsert on steroids )

Source

pub async fn insert_or_update_many( &self, config: InsertOrUpdateManyRequest, ) -> Result<InsertOrUpdateManyResponse, OpenIAPError>

Using a unique key, insert many documents or update them if they already exist ( upsert on steroids )

Source

pub async fn update_document( &self, config: UpdateDocumentRequest, ) -> Result<UpdateDocumentResponse, OpenIAPError>

Update one or more documents in a collection using a update document

Source

pub async fn delete_one( &self, config: DeleteOneRequest, ) -> Result<i32, OpenIAPError>

Delete a document from a collection using a unique key

Source

pub async fn delete_many( &self, config: DeleteManyRequest, ) -> Result<i32, OpenIAPError>

Delete many documents from a collection using a query or list of unique keys

Source

pub async fn download( &self, config: DownloadRequest, folder: Option<&str>, filename: Option<&str>, ) -> Result<DownloadResponse, OpenIAPError>

Download a file from the database

Source

pub async fn upload( &self, config: UploadRequest, filepath: &str, ) -> Result<UploadResponse, OpenIAPError>

Upload a file to the database

Source

pub async fn watch( &self, config: WatchRequest, callback: Box<dyn Fn(WatchEvent) + Send + Sync>, ) -> Result<String, OpenIAPError>

Watch for changes in a collection ( change stream )

Source

pub async fn unwatch(&self, id: &str) -> Result<(), OpenIAPError>

Cancel a watch ( change stream )

Source

pub async fn register_queue( &self, config: RegisterQueueRequest, callback: Arc<dyn Fn(Arc<Client>, QueueEvent) -> BoxFuture<'static, Option<String>> + Send + Sync>, ) -> Result<String, OpenIAPError>

Register a queue for messaging ( amqp ) in the OpenIAP service

Source

pub async fn unregister_queue( &self, queuename: &str, ) -> Result<(), OpenIAPError>

Unregister a queue or exchange for messaging ( amqp ) in the OpenIAP service

Source

pub async fn register_exchange( &self, config: RegisterExchangeRequest, callback: Arc<dyn Fn(Arc<Client>, QueueEvent) -> BoxFuture<'static, Option<String>> + Send + Sync>, ) -> Result<String, OpenIAPError>

Register a exchange for messaging ( amqp ) in the OpenIAP service

Source

pub async fn queue_message( &self, config: QueueMessageRequest, ) -> Result<QueueMessageResponse, OpenIAPError>

Send a message to a queue or exchange in the OpenIAP service

Source

pub async fn rpc( &self, config: QueueMessageRequest, timeout: Duration, ) -> Result<String, OpenIAPError>

Send message to a queue or exchange in the OpenIAP service, and wait for a reply

Source

pub async fn push_workitem( &self, config: PushWorkitemRequest, ) -> Result<PushWorkitemResponse, OpenIAPError>

Push a new workitem to a workitem queue If the file is less than 5 megabytes it will be attached to the workitem If the file is larger than 5 megabytes it will be uploaded to the database and attached to the workitem

Source

pub async fn push_workitems( &self, config: PushWorkitemsRequest, ) -> Result<PushWorkitemsResponse, OpenIAPError>

Push multiple workitems to a workitem queue If the file is less than 5 megabytes it will be attached to the workitem If the file is larger than 5 megabytes it will be uploaded to the database and attached to the workitem

Source

pub async fn pop_workitem( &self, config: PopWorkitemRequest, downloadfolder: Option<&str>, ) -> Result<PopWorkitemResponse, OpenIAPError>

Pop a workitem from a workitem queue, return None if no workitem is available Any files attached to the workitem will be downloaded to the downloadfolder ( default “.” )

Source

pub async fn update_workitem( &self, config: UpdateWorkitemRequest, ) -> Result<UpdateWorkitemResponse, OpenIAPError>

Update a workitem in a workitem queue If the file is less than 5 megabytes it will be attached to the workitem If the file is larger than 5 megabytes it will be uploaded to the database and attached to the workitem If a fileid is provided it will be used to update the file if a filename is provided without the id, it will be deleted

Source

pub async fn delete_workitem( &self, config: DeleteWorkitemRequest, ) -> Result<DeleteWorkitemResponse, OpenIAPError>

Delete a workitem from a workitem queue

Source

pub async fn add_workitem_queue( &self, config: AddWorkItemQueueRequest, ) -> Result<WorkItemQueue, OpenIAPError>

Add a workitem queue to openiap instance

Source

pub async fn update_workitem_queue( &self, config: UpdateWorkItemQueueRequest, ) -> Result<WorkItemQueue, OpenIAPError>

Update a workitem queue in openiap instance

Source

pub async fn delete_workitem_queue( &self, config: DeleteWorkItemQueueRequest, ) -> Result<(), OpenIAPError>

Delete a workitem queue from openiap instance

Source

pub async fn custom_command( &self, config: CustomCommandRequest, timeout: Option<Duration>, ) -> Result<String, OpenIAPError>

Run custom command on server. Custom commands are commands who is “on trail”, they may change and are not ready to be moved to the fixed protobuf format yet

Source

pub async fn delete_package(&self, packageid: &str) -> Result<(), OpenIAPError>

Delete a package from the database, cleaning up all all files and data

Source

pub async fn start_agent(&self, agentid: &str) -> Result<(), OpenIAPError>

Start Agent

Source

pub async fn stop_agent(&self, agentid: &str) -> Result<(), OpenIAPError>

Stop an agent, this will cleanup all resources and stop the agent

Source

pub async fn delete_agent_pod( &self, agentid: &str, podname: &str, ) -> Result<(), OpenIAPError>

Delete a pod from an agent, on kubernetes this will remove the pod and kubernetes will re-create it, on docker this will remove the pod. Then use start_agent to start the agent again

Source

pub async fn delete_agent(&self, agentid: &str) -> Result<(), OpenIAPError>

Delete an agent, this will cleanup all resources and delete the agent

Source

pub async fn get_agent_pods( &self, agentid: &str, stats: bool, ) -> Result<String, OpenIAPError>

Get all pods associated with an agent, if stats is true, it will return memory and cpu usage for each pod

Source

pub async fn get_agent_pod_logs( &self, agentid: &str, podname: &str, ) -> Result<String, OpenIAPError>

Get logs from a pod associated with an agent, leave podname empty to get logs from all pods

Source

pub async fn ensure_customer( &self, config: EnsureCustomerRequest, ) -> Result<EnsureCustomerResponse, OpenIAPError>

Create/update a customer in the OpenIAP service. If stripe has been configured, it will create or update a customer in stripe as well A customer is a customer object that can only be updated using this function, and 2 roles ( customername admins and customername users )

Source

pub async fn create_workflow_instance( &self, config: CreateWorkflowInstanceRequest, ) -> Result<String, OpenIAPError>

Create a new workflow instance, to be used to workflow in/out nodes in NodeRED

Source

pub async fn invoke_openrpa( &self, config: InvokeOpenRpaRequest, timeout: Option<Duration>, ) -> Result<String, OpenIAPError>

Invoke a workflow in the OpenRPA robot where robotid is the userid of the user the robot is running as, or a roleid with RPA enabled

Trait Implementations§

Source§

impl Clone for Client

Source§

fn clone(&self) -> Client

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for Client

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Client

§

impl !RefUnwindSafe for Client

§

impl Send for Client

§

impl Sync for Client

§

impl !Unpin for Client

§

impl !UnwindSafe for Client

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,