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]

[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);

[src]

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

[src]

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

[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();
}

[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();
}

[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);
    }
}

[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);
    }
}

[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);
    }
}

[src]

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);
    }
}

[src]

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]

[src]

Formats the value using the given formatter.

impl Clone for ThingsApi
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Default for ThingsApi
[src]

[src]

Create a ThingsApi handle for the Production Things Manager

Example

use geeny_api::ThingsApi;

let api = ThingsApi::default();