marketplacemetering

package
v1.5.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2016 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package marketplacemetering provides a client for AWSMarketplace Metering.

Index

Examples

Constants

View Source
const (
	// UsageRecordResultStatusSuccess is a UsageRecordResultStatus enum value
	UsageRecordResultStatusSuccess = "Success"

	// UsageRecordResultStatusCustomerNotSubscribed is a UsageRecordResultStatus enum value
	UsageRecordResultStatusCustomerNotSubscribed = "CustomerNotSubscribed"

	// UsageRecordResultStatusDuplicateRecord is a UsageRecordResultStatus enum value
	UsageRecordResultStatusDuplicateRecord = "DuplicateRecord"
)
View Source
const ServiceName = "metering.marketplace"

A ServiceName is the name of the service the client will make API calls to.

Variables

This section is empty.

Functions

This section is empty.

Types

type BatchMeterUsageInput added in v1.5.7

type BatchMeterUsageInput struct {

	// Product code is used to uniquely identify a product in AWS Marketplace. The
	// product code should be the same as the one used during the publishing of
	// a new product.
	//
	// ProductCode is a required field
	ProductCode *string `min:"1" type:"string" required:"true"`

	// The set of UsageRecords to submit. BatchMeterUsage accepts up to 25 UsageRecords
	// at a time.
	//
	// UsageRecords is a required field
	UsageRecords []*UsageRecord `type:"list" required:"true"`
	// contains filtered or unexported fields
}

A BatchMeterUsageRequest contains UsageRecords, which indicate quantities of usage within your application.

func (BatchMeterUsageInput) GoString added in v1.5.7

func (s BatchMeterUsageInput) GoString() string

GoString returns the string representation

func (*BatchMeterUsageInput) SetProductCode added in v1.5.7

func (s *BatchMeterUsageInput) SetProductCode(v string) *BatchMeterUsageInput

SetProductCode sets the ProductCode field's value.

func (*BatchMeterUsageInput) SetUsageRecords added in v1.5.7

func (s *BatchMeterUsageInput) SetUsageRecords(v []*UsageRecord) *BatchMeterUsageInput

SetUsageRecords sets the UsageRecords field's value.

func (BatchMeterUsageInput) String added in v1.5.7

func (s BatchMeterUsageInput) String() string

String returns the string representation

func (*BatchMeterUsageInput) Validate added in v1.5.7

func (s *BatchMeterUsageInput) Validate() error

Validate inspects the fields of the type to determine if they are valid.

type BatchMeterUsageOutput added in v1.5.7

type BatchMeterUsageOutput struct {

	// Contains all UsageRecords processed by BatchMeterUsage. These records were
	// either honored by AWS Marketplace Metering Service or were invalid.
	Results []*UsageRecordResult `type:"list"`

	// Contains all UsageRecords that were not processed by BatchMeterUsage. This
	// is a list of UsageRecords. You can retry the failed request by making another
	// BatchMeterUsage call with this list as input in the BatchMeterUsageRequest.
	UnprocessedRecords []*UsageRecord `type:"list"`
	// contains filtered or unexported fields
}

Contains the UsageRecords processed by BatchMeterUsage and any records that have failed due to transient error.

func (BatchMeterUsageOutput) GoString added in v1.5.7

func (s BatchMeterUsageOutput) GoString() string

GoString returns the string representation

func (*BatchMeterUsageOutput) SetResults added in v1.5.7

SetResults sets the Results field's value.

func (*BatchMeterUsageOutput) SetUnprocessedRecords added in v1.5.7

func (s *BatchMeterUsageOutput) SetUnprocessedRecords(v []*UsageRecord) *BatchMeterUsageOutput

SetUnprocessedRecords sets the UnprocessedRecords field's value.

func (BatchMeterUsageOutput) String added in v1.5.7

func (s BatchMeterUsageOutput) String() string

String returns the string representation

type MarketplaceMetering

type MarketplaceMetering struct {
	*client.Client
}

This reference provides descriptions of the low-level AWS Marketplace Metering Service API.

