mobileanalytics

package
v1.8.22-0...-952498f Latest Latest
Warning

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

Go to latest
Published: May 10, 2017 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package mobileanalytics provides the client and types for making API requests to Amazon Mobile Analytics.

Amazon Mobile Analytics is a service for collecting, visualizing, and understanding app usage data at scale.

See mobileanalytics package documentation for more information. https://docs.aws.amazon.com/sdk-for-go/api/service/mobileanalytics/

Using the Client

To use the client for Amazon Mobile Analytics you will first need to create a new instance of it.

When creating a client for an AWS service you'll first need to have a Session already created. The Session provides configuration that can be shared between multiple service clients. Additional configuration can be applied to the Session and service's client when they are constructed. The aws package's Config type contains several fields such as Region for the AWS Region the client should make API requests too. The optional Config value can be provided as the variadic argument for Sessions and client creation.

Once the service's client is created you can use it to make API requests the AWS service. These clients are safe to use concurrently.

// Create a session to share configuration, and load external configuration.
sess := session.Must(session.NewSession())

// Create the service's client with the session.
svc := mobileanalytics.New(sess)

See the SDK's documentation for more information on how to use service clients. https://docs.aws.amazon.com/sdk-for-go/api/

See aws package's Config type for more information on configuration options. https://docs.aws.amazon.com/sdk-for-go/api/aws/#Config

See the Amazon Mobile Analytics client MobileAnalytics for more information on creating the service's client. https://docs.aws.amazon.com/sdk-for-go/api/service/mobileanalytics/#New

Once the client is created you can make an API request to the service. Each API method takes a input parameter, and returns the service response and an error.

The API method will document which error codes the service can be returned by the operation if the service models the API operation's errors. These errors will also be available as const strings prefixed with "ErrCode".

result, err := svc.PutEvents(params)
if err != nil {
    // Cast err to awserr.Error to handle specific error codes.
    aerr, ok := err.(awserr.Error)
    if ok && aerr.Code() == <error code to check for> {
        // Specific error code handling
    }
    return err
}

fmt.Println("PutEvents result:")
fmt.Println(result)

Using the Client with Context

The service's client also provides methods to make API requests with a Context value. This allows you to control the timeout, and cancellation of pending requests. These methods also take request Option as variadic parameter to apply additional configuration to the API request.

ctx := context.Background()

result, err := svc.PutEventsWithContext(ctx, params)

See the request package documentation for more information on using Context pattern with the SDK. https://docs.aws.amazon.com/sdk-for-go/api/aws/request/

Index

Examples

Constants

View Source
const (
	ServiceName = "mobileanalytics" // Service endpoint prefix API calls made to.
	EndpointsID = ServiceName       // Service ID for Regions and Endpoints metadata.
)

Service information constants

