service.go 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package dynamodb
  3. import (
  4. "github.com/aws/aws-sdk-go/aws"
  5. "github.com/aws/aws-sdk-go/aws/client"
  6. "github.com/aws/aws-sdk-go/aws/client/metadata"
  7. "github.com/aws/aws-sdk-go/aws/request"
  8. "github.com/aws/aws-sdk-go/aws/signer/v4"
  9. "github.com/aws/aws-sdk-go/private/protocol/jsonrpc"
  10. )
  11. // This is the Amazon DynamoDB API Reference. This guide provides descriptions
  12. // of the low-level DynamoDB API.
  13. //
  14. // This guide is intended for use with the following DynamoDB documentation:
  15. //
  16. // * Amazon DynamoDB Getting Started Guide (http://docs.aws.amazon.com/amazondynamodb/latest/gettingstartedguide/)
  17. // - provides hands-on exercises that help you learn the basics of working
  18. // with DynamoDB. If you are new to DynamoDB, we recommend that you begin
  19. // with the Getting Started Guide.
  20. //
  21. // * Amazon DynamoDB Developer Guide (http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/)
  22. // - contains detailed information about DynamoDB concepts, usage, and best
  23. // practices.
  24. //
  25. // * Amazon DynamoDB Streams API Reference (http://docs.aws.amazon.com/dynamodbstreams/latest/APIReference/)
  26. // - provides descriptions and samples of the DynamoDB Streams API. (For
  27. // more information, see Capturing Table Activity with DynamoDB Streams (http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Streams.html)
  28. // in the Amazon DynamoDB Developer Guide.)
  29. //
  30. // Instead of making the requests to the low-level DynamoDB API directly from
  31. // your application, we recommend that you use the AWS Software Development
  32. // Kits (SDKs). The easy-to-use libraries in the AWS SDKs make it unnecessary
  33. // to call the low-level DynamoDB API directly from your application. The libraries
  34. // take care of request authentication, serialization, and connection management.
  35. // For more information, see Using the AWS SDKs with DynamoDB (http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/UsingAWSSDK.html)
  36. // in the Amazon DynamoDB Developer Guide.
  37. //
  38. // If you decide to code against the low-level DynamoDB API directly, you will
  39. // need to write the necessary code to authenticate your requests. For more
  40. // information on signing your requests, see Using the DynamoDB API (http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/API.html)
  41. // in the Amazon DynamoDB Developer Guide.
  42. //
  43. // The following are short descriptions of each low-level API action, organized
  44. // by function.
  45. //
  46. // Managing Tables
  47. //
  48. // * CreateTable - Creates a table with user-specified provisioned throughput
  49. // settings. You must define a primary key for the table - either a simple
  50. // primary key (partition key), or a composite primary key (partition key
  51. // and sort key). Optionally, you can create one or more secondary indexes,
  52. // which provide fast data access using non-key attributes.
  53. //
  54. // * DescribeTable - Returns metadata for a table, such as table size, status,
  55. // and index information.
  56. //
  57. // * UpdateTable - Modifies the provisioned throughput settings for a table.
  58. // Optionally, you can modify the provisioned throughput settings for global
  59. // secondary indexes on the table.
  60. //
  61. // * ListTables - Returns a list of all tables associated with the current
  62. // AWS account and endpoint.
  63. //
  64. // * DeleteTable - Deletes a table and all of its indexes.
  65. //
  66. // For conceptual information about managing tables, see Working with Tables
  67. // (http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithTables.html)
  68. // in the Amazon DynamoDB Developer Guide.
  69. //
  70. // Reading Data
  71. //
  72. // * GetItem - Returns a set of attributes for the item that has a given
  73. // primary key. By default, GetItem performs an eventually consistent read;
  74. // however, applications can request a strongly consistent read instead.
  75. //
  76. // * BatchGetItem - Performs multiple GetItem requests for data items using
  77. // their primary keys, from one table or multiple tables. The response from
  78. // BatchGetItem has a size limit of 16 MB and returns a maximum of 100 items.
  79. // Both eventually consistent and strongly consistent reads can be used.
  80. //
  81. // * Query - Returns one or more items from a table or a secondary index.
  82. // You must provide a specific value for the partition key. You can narrow
  83. // the scope of the query using comparison operators against a sort key value,
  84. // or on the index key. Query supports either eventual or strong consistency.
  85. // A single response has a size limit of 1 MB.
  86. //
  87. // * Scan - Reads every item in a table; the result set is eventually consistent.
  88. // You can limit the number of items returned by filtering the data attributes,
  89. // using conditional expressions. Scan can be used to enable ad-hoc querying
  90. // of a table against non-key attributes; however, since this is a full table
  91. // scan without using an index, Scan should not be used for any application
  92. // query use case that requires predictable performance.
  93. //
  94. // For conceptual information about reading data, see Working with Items (http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithItems.html)
  95. // and Query and Scan Operations (http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/QueryAndScan.html)
  96. // in the Amazon DynamoDB Developer Guide.
  97. //
  98. // Modifying Data
  99. //
  100. // * PutItem - Creates a new item, or replaces an existing item with a new
  101. // item (including all the attributes). By default, if an item in the table
  102. // already exists with the same primary key, the new item completely replaces
  103. // the existing item. You can use conditional operators to replace an item
  104. // only if its attribute values match certain conditions, or to insert a
  105. // new item only if that item doesn't already exist.
  106. //
  107. // * UpdateItem - Modifies the attributes of an existing item. You can also
  108. // use conditional operators to perform an update only if the item's attribute
  109. // values match certain conditions.
  110. //
  111. // * DeleteItem - Deletes an item in a table by primary key. You can use
  112. // conditional operators to perform a delete an item only if the item's attribute
  113. // values match certain conditions.
  114. //
  115. // * BatchWriteItem - Performs multiple PutItem and DeleteItem requests across
  116. // multiple tables in a single request. A failure of any request(s) in the
  117. // batch will not cause the entire BatchWriteItem operation to fail. Supports
  118. // batches of up to 25 items to put or delete, with a maximum total request
  119. // size of 16 MB.
  120. //
  121. // For conceptual information about modifying data, see Working with Items (http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithItems.html)
  122. // and Query and Scan Operations (http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/QueryAndScan.html)
  123. // in the Amazon DynamoDB Developer Guide.
  124. //The service client's operations are safe to be used concurrently.
  125. // It is not safe to mutate any of the client's properties though.
  126. type DynamoDB struct {
  127. *client.Client
  128. }
  129. // Used for custom client initialization logic
  130. var initClient func(*client.Client)
  131. // Used for custom request initialization logic
  132. var initRequest func(*request.Request)
  133. // A ServiceName is the name of the service the client will make API calls to.
  134. const ServiceName = "dynamodb"
  135. // New creates a new instance of the DynamoDB client with a session.
  136. // If additional configuration is needed for the client instance use the optional
  137. // aws.Config parameter to add your extra config.
  138. //
  139. // Example:
  140. // // Create a DynamoDB client from just a session.
  141. // svc := dynamodb.New(mySession)
  142. //
  143. // // Create a DynamoDB client with additional configuration
  144. // svc := dynamodb.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
  145. func New(p client.ConfigProvider, cfgs ...*aws.Config) *DynamoDB {
  146. c := p.ClientConfig(ServiceName, cfgs...)
  147. return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion)
  148. }
  149. // newClient creates, initializes and returns a new service client instance.
  150. func newClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion string) *DynamoDB {
  151. svc := &DynamoDB{
  152. Client: client.New(
  153. cfg,
  154. metadata.ClientInfo{
  155. ServiceName: ServiceName,
  156. SigningRegion: signingRegion,
  157. Endpoint: endpoint,
  158. APIVersion: "2012-08-10",
  159. JSONVersion: "1.0",
  160. TargetPrefix: "DynamoDB_20120810",
  161. },
  162. handlers,
  163. ),
  164. }
  165. // Handlers
  166. svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
  167. svc.Handlers.Build.PushBackNamed(jsonrpc.BuildHandler)
  168. svc.Handlers.Unmarshal.PushBackNamed(jsonrpc.UnmarshalHandler)
  169. svc.Handlers.UnmarshalMeta.PushBackNamed(jsonrpc.UnmarshalMetaHandler)
  170. svc.Handlers.UnmarshalError.PushBackNamed(jsonrpc.UnmarshalErrorHandler)
  171. // Run custom client initialization if present
  172. if initClient != nil {
  173. initClient(svc.Client)
  174. }
  175. return svc
  176. }
  177. // newRequest creates a new request for a DynamoDB operation and runs any
  178. // custom request initialization.
  179. func (c *DynamoDB) newRequest(op *request.Operation, params, data interface{}) *request.Request {
  180. req := c.NewRequest(op, params, data)
  181. // Run custom request initialization if present
  182. if initRequest != nil {
  183. initRequest(req)
  184. }
  185. return req
  186. }