AWS Marketplace sellers can use this API to submit usage data for custom usage dimensions.

Submitting Metering Records

  • MeterUsage- Submits the metering record for a Marketplace product. MeterUsage is called from an EC2 instance.

  • BatchMeterUsage- Submits the metering record for a set of customers. BatchMeterUsage is called from a software-as-a-service (SaaS) application.

Accepting New Customers

  • ResolveCustomer- Called by a SaaS application during the registration process. When a buyer visits your website during the registration process, the buyer submits a Registration Token through the browser. The Registration Token is resolved through this API to obtain a CustomerIdentifier and Product Code.

The service client's operations are safe to be used concurrently. It is not safe to mutate any of the client's properties though.

func New

New creates a new instance of the MarketplaceMetering client with a session. If additional configuration is needed for the client instance use the optional aws.Config parameter to add your extra config.

Example:

// Create a MarketplaceMetering client from just a session.
svc := marketplacemetering.New(mySession)

// Create a MarketplaceMetering client with additional configuration
svc := marketplacemetering.New(mySession, aws.NewConfig().WithRegion("us-west-2"))

func (*MarketplaceMetering) BatchMeterUsage added in v1.5.7

BatchMeterUsage API operation for AWSMarketplace Metering.

BatchMeterUsage is called from a SaaS application listed on the AWS Marketplace to post metering records for a set of customers.

For identical requests, the API is idempotent; requests can be retried with the same records or a subset of the input records.

Every request to BatchMeterUsage is for one product. If you need to meter usage for multiple products, you must make multiple calls to BatchMeterUsage.

BatchMeterUsage can process up to 25 UsageRecords at a time.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for AWSMarketplace Metering's API operation BatchMeterUsage for usage and error information.

Returned Error Codes:

  • InternalServiceErrorException An internal error has occurred. Retry your request. If the problem persists, post a message with details on the AWS forums.

  • InvalidProductCodeException The product code passed does not match the product code used for publishing the product.

  • InvalidUsageDimensionException The usage dimension does not match one of the UsageDimensions associated with products.

  • InvalidCustomerIdentifierException You have metered usage for a CustomerIdentifier that does not exist.

  • TimestampOutOfBoundsException The timestamp value passed in the meterUsage() is out of allowed range.

  • ThrottlingException The calls to the MeterUsage API are throttled.

Example
package main

import (
	"fmt"
	"time"

	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/aws/session"
	"github.com/aws/aws-sdk-go/service/marketplacemetering"
)

func main() {
	sess, err := session.NewSession()
	if err != nil {
		fmt.Println("failed to create session,", err)
		return
	}

	svc := marketplacemetering.New(sess)

	params := &marketplacemetering.BatchMeterUsageInput{
		ProductCode: aws.String("ProductCode"), // Required
		UsageRecords: []*marketplacemetering.UsageRecord{ // Required
			{ // Required
				CustomerIdentifier: aws.String("CustomerIdentifier"), // Required
				Dimension:          aws.String("UsageDimension"),     // Required
				Quantity:           aws.Int64(1),                     // Required
				Timestamp:          aws.Time(time.Now()),             // Required
			},
			// More values...
		},
	}
	resp, err := svc.BatchMeterUsage(params)

	if err != nil {
		// Print the error, cast err to awserr.Error to get the Code and
		// Message from an error.
		fmt.Println(err.Error())
		return
	}

	// Pretty-print the response data.
	fmt.Println(resp)
}
Output:

func (*MarketplaceMetering) BatchMeterUsageRequest added in v1.5.7

func (c *MarketplaceMetering) BatchMeterUsageRequest(input *BatchMeterUsageInput) (req *request.Request, output *BatchMeterUsageOutput)

BatchMeterUsageRequest generates a "aws/request.Request" representing the client's request for the BatchMeterUsage operation. The "output" return value can be used to capture response data after the request's "Send" method is called.

See BatchMeterUsage for usage and error information.

Creating a request object using this method should be used when you want to inject custom logic into the request's lifecycle using a custom handler, or if you want to access properties on the request object before or after sending the request. If you just want the service response, call the BatchMeterUsage method directly instead.

