service.go 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package simpledb
  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/corehandlers"
  8. "github.com/aws/aws-sdk-go/aws/request"
  9. "github.com/aws/aws-sdk-go/private/protocol/query"
  10. "github.com/aws/aws-sdk-go/private/signer/v2"
  11. )
  12. // Amazon SimpleDB is a web service providing the core database functions of
  13. // data indexing and querying in the cloud. By offloading the time and effort
  14. // associated with building and operating a web-scale database, SimpleDB provides
  15. // developers the freedom to focus on application development. A traditional,
  16. // clustered relational database requires a sizable upfront capital outlay,
  17. // is complex to design, and often requires extensive and repetitive database
  18. // administration. Amazon SimpleDB is dramatically simpler, requiring no schema,
  19. // automatically indexing your data and providing a simple API for storage and
  20. // access. This approach eliminates the administrative burden of data modeling,
  21. // index maintenance, and performance tuning. Developers gain access to this
  22. // functionality within Amazon's proven computing environment, are able to scale
  23. // instantly, and pay only for what they use.
  24. //
  25. // Visit http://aws.amazon.com/simpledb/ (http://aws.amazon.com/simpledb/) for
  26. // more information.
  27. //The service client's operations are safe to be used concurrently.
  28. // It is not safe to mutate any of the client's properties though.
  29. type SimpleDB struct {
  30. *client.Client
  31. }
  32. // Used for custom client initialization logic
  33. var initClient func(*client.Client)
  34. // Used for custom request initialization logic
  35. var initRequest func(*request.Request)
  36. // A ServiceName is the name of the service the client will make API calls to.
  37. const ServiceName = "sdb"
  38. // New creates a new instance of the SimpleDB client with a session.
  39. // If additional configuration is needed for the client instance use the optional
  40. // aws.Config parameter to add your extra config.
  41. //
  42. // Example:
  43. // // Create a SimpleDB client from just a session.
  44. // svc := simpledb.New(mySession)
  45. //
  46. // // Create a SimpleDB client with additional configuration
  47. // svc := simpledb.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
  48. func New(p client.ConfigProvider, cfgs ...*aws.Config) *SimpleDB {
  49. c := p.ClientConfig(ServiceName, cfgs...)
  50. return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion)
  51. }
  52. // newClient creates, initializes and returns a new service client instance.
  53. func newClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion string) *SimpleDB {
  54. svc := &SimpleDB{
  55. Client: client.New(
  56. cfg,
  57. metadata.ClientInfo{
  58. ServiceName: ServiceName,
  59. SigningRegion: signingRegion,
  60. Endpoint: endpoint,
  61. APIVersion: "2009-04-15",
  62. },
  63. handlers,
  64. ),
  65. }
  66. // Handlers
  67. svc.Handlers.Sign.PushBackNamed(v2.SignRequestHandler)
  68. svc.Handlers.Sign.PushBackNamed(corehandlers.BuildContentLengthHandler)
  69. svc.Handlers.Build.PushBackNamed(query.BuildHandler)
  70. svc.Handlers.Unmarshal.PushBackNamed(query.UnmarshalHandler)
  71. svc.Handlers.UnmarshalMeta.PushBackNamed(query.UnmarshalMetaHandler)
  72. svc.Handlers.UnmarshalError.PushBackNamed(query.UnmarshalErrorHandler)
  73. // Run custom client initialization if present
  74. if initClient != nil {
  75. initClient(svc.Client)
  76. }
  77. return svc
  78. }
  79. // newRequest creates a new request for a SimpleDB operation and runs any
  80. // custom request initialization.
  81. func (c *SimpleDB) newRequest(op *request.Operation, params, data interface{}) *request.Request {
  82. req := c.NewRequest(op, params, data)
  83. // Run custom request initialization if present
  84. if initRequest != nil {
  85. initRequest(req)
  86. }
  87. return req
  88. }