api.go 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. // Package marketplacemetering provides a client for AWSMarketplace Metering.
  3. package marketplacemetering
  4. import (
  5. "time"
  6. "github.com/aws/aws-sdk-go/aws/awsutil"
  7. "github.com/aws/aws-sdk-go/aws/request"
  8. )
  9. const opMeterUsage = "MeterUsage"
  10. // MeterUsageRequest generates a "aws/request.Request" representing the
  11. // client's request for the MeterUsage operation. The "output" return
  12. // value can be used to capture response data after the request's "Send" method
  13. // is called.
  14. //
  15. // Creating a request object using this method should be used when you want to inject
  16. // custom logic into the request's lifecycle using a custom handler, or if you want to
  17. // access properties on the request object before or after sending the request. If
  18. // you just want the service response, call the MeterUsage method directly
  19. // instead.
  20. //
  21. // Note: You must call the "Send" method on the returned request object in order
  22. // to execute the request.
  23. //
  24. // // Example sending a request using the MeterUsageRequest method.
  25. // req, resp := client.MeterUsageRequest(params)
  26. //
  27. // err := req.Send()
  28. // if err == nil { // resp is now filled
  29. // fmt.Println(resp)
  30. // }
  31. //
  32. func (c *MarketplaceMetering) MeterUsageRequest(input *MeterUsageInput) (req *request.Request, output *MeterUsageOutput) {
  33. op := &request.Operation{
  34. Name: opMeterUsage,
  35. HTTPMethod: "POST",
  36. HTTPPath: "/",
  37. }
  38. if input == nil {
  39. input = &MeterUsageInput{}
  40. }
  41. req = c.newRequest(op, input, output)
  42. output = &MeterUsageOutput{}
  43. req.Data = output
  44. return
  45. }
  46. // API to emit metering records. For identical requests, the API is idempotent.
  47. // It simply returns the metering record ID.
  48. func (c *MarketplaceMetering) MeterUsage(input *MeterUsageInput) (*MeterUsageOutput, error) {
  49. req, out := c.MeterUsageRequest(input)
  50. err := req.Send()
  51. return out, err
  52. }
  53. type MeterUsageInput struct {
  54. _ struct{} `type:"structure"`
  55. // Checks whether you have the permissions required for the action, but does
  56. // not make the request. If you have the permissions, the request returns DryRunOperation;
  57. // otherwise, it returns UnauthorizedException.
  58. DryRun *bool `type:"boolean" required:"true"`
  59. // Product code is used to uniquely identify a product in AWS Marketplace. The
  60. // product code should be the same as the one used during the publishing of
  61. // a new product.
  62. ProductCode *string `min:"1" type:"string" required:"true"`
  63. // Timestamp of the hour, recorded in UTC. The seconds and milliseconds portions
  64. // of the timestamp will be ignored.
  65. Timestamp *time.Time `type:"timestamp" timestampFormat:"unix" required:"true"`
  66. // It will be one of the 'fcp dimension name' provided during the publishing
  67. // of the product.
  68. UsageDimension *string `min:"1" type:"string" required:"true"`
  69. // Consumption value for the hour.
  70. UsageQuantity *int64 `type:"integer" required:"true"`
  71. }
  72. // String returns the string representation
  73. func (s MeterUsageInput) String() string {
  74. return awsutil.Prettify(s)
  75. }
  76. // GoString returns the string representation
  77. func (s MeterUsageInput) GoString() string {
  78. return s.String()
  79. }
  80. // Validate inspects the fields of the type to determine if they are valid.
  81. func (s *MeterUsageInput) Validate() error {
  82. invalidParams := request.ErrInvalidParams{Context: "MeterUsageInput"}
  83. if s.DryRun == nil {
  84. invalidParams.Add(request.NewErrParamRequired("DryRun"))
  85. }
  86. if s.ProductCode == nil {
  87. invalidParams.Add(request.NewErrParamRequired("ProductCode"))
  88. }
  89. if s.ProductCode != nil && len(*s.ProductCode) < 1 {
  90. invalidParams.Add(request.NewErrParamMinLen("ProductCode", 1))
  91. }
  92. if s.Timestamp == nil {
  93. invalidParams.Add(request.NewErrParamRequired("Timestamp"))
  94. }
  95. if s.UsageDimension == nil {
  96. invalidParams.Add(request.NewErrParamRequired("UsageDimension"))
  97. }
  98. if s.UsageDimension != nil && len(*s.UsageDimension) < 1 {
  99. invalidParams.Add(request.NewErrParamMinLen("UsageDimension", 1))
  100. }
  101. if s.UsageQuantity == nil {
  102. invalidParams.Add(request.NewErrParamRequired("UsageQuantity"))
  103. }
  104. if invalidParams.Len() > 0 {
  105. return invalidParams
  106. }
  107. return nil
  108. }
  109. type MeterUsageOutput struct {
  110. _ struct{} `type:"structure"`
  111. MeteringRecordId *string `type:"string"`
  112. }
  113. // String returns the string representation
  114. func (s MeterUsageOutput) String() string {
  115. return awsutil.Prettify(s)
  116. }
  117. // GoString returns the string representation
  118. func (s MeterUsageOutput) GoString() string {
  119. return s.String()
  120. }