Note: You must call the "Send" method on the returned request object in order to execute the request.

// Example sending a request using the BatchMeterUsageRequest method.
req, resp := client.BatchMeterUsageRequest(params)

err := req.Send()
if err == nil { // resp is now filled
    fmt.Println(resp)
}

func (*MarketplaceMetering) MeterUsage

func (c *MarketplaceMetering) MeterUsage(input *MeterUsageInput) (*MeterUsageOutput, error)

MeterUsage API operation for AWSMarketplace Metering.

API to emit metering records. For identical requests, the API is idempotent. It simply returns the metering record ID.

MeterUsage is authenticated on the buyer's AWS account, generally when running from an EC2 instance on the AWS Marketplace.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for AWSMarketplace Metering's API operation MeterUsage for usage and error information.

Returned Error Codes:

  • InternalServiceErrorException An internal error has occurred. Retry your request. If the problem persists, post a message with details on the AWS forums.

  • InvalidProductCodeException The product code passed does not match the product code used for publishing the product.

  • InvalidUsageDimensionException The usage dimension does not match one of the UsageDimensions associated with products.

  • InvalidEndpointRegionException The endpoint being called is in a region different from your EC2 instance. The region of the Metering service endpoint and the region of the EC2 instance must match.

  • TimestampOutOfBoundsException The timestamp value passed in the meterUsage() is out of allowed range.

  • DuplicateRequestException A metering record has already been emitted by the same EC2 instance for the given {usageDimension, timestamp} with a different usageQuantity.

  • ThrottlingException The calls to the MeterUsage API are throttled.

Example
package main

import (
	"fmt"
	"time"

	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/aws/session"
	"github.com/aws/aws-sdk-go/service/marketplacemetering"
)

func main() {
	sess, err := session.NewSession()
	if err != nil {
		fmt.Println("failed to create session,", err)
		return
	}

	svc := marketplacemetering.New(sess)

	params := &marketplacemetering.MeterUsageInput{
		DryRun:         aws.Bool(true),               // Required
		ProductCode:    aws.String("ProductCode"),    // Required
		Timestamp:      aws.Time(time.Now()),         // Required
		UsageDimension: aws.String("UsageDimension"), // Required
		UsageQuantity:  aws.Int64(1),                 // Required
	}
	resp, err := svc.MeterUsage(params)

	if err != nil {
		// Print the error, cast err to awserr.Error to get the Code and
		// Message from an error.
		fmt.Println(err.Error())
		return
	}

	// Pretty-print the response data.
	fmt.Println(resp)
}
Output:

func (*MarketplaceMetering) MeterUsageRequest

func (c *MarketplaceMetering) MeterUsageRequest(input *MeterUsageInput) (req *request.Request, output *MeterUsageOutput)

MeterUsageRequest generates a "aws/request.Request" representing the client's request for the MeterUsage operation. The "output" return value can be used to capture response data after the request's "Send" method is called.

See MeterUsage for usage and error information.

Creating a request object using this method should be used when you want to inject custom logic into the request's lifecycle using a custom handler, or if you want to access properties on the request object before or after sending the request. If you just want the service response, call the MeterUsage method directly instead.

Note: You must call the "Send" method on the returned request object in order to execute the request.

// Example sending a request using the MeterUsageRequest method.
req, resp := client.MeterUsageRequest(params)

err := req.Send()
if err == nil { // resp is now filled
    fmt.Println(resp)
}

func (*MarketplaceMetering) ResolveCustomer added in v1.5.7

* ExpiredTokenException The submitted registration token has expired. This can happen if the buyer's browser takes too long to redirect to your page, the buyer has resubmitted the registration token, or your application has held on to the registration token for too long. Your SaaS registration website should redeem this token as soon as it is submitted by the buyer's browser.

* ThrottlingException The calls to the MeterUsage API are throttled.

* InternalServiceErrorException An internal error has occurred. Retry your request. If the problem persists, post a message with details on the AWS forums.

