Struct openwhisk_rust::OpenwhiskClient
source · [−]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
sourceimpl<T: Clone> OpenwhiskClient<T> where
T: OpenWhisk + OpenWhisk<Output = T>,
impl<T: Clone> OpenwhiskClient<T> where
T: OpenWhisk + OpenWhisk<Output = 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
sourceimpl<T: Clone> Clone for OpenwhiskClient<T>
impl<T: Clone> Clone for OpenwhiskClient<T>
sourcefn clone(&self) -> OpenwhiskClient<T>
fn clone(&self) -> OpenwhiskClient<T>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<T: Debug> Debug for OpenwhiskClient<T>
impl<T: Debug> Debug for OpenwhiskClient<T>
sourceimpl<T: Default> Default for OpenwhiskClient<T>
impl<T: Default> Default for OpenwhiskClient<T>
sourcefn default() -> OpenwhiskClient<T>
fn default() -> OpenwhiskClient<T>
Returns the “default value” for a type. Read more
Auto Trait Implementations
impl<T> RefUnwindSafe for OpenwhiskClient<T> where
T: RefUnwindSafe,
impl<T> Send for OpenwhiskClient<T> where
T: Send,
impl<T> Sync for OpenwhiskClient<T> where
T: Sync,
impl<T> Unpin for OpenwhiskClient<T> where
T: Unpin,
impl<T> UnwindSafe for OpenwhiskClient<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more