Official Sensit API library client for PHP
This library is generated by alpaca
Make sure you have composer installed.
Add the following to your composer.json
{
"require": {
"cwadding/sensit-client": "*"
}
}
Update your dependencies
$ php composer.phar update
This package follows the
PSR-0
convention names for its classes, which means you can easily integrate these classes loading in your own autoloader.
Works with [ 5.4 / 5.5 ]
<?php
// This file is generated by Composer
require_once 'vendor/autoload.php';
// Then we instantiate a client (as shown below)
$client = new Sensit\Client();
// If you need to send options
$client = new Sensit\Client(array(), $options);
$client = new Sensit\Client('1a2b3', $options);
$response = $client->klass('args')->method('args');
$response->body;
// >>> 'Hello world!'
$response->code;
// >>> 200
$response->headers;
// >>> array('content-type' => 'text/html')
$response->body;
// >>> 'The username is pksunkara!'
$response->body;
// >>> array('user' => 'pksunkara')
$body = 'username=pksunkara';
$body = array('user' => 'pksunkara');
$body = array('user' => 'pksunkara');
The following options are available while instantiating a client:
- base: Base url for the api
- api_version: Default version of the api (to be used in url)
- user_agent: Default user-agent for all requests
- headers: Default headers for all requests
- request_type: Default format of the request body
The following options are available while calling a method of an api:
- api_version: Version of the api (to be used in url)
- headers: Headers for the request
- query: Query parameters for the url
- body: Body of the request
- request_type: Format of the request body
A Percolator is a reverse query much like a match rule which is run whenever a new feed is added. These can be used to create alerts by causing the sensit to publish the feed that was just added. A percolator query is defined by a name
and and valid query
according to the according the the elasticsearch Query DSL. For more information about Percolator queries please refer to the elasticsearch percolator documentation.
The following arguments are required:
- topic_id: The key for the parent topic
- id: The name of the percolator query
$percolator = $client->percolator("my_rule", "my_topic");
Returns a list or percolators for a given topic. Requires authorization of read_any_percolators, or read_application_percolators.
$response = $percolator->list($options);
Return a specific percolator of the associated Topic by Id. Requires authorization of read_any_percolators, or read_application_percolators.
$response = $percolator->find($options);
Create a percolator on the associated Topic with the specified name and query. Requires authorization of manage_any_percolators, or manage_application_percolators.
The following arguments are required:
- percolator: A Hash containing
name
: The name of the percolator(required).query
: The query hash according to the according the the elasticsearch Query DSL
$response = $percolator->create("{name: 'Kimchy-User', query:{term: {user: 'kimchy'}}}", $options);
Update the query for a specific percolator. Requires authorization of manage_any_percolators, or manage_application_percolators.
The following arguments are required:
- percolator: A Hash containing the
query
hash according to the according the the elasticsearch Query DSL
$response = $percolator->update("{query:{term: {user: 'kimchy'}}}", $options);
Delete a percolator on the associated topic. Requires authorization of manage_any_percolators, or manage_application_percolators.
$response = $percolator->delete($options);
Reports are stored filter and facet queries on the Feed data. A report is a assigned a name
and the query
is any elasticsearch query which filters only the desired data for the facets (See the elasticsearch Query DSL for valid queries). A report can have many facets
with each facet is referred to by a user defined name
. Valid type
's of facet include terms, range, histogram, filter, statistical, query, terms_stats, or geo_distance. The query
within a facet defines the field counts or statistics which the data is calculated over. See the elasticsearch facet dsl for information about the various facet types and valid query fields.
The following arguments are required:
- topic_id: The key for the parent topic
- id: The identifier of the report
$report = $client->report("my_report", "my_topic");
Get all reports for the associated Topic. Requires authorization of read_any_reports, or read_application_reports.
$response = $report->list($options);
Retrieve a specific report on the associated topic by Id. Requires authorization of read_any_reports, or read_application_reports.
$response = $report->find($options);
Create a new report on the associated Topic which can be easily retrieved later using an id. Requires authorization of manage_any_reports, or manage_application_reports.
The following arguments are required:
- report: A Hash containing
name
: The name of the report (required).query
:The search query acccording to the elasticsearch Query DSL to filter the data for the facets (Defaults to match all).facets
:An array of facet hashes which each contain aname
ad type of the facet along with its query hash (required).
$response = $report->create("{name:'My report', query:{match_all: { }}, facets:[{name: 'facet1', type: 'terms', query: { field: 'value1'}}]}", $options);
Update the query, facets or name of the report. Requires authorization of manage_any_reports, or manage_application_reports.
The following arguments are required:
- report: A Hash containing
name
: The name of the report (required).query
:The search query acccording to the elasticsearch Query DSL to filter the data for the facets (Defaults to match all).facets
:An array of facet hashes which each contain aname
ad type of the facet along with its query hash (required).
$response = $report->update("{name:'My report', query:{match_all: { }}, facets:[{name: 'facet1', type: 'terms', query: { field: 'value1'}}]}", $options);
Remove a saved report on the associated Topic by Id. Requires authorization of manage_any_reports, or manage_application_reports.
$response = $report->delete($options);
$user = $client->user();
$response = $user->profile($options);
A topic is root that data is attached to. It is the equivalent of a source in searchlight/solink and acts as a table which has columns(Fields) and rows(Feeds).
$topic = $client->topic();
Requires authorization of read_any_data, or read_application_data.
$response = $topic->list($options);
Requires authorization of read_any_data, or read_application_data.
$response = $topic->find($options);
Requires authorization of manage_any_data, or manage_application_data.
The following arguments are required:
- topic: A hash containing the name/id of the topic (required) and a description of the topic.
$response = $topic->create("{name:'my_topic', description:'Event data from source A.'}", $options);
Requires authorization of manage_any_data, or manage_application_data.
The following arguments are required:
- topic: A hash containing the name/id of the topic (required) and a description of the topic.
$response = $topic->update("{name:'my_topic', description:'Event data from source A.'}", $options);
Requires authorization of manage_any_data, or manage_application_data.
$response = $topic->delete($options);
Returns api instance to get auxilary information about Buffer useful when creating your app.
The following arguments are required:
- topic_id: The key for the parent topic
- id: The id of the feed
$feed = $client->feed("1", "my_topic");
Returns a list of feeds for a given topic. Requires authorization of read_any_data, or read_application_data.
$response = $feed->list($options);
Returns a specific feed for a topic. Requires authorization of read_any_data, or read_application_data.
$response = $feed->find($options);
Create a feed on a given topic. Requires authorization of read_any_data, or read_application_data.
The following arguments are required:
- feed: A Hash containing
at
: a formatted time of the event. Defaults to the current time if not present.tz
: The time zone of the time given inat
. Defaults to UTCdata
:A hash of data to be stored
$response = $feed->create("{at: '2013-02-14T16:13:33.378Z', tz: 'Eastern Time (US & Canada)', data:{key1:123, key2:456.2, city:'alabama'}}", $options);
Update an associated Feed to the Topic. Requires authorization of read_any_data, or read_application_data.
The following arguments are required:
- feed: A hash containing
data
:A hash of data to be stored
$response = $feed->update("{data:{key1:123, key2:456.2, city:'alabama'}}", $options);
Deletes the desired feed. Requires authorization of read_any_data, or read_application_data.
$response = $feed->delete($options);
Get the value of a specific field within a feed
The following arguments are required:
- topic_id: The key for the parent topic
- feed_id: The id of the parent feed
- id: The key of the specific field
$data = $client->data("my_topic", "2", "captured_at");
Requires authorization of read_any_data, or read_application_data.
$response = $data->find($options);
Update a specific value of a field within a feed with the data passed in. Requires authorization of read_any_data, or read_application_data.
$response = $data->update($options);
Subscriptions allows feed data to imported using a socket rather than just using the Feed REST API. By creating a subscription sensit will start to listen for feed data being imported using the specified host
and while using the topic name as the channel
name.
The following arguments are required:
- id: The identifier for the subscription
$subscription = $client->subscription("subscription1");
Get the list of all subscriptions for importing feed data to the associated topics. Requires authorization of read_any_subscriptions, or read_application_subscriptions.
$response = $subscription->list($options);
Get the information of a specific subscription. Requires authorization of read_any_subscriptions, or read_application_subscriptions.
$response = $subscription->find($options);
Create a subscription which will connect to the server and listen for feed data for any of the associated topics. Requires authorization of manage_any_subscriptions, or manage_application_subscriptions.
The following arguments are required:
- subscription: A Hash containing
name
:The channel or name to identify the subscription(required).host
:The ip address or host of the connection(required).protocol
:the protocol to communicate over (http, tcp, udp, mqtt) (required)port
:The port of the connection.
$response = $subscription->create("{name:'alpha', host:'10.234.12.11', protocol:'tcp', port:8800}", $options);
Returns an object with the current configuration that Buffer is using, including supported services, their icons and the varying limits of character and schedules. Requires authorization of manage_any_subscriptions, or manage_application_subscriptions.
The following arguments are required:
- subscription: A Hash containing
name
:The channel or name to identify the subscription(required).host
:The ip address or host of the connection(required).protocol
:the protocol to communicate over (http, tcp, udp, mqtt) (required)port
:The port of the connection.
$response = $subscription->update("{name:'alpha', host:'10.234.12.11', protocol:'udp', port:8800}", $options);
Delete the subscription and stop listening for feed data for the associated topics. Requires authorization of manage_any_subscriptions, or manage_application_subscriptions.
$response = $subscription->delete($options);
.
The following arguments are required:
- topic_id: The key for the parent topic
- id: Username of the user
$field = $client->field("pksunkara", "my_topic");
Get all the fields associated with a topic. Requires authorization of read_any_data, or read_application_data
$response = $field->list($options);
Get a Field of the associated a topic and Id. Requires authorization of read_any_data, or read_application_data
$response = $field->find($options);
Adds a new field that feed data can be added too. Requires authorization of manage_any_data, or manage_application_data
The following arguments are required:
- field: A Hash containing
name
: A descriptive name of the field.key
:The name that is used to identify the field in a feed (required).datatype
:The type of data that is stored in the field. ie. integer, float, string, bool, datetime
$response = $field->create("{name:'Transaction ID', key:'tran_id', datatype:'integer'}", $options);
Updates the Field data and makes the corresponding changes in the index. Requires authorization of manage_any_data, or manage_application_data
The following arguments are required:
- field: A Hash containing
name
: A descriptive name of the field.key
:The name that is used to identify the field in a feed (required).datatype
:The type of data that is stored in the field. ie. integer, float, string, bool, datetime
$response = $field->update("{name:'Transaction ID', key:'tran_id', datatype:'integer'}", $options);
Deletes a field and the feed data in that field. Requires authorization of manage_any_data, or manage_application_data
$response = $field->delete($options);
Publications are stored actions which are taken when a feed is created, updated, deleted, or there is a matching percolator query.
The following arguments are required:
- topic_id: The key for the parent topic
- id: The identifier of the publication
$publication = $client->publication("my_publication", "my_topic");
Get all publications for the associated Topic. Requires authorization of read_any_publications, or read_application_publications.
$response = $publication->list($options);
Retrieve a specific publication on the associated topic by Id. Requires authorization of read_any_publications, or read_application_publications.
$response = $publication->find($options);
Create a new publication on the associated Topic which can be easily retrieved later using an id. Requires authorization of manage_any_publications, or manage_application_publications.
The following arguments are required:
- publication: A Hash containing
host
:The ip address or host of the connection(required).protocol
:the protocol to communicate over (http, tcp, udp, mqtt) (required)port
:The port of the connection.
$response = $publication->create("{host:'10.234.12.11', protocol:'http', port:80}", $options);
Update a publication. Requires authorization of manage_any_publications, or manage_application_publications.
The following arguments are required:
- publication: A Hash containing
host
:The ip address or host of the connection(required).protocol
:the protocol to communicate over (http, tcp, udp, mqtt) (required)port
:The port of the connection.
$response = $publication->update("{host:'10.234.12.11', protocol:'http', port:80}", $options);
Remove a saved publication on the associated Topic by Id. Requires authorization of manage_any_publications, or manage_application_publications.
$response = $publication->delete($options);
Here is a list of Contributors
MIT
Report here.
Christopher Waddington (cwadding@gmail.com)