Example
package main

import (
	"fmt"

	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/aws/session"
	"github.com/aws/aws-sdk-go/service/marketplacemetering"
)

func main() {
	sess, err := session.NewSession()
	if err != nil {
		fmt.Println("failed to create session,", err)
		return
	}

	svc := marketplacemetering.New(sess)

	params := &marketplacemetering.ResolveCustomerInput{
		RegistrationToken: aws.String("NonEmptyString"), // Required
	}
	resp, err := svc.ResolveCustomer(params)

	if err != nil {
		// Print the error, cast err to awserr.Error to get the Code and
		// Message from an error.
		fmt.Println(err.Error())
		return
	}

	// Pretty-print the response data.
	fmt.Println(resp)
}
Output:

func (*MarketplaceMetering) ResolveCustomerRequest added in v1.5.7

func (c *MarketplaceMetering) ResolveCustomerRequest(input *ResolveCustomerInput) (req *request.Request, output *ResolveCustomerOutput)

ResolveCustomerRequest generates a "aws/request.Request" representing the client's request for the ResolveCustomer operation. The "output" return value can be used to capture response data after the request's "Send" method is called.

See ResolveCustomer for usage and error information.

Creating a request object using this method should be used when you want to inject custom logic into the request's lifecycle using a custom handler, or if you want to access properties on the request object before or after sending the request. If you just want the service response, call the ResolveCustomer method directly instead.

Note: You must call the "Send" method on the returned request object in order to execute the request.

// Example sending a request using the ResolveCustomerRequest method.
req, resp := client.ResolveCustomerRequest(params)

err := req.Send()
if err == nil { // resp is now filled
    fmt.Println(resp)
}

type MeterUsageInput

type MeterUsageInput struct {

	// Checks whether you have the permissions required for the action, but does
	// not make the request. If you have the permissions, the request returns DryRunOperation;
	// otherwise, it returns UnauthorizedException.
	//
	// DryRun is a required field
	DryRun *bool `type:"boolean" required:"true"`

	// Product code is used to uniquely identify a product in AWS Marketplace. The
	// product code should be the same as the one used during the publishing of
	// a new product.
	//
	// ProductCode is a required field
	ProductCode *string `min:"1" type:"string" required:"true"`

	// Timestamp of the hour, recorded in UTC. The seconds and milliseconds portions
	// of the timestamp will be ignored.
	//
	// Timestamp is a required field
	Timestamp *time.Time `type:"timestamp" timestampFormat:"unix" required:"true"`

	// It will be one of the fcp dimension name provided during the publishing of
	// the product.
	//
	// UsageDimension is a required field
	UsageDimension *string `min:"1" type:"string" required:"true"`

	// Consumption value for the hour.
	//
	// UsageQuantity is a required field
	UsageQuantity *int64 `type:"integer" required:"true"`
	// contains filtered or unexported fields
}

func (MeterUsageInput) GoString

func (s MeterUsageInput) GoString() string

GoString returns the string representation

func (*MeterUsageInput) SetDryRun added in v1.5.0

func (s *MeterUsageInput) SetDryRun(v bool) *MeterUsageInput

SetDryRun sets the DryRun field's value.

func (*MeterUsageInput) SetProductCode added in v1.5.0

func (s *MeterUsageInput) SetProductCode(v string) *MeterUsageInput

SetProductCode sets the ProductCode field's value.

func (*MeterUsageInput) SetTimestamp added in v1.5.0

func (s *MeterUsageInput) SetTimestamp(v time.Time) *MeterUsageInput

SetTimestamp sets the Timestamp field's value.

func (*MeterUsageInput) SetUsageDimension added in v1.5.0

func (s *MeterUsageInput) SetUsageDimension(v string) *MeterUsageInput

SetUsageDimension sets the UsageDimension field's value.

func (*MeterUsageInput) SetUsageQuantity added in v1.5.0

func (s *MeterUsageInput) SetUsageQuantity(v int64) *MeterUsageInput

SetUsageQuantity sets the UsageQuantity field's value.

