Struct geeny_api::ThingsApi
[−]
[src]
pub struct ThingsApi(_);
Interface for Geeny Things Mangager APIs
ThingsApi
is an interface for interacting with the Geeny Things Manager API.
The full specification of these APIs may be found in the
API Specification.
An explanation of what each of these Geeny items are (e.g. ThingTypes
,
MessageTypes
) may be found in the
Geeny Glossary
Methods
impl ThingsApi
[src]
fn new(host: String, port: u16) -> Self
[src]
Create a new Things API handle
If it is not necessary to set a custom host or port, the default()
method may be used instead.
Example
use geeny_api::ThingsApi; let api = ThingsApi::new("https://labs.geeny.io".into(), 443);
fn create_message_type(
&self,
token: &str,
req: &MessageTypeRequest
) -> Result<MessageType>
[src]
&self,
token: &str,
req: &MessageTypeRequest
) -> Result<MessageType>
Define a new MessageType on the Geeny Cloud
Example
extern crate geeny_api; use geeny_api::ThingsApi; use geeny_api::models::*; fn main() { let api = ThingsApi::default(); let token = "...".to_string(); // from ConnectApi // Define a new MessageType to create let mt_request = MessageTypeRequest { name: "New MessageType".into(), description: "Cool Test Message Type".into(), media_type: "application/json".into(), tags: vec![ "IoT".into(), "Test".into(), "Geeny".into(), ], }; let mt = api.create_message_type(&token, &mt_request).unwrap(); }
fn create_thing_type(
&self,
token: &str,
req: &ThingTypeRequest
) -> Result<ThingType>
[src]
&self,
token: &str,
req: &ThingTypeRequest
) -> Result<ThingType>
Define a new ThingType on the Geeny Cloud
Example
extern crate geeny_api; extern crate uuid; use geeny_api::ThingsApi; use geeny_api::models::*; use uuid::Uuid; fn main() { let api = ThingsApi::default(); let token = "...".to_string(); // from ConnectApi // Define a new ThingType to create let tt_request = ThingTypeRequest { name: "New ThingType".into(), resources: vec![ Resource { uri: "demo/send/path".into(), method: ResourceMethod::Pub, message_type: Uuid::nil(), // 'id' field from `MessageType` struct }, Resource { uri: "demo/receive/path".into(), method: ResourceMethod::Sub, message_type: Uuid::nil(), // 'id' field from `MessageType` struct }, ], }; let tt = api.create_thing_type(&token, &tt_request).unwrap(); }
fn create_thing(&self, token: &str, req: &ThingRequest) -> Result<Thing>
[src]
Create a new instance of a Thing on the Geeny Cloud
Example
extern crate geeny_api; extern crate uuid; use geeny_api::ThingsApi; use geeny_api::models::*; use uuid::Uuid; fn main() { let api = ThingsApi::default(); let token = "...".to_string(); // from ConnectApi // Define a new ThingType to create let t_request = ThingRequest { name: "New Thing".into(), // Serial Number must be unique across all instances of... serial_number: "ABCD12345".into(), // ...this thing_type, from the `id` field of `ThingType` struct thing_type: Uuid::nil(), }; let thing = api.create_thing(&token, &t_request).unwrap(); }
fn delete_thing(&self, token: &str, id: &Uuid) -> Result<Thing>
[src]
Delete a specific Thing from the Geeny Cloud
Example
extern crate geeny_api; extern crate uuid; use geeny_api::ThingsApi; use uuid::Uuid; fn main() { let api = ThingsApi::default(); let token = "...".to_string(); // from ConnectApi let thing = api.delete_thing(&token, &Uuid::nil()).unwrap(); }
fn get_thing_types(&self, token: &str) -> Result<Vec<ThingType>>
[src]
Get all publicly visible ThingTypes from the Geeny Cloud
Example
extern crate geeny_api; use geeny_api::ThingsApi; fn main() { let api = ThingsApi::default(); let token = "...".to_string(); // from ConnectApi let all_thing_types = api.get_thing_types(&token).unwrap(); for tt in all_thing_types { println!("{:?}", tt); } }
fn get_message_types(&self, token: &str) -> Result<Vec<MessageType>>
[src]
Get all publicly visible MessageTypes from the Geeny Cloud
Example
extern crate geeny_api; use geeny_api::ThingsApi; fn main() { let api = ThingsApi::default(); let token = "...".to_string(); // from ConnectApi let all_message_types = api.get_message_types(&token).unwrap(); for mt in all_message_types { println!("{:?}", mt); } }
fn get_things(&self, token: &str) -> Result<Vec<Thing>>
[src]
Get all Things from the current account from the Geeny Cloud
Example
extern crate geeny_api; use geeny_api::ThingsApi; fn main() { let api = ThingsApi::default(); let token = "...".to_string(); // from ConnectApi let all_things = api.get_things(&token).unwrap(); for thing in all_things { println!("{:?}", thing); } }
fn get_thing_type_resources(
&self,
token: &str,
ttid: &Uuid
) -> Result<Vec<Resource>>
[src]
&self,
token: &str,
ttid: &Uuid
) -> Result<Vec<Resource>>
Get all Resources for a given ThingType from the Geeny Cloud
Example
extern crate geeny_api; extern crate uuid; use geeny_api::ThingsApi; use uuid::Uuid; fn main() { let api = ThingsApi::default(); let token = "...".to_string(); // from ConnectApi let resources = api.get_thing_type_resources( &token, &Uuid::nil() // from `id` field of `ThingType` struct ).unwrap(); for resource in resources { println!("{:?}", resource); } }
fn get_thing_by_serial(
&self,
token: &str,
serial: &str
) -> Result<Option<Thing>>
[src]
&self,
token: &str,
serial: &str
) -> Result<Option<Thing>>
Obtain a specific Thing from the current account from the Geeny Cloud by the Thing's serial number
Example
extern crate geeny_api; use geeny_api::ThingsApi; fn main() { let api = ThingsApi::default(); let token = "...".to_string(); // from ConnectApi let thing = api.get_thing_by_serial( &token, "ABCD12345" ).unwrap(); }
Trait Implementations
impl Debug for ThingsApi
[src]
impl Clone for ThingsApi
[src]
fn clone(&self) -> ThingsApi
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Hash for ThingsApi
[src]
fn hash<__H: Hasher>(&self, __arg_0: &mut __H)
[src]
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more