AWS SDK for Smalltalk

Click here to load reader

  • date post

    21-Jul-2015
  • Category

    Engineering

  • view

    1.802
  • download

    0

Embed Size (px)

Transcript of AWS SDK for Smalltalk

  • Copyright 2014 SORABITO Co., Ltd. All Rights Reserved.

    A W S S D K f o r S m a l l t a l k2 0 1 4 M E R R Y C H R I S T M A S

    @newapplesho

  • Copyright 2014 SORABITO Co., Ltd. All Rights Reserved.

    S m a l l t a l kR D B

    OmniBase

    Magma

    GemStone

    MongoDB

    Neo4j

  • Copyright 2014 SORABITO Co., Ltd. All Rights Reserved.

    O m n i B a s e

    Smalltalk

    GORISEK Ltd.Dolphin Smalltalk

    VisualWorks, Squeak

    2014GitHub

    MIThttps://github.com/sebastianconcept/OmniBase

  • Copyright 2014 SORABITO Co., Ltd. All Rights Reserved.

    M a g m a

    Smalltalk

    Squeak

    Pharo, VisualWorks

    http://wiki.squeak.org/squeak/2665

  • Copyright 2014 SORABITO Co., Ltd. All Rights Reserved.

    G e m S t o n e

    GemStone/S SmalltalkOODB

    SmalltalkDBSmalltalk

    OODB

    GLASSWeb

    https://github.com/GsDevKit/gsDevKitHome

  • Copyright 2014 SORABITO Co., Ltd. All Rights Reserved.

    M o n g o D B

    NoSQL

    SmalltalkKent Beck

    http://smalltalkhub.com/#!/~francois/MongoTalk

  • Copyright 2014 SORABITO Co., Ltd. All Rights Reserved.

    N e o 4 j

    SmalltalkNeo4reSt

    http://smalltalkhub.com/#!/~MasashiUmezawa/Neo4reSt

  • Copyright 2014 SORABITO Co., Ltd. All Rights Reserved.

    Mikatahttps://mikatacloud.com

    https://mikatacloud.com
  • Copyright 2014 SORABITO Co., Ltd. All Rights Reserved.

    N o S Q L

    OODB

    Replica SetsDCArbiter

    I/O

  • Copyright 2014 SORABITO Co., Ltd. All Rights Reserved.

  • Copyright 2014 SORABITO Co., Ltd. All Rights Reserved.

    2 0 1 4 0 4

  • Copyright 2014 SORABITO Co., Ltd. All Rights Reserved.

    A m a z o n D y n a m o D B

    NoSQL

    SSD

    APISDK

  • Copyright 2014 SORABITO Co., Ltd. All Rights Reserved.

    S m a l l t a l k e rA W S

    nodeJS

    iOS

    iOS JavaJavascript Net

    nodeJS

    Android

    PHP Python

    Ruby

    Ruby

    SDK

  • I love Smalltalk

  • Copyright 2014 SORABITO Co., Ltd. All Rights Reserved.

    A W S S D K f o r S m a l l t a l k

    https://github.com/newapplesho/aws-sdk-smalltalk

  • Copyright 2014 SORABITO Co., Ltd. All Rights Reserved.

    Signature V4

    DynamoDB API

    DynamoDB

    SDKDynamoDB

  • Copyright 2014 SORABITO Co., Ltd. All Rights Reserved.

    A W S S i g n a t u r e Ve r s i o n 4

    AWS

    Signature version 4 signing process

    http://docs.aws.amazon.com/general/latest/gr/signature-version-4.html

  • Copyright 2014 SORABITO Co., Ltd. All Rights Reserved.

    D y n a m o D B H T T P A P I

    SSL

    URL/URL

    x-amz-target

    JSONJSON

    x-amz-dateISO 8601: 20130315T092054Z

    http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/MakingHTTPRequests.html

  • Copyright 2014 SORABITO Co., Ltd. All Rights Reserved.

    A W S S D K f o r S m a l l t a l k D y n a m o D B

    AWS SDK for Smalltalk DynamoDB

    * - * -

    Amazon DynamoDB for Smalltalk supports the following data types:

    * Scalar types Number, String. * Multi-valued types String Set, Number Set.

  • Copyright 2014 SORABITO Co., Ltd. All Rights Reserved.

    DynamoDB

  • Copyright 2014 SORABITO Co., Ltd. All Rights Reserved.

    H o w t o i n s t a l l S t e p 1

    Get started in minutes using Metacello and FileTree.

    $ git clone https://github.com/newapplesho/aws-sdk-smalltalk

    https://github.com/newapplesho/aws-sdk-smalltalk
  • Copyright 2014 SORABITO Co., Ltd. All Rights Reserved.

    H o w t o i n s t a l l S t e p 2

    Get started in minutes using Metacello and FileTree.

    | pathToPackageDirectory | "edit to match the path to your chosen package directory" pathToPackageDirectory := /YOUR-GIT-DIRECTORY-PATH/aws-sdk-smalltalk/pharo-repository/. Metacello new baseline: 'AWS'; repository: 'filetree://', pathToPackageDirectory; load.

  • Copyright 2014 SORABITO Co., Ltd. All Rights Reserved.

  • R A W A P I

  • Copyright 2014 SORABITO Co., Ltd. All Rights Reserved.

    S e t u p

    awsConfig := AWSDynamoDBConfig default. awsConfig accessKeyId:'YOURACCESSKEY'. awsConfig secretKey:'YOURSECRETKEY'.

    dy := DynamoDBRawClient new. dy awsConfig accessKeyId:'YOURACCESSKEY'. dy awsConfig secretKey:'YOURSECRETKEY'.

    or

  • Copyright 2014 SORABITO Co., Ltd. All Rights Reserved.

    C r e a t e Ta b l e

    DynamoDBDynamoDB

    Table

    C o l u m n Ty p e K e y S c h e ma

    i d S t r i n g H A S H

    { "AttributeDefinitions": [ { "AttributeName": "id", "AttributeType": "S"} ], "TableName": "dmodeltest1", "KeySchema": [ { "AttributeName": "id", "KeyType": "HASH"}], "ProvisionedThroughput": { "ReadCapacityUnits": 10, "WriteCapacityUnits": 10} }

    dmodeltest1

  • Copyright 2014 SORABITO Co., Ltd. All Rights Reserved.

    C r e a t e Ta b l e

    dy := DynamoDBRawClient new. operationName := #CreateTable. requestBody := '{ "AttributeDefinitions": [ { "AttributeName": "id", "AttributeType": "S"} ], "TableName": "dmodeltest1", "KeySchema": [ { "AttributeName": "id", "KeyType": "HASH"}], "ProvisionedThroughput": { "ReadCapacityUnits": 10, "WriteCapacityUnits": 10} }'. resp := dy operationName: operationName entityContents: requestBody.

  • Copyright 2014 SORABITO Co., Ltd. All Rights Reserved.

    L i s t Ta b l e s

    dy := DynamoDBRawClient new. operationName := #ListTables. requestBody := '{}'. resp := dy operationName: operationName entityContents: requestBody. Json readFrom: (resp contents) readStream.

  • Copyright 2014 SORABITO Co., Ltd. All Rights Reserved.

    P u t I t e m

    DynamoDB Item

    C o l u m n Ty p e K e y S c h e m a

    i d S t r i n g H A S H

    {"TableName":"dmodeltest1", "Item": {"id": {"S":"af2d4b16147f45fea3753cc9c0a3f739"} } }

    DynamoDB Table

    UUID new primMakeUUID hex.

  • Copyright 2014 SORABITO Co., Ltd. All Rights Reserved.

    P u t I t e m ( J a v a )

    client = new AmazonDynamoDBClient(credentials); String tableName = "dmodeltest1"; Map item = new HashMap(); item.put("id", new AttributeValue().withS("babe2d60c42a45fca9120d1c111d8844")); PutItemRequest putItemRequest = new PutItemRequest() .withTableName(tableName) .withItem(item); PutItemResult result = client.putItem(putItemRequest);

  • Copyright 2014 SORABITO Co., Ltd. All Rights Reserved.

    P u t I t e m

    dy := DynamoDBRawClient new. operationName := 'PutItem'. requestBody := '{"TableName":"dmodeltest1","Item":{"id":{"S":"af2d4b16147f45fea3753cc9c0a3f739"}}}' resp := dy operationName: operationName entityContents: requestBody.

  • Copyright 2014 SORABITO Co., Ltd. All Rights Reserved.

    P u t I t e m

    DynamoDBModelModel

    DynamoDBModelDictionarydataModel

  • P u t I t e m

    dy := DynamoDBRawClient new. operationName := 'PutItem'. json := JsonObject new at:'TableName' put:'dmodeltest1';yourself. d:= DModelTest1 new. d at: id put:af2d4b16147f45fea3753cc9c0a3f739. mapper := DynamoDBMapper new. c := (mapper convertItem:d). json at:'Item' put: c . requestBody := json asJsonString . resp := dy operationName: operationName entityContents: requestBody.

    Json is generated in Smalltalk.

  • Copyright 2014 SORABITO Co., Ltd. All Rights Reserved.

    G e t I t e m

    DynamoDB Item

    C o l u m n Ty p e K e y S c h e m a

    i d S t r i n g H A S H

    {"TableName":"dmodeltest1", "Key": {"id": {"S":"af2d4b16147f45fea3753cc9c0a3f739"} } }

    DynamoDB Table

  • Copyright 2014 SORABITO Co., Ltd. All Rights Reserved.

    G e t I t e m

    operationName := 'GetItem'. json := JsonObject new at:'TableName' put:'dmodeltest1';yourself. d:= DModelTest1 new. d at: id put:af2d4b16147f45fea3753cc9c0a3f739. mapper := DynamoDBMapper new. c := (mapper convertItem:d). json at:'Key' put: c . requestBody := json asJsonString . resp := dy operationName: operationName entityContents: requestBody. result := Json readFrom: (resp contents) readStream. mapper loadItem: (result at:'Item') .

  • Copyright 2014 SORABITO Co., Ltd. All Rights Reserved.

    Q u e r y

    operationName := 'Query'. json := JsonObject new at:'TableName' put:'dmodeltest1';yourself. d:= DModelTest1 new. d data at:#id put:uuid. mapper := DynamoDBMapper new. c := (mapper convertItem:d). c := JsonObject new at: (c keys first) put: ((JsonObject new at:'AttributeValueList' put: (Array with: c anyOne); yourself ) at:'ComparisonOperator' put:'EQ'; yourself); yourself. json at:'KeyConditions' put: c . json at:'Select' put: 'ALL_ATTRIBUTES'. requestBody := json asJsonString . resp := dy operationName: operationName entityContents: requestBody. result := Json readFrom: (resp contents) readStream. (result at:'Count') > 0 ifTrue:[ ^ (result at:'Items') collect:[:v | mapper loadItem:v ]. ] .

  • Copyright 2014 SORABITO Co., Ltd. All Rights Reserved.

    D e l e t e I t e m

    operationName := 'DeleteItem'. json := JsonObject new at:'TableName' put:'dmodeltest1';yourself. d:= DModelTest1 new. d id:uuid. mapper := DynamoDBMapper new. c := (mapper convertItem:d). json at:'Key' put: c . requestBody := json asJsonString. resp := dy operationName: operationName entityContents: requestBody. result := Json readFrom: (resp contents) readStream.

  • Copyright 2014 SORABITO Co., Ltd. All Rights Reserved.

    D e l e t e Ta b l e

    operationName := #DeleteTable. requestBody := JsonObject new at:'TableN