View Source
const (

	// ErrCodeBadRequestException for service response error code
	// "BadRequestException".
	//
	// An exception object returned when a request fails.
	ErrCodeBadRequestException = "BadRequestException"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {

	// A collection of key-value pairs that give additional context to the event.
	// The key-value pairs are specified by the developer.
	//
	// This collection can be empty or the attribute object can be omitted.
	Attributes map[string]*string `locationName:"attributes" type:"map"`

	// A name signifying an event that occurred in your app. This is used for grouping
	// and aggregating like events together for reporting purposes.
	//
	// EventType is a required field
	EventType *string `locationName:"eventType" min:"1" type:"string" required:"true"`

	// A collection of key-value pairs that gives additional, measurable context
	// to the event. The key-value pairs are specified by the developer.
	//
	// This collection can be empty or the attribute object can be omitted.
	Metrics map[string]*float64 `locationName:"metrics" type:"map"`

	// The session the event occured within.
	Session *Session `locationName:"session" type:"structure"`

	// The time the event occurred in ISO 8601 standard date time format. For example,
	// 2014-06-30T19:07:47.885Z
	//
	// Timestamp is a required field
	Timestamp *string `locationName:"timestamp" type:"string" required:"true"`

	// The version of the event.
	Version *string `locationName:"version" min:"1" type:"string"`
	// contains filtered or unexported fields
}

A JSON object representing a batch of unique event occurrences in your app.

func (Event) GoString

func (s Event) GoString() string

GoString returns the string representation

func (*Event) SetAttributes

func (s *Event) SetAttributes(v map[string]*string) *Event

SetAttributes sets the Attributes field's value.

func (*Event) SetEventType

func (s *Event) SetEventType(v string) *Event

SetEventType sets the EventType field's value.

func (*Event) SetMetrics

func (s *Event) SetMetrics(v map[string]*float64) *Event

SetMetrics sets the Metrics field's value.

func (*Event) SetSession

func (s *Event) SetSession(v *Session) *Event

SetSession sets the Session field's value.

func (*Event) SetTimestamp

func (s *Event) SetTimestamp(v string) *Event

SetTimestamp sets the Timestamp field's value.

func (*Event) SetVersion

func (s *Event) SetVersion(v string) *Event

SetVersion sets the Version field's value.

func (Event) String

func (s Event) String() string

String returns the string representation

func (*Event) Validate

func (s *Event) Validate() error

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

type MobileAnalytics

type MobileAnalytics struct {
	*client.Client
}

MobileAnalytics provides the API operation methods for making requests to Amazon Mobile Analytics. See this package's package overview docs for details on the service.

MobileAnalytics methods are safe to use concurrently. It is not safe to modify mutate any of the struct's properties though.

func New

New creates a new instance of the MobileAnalytics 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 MobileAnalytics client from just a session.
svc := mobileanalytics.New(mySession)

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

func (*MobileAnalytics) PutEvents

func (c *MobileAnalytics) PutEvents(input *PutEventsInput) (*PutEventsOutput, error)

PutEvents API operation for Amazon Mobile Analytics.

The PutEvents operation records one or more events. You can have up to 1,500 unique custom events per app, any combination of up to 40 attributes and metrics per custom event, and any number of attribute or metric values.

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 Amazon Mobile Analytics's API operation PutEvents for usage and error information.

Returned Error Codes:

  • ErrCodeBadRequestException "BadRequestException" An exception object returned when a request fails.
Example
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.

package main

import (
	"bytes"
	"fmt"
	"time"

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

var _ time.Duration
var _ bytes.Buffer

func main() {
	sess := session.Must(session.NewSession())

	svc := mobileanalytics.New(sess)

	params := &mobileanalytics.PutEventsInput{
		ClientContext: aws.String("String"), // Required
		Events: []*mobileanalytics.Event{ // Required
			{ // Required
				EventType: aws.String("String50Chars"),    // Required
				Timestamp: aws.String("ISO8601Timestamp"), // Required
				Attributes: map[string]*string{
					"Key": aws.String("String0to1000Chars"), // Required
					// More values...
				},
				Metrics: map[string]*float64{
					"Key": aws.Float64(1.0), // Required
					// More values...
				},
				Session: &mobileanalytics.Session{
					Duration:       aws.Int64(1),
					Id:             aws.String("String50Chars"),
					StartTimestamp: aws.String("ISO8601Timestamp"),
					StopTimestamp:  aws.String("ISO8601Timestamp"),
				},
				Version: aws.String("String10Chars"),
			},
			// More values...
		},
		ClientContextEncoding: aws.String("String"),
	}
	resp, err := svc.PutEvents(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 (*MobileAnalytics) PutEventsRequest

func (c *MobileAnalytics) PutEventsRequest(input *PutEventsInput) (req *request.Request, output *PutEventsOutput)

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

See PutEvents 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 PutEvents 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 PutEventsRequest method.
req, resp := client.PutEventsRequest(params)

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

func (*MobileAnalytics) PutEventsWithContext

func (c *MobileAnalytics) PutEventsWithContext(ctx aws.Context, input *PutEventsInput, opts ...request.Option) (*PutEventsOutput, error)

PutEventsWithContext is the same as PutEvents with the addition of the ability to pass a context and additional request options.

See PutEvents for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

type PutEventsInput

type PutEventsInput struct {

	// The client context including the client ID, app title, app version and package
	// name.
	//
	// ClientContext is a required field
	ClientContext *string `location:"header" locationName:"x-amz-Client-Context" type:"string" required:"true"`

	// The encoding used for the client context.
	ClientContextEncoding *string `location:"header" locationName:"x-amz-Client-Context-Encoding" type:"string"`

	// An array of Event JSON objects
	//
	// Events is a required field
	Events []*Event `locationName:"events" type:"list" required:"true"`
	// contains filtered or unexported fields
}

A container for the data needed for a PutEvent operation

func (PutEventsInput) GoString

func (s PutEventsInput) GoString() string

GoString returns the string representation

func (*PutEventsInput) SetClientContext

func (s *PutEventsInput) SetClientContext(v string) *PutEventsInput

SetClientContext sets the ClientContext field's value.

func (*PutEventsInput) SetClientContextEncoding

func (s *PutEventsInput) SetClientContextEncoding(v string) *PutEventsInput

SetClientContextEncoding sets the ClientContextEncoding field's value.

func (*PutEventsInput) SetEvents

func (s *PutEventsInput) SetEvents(v []*Event) *PutEventsInput

SetEvents sets the Events field's value.

func (PutEventsInput) String

func (s PutEventsInput) String() string

String returns the string representation

func (*PutEventsInput) Validate

func (s *PutEventsInput) Validate() error

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

type PutEventsOutput

type PutEventsOutput struct {
	// contains filtered or unexported fields
}

func (PutEventsOutput) GoString

func (s PutEventsOutput) GoString() string

GoString returns the string representation

func (PutEventsOutput) String

func (s PutEventsOutput) String() string

String returns the string representation

type Session

type Session struct {

	// The duration of the session.
	Duration *int64 `locationName:"duration" type:"long"`

	// A unique identifier for the session
	Id *string `locationName:"id" min:"1" type:"string"`

	// The time the event started in ISO 8601 standard date time format. For example,
	// 2014-06-30T19:07:47.885Z
	StartTimestamp *string `locationName:"startTimestamp" type:"string"`

	// The time the event terminated in ISO 8601 standard date time format. For
	// example, 2014-06-30T19:07:47.885Z
	StopTimestamp *string `locationName:"stopTimestamp" type:"string"`
	// contains filtered or unexported fields
}

Describes the session. Session information is required on ALL events.

func (Session) GoString

func (s Session) GoString() string

GoString returns the string representation

func (*Session) SetDuration

func (s *Session) SetDuration(v int64) *Session

SetDuration sets the Duration field's value.

func (*Session) SetId

func (s *Session) SetId(v string) *Session

SetId sets the Id field's value.

func (*Session) SetStartTimestamp

func (s *Session) SetStartTimestamp(v string) *Session

SetStartTimestamp sets the StartTimestamp field's value.

func (*Session) SetStopTimestamp

func (s *Session) SetStopTimestamp(v string) *Session

SetStopTimestamp sets the StopTimestamp field's value.

func (Session) String

func (s Session) String() string

String returns the string representation

func (*Session) Validate

func (s *Session) Validate() error

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

Directories

Path Synopsis
Package mobileanalyticsiface provides an interface to enable mocking the Amazon Mobile Analytics service client for testing your code.
Package mobileanalyticsiface provides an interface to enable mocking the Amazon Mobile Analytics service client for testing your code.

Jump to

Keyboard shortcuts

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