github.com/aavshr/aws-sdk-go@v1.41.3/service/mobileanalytics/api.go (about)

     1  // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
     2  
     3  package mobileanalytics
     4  
     5  import (
     6  	"fmt"
     7  
     8  	"github.com/aavshr/aws-sdk-go/aws"
     9  	"github.com/aavshr/aws-sdk-go/aws/awsutil"
    10  	"github.com/aavshr/aws-sdk-go/aws/request"
    11  	"github.com/aavshr/aws-sdk-go/private/protocol"
    12  	"github.com/aavshr/aws-sdk-go/private/protocol/restjson"
    13  )
    14  
    15  const opPutEvents = "PutEvents"
    16  
    17  // PutEventsRequest generates a "aws/request.Request" representing the
    18  // client's request for the PutEvents operation. The "output" return
    19  // value will be populated with the request's response once the request completes
    20  // successfully.
    21  //
    22  // Use "Send" method on the returned Request to send the API call to the service.
    23  // the "output" return value is not valid until after Send returns without error.
    24  //
    25  // See PutEvents for more information on using the PutEvents
    26  // API call, and error handling.
    27  //
    28  // This method is useful when you want to inject custom logic or configuration
    29  // into the SDK's request lifecycle. Such as custom headers, or retry logic.
    30  //
    31  //
    32  //    // Example sending a request using the PutEventsRequest method.
    33  //    req, resp := client.PutEventsRequest(params)
    34  //
    35  //    err := req.Send()
    36  //    if err == nil { // resp is now filled
    37  //        fmt.Println(resp)
    38  //    }
    39  func (c *MobileAnalytics) PutEventsRequest(input *PutEventsInput) (req *request.Request, output *PutEventsOutput) {
    40  	op := &request.Operation{
    41  		Name:       opPutEvents,
    42  		HTTPMethod: "POST",
    43  		HTTPPath:   "/2014-06-05/events",
    44  	}
    45  
    46  	if input == nil {
    47  		input = &PutEventsInput{}
    48  	}
    49  
    50  	output = &PutEventsOutput{}
    51  	req = c.newRequest(op, input, output)
    52  	req.Handlers.Unmarshal.Swap(restjson.UnmarshalHandler.Name, protocol.UnmarshalDiscardBodyHandler)
    53  	return
    54  }
    55  
    56  // PutEvents API operation for Amazon Mobile Analytics.
    57  //
    58  // The PutEvents operation records one or more events. You can have up to 1,500
    59  // unique custom events per app, any combination of up to 40 attributes and
    60  // metrics per custom event, and any number of attribute or metric values.
    61  //
    62  // Returns awserr.Error for service API and SDK errors. Use runtime type assertions
    63  // with awserr.Error's Code and Message methods to get detailed information about
    64  // the error.
    65  //
    66  // See the AWS API reference guide for Amazon Mobile Analytics's
    67  // API operation PutEvents for usage and error information.
    68  //
    69  // Returned Error Types:
    70  //   * BadRequestException
    71  //   An exception object returned when a request fails.
    72  //
    73  func (c *MobileAnalytics) PutEvents(input *PutEventsInput) (*PutEventsOutput, error) {
    74  	req, out := c.PutEventsRequest(input)
    75  	return out, req.Send()
    76  }
    77  
    78  // PutEventsWithContext is the same as PutEvents with the addition of
    79  // the ability to pass a context and additional request options.
    80  //
    81  // See PutEvents for details on how to use this API operation.
    82  //
    83  // The context must be non-nil and will be used for request cancellation. If
    84  // the context is nil a panic will occur. In the future the SDK may create
    85  // sub-contexts for http.Requests. See https://golang.org/pkg/context/
    86  // for more information on using Contexts.
    87  func (c *MobileAnalytics) PutEventsWithContext(ctx aws.Context, input *PutEventsInput, opts ...request.Option) (*PutEventsOutput, error) {
    88  	req, out := c.PutEventsRequest(input)
    89  	req.SetContext(ctx)
    90  	req.ApplyOptions(opts...)
    91  	return out, req.Send()
    92  }
    93  
    94  // An exception object returned when a request fails.
    95  type BadRequestException struct {
    96  	_            struct{}                  `type:"structure"`
    97  	RespMetadata protocol.ResponseMetadata `json:"-" xml:"-"`
    98  
    99  	// A text description associated with the BadRequestException object.
   100  	Message_ *string `locationName:"message" type:"string"`
   101  }
   102  
   103  // String returns the string representation.
   104  //
   105  // API parameter values that are decorated as "sensitive" in the API will not
   106  // be included in the string output. The member name will be present, but the
   107  // value will be replaced with "sensitive".
   108  func (s BadRequestException) String() string {
   109  	return awsutil.Prettify(s)
   110  }
   111  
   112  // GoString returns the string representation.
   113  //
   114  // API parameter values that are decorated as "sensitive" in the API will not
   115  // be included in the string output. The member name will be present, but the
   116  // value will be replaced with "sensitive".
   117  func (s BadRequestException) GoString() string {
   118  	return s.String()
   119  }
   120  
   121  func newErrorBadRequestException(v protocol.ResponseMetadata) error {
   122  	return &BadRequestException{
   123  		RespMetadata: v,
   124  	}
   125  }
   126  
   127  // Code returns the exception type name.
   128  func (s *BadRequestException) Code() string {
   129  	return "BadRequestException"
   130  }
   131  
   132  // Message returns the exception's message.
   133  func (s *BadRequestException) Message() string {
   134  	if s.Message_ != nil {
   135  		return *s.Message_
   136  	}
   137  	return ""
   138  }
   139  
   140  // OrigErr always returns nil, satisfies awserr.Error interface.
   141  func (s *BadRequestException) OrigErr() error {
   142  	return nil
   143  }
   144  
   145  func (s *BadRequestException) Error() string {
   146  	return fmt.Sprintf("%s: %s", s.Code(), s.Message())
   147  }
   148  
   149  // Status code returns the HTTP status code for the request's response error.
   150  func (s *BadRequestException) StatusCode() int {
   151  	return s.RespMetadata.StatusCode
   152  }
   153  
   154  // RequestID returns the service's response RequestID for request.
   155  func (s *BadRequestException) RequestID() string {
   156  	return s.RespMetadata.RequestID
   157  }
   158  
   159  // A JSON object representing a batch of unique event occurrences in your app.
   160  type Event struct {
   161  	_ struct{} `type:"structure"`
   162  
   163  	// A collection of key-value pairs that give additional context to the event.
   164  	// The key-value pairs are specified by the developer.
   165  	//
   166  	// This collection can be empty or the attribute object can be omitted.
   167  	Attributes map[string]*string `locationName:"attributes" type:"map"`
   168  
   169  	// A name signifying an event that occurred in your app. This is used for grouping
   170  	// and aggregating like events together for reporting purposes.
   171  	//
   172  	// EventType is a required field
   173  	EventType *string `locationName:"eventType" min:"1" type:"string" required:"true"`
   174  
   175  	// A collection of key-value pairs that gives additional, measurable context
   176  	// to the event. The key-value pairs are specified by the developer.
   177  	//
   178  	// This collection can be empty or the attribute object can be omitted.
   179  	Metrics map[string]*float64 `locationName:"metrics" type:"map"`
   180  
   181  	// The session the event occured within.
   182  	Session *Session `locationName:"session" type:"structure"`
   183  
   184  	// The time the event occurred in ISO 8601 standard date time format. For example,
   185  	// 2014-06-30T19:07:47.885Z
   186  	//
   187  	// Timestamp is a required field
   188  	Timestamp *string `locationName:"timestamp" type:"string" required:"true"`
   189  
   190  	// The version of the event.
   191  	Version *string `locationName:"version" min:"1" type:"string"`
   192  }
   193  
   194  // String returns the string representation.
   195  //
   196  // API parameter values that are decorated as "sensitive" in the API will not
   197  // be included in the string output. The member name will be present, but the
   198  // value will be replaced with "sensitive".
   199  func (s Event) String() string {
   200  	return awsutil.Prettify(s)
   201  }
   202  
   203  // GoString returns the string representation.
   204  //
   205  // API parameter values that are decorated as "sensitive" in the API will not
   206  // be included in the string output. The member name will be present, but the
   207  // value will be replaced with "sensitive".
   208  func (s Event) GoString() string {
   209  	return s.String()
   210  }
   211  
   212  // Validate inspects the fields of the type to determine if they are valid.
   213  func (s *Event) Validate() error {
   214  	invalidParams := request.ErrInvalidParams{Context: "Event"}
   215  	if s.EventType == nil {
   216  		invalidParams.Add(request.NewErrParamRequired("EventType"))
   217  	}
   218  	if s.EventType != nil && len(*s.EventType) < 1 {
   219  		invalidParams.Add(request.NewErrParamMinLen("EventType", 1))
   220  	}
   221  	if s.Timestamp == nil {
   222  		invalidParams.Add(request.NewErrParamRequired("Timestamp"))
   223  	}
   224  	if s.Version != nil && len(*s.Version) < 1 {
   225  		invalidParams.Add(request.NewErrParamMinLen("Version", 1))
   226  	}
   227  	if s.Session != nil {
   228  		if err := s.Session.Validate(); err != nil {
   229  			invalidParams.AddNested("Session", err.(request.ErrInvalidParams))
   230  		}
   231  	}
   232  
   233  	if invalidParams.Len() > 0 {
   234  		return invalidParams
   235  	}
   236  	return nil
   237  }
   238  
   239  // SetAttributes sets the Attributes field's value.
   240  func (s *Event) SetAttributes(v map[string]*string) *Event {
   241  	s.Attributes = v
   242  	return s
   243  }
   244  
   245  // SetEventType sets the EventType field's value.
   246  func (s *Event) SetEventType(v string) *Event {
   247  	s.EventType = &v
   248  	return s
   249  }
   250  
   251  // SetMetrics sets the Metrics field's value.
   252  func (s *Event) SetMetrics(v map[string]*float64) *Event {
   253  	s.Metrics = v
   254  	return s
   255  }
   256  
   257  // SetSession sets the Session field's value.
   258  func (s *Event) SetSession(v *Session) *Event {
   259  	s.Session = v
   260  	return s
   261  }
   262  
   263  // SetTimestamp sets the Timestamp field's value.
   264  func (s *Event) SetTimestamp(v string) *Event {
   265  	s.Timestamp = &v
   266  	return s
   267  }
   268  
   269  // SetVersion sets the Version field's value.
   270  func (s *Event) SetVersion(v string) *Event {
   271  	s.Version = &v
   272  	return s
   273  }
   274  
   275  // A container for the data needed for a PutEvent operation
   276  type PutEventsInput struct {
   277  	_ struct{} `type:"structure"`
   278  
   279  	// The client context including the client ID, app title, app version and package
   280  	// name.
   281  	//
   282  	// ClientContext is a required field
   283  	ClientContext *string `location:"header" locationName:"x-amz-Client-Context" type:"string" required:"true"`
   284  
   285  	// The encoding used for the client context.
   286  	ClientContextEncoding *string `location:"header" locationName:"x-amz-Client-Context-Encoding" type:"string"`
   287  
   288  	// An array of Event JSON objects
   289  	//
   290  	// Events is a required field
   291  	Events []*Event `locationName:"events" type:"list" required:"true"`
   292  }
   293  
   294  // String returns the string representation.
   295  //
   296  // API parameter values that are decorated as "sensitive" in the API will not
   297  // be included in the string output. The member name will be present, but the
   298  // value will be replaced with "sensitive".
   299  func (s PutEventsInput) String() string {
   300  	return awsutil.Prettify(s)
   301  }
   302  
   303  // GoString returns the string representation.
   304  //
   305  // API parameter values that are decorated as "sensitive" in the API will not
   306  // be included in the string output. The member name will be present, but the
   307  // value will be replaced with "sensitive".
   308  func (s PutEventsInput) GoString() string {
   309  	return s.String()
   310  }
   311  
   312  // Validate inspects the fields of the type to determine if they are valid.
   313  func (s *PutEventsInput) Validate() error {
   314  	invalidParams := request.ErrInvalidParams{Context: "PutEventsInput"}
   315  	if s.ClientContext == nil {
   316  		invalidParams.Add(request.NewErrParamRequired("ClientContext"))
   317  	}
   318  	if s.Events == nil {
   319  		invalidParams.Add(request.NewErrParamRequired("Events"))
   320  	}
   321  	if s.Events != nil {
   322  		for i, v := range s.Events {
   323  			if v == nil {
   324  				continue
   325  			}
   326  			if err := v.Validate(); err != nil {
   327  				invalidParams.AddNested(fmt.Sprintf("%s[%v]", "Events", i), err.(request.ErrInvalidParams))
   328  			}
   329  		}
   330  	}
   331  
   332  	if invalidParams.Len() > 0 {
   333  		return invalidParams
   334  	}
   335  	return nil
   336  }
   337  
   338  // SetClientContext sets the ClientContext field's value.
   339  func (s *PutEventsInput) SetClientContext(v string) *PutEventsInput {
   340  	s.ClientContext = &v
   341  	return s
   342  }
   343  
   344  // SetClientContextEncoding sets the ClientContextEncoding field's value.
   345  func (s *PutEventsInput) SetClientContextEncoding(v string) *PutEventsInput {
   346  	s.ClientContextEncoding = &v
   347  	return s
   348  }
   349  
   350  // SetEvents sets the Events field's value.
   351  func (s *PutEventsInput) SetEvents(v []*Event) *PutEventsInput {
   352  	s.Events = v
   353  	return s
   354  }
   355  
   356  type PutEventsOutput struct {
   357  	_ struct{} `type:"structure" nopayload:"true"`
   358  }
   359  
   360  // String returns the string representation.
   361  //
   362  // API parameter values that are decorated as "sensitive" in the API will not
   363  // be included in the string output. The member name will be present, but the
   364  // value will be replaced with "sensitive".
   365  func (s PutEventsOutput) String() string {
   366  	return awsutil.Prettify(s)
   367  }
   368  
   369  // GoString returns the string representation.
   370  //
   371  // API parameter values that are decorated as "sensitive" in the API will not
   372  // be included in the string output. The member name will be present, but the
   373  // value will be replaced with "sensitive".
   374  func (s PutEventsOutput) GoString() string {
   375  	return s.String()
   376  }
   377  
   378  // Describes the session. Session information is required on ALL events.
   379  type Session struct {
   380  	_ struct{} `type:"structure"`
   381  
   382  	// The duration of the session.
   383  	Duration *int64 `locationName:"duration" type:"long"`
   384  
   385  	// A unique identifier for the session
   386  	Id *string `locationName:"id" min:"1" type:"string"`
   387  
   388  	// The time the event started in ISO 8601 standard date time format. For example,
   389  	// 2014-06-30T19:07:47.885Z
   390  	StartTimestamp *string `locationName:"startTimestamp" type:"string"`
   391  
   392  	// The time the event terminated in ISO 8601 standard date time format. For
   393  	// example, 2014-06-30T19:07:47.885Z
   394  	StopTimestamp *string `locationName:"stopTimestamp" type:"string"`
   395  }
   396  
   397  // String returns the string representation.
   398  //
   399  // API parameter values that are decorated as "sensitive" in the API will not
   400  // be included in the string output. The member name will be present, but the
   401  // value will be replaced with "sensitive".
   402  func (s Session) String() string {
   403  	return awsutil.Prettify(s)
   404  }
   405  
   406  // GoString returns the string representation.
   407  //
   408  // API parameter values that are decorated as "sensitive" in the API will not
   409  // be included in the string output. The member name will be present, but the
   410  // value will be replaced with "sensitive".
   411  func (s Session) GoString() string {
   412  	return s.String()
   413  }
   414  
   415  // Validate inspects the fields of the type to determine if they are valid.
   416  func (s *Session) Validate() error {
   417  	invalidParams := request.ErrInvalidParams{Context: "Session"}
   418  	if s.Id != nil && len(*s.Id) < 1 {
   419  		invalidParams.Add(request.NewErrParamMinLen("Id", 1))
   420  	}
   421  
   422  	if invalidParams.Len() > 0 {
   423  		return invalidParams
   424  	}
   425  	return nil
   426  }
   427  
   428  // SetDuration sets the Duration field's value.
   429  func (s *Session) SetDuration(v int64) *Session {
   430  	s.Duration = &v
   431  	return s
   432  }
   433  
   434  // SetId sets the Id field's value.
   435  func (s *Session) SetId(v string) *Session {
   436  	s.Id = &v
   437  	return s
   438  }
   439  
   440  // SetStartTimestamp sets the StartTimestamp field's value.
   441  func (s *Session) SetStartTimestamp(v string) *Session {
   442  	s.StartTimestamp = &v
   443  	return s
   444  }
   445  
   446  // SetStopTimestamp sets the StopTimestamp field's value.
   447  func (s *Session) SetStopTimestamp(v string) *Session {
   448  	s.StopTimestamp = &v
   449  	return s
   450  }