func (MeterUsageInput) String

func (s MeterUsageInput) String() string

String returns the string representation

func (*MeterUsageInput) Validate added in v1.1.21

func (s *MeterUsageInput) Validate() error

Validate inspects the fields of the type to determine if they are valid.

type MeterUsageOutput

type MeterUsageOutput struct {
	MeteringRecordId *string `type:"string"`
	// contains filtered or unexported fields
}

func (MeterUsageOutput) GoString

func (s MeterUsageOutput) GoString() string

GoString returns the string representation

func (*MeterUsageOutput) SetMeteringRecordId added in v1.5.0

func (s *MeterUsageOutput) SetMeteringRecordId(v string) *MeterUsageOutput

SetMeteringRecordId sets the MeteringRecordId field's value.

func (MeterUsageOutput) String

func (s MeterUsageOutput) String() string

String returns the string representation

type ResolveCustomerInput added in v1.5.7

type ResolveCustomerInput struct {

	// When a buyer visits your website during the registration process, the buyer
	// submits a registration token through the browser. The registration token
	// is resolved to obtain a CustomerIdentifier and product code.
	//
	// RegistrationToken is a required field
	RegistrationToken *string `type:"string" required:"true"`
	// contains filtered or unexported fields
}

Contains input to the ResolveCustomer operation.

func (ResolveCustomerInput) GoString added in v1.5.7

func (s ResolveCustomerInput) GoString() string

GoString returns the string representation

func (*ResolveCustomerInput) SetRegistrationToken added in v1.5.7

func (s *ResolveCustomerInput) SetRegistrationToken(v string) *ResolveCustomerInput

SetRegistrationToken sets the RegistrationToken field's value.

func (ResolveCustomerInput) String added in v1.5.7

func (s ResolveCustomerInput) String() string

String returns the string representation

func (*ResolveCustomerInput) Validate added in v1.5.7

func (s *ResolveCustomerInput) Validate() error

Validate inspects the fields of the type to determine if they are valid.

type ResolveCustomerOutput added in v1.5.7

type ResolveCustomerOutput struct {

	// The CustomerIdentifier is used to identify an individual customer in your
	// application. Calls to BatchMeterUsage require CustomerIdentifiers for each
	// UsageRecord.
	CustomerIdentifier *string `min:"1" type:"string"`

	// The product code is returned to confirm that the buyer is registering for
	// your product. Subsequent BatchMeterUsage calls should be made using this
	// product code.
	ProductCode *string `min:"1" type:"string"`
	// contains filtered or unexported fields
}

The result of the ResolveCustomer operation. Contains the CustomerIdentifier and product code.

func (ResolveCustomerOutput) GoString added in v1.5.7

func (s ResolveCustomerOutput) GoString() string

GoString returns the string representation

func (*ResolveCustomerOutput) SetCustomerIdentifier added in v1.5.7

func (s *ResolveCustomerOutput) SetCustomerIdentifier(v string) *ResolveCustomerOutput

SetCustomerIdentifier sets the CustomerIdentifier field's value.

func (*ResolveCustomerOutput) SetProductCode added in v1.5.7

func (s *ResolveCustomerOutput) SetProductCode(v string) *ResolveCustomerOutput

SetProductCode sets the ProductCode field's value.

func (ResolveCustomerOutput) String added in v1.5.7

func (s ResolveCustomerOutput) String() string

String returns the string representation

type UsageRecord added in v1.5.7

type UsageRecord struct {

	// The CustomerIdentifier is obtained through the ResolveCustomer operation
	// and represents an individual buyer in your application.
	//
	// CustomerIdentifier is a required field
	CustomerIdentifier *string `min:"1" type:"string" required:"true"`

	// During the process of registering a product on AWS Marketplace, up to eight
	// dimensions are specified. These represent different units of value in your
	// application.
	//
	// Dimension is a required field
	Dimension *string `min:"1" type:"string" required:"true"`

	// The quantity of usage consumed by the customer for the given dimension and
	// time.
	//
	// Quantity is a required field
	Quantity *int64 `type:"integer" required:"true"`

	// Timestamp of the hour, recorded in UTC. The seconds and milliseconds portions
	// of the timestamp will be ignored.
	//
	// Your application can meter usage for up to one hour in the past.
	//
	// Timestamp is a required field
	Timestamp *time.Time `type:"timestamp" timestampFormat:"unix" required:"true"`
	// contains filtered or unexported fields
}

