service.go 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package cloudtrail
  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 CloudTrail API Reference. It provides descriptions of actions,
  12. // data types, common parameters, and common errors for CloudTrail.
  13. //
  14. // CloudTrail is a web service that records AWS API calls for your AWS account
  15. // and delivers log files to an Amazon S3 bucket. The recorded information includes
  16. // the identity of the user, the start time of the AWS API call, the source
  17. // IP address, the request parameters, and the response elements returned by
  18. // the service.
  19. //
  20. // As an alternative to the API, you can use one of the AWS SDKs, which consist
  21. // of libraries and sample code for various programming languages and platforms
  22. // (Java, Ruby, .NET, iOS, Android, etc.). The SDKs provide a convenient way
  23. // to create programmatic access to AWSCloudTrail. For example, the SDKs take
  24. // care of cryptographically signing requests, managing errors, and retrying
  25. // requests automatically. For information about the AWS SDKs, including how
  26. // to download and install them, see the Tools for Amazon Web Services page
  27. // (http://aws.amazon.com/tools/).
  28. //
  29. // See the CloudTrail User Guide for information about the data that is included
  30. // with each AWS API call listed in the log files.
  31. //The service client's operations are safe to be used concurrently.
  32. // It is not safe to mutate any of the client's properties though.
  33. type CloudTrail struct {
  34. *client.Client
  35. }
  36. // Used for custom client initialization logic
  37. var initClient func(*client.Client)
  38. // Used for custom request initialization logic
  39. var initRequest func(*request.Request)
  40. // A ServiceName is the name of the service the client will make API calls to.
  41. const ServiceName = "cloudtrail"
  42. // New creates a new instance of the CloudTrail client with a session.
  43. // If additional configuration is needed for the client instance use the optional
  44. // aws.Config parameter to add your extra config.
  45. //
  46. // Example:
  47. // // Create a CloudTrail client from just a session.
  48. // svc := cloudtrail.New(mySession)
  49. //
  50. // // Create a CloudTrail client with additional configuration
  51. // svc := cloudtrail.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
  52. func New(p client.ConfigProvider, cfgs ...*aws.Config) *CloudTrail {
  53. c := p.ClientConfig(ServiceName, cfgs...)
  54. return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion)
  55. }
  56. // newClient creates, initializes and returns a new service client instance.
  57. func newClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion string) *CloudTrail {
  58. svc := &CloudTrail{
  59. Client: client.New(
  60. cfg,
  61. metadata.ClientInfo{
  62. ServiceName: ServiceName,
  63. SigningRegion: signingRegion,
  64. Endpoint: endpoint,
  65. APIVersion: "2013-11-01",
  66. JSONVersion: "1.1",
  67. TargetPrefix: "com.amazonaws.cloudtrail.v20131101.CloudTrail_20131101",
  68. },
  69. handlers,
  70. ),
  71. }
  72. // Handlers
  73. svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
  74. svc.Handlers.Build.PushBackNamed(jsonrpc.BuildHandler)
  75. svc.Handlers.Unmarshal.PushBackNamed(jsonrpc.UnmarshalHandler)
  76. svc.Handlers.UnmarshalMeta.PushBackNamed(jsonrpc.UnmarshalMetaHandler)
  77. svc.Handlers.UnmarshalError.PushBackNamed(jsonrpc.UnmarshalErrorHandler)
  78. // Run custom client initialization if present
  79. if initClient != nil {
  80. initClient(svc.Client)
  81. }
  82. return svc
  83. }
  84. // newRequest creates a new request for a CloudTrail operation and runs any
  85. // custom request initialization.
  86. func (c *CloudTrail) newRequest(op *request.Operation, params, data interface{}) *request.Request {
  87. req := c.NewRequest(op, params, data)
  88. // Run custom request initialization if present
  89. if initRequest != nil {
  90. initRequest(req)
  91. }
  92. return req
  93. }