GithubHelp home page GithubHelp logo

erlaws's Introduction

Erlaws provides Erlang interfaces to various Amazon WebService offerings.

= Description = 
Erlaws is a collection of client implementations of Amazon's WebServices offerings. Currently there are clients for EC2, S3, SQS and SDB.

= Build =

Issue `erl -make` to build the sources.
If you get 'error write file' errors, do `mkdir ebin`.

= Usage =

All erlaws modules (erlaws_s3, _sdb, _sqs, _ec2) are now parameterized modules. You can create a new instance of a modules using (example for erlaws_sdb):

SDB = erlaws_sdb:new(AWS_KEY, AWS_SEC_KEY, (true|false)).

The last parameter determines whether the connection should made using plain HTTP (false) or HTTPS (true).

In order to be able to use erlaws the "inets" and "crypto" application must be started.

= Documentation =

All available functions are documented in the .erl files for the service clients. 

Here a short overview:

== erlaws_s3 ==

  * list_buckets/0
  * create_bucket/1
  * create_bucket/2 (for EU and other region buckets)
  * delete_bucket/1
  * list_contents/1
  * list_contents/2
  * put_object/5
  * put_file/5
  * get_object/2
  * info_object/2
  * delete_object/2

== erlaws_sqs == 

  * list_queues/0
  * list_queues/1 
  * get_queue/1
  * create_queue/1
  * create_queue/2
  * get_queue_attr/1
  * set_queue_attr/3
  * delete_queue/1
  * send_message/2 
  * receive_message/1
  * receive_message/2
  * receive_message/3
  * delete_message/2

== erlaws_sdb ==

  * create_domain/1
  * delete_domain/1
  * list_domains/0
  * list_domains/1
  * put_attributes/3
  * batch_put_attributes/2
  * delete_item/2
  * delete_attributes/3
  * get_attributes/2
  * get_attributes/3
  * list_items/1
  * list_items/2 
  * query_items/2
  * query_items/3
  * select/1
  * select/2

== erlaws_ec2 ==

  * start_instances/1 
  * run_instances/13 
  * stop_instances/2
  * terminate_instances/1
  * describe_instances/0
  * describe_instances/1

== SimpleDB Intro ==
> inets:start().
ok
> ssl:start().
ok
> SDB = erlaws_sdb:new("<your aws access key>", "<your aws secret key">).
{erlaws_sdb,"<your aws access key>",
            "<your aws secret key>",true}

% To create a new domain
> SDB:create_domain("my_domain").
{ok,{requestId,"<request id here>"}}

% Create a new item in our new domain,
% which has name "item1", with one attribute named "surname",
% with one value "Suzuki".
> SDB:put_attributes("my_domain", "item1", [{"surname", ["Suzuki"]}]).
{ok,{requestId,"<request id here>"}}

% Create another attribute "givenname" within "Ichiro"
> SDB:put_attributes("my_domain", "item1", [{"givenname", ["Ichiro"]}]).

% Now item1 looks like this
> SDB:get_attributes("my_domain", "item1").
{ok,[{"item1",
      [{"givenname",["Ichiro"]},{"surname",["Suzuki"]}]}]}

% Add another item named "item2"
> SDB:put_attributes("my_domain", "item2", [{"surname", ["Asada"]}, {"givenname", ["Mao"}]).
{ok,{requestId,"<request id here>"}}

% Use select/1 for select queries.
> SDB:select("select * from my_domain").
{ok,[{"item1",
      [{"surname",["Suzuki"]},{"givenname",["Ichiro"]}]},
     {"item2",[{"surname",["Asada"]},{"givenname",["Mao"]}]}],
    []}


== SQS Intro ==
> inets:start().
ok
> ssl:start().
ok
> SQS = erlaws_sqs:new("<your aws access key>", "<your aws secret key">).
{erlaws_sqs,"<your aws access key>",
            "<your aws secret key>",true}
> rr(erlaws_sqs).
[s3_list_result,s3_object_info,sqs_message,sqs_queue,
 xmerl_event,xmerl_fun_states,xmerl_scanner,xmlAttribute,
 xmlComment,xmlContext,xmlDecl,xmlDocument,xmlElement,
 xmlNamespace,xmlNode,xmlNsNode,xmlObj,xmlPI,xmlText]

% Create a new queue.
> SQS:create_queue("my_queue")
{ok,"https://queue.amazonaws.com/my_queue",
    {requestId,"<request id here>"}}

% Send a message
> SQS:send_message("https://queue.amazonaws.com/my_queue", "hello").
{ok,#sqs_message{messageId = "<message id here>",
                 receiptHandle = [],
                 contentMD5 = "<md5 sum here>",
                 body = "hello"},
    {requestId,"<request id here>"}}

% Receive messages
> SQS:receive_message("https://queue.amazonaws.com/my_queue").
{ok,[#sqs_message{messageId = "<message id here>",
                  receiptHandle = "<some long receipt handle>",
                  contentMD5 = "<md5 sum here>",
                  body = "hello"}],
    {requestId,"<request id here>"}}

% Following immediate receive will return nothing.
> SQS:receive_message("https://queue.amazonaws.com/my_queue").
{ok,[],{requestId,"<request id here>"}}

% After some 30 seconds you can receive "hello" again.
> SQS:receive_message("https://queue.amazonaws.com/my_queue").
{ok,[#sqs_message{messageId = "<message id here>",
                  receiptHandle = "<some long receipt handle>",
                  contentMD5 = "<md5 sum here>",
                  body = "hello"}],
    {requestId,"<request id here>"}}

% Visibility timeout is defined in queue attributes.
> SQS:get_queue_attr("https://queue.amazonaws.com/my_queue").
{ok,[{"VisibilityTimeout",30},
     {"ApproximateNumberOfMessages",0}],
    {requestId,"<request id here>"}}

% To delete message from queue, use the "receiptHandle",
% which is a unique identifier for each item in the queue.
> SQS:delete_message("https://queue.amazonaws.com/my_queue", "<some long receipt handle>").
{ok,{requestId,"<request id here>"}}

erlaws's People

Contributors

aduston avatar burbas avatar dieu avatar flamefork avatar goura avatar japerk avatar ugglan avatar vlm avatar x6j8x avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.