A UsageRecord indicates a quantity of usage for a given product, customer, dimension and time.

Multiple requests with the same UsageRecords as input will be deduplicated to prevent double charges.

func (UsageRecord) GoString added in v1.5.7

func (s UsageRecord) GoString() string

GoString returns the string representation

func (*UsageRecord) SetCustomerIdentifier added in v1.5.7

func (s *UsageRecord) SetCustomerIdentifier(v string) *UsageRecord

SetCustomerIdentifier sets the CustomerIdentifier field's value.

func (*UsageRecord) SetDimension added in v1.5.7

func (s *UsageRecord) SetDimension(v string) *UsageRecord

SetDimension sets the Dimension field's value.

func (*UsageRecord) SetQuantity added in v1.5.7

func (s *UsageRecord) SetQuantity(v int64) *UsageRecord

SetQuantity sets the Quantity field's value.

func (*UsageRecord) SetTimestamp added in v1.5.7

func (s *UsageRecord) SetTimestamp(v time.Time) *UsageRecord

SetTimestamp sets the Timestamp field's value.

func (UsageRecord) String added in v1.5.7

func (s UsageRecord) String() string

String returns the string representation

func (*UsageRecord) Validate added in v1.5.7

func (s *UsageRecord) Validate() error

Validate inspects the fields of the type to determine if they are valid.

type UsageRecordResult added in v1.5.7

type UsageRecordResult struct {

	// The MeteringRecordId is a unique identifier for this metering event.
	MeteringRecordId *string `type:"string"`

	// The UsageRecordResult Status indicates the status of an individual UsageRecord
	// processed by BatchMeterUsage.
	//
	//    * Success- The UsageRecord was accepted and honored by BatchMeterUsage.
	//
	//    * CustomerNotSubscribed- The CustomerIdentifier specified is not subscribed
	//    to your product. The UsageRecord was not honored. Future UsageRecords
	//    for this customer will fail until the customer subscribes to your product.
	//
	//    * DuplicateRecord- Indicates that the UsageRecord was invalid and not
	//    honored. A previously metered UsageRecord had the same customer, dimension,
	//    and time, but a different quantity.
	Status *string `type:"string" enum:"UsageRecordResultStatus"`

	// The UsageRecord that was part of the BatchMeterUsage request.
	UsageRecord *UsageRecord `type:"structure"`
	// contains filtered or unexported fields
}

A UsageRecordResult indicates the status of a given UsageRecord processed by BatchMeterUsage.

func (UsageRecordResult) GoString added in v1.5.7

func (s UsageRecordResult) GoString() string

GoString returns the string representation

func (*UsageRecordResult) SetMeteringRecordId added in v1.5.7

func (s *UsageRecordResult) SetMeteringRecordId(v string) *UsageRecordResult

SetMeteringRecordId sets the MeteringRecordId field's value.

func (*UsageRecordResult) SetStatus added in v1.5.7

func (s *UsageRecordResult) SetStatus(v string) *UsageRecordResult

SetStatus sets the Status field's value.

func (*UsageRecordResult) SetUsageRecord added in v1.5.7

func (s *UsageRecordResult) SetUsageRecord(v *UsageRecord) *UsageRecordResult

SetUsageRecord sets the UsageRecord field's value.

func (UsageRecordResult) String added in v1.5.7

func (s UsageRecordResult) String() string

String returns the string representation

Directories

Path Synopsis
Package marketplacemeteringiface provides an interface to enable mocking the AWSMarketplace Metering service client for testing your code.
Package marketplacemeteringiface provides an interface to enable mocking the AWSMarketplace Metering service client for testing your code.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL