monitor_services_create_token.go raw

   1  package linodego
   2  
   3  import (
   4  	"context"
   5  )
   6  
   7  // MonitorServiceToken represents a MonitorServiceToken object
   8  type MonitorServiceToken struct {
   9  	Token string `json:"token"`
  10  }
  11  
  12  // MonitorTokenCreateOptions contains create token options.
  13  type MonitorTokenCreateOptions struct {
  14  	// EntityIDs are expected to be type "any" as different service_types have different variable type for their entity_ids. For example, Linode has "int" entity_ids whereas object storage has "string" as entity_ids.
  15  	EntityIDs []any `json:"entity_ids"`
  16  }
  17  
  18  // CreateMonitorServiceTokenForServiceType to create token for a given serviceType
  19  func (c *Client) CreateMonitorServiceTokenForServiceType(
  20  	ctx context.Context,
  21  	serviceType string,
  22  	opts MonitorTokenCreateOptions,
  23  ) (*MonitorServiceToken, error) {
  24  	e := formatAPIPath("monitor/services/%s/token", serviceType)
  25  	return doPOSTRequest[MonitorServiceToken](ctx, c, e, opts)
  26  }
  27