Struct 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§

Source§

impl<T> OpenwhiskClient<T>
where T: OpenWhisk + OpenWhisk<Output = T> + Clone,

Source

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
Source

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();
Source

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();
Source

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();
Source

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>

Source§

fn clone(&self) -> OpenwhiskClient<T>

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

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

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for OpenwhiskClient<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Default> Default for OpenwhiskClient<T>

Source§

fn default() -> OpenwhiskClient<T>

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

Auto Trait Implementations§

§

impl<T> Freeze for OpenwhiskClient<T>
where T: Freeze,

§

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§

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> 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> 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<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,