pub struct OpenwhiskClient<T> {
pub context: Context,
pub client: T,
/* private fields */
}
Expand description
Representation of Openwhisk Client
Fields§
§context: Context
Openwhisk client context (Properties set for the openwhisk)
client: T
Client represents the http client (OpenwhiskClient takes generic type for http client)
Implementations§
Source§impl<T> OpenwhiskClient<T>
impl<T> OpenwhiskClient<T>
Sourcepub fn new(config: Option<&WskProperties>) -> Self
pub fn new(config: Option<&WskProperties>) -> Self
To set Openwhisk config for library to interact with Openwhisk API’s
§Arguments
config
- Can be None or Openwhisk Properties defined by User when None is supplied poperties are set by environment
§Example
use openwhisk_rust::{NativeClient, OpenwhiskClient, WskProperties};
// setting openwhisk props with user Input
let new_wsk_props = WskProperties::new(
"your:auth_token".to_string(),
"host".to_string(),
true,
"namespace".to_string()
);
// creating new client from using the propety
let client = OpenwhiskClient::<NativeClient>::new(Some(&new_wsk_props));
// use initilalised client to interact with openwhisk API
Sourcepub fn actions(&self) -> &ActionService<T>
pub fn actions(&self) -> &ActionService<T>
To Access action endpoints from the Openwhisk Client using this method
Returns ActionService
This can be used to call underlying action service methods
list
- Lists all the actions in the namesapce
§Example
use openwhisk_rust::{NativeClient, OpenwhiskClient, WskProperties};
// setting openwhisk props with user Input
let new_wsk_props = WskProperties::new(
"your:auth_token".to_string(),
"host".to_string(),
true,
"namespace".to_string()
);
// creating new client from using the propety
let client = OpenwhiskClient::<NativeClient>::new(Some(&new_wsk_props));
// use initilalised client to interact with openwhisk API
// Lists the actions deployed in the openwhisk
let actions = client.actions().list().unwrap();
get
- Get the action property based on the action name provided as paramter
§Example
use openwhisk_rust::{NativeClient, OpenwhiskClient, WskProperties};
// setting openwhisk props with user Input
let new_wsk_props = WskProperties::new(
"your:auth_token".to_string(),
"host".to_string(),
true,
"namespace".to_string()
);
// creating new client from using the propety
let client = OpenwhiskClient::<NativeClient>::new(Some(&new_wsk_props));
// use initilalised client to interact with openwhisk API
// get the action properties which is deployed in the openwhisk
let action_property = client.actions().get("action_name").unwrap();
delete
- Delete action based on the action name
§Example
use openwhisk_rust::{NativeClient, OpenwhiskClient, WskProperties};
// setting openwhisk props with user Input
let new_wsk_props = WskProperties::new(
"your:auth_token".to_string(),
"host".to_string(),
true,
"namespace".to_string()
);
// creating new client from using the propety
let client = OpenwhiskClient::<NativeClient>::new(Some(&new_wsk_props));
// use initilalised client to interact with openwhisk API
// deletes the action which is deployed in the openwhisk
let action = client.actions().delete("action_name").unwrap();
insert
- Insert action and returns new action created
§Example
use openwhisk_rust::{NativeClient, OpenwhiskClient, WskProperties};
// setting openwhisk props with user Input
let new_wsk_props = WskProperties::new(
"your:auth_token".to_string(),
"host".to_string(),
true,
"namespace".to_string()
);
// creating new client from using the propety
let client = OpenwhiskClient::<NativeClient>::new(Some(&new_wsk_props));
// use initilalised client to interact with openwhisk API
// insert the action and deploys in the openwhisk
let action = client.actions().insert(action,true,true).unwrap();
invoke
- Invoke action based on the action name and payload for the actions
§Example
use openwhisk_rust::{NativeClient, OpenwhiskClient, WskProperties};
// setting openwhisk props with user Input
let new_wsk_props = WskProperties::new(
"your:auth_token".to_string(),
"host".to_string(),
true,
"namespace".to_string()
);
// creating new client from using the propety
let client = OpenwhiskClient::<NativeClient>::new(Some(&new_wsk_props));
// use initilalised client to interact with openwhisk API
// invoke the action deployed in the openwhisk
let action_result = client.actions().invoke("action_name","action_payload",true,true).unwrap();
Sourcepub fn triggers(&self) -> &TriggerService<T>
pub fn triggers(&self) -> &TriggerService<T>
To Access trigger endpoints from the Openwhisk Client using this method
Returns TriggerService This can be used to call underlying action service methods
list
- Lists all the triggers in the namesapce
§Example
use openwhisk_rust::{NativeClient, OpenwhiskClient, WskProperties};
// setting openwhisk props with user Input
let new_wsk_props = WskProperties::new(
"your:auth_token".to_string(),
"host".to_string(),
true,
"namespace".to_string()
);
// creating new client from using the propety
let client = OpenwhiskClient::<NativeClient>::new(Some(&new_wsk_props));
// use initilalised client to interact with openwhisk API
// Lists the triggers deployed in the openwhisk
let triggers = client.triggers().list().unwrap();
get
- Get the trigger property based on the trigger name provided as paramter
§Example
use openwhisk_rust::{NativeClient, OpenwhiskClient, WskProperties};
// setting openwhisk props with user Input
let new_wsk_props = WskProperties::new(
"your:auth_token".to_string(),
"host".to_string(),
true,
"namespace".to_string()
);
// creating new client from using the propety
let client = OpenwhiskClient::<NativeClient>::new(Some(&new_wsk_props));
// use initilalised client to interact with openwhisk API
// get the trigger properties which is deployed in the openwhisk
let trigger_property = client.triggers().get("trigger_name").unwrap();
delete
- Delete trigger based on the trigger name
§Example
use openwhisk_rust::{NativeClient, OpenwhiskClient, WskProperties};
// setting openwhisk props with user Input
let new_wsk_props = WskProperties::new(
"your:auth_token".to_string(),
"host".to_string(),
true,
"namespace".to_string()
);
// creating new client from using the propety
let client = OpenwhiskClient::<NativeClient>::new(Some(&new_wsk_props));
// use initilalised client to interact with openwhisk API
// deletes the trigger which is deployed in the openwhisk
let trigger = client.triggers().delete("trigger_name").unwrap();
insert
- Insert trigger and returns new trigger created
§Example
use openwhisk_rust::{NativeClient, OpenwhiskClient, WskProperties};
// setting openwhisk props with user Input
let new_wsk_props = WskProperties::new(
"your:auth_token".to_string(),
"host".to_string(),
true,
"namespace".to_string()
);
// creating new client from using the propety
let client = OpenwhiskClient::<NativeClient>::new(Some(&new_wsk_props));
// use initilalised client to interact with openwhisk API
// insert the trigger and deploys in the openwhisk
let trigger = client.triggers().insert(trigger,true).unwrap();
fire
- Fires a trigger to an action
§Example
use openwhisk_rust::{NativeClient, OpenwhiskClient, WskProperties};
// setting openwhisk props with user Input
let new_wsk_props = WskProperties::new(
"your:auth_token".to_string(),
"host".to_string(),
true,
"namespace".to_string()
);
// creating new client from using the propety
let client = OpenwhiskClient::<NativeClient>::new(Some(&new_wsk_props));
// use initilalised client to interact with openwhisk API
// Fires a trigger to an action
let trigger = client.actions().fire("trigger_name",value).unwrap();
Sourcepub fn rules(&self) -> &RuleService<T>
pub fn rules(&self) -> &RuleService<T>
To Access action endpoints from the Openwhisk Client using this method
Returns RuleService This can be used to call underlying action service methods
list
- Lists all the rules in the namesapce
§Example
use openwhisk_rust::{NativeClient, OpenwhiskClient, WskProperties};
// setting openwhisk props with user Input
let new_wsk_props = WskProperties::new(
"your:auth_token".to_string(),
"host".to_string(),
true,
"namespace".to_string()
);
// creating new client from using the propety
let client = OpenwhiskClient::<NativeClient>::new(Some(&new_wsk_props));
// use initilalised client to interact with openwhisk API
// Lists the rules deployed in the openwhisk
let rules = client.rules().list().unwrap();
get
- Get the rule property based on the rule name provided as paramter
§Example
use openwhisk_rust::{NativeClient, OpenwhiskClient, WskProperties};
// setting openwhisk props with user Input
let new_wsk_props = WskProperties::new(
"your:auth_token".to_string(),
"host".to_string(),
true,
"namespace".to_string()
);
// creating new client from using the propety
let client = OpenwhiskClient::<NativeClient>::new(Some(&new_wsk_props));
// use initilalised client to interact with openwhisk API
// get the rule properties which is deployed in the openwhisk
let rule_property = client.rules().get("rule_name").unwrap();
delete
- Delete rule based on the rule name
§Example
use openwhisk_rust::{NativeClient, OpenwhiskClient, WskProperties};
// setting openwhisk props with user Input
let new_wsk_props = WskProperties::new(
"your:auth_token".to_string(),
"host".to_string(),
true,
"namespace".to_string()
);
// creating new client from using the propety
let client = OpenwhiskClient::<NativeClient>::new(Some(&new_wsk_props));
// use initilalised client to interact with openwhisk API
// deletes the rule which is deployed in the openwhisk
let rule = client.rules().delete("rule_name").unwrap();
setstate
- Sets the state of the rule
§Example
use openwhisk_rust::{NativeClient, OpenwhiskClient, WskProperties};
// setting openwhisk props with user Input
let new_wsk_props = WskProperties::new(
"your:auth_token".to_string(),
"host".to_string(),
true,
"namespace".to_string()
);
// creating new client from using the propety
let client = OpenwhiskClient::<NativeClient>::new(Some(&new_wsk_props));
// use initilalised client to interact with openwhisk API
// set state for the rule deployed in the openwhisk
let rule = client.rules().setstate("rule_name","state").unwrap();
Sourcepub fn namespaces(&self) -> &NamespaceService<T>
pub fn namespaces(&self) -> &NamespaceService<T>
To Access namespace endpoints from the Openwhisk Client using this method
Returns NamespaceService
This can be used to call underlying action service methods
list
- Lists all the actions in the namesapce
§Example
use openwhisk_rust::{NativeClient, OpenwhiskClient, WskProperties};
// setting openwhisk props with user Input
let new_wsk_props = WskProperties::new(
"your:auth_token".to_string(),
"host".to_string(),
true,
"namespace".to_string()
);
// creating new client from using the propety
let client = OpenwhiskClient::<NativeClient>::new(Some(&new_wsk_props));
// use initilalised client to interact with openwhisk API
// Lists the namespaces available in the openwhisk
let namespaces = client.namespaces().list().unwrap();
Trait Implementations§
Source§impl<T: Clone> Clone for OpenwhiskClient<T>
impl<T: Clone> Clone for OpenwhiskClient<T>
Source§fn clone(&self) -> OpenwhiskClient<T>
fn clone(&self) -> OpenwhiskClient<T>
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read more