moesifapi

package module
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: Apache-2.0 Imports: 14 Imported by: 4

README

MoesifApi Lib for Golang

Send REST API Events to Moesif for API analytics and monitoring.

Source Code on GitHub

Introduction

This lib has both synchronous and async methods:

  • The synchronous methods call the Moesif API directly
  • The async methods (Which start with QueueXXX) will queue the requests into batches and flush buffers periodically.

Async methods are expected to be the common use case

How to install

Run the following commands:

moesifapi-go can be installed like any other Go library through go get:

go get github.com/moesif/moesifapi-go

Or, if you are already using Go Modules, specify a version number as well:

go get github.com/moesif/moesifapi-go@v1.0.6

How to use

(See examples/api_test.go for usage examples)

Create single event
import "github.com/moesif/moesifapi-go"
import "github.com/moesif/moesifapi-go/models"
import "time"

var apiEndpoint string
var batchSize int
var eventQueueSize int 
var timerWakeupSeconds int

apiClient := moesifapi.NewAPI("YOUR_COLLECTOR_APPLICATION_ID", &apiEndpoint, eventQueueSize, batchSize, timerWakeupSeconds)

reqTime := time.Now().UTC()
apiVersion := "1.0"
ipAddress := "61.48.220.123"

req := models.EventRequestModel{
	Time:       &reqTime,
	Uri:        "https://api.acmeinc.com/widgets",
	Verb:       "GET",
	ApiVersion: &apiVersion,
	IpAddress:  &ipAddress,
	Headers: map[string]interface{}{
		"ReqHeader1": "ReqHeaderValue1",
	},
	Body: nil,
}

rspTime := time.Now().UTC().Add(time.Duration(1) * time.Second)

rsp := models.EventResponseModel{
	Time:      &rspTime,
	Status:    500,
	IpAddress: nil,
	Headers: map[string]interface{}{
		"RspHeader1": "RspHeaderValue1",
	},
	Body: map[string]interface{}{
		"Key1": "Value1",
		"Key2": 12,
		"Key3": map[string]interface{}{
			"Key3_1": "SomeValue",
		},
	},
}

sessionToken := "23jdf0owekfmcn4u3qypxg09w4d8ayrcdx8nu2ng]s98y18cx98q3yhwmnhcfx43f"
userId := "my_user_id"
companyId := "my_company_id"
metadata := map[string]interface{}{
		"Key1": "metadata",
		"Key2": 12,
		"Key3": map[string]interface{}{
			"Key3_1": "SomeValue",
		},
	}

event := models.EventModel{
  Request:      req,
  Response:     rsp,
  SessionToken: &sessionToken,
  Tags:         nil,
  UserId:       &userId,
  CompanyId: 	&companyId,
  Metadata: 	&metadata,
}

// Queue the events
err := apiClient.QueueEvent(&event)

// Create the events synchronously
err := apiClient.CreateEvent(&event)

Create batches of events with bulk API
import "github.com/moesif/moesifapi-go"
import "github.com/moesif/moesifapi-go/models"
import "time"

var apiEndpoint string
var batchSize int
var eventQueueSize int 
var timerWakeupSeconds int

apiClient := moesifapi.NewAPI("YOUR_COLLECTOR_APPLICATION_ID", &apiEndpoint, eventQueueSize, batchSize, timerWakeupSeconds)

reqTime := time.Now().UTC()
apiVersion := "1.0"
ipAddress := "61.48.220.123"

req := models.EventRequestModel{
	Time:       &reqTime,
	Uri:        "https://api.acmeinc.com/widgets",
	Verb:       "GET",
	ApiVersion: &apiVersion,
	IpAddress:  &ipAddress,
	Headers: map[string]interface{}{
		"ReqHeader1": "ReqHeaderValue1",
	},
	Body: nil,
}

rspTime := time.Now().UTC().Add(time.Duration(1) * time.Second)

rsp := models.EventResponseModel{
	Time:      &rspTime,
	Status:    500,
	IpAddress: nil,
	Headers: map[string]interface{}{
		"RspHeader1": "RspHeaderValue1",
	},
	Body: map[string]interface{}{
		"Key1": "Value1",
		"Key2": 12,
		"Key3": map[string]interface{}{
			"Key3_1": "SomeValue",
		},
	},
}

sessionToken := "23jdf0owekfmcn4u3qypxg09w4d8ayrcdx8nu2ng]s98y18cx98q3yhwmnhcfx43f"
userId := "my_user_id"
companyId := "my_company_id"
metadata := map[string]interface{}{
		"Key1": "metadata",
		"Key2": 12,
		"Key3": map[string]interface{}{
			"Key3_1": "SomeValue",
		},
	}

event := models.EventModel{
  Request:      req,
  Response:     rsp,
  SessionToken: &sessionToken,
  Tags:         nil,
  UserId:       &userId,
  CompanyId: 	&companyId,
  Metadata: 	&metadata,
}

events := make([]*models.EventModel, 20)
for i := 0; i < 20; i++ {
	events[i] = &event
}

// Queue the events
err := apiClient.QueueEvents(events)

// Create the events batch synchronously
err := apiClient.CreateEventsBatch(event)

Update a Single User

Create or update a user profile in Moesif. The metadata field can be any customer demographic or other info you want to store. Only the UserId field is required. For details, visit the Go API Reference.

import "github.com/moesif/moesifapi-go"
import "github.com/moesif/moesifapi-go/models"

func literalFieldValue(value string) *string {
    return &value
}

var apiEndpoint string
var batchSize int
var eventQueueSize int 
var timerWakeupSeconds int

apiClient := moesifapi.NewAPI("YOUR_COLLECTOR_APPLICATION_ID", &apiEndpoint, eventQueueSize, batchSize, timerWakeupSeconds)

// Campaign object is optional, but useful if you want to track ROI of acquisition channels
// See https://www.moesif.com/docs/api#users for campaign schema
campaign := models.CampaignModel {
  UtmSource: literalFieldValue("google"),
  UtmMedium: literalFieldValue("cpc"), 
  UtmCampaign: literalFieldValue("adwords"),
  UtmTerm: literalFieldValue("api+tooling"),
  UtmContent: literalFieldValue("landing"),
}

// metadata can be any custom dictionary
metadata := map[string]interface{}{
  "email": "john@acmeinc.com",
  "first_name": "John",
  "last_name": "Doe",
  "title": "Software Engineer",
  "sales_info": map[string]interface{}{
      "stage": "Customer",
      "lifetime_value": 24000,
      "account_owner": "mary@contoso.com",
  },
}

// Only UserId is required
user := models.UserModel{
  UserId:  "12345",
  CompanyId:  literalFieldValue("67890"), // If set, associate user with a company object
  Campaign:  &campaign,
  Metadata:  &metadata,
}

// Queue the user asynchronously
err := apiClient.QueueUser(&user)

// Update the user synchronously
err := apiClient.UpdateUser(&user)

Update Users in Batch

Similar to UpdateUser, but used to update a list of users in one batch. Only the UserId field is required. For details, visit the Go API Reference.

import "github.com/moesif/moesifapi-go"
import "github.com/moesif/moesifapi-go/models"

func literalFieldValue(value string) *string {
    return &value
}

var apiEndpoint string
var batchSize int
var eventQueueSize int 
var timerWakeupSeconds int

apiClient := moesifapi.NewAPI("YOUR_COLLECTOR_APPLICATION_ID", &apiEndpoint, eventQueueSize, batchSize, timerWakeupSeconds)

// List of Users
var users []*models.UserModel

// Campaign object is optional, but useful if you want to track ROI of acquisition channels
// See https://www.moesif.com/docs/api#users for campaign schema
campaign := models.CampaignModel {
  UtmSource: literalFieldValue("google"),
  UtmMedium: literalFieldValue("cpc"), 
  UtmCampaign: literalFieldValue("adwords"),
  UtmTerm: literalFieldValue("api+tooling"),
  UtmContent: literalFieldValue("landing"),
}

// metadata can be any custom dictionary
metadata := map[string]interface{}{
  "email": "john@acmeinc.com",
  "first_name": "John",
  "last_name": "Doe",
  "title": "Software Engineer",
  "sales_info": map[string]interface{}{
      "stage": "Customer",
      "lifetime_value": 24000,
      "account_owner": "mary@contoso.com",
  },
}

// Only UserId is required
userA := models.UserModel{
  UserId:  "12345",
  CompanyId:  literalFieldValue("67890"), // If set, associate user with a company object
  Campaign:  &campaign,
  Metadata:  &metadata,
}

users = append(users, &userA)

// Queue the user asynchronously
err := apiClient.QueueUsers(&users)

// Update the user synchronously
err := apiClient.UpdateUsersBatch(&users)

Update a Single Company

Create or update a company profile in Moesif. The metadata field can be any company demographic or other info you want to store. Only the CompanyId field is required. For details, visit the Go API Reference.

import "github.com/moesif/moesifapi-go"
import "github.com/moesif/moesifapi-go/models"

func literalFieldValue(value string) *string {
    return &value
}

var apiEndpoint string
var batchSize int
var eventQueueSize int 
var timerWakeupSeconds int

apiClient := moesifapi.NewAPI("YOUR_COLLECTOR_APPLICATION_ID", &apiEndpoint, eventQueueSize, batchSize, timerWakeupSeconds)

// Campaign object is optional, but useful if you want to track ROI of acquisition channels
// See https://www.moesif.com/docs/api#update-a-company for campaign schema
campaign := models.CampaignModel {
  UtmSource: literalFieldValue("google"),
  UtmMedium: literalFieldValue("cpc"), 
  UtmCampaign: literalFieldValue("adwords"),
  UtmTerm: literalFieldValue("api+tooling"),
  UtmContent: literalFieldValue("landing"),
}

// metadata can be any custom dictionary
metadata := map[string]interface{}{
  "org_name": "Acme, Inc",
  "plan_name": "Free",
  "deal_stage": "Lead",
  "mrr": 24000,
  "demographics": map[string]interface{}{
      "alexa_ranking": 500000,
      "employee_count": 47,
  },
}

// Prepare company model
company := models.CompanyModel{
    CompanyId:        "67890",  // The only required field is your company id
    CompanyDomain:    literalFieldValue("acmeinc.com"), // If domain is set, Moesif will enrich your profiles with publicly available info 
    Campaign:         &campaign,
    Metadata:         &metadata,
}

// Queue the company asynchronously
apiClient.QueueCompany(&company)

// Update the company synchronously
err := apiClient.UpdateCompany(&company)

Update Companies in Batch

Similar to updateCompany, but used to update a list of companies in one batch. Only the CompanyId field is required. For details, visit the Go API Reference.

import "github.com/moesif/moesifapi-go"
import "github.com/moesif/moesifapi-go/models"

func literalFieldValue(value string) *string {
    return &value
}

var apiEndpoint string
var batchSize int
var eventQueueSize int 
var timerWakeupSeconds int

apiClient := moesifapi.NewAPI("YOUR_COLLECTOR_APPLICATION_ID", &apiEndpoint, eventQueueSize, batchSize, timerWakeupSeconds)

// List of Companies
var companies []*models.CompanyModel

// Campaign object is optional, but useful if you want to track ROI of acquisition channels
// See https://www.moesif.com/docs/api#update-a-company for campaign schema
campaign := models.CampaignModel {
  UtmSource: literalFieldValue("google"),
  UtmMedium: literalFieldValue("cpc"), 
  UtmCampaign: literalFieldValue("adwords"),
  UtmTerm: literalFieldValue("api+tooling"),
  UtmContent: literalFieldValue("landing"),
}

// metadata can be any custom dictionary
metadata := map[string]interface{}{
  "org_name": "Acme, Inc",
  "plan_name": "Free",
  "deal_stage": "Lead",
  "mrr": 24000,
  "demographics": map[string]interface{}{
      "alexa_ranking": 500000,
      "employee_count": 47,
  },
}

// Prepare company model
companyA := models.CompanyModel{
    CompanyId:        "67890",  // The only required field is your company id
    CompanyDomain:    literalFieldValue("acmeinc.com"), // If domain is set, Moesif will enrich your profiles with publicly available info 
    Campaign:         &campaign,
    Metadata:         &metadata,
}

companies = append(companies, &companyA)

// Queue the company asynchronously
apiClient.QueueCompanies(&companies)

// Update the company synchronously
err := apiClient.UpdateCompaniesBatch(&companies)

Update a Single Company

Create or update a company profile in Moesif. The metadata field can be any company demographic or other info you want to store. Only the CompanyId field is required. For details, visit the Go API Reference.

import "github.com/moesif/moesifapi-go"
import "github.com/moesif/moesifapi-go/models"

func literalFieldValue(value string) *string {
    return &value
}

var apiEndpoint string
var batchSize int
var eventQueueSize int 
var timerWakeupSeconds int

apiClient := moesifapi.NewAPI("YOUR_COLLECTOR_APPLICATION_ID", &apiEndpoint, eventQueueSize, batchSize, timerWakeupSeconds)

// Campaign object is optional, but useful if you want to track ROI of acquisition channels
// See https://www.moesif.com/docs/api#update-a-company for campaign schema
campaign := models.CampaignModel {
  UtmSource: literalFieldValue("google"),
  UtmMedium: literalFieldValue("cpc"), 
  UtmCampaign: literalFieldValue("adwords"),
  UtmTerm: literalFieldValue("api+tooling"),
  UtmContent: literalFieldValue("landing"),
}

// metadata can be any custom dictionary
metadata := map[string]interface{}{
  "org_name": "Acme, Inc",
  "plan_name": "Free",
  "deal_stage": "Lead",
  "mrr": 24000,
  "demographics": map[string]interface{}{
      "alexa_ranking": 500000,
      "employee_count": 47,
  },
}

// Prepare company model
company := models.CompanyModel{
    CompanyId:        "67890",  // The only required field is your company id
    CompanyDomain:    literalFieldValue("acmeinc.com"), // If domain is set, Moesif will enrich your profiles with publicly available info 
    Campaign:         &campaign,
    Metadata:         &metadata,
}

// Queue the company asynchronously
apiClient.QueueCompany(&company)

// Update the company synchronously
err := apiClient.UpdateCompany(&company)

Update Companies in Batch

Similar to updateCompany, but used to update a list of companies in one batch. Only the CompanyId field is required. For details, visit the Go API Reference.

import "github.com/moesif/moesifapi-go"
import "github.com/moesif/moesifapi-go/models"

func literalFieldValue(value string) *string {
    return &value
}

var apiEndpoint string
var batchSize int
var eventQueueSize int 
var timerWakeupSeconds int

apiClient := moesifapi.NewAPI("YOUR_COLLECTOR_APPLICATION_ID", &apiEndpoint, eventQueueSize, batchSize, timerWakeupSeconds)

// List of Companies
var companies []*models.CompanyModel

// Campaign object is optional, but useful if you want to track ROI of acquisition channels
// See https://www.moesif.com/docs/api#update-a-company for campaign schema
campaign := models.CampaignModel {
  UtmSource: literalFieldValue("google"),
  UtmMedium: literalFieldValue("cpc"), 
  UtmCampaign: literalFieldValue("adwords"),
  UtmTerm: literalFieldValue("api+tooling"),
  UtmContent: literalFieldValue("landing"),
}

// metadata can be any custom dictionary
metadata := map[string]interface{}{
  "org_name": "Acme, Inc",
  "plan_name": "Free",
  "deal_stage": "Lead",
  "mrr": 24000,
  "demographics": map[string]interface{}{
      "alexa_ranking": 500000,
      "employee_count": 47,
  },
}

// Prepare company model
companyA := models.CompanyModel{
    CompanyId:        "67890",  // The only required field is your company id
    CompanyDomain:    literalFieldValue("acmeinc.com"), // If domain is set, Moesif will enrich your profiles with publicly available info 
    Campaign:         &campaign,
    Metadata:         &metadata,
}

companies = append(companies, &companyA)

// Queue the company asynchronously
apiClient.QueueCompanies(&companies)

// Update the company synchronously
err := apiClient.UpdateCompaniesBatch(&companies)

Update a Single Subscription

Create or update a subscription profile in Moesif. The metadata field can be any subscription demographic or other info you want to store. Only the SubscriptionId and CompanyId fields are required. For details, visit the Go API Reference.

import "github.com/moesif/moesifapi-go"
import "github.com/moesif/moesifapi-go/models"

func literalFieldValue(value string) *string {
    return &value
}

var apiEndpoint string
var batchSize int
var eventQueueSize int 
var timerWakeupSeconds int

apiClient := moesifapi.NewAPI("YOUR_COLLECTOR_APPLICATION_ID", &apiEndpoint, eventQueueSize, batchSize, timerWakeupSeconds)

// metadata can be any custom dictionary
metadata := map[string]interface{}{
  "plan_name": "Pro",
  "deal_stage": "Customer",
  "mrr": 48000,
  "demographics": map[string]interface{}{
      "alexa_ranking": 250000,
      "employee_count": 95,
  },
}

// Prepare subscription model
subscription := models.SubscriptionModel{
    SubscriptionId:    "12345",  // Required field subscription id
    CompanyId:         literalFieldValue("67890"), // Required field company id
    Metadata:          &metadata,
}

// Queue the subscription asynchronously
apiClient.QueueSubscription(&subscription)

// Update the subscription synchronously
err := apiClient.UpdateSubscription(&subscription)

Update Subscriptions in Batch

Similar to updateSubscription, but used to update a list of subscriptions in one batch. Only the SubscriptionId and CompanyId fields are required. For details, visit the Go API Reference.

import "github.com/moesif/moesifapi-go"
import "github.com/moesif/moesifapi-go/models"

func literalFieldValue(value string) *string {
    return &value
}

var apiEndpoint string
var batchSize int
var eventQueueSize int 
var timerWakeupSeconds int

apiClient := moesifapi.NewAPI("YOUR_COLLECTOR_APPLICATION_ID", &apiEndpoint, eventQueueSize, batchSize, timerWakeupSeconds)

// List of Subscriptions
var subscriptions []*models.SubscriptionModel

// metadata can be any custom dictionary
metadata := map[string]interface{}{
  "plan_name": "Pro",
  "deal_stage": "Customer",
  "mrr": 48000,
}

// Prepare subscription model
subscriptionA := models.SubscriptionModel{
    SubscriptionId:    "12345",  // The only required field is your subscription id
    CompanyId:         literalFieldValue("67890"), // Link the subscription to a company
    Metadata:          &metadata,
}

subscriptions = append(subscriptions, &subscriptionA)

// Queue the subscription asynchronously
apiClient.QueueSubscriptions(&subscriptions)

// Update the subscription synchronously
err := apiClient.UpdateSubscriptionsBatch(&subscriptions)
Health Check
go get github.com/moesif/moesifapi-go/health;

How To Test:

git clone https://github.com/moesif/moesifapi-go
cd moesifapi-go/examples
# Be sure to edit the examples/api_test.go to change the application id to your real one obtained from Moesif.
# var applicationId = "Your Moesif Application Id"
go test  -v

Other integrations

To view more documentation on integration options, please visit the Integration Options Documentation.

Documentation

Overview

* moesifapi-go

* moesifapi-go

* moesifapi-go

Index

Constants

View Source
const Version string = "1.0.6"

* Version of this lib

Variables

View Source
var Config = config{}

Functions

func Template added in v1.1.0

func Template(t string, vars map[string]string) string

Template replaces substitution variables in the request body template vars is a map of variable name to variable substitution value

Types

type API

type API interface {

	/**
	 * Queue Single API Event Call to be created
	 * @param    *models.EventModel        body     parameter: Required
	 * @return	Returns the  response from the API call
	 */
	QueueEvent(*models.EventModel) error

	/**
	 * Queue multiple API Events to be added
	 * @param    []*models.EventModel        body     parameter: Required
	 * @return	Returns the  response from the API call
	 */
	QueueEvents([]*models.EventModel) error

	/**
	 * Queue Single User to be updated
	 * @param    *models.UserModel        body     parameter: Required
	 * @return	Returns the  response from the API call
	 */
	QueueUser(*models.UserModel) error

	/**
	 * Queue multiple Users to be updated
	 * @param    []*models.UserModel        body     parameter: Required
	 * @return	Returns the  response from the API call
	 */
	QueueUsers([]*models.UserModel) error

	/**
	 * Queue Single Company to be added
	 * @param    *models.CompanyModel        body     parameter: Required
	 * @return	Returns the  response from the API call
	 */
	QueueCompany(*models.CompanyModel) error

	/**
	 * Queue multiple companies to be added
	 * @param    []*models.CompanyModel        body     parameter: Required
	 * @return	Returns the  response from the API call
	 */
	QueueCompanies([]*models.CompanyModel) error

	/**
	 * Queue Single Subscription to be added
	 * @param    *models.SubscriptionModel        body     parameter: Required
	 * @return	Returns the  response from the API call
	 */
	QueueSubscription(*models.SubscriptionModel) error

	/**
	 * Queue multiple Subscriptions to be added
	 * @param    []*models.SubscriptionModel        body     parameter: Required
	 * @return	Returns the  response from the API call
	 */
	QueueSubscriptions([]*models.SubscriptionModel) error

	/**
	 * Add Single API Event Call
	 * @param    *models.EventModel        body     parameter: Required
	 * @return	Returns the  response from the API call
	 */
	CreateEvent(*models.EventModel) (http.Header, error)

	/**
	 * Add multiple API Events in a single batch (batch size must be less than 250kb)
	 * @param    []*models.EventModel        body     parameter: Required
	 * @return	Returns the  response from the API call
	 */
	CreateEventsBatch([]*models.EventModel) (http.Header, error)

	/**
	 * Update a Single User
	 * @param    *models.UserModel        body     parameter: Required
	 * @return	Returns the  response from the API call
	 */
	UpdateUser(*models.UserModel) error

	/**
	 * Update multiple Users in a single batch (batch size must be less than 250kb)
	 * @param    []*models.UserModel        body     parameter: Required
	 * @return	Returns the  response from the API call
	 */
	UpdateUsersBatch([]*models.UserModel) error

	/**
	 * Get Application configuration
	 * @param    nil        body     parameter: Required
	 * @return	Returns the  response from the API call
	 */
	GetAppConfig() (*http.Response, error)

	/**
	 * Update a Single Company
	 * @param    *models.CompanyModel        body     parameter: Required
	 * @return	Returns the  response from the API call
	 */
	UpdateCompany(*models.CompanyModel) error

	/**
	 * Update multiple companies in a single batch (batch size must be less than 250kb)
	 * @param    []*models.CompanyModel        body     parameter: Required
	 * @return	Returns the  response from the API call
	 */
	UpdateCompaniesBatch([]*models.CompanyModel) error

	/**
	 * Update a Single Subscription
	 * @param    *models.SubscriptionModel        body     parameter: Required
	 * @return	Returns the  response from the API call
	 */
	UpdateSubscription(*models.SubscriptionModel) error

	/**
	 * Update multiple Subscriptions in a single batch (batch size must be less than 250kb)
	 * @param    []*models.SubscriptionModel        body     parameter: Required
	 * @return	Returns the  response from the API call
	 */
	UpdateSubscriptionsBatch([]*models.SubscriptionModel) error

	// GetGovernanceRules gets the collector's /v1/rules endpoint which contains
	// regex governance rules and user/company governance rule templates which are
	// templated with individual user and company info from the /v1/config endpoint
	GetGovernanceRules() (GovernanceRulesResponse, error)

	// SetEventsHeaderCallback sets a Moesif API response header value and callback
	// function which is called with
	SetEventsHeaderCallback(string, func(string))

	Flush()

	Close()
}

* Interface for the Client

func NewAPI

func NewAPI(moesifApplicationId string, apiEndpoint *string, eventQueueSize int, batchSize int, timerWakeupSeconds int) API

* Factory for the API interaface returning Client

type BodyTemplate added in v1.1.0

type BodyTemplate string

func (*BodyTemplate) UnmarshalJSON added in v1.1.0

func (b *BodyTemplate) UnmarshalJSON(data []byte) error

type Client

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

* Client structure as interface implementation

func NewClient

func NewClient() *Client

func (*Client) Close

func (c *Client) Close()

func (*Client) CreateEvent

func (c *Client) CreateEvent(event *models.EventModel) (http.Header, error)

*

  • Add Single API Event Call
  • @param *models.EventModel body parameter: Required
  • @return Returns the response from the API call

func (*Client) CreateEventsBatch

func (c *Client) CreateEventsBatch(events []*models.EventModel) (http.Header, error)

*

  • Add multiple API Events in a single batch (batch size must be less than 250kb)
  • @param []*models.EventModel body parameter: Required
  • @return Returns the response from the API call

func (*Client) Flush

func (c *Client) Flush()

func (*Client) GetAppConfig

func (c *Client) GetAppConfig() (*http.Response, error)

*

  • Get Application configuration
  • @param nil parameter: Required
  • @return Returns the response from the API call

func (*Client) GetGovernanceRules added in v1.1.0

func (c *Client) GetGovernanceRules() (r GovernanceRulesResponse, err error)

func (*Client) QueueCompanies

func (c *Client) QueueCompanies(u []*models.CompanyModel) error

*

  • Queue multiple companies to be added
  • @param []*models.UserModel body parameter: Required
  • @return Returns the response from the API call

func (*Client) QueueCompany

func (c *Client) QueueCompany(u *models.CompanyModel) error

*

  • Queue Single Company to be added
  • @param *models.CompanyModel body parameter: Required
  • @return Returns the response from the API call

func (*Client) QueueEvent

func (c *Client) QueueEvent(e *models.EventModel) error

*

  • Queue Single API Event Call to be created
  • @param *models.EventModel body parameter: Required
  • @return Returns the response from the API call

func (*Client) QueueEvents

func (c *Client) QueueEvents(e []*models.EventModel) error

*

  • Queue multiple API Events to be added
  • @param []*models.EventModel body parameter: Required
  • @return Returns the response from the API call

func (*Client) QueueSubscription added in v1.1.5

func (c *Client) QueueSubscription(u *models.SubscriptionModel) error

func (*Client) QueueSubscriptions added in v1.1.5

func (c *Client) QueueSubscriptions(u []*models.SubscriptionModel) error

func (*Client) QueueUser

func (c *Client) QueueUser(u *models.UserModel) error

*

  • Queue Single User to be updated
  • @param *models.UserModel body parameter: Required
  • @return Returns the response from the API call

func (*Client) QueueUsers

func (c *Client) QueueUsers(u []*models.UserModel) error

*

  • Queue multiple Users to be updated
  • @param []*models.UserModel body parameter: Required
  • @return Returns the response from the API call

func (*Client) SendDataToMoesif added in v1.0.6

func (c *Client) SendDataToMoesif(body []byte, rawPath string)

func (*Client) SetEventsHeaderCallback added in v1.1.1

func (c *Client) SetEventsHeaderCallback(header string, callback func(string))

SetEventsHeaderCallback takes a response header name and callback function on SendDataToMoesif, the callback headers are read from the response and passed to the callback functions

func (*Client) UpdateCompaniesBatch

func (c *Client) UpdateCompaniesBatch(companies []*models.CompanyModel) error

*

  • Update multiple companies in a single batch (batch size must be less than 250kb)
  • @param []*models.CompanyModel body parameter: Required
  • @return Returns the response from the API call

func (*Client) UpdateCompany

func (c *Client) UpdateCompany(company *models.CompanyModel) error

*

  • Update a Single Company
  • @param *models.CompanyModel body parameter: Required
  • @return Returns the response from the API call

func (*Client) UpdateSubscription added in v1.1.5

func (c *Client) UpdateSubscription(subscription *models.SubscriptionModel) error

*

  • Update a Single Subscription
  • @param *models.SubscriptionModel body parameter: Required
  • @return Returns the response from the API call

func (*Client) UpdateSubscriptionsBatch added in v1.1.5

func (c *Client) UpdateSubscriptionsBatch(subscriptions []*models.SubscriptionModel) error

*

  • Update multiple Subscriptions in a single batch (batch size must be less than 250kb)
  • @param []*models.SubscriptionModel body parameter: Required
  • @return Returns the response from the API call

func (*Client) UpdateUser

func (c *Client) UpdateUser(user *models.UserModel) error

*

  • Update a Single User
  • @param *models.UserModel body parameter: Required
  • @return Returns the response from the API call

func (*Client) UpdateUsersBatch

func (c *Client) UpdateUsersBatch(users []*models.UserModel) error

*

  • Update multiple Users in a single batch (batch size must be less than 250kb)
  • @param []*models.UserModel body parameter: Required
  • @return Returns the response from the API call

type GovernanceRule added in v1.1.0

type GovernanceRule struct {
	ID                string `json:"_id"`
	Name              string `json:"name"`
	Type              string `json:"type"`
	Block             bool   `json:"block"`
	ApplyTo           string `json:"applied_to"`              // "matching" or "not_matching"
	ApplyUnidentified bool   `json:"applied_to_unidentified"` // true if rule applies to unidentified entities
	// RegexConfigOr is a boolean expression tree with a fixed depth of two,
	// a slice of slices of regex patterns.  The regex rule as a whole is a match,
	// evals to true, if one OR more of the top level slice items is true.
	// One of the top level slices is a slice of regex patterns to match, and
	// one slice is true of one pattern AND the others are all matches.
	RegexConfigOr     []RegexConditionsAnd `json:"regex_config"`
	ResponseOverrides ResponseOverrides    `json:"response"`
	Variables         []Variable           `json:"variables"`
	OrgID             string               `json:"org_id"`
	AppID             string               `json:"app_id"`
	CreatedAt         string               `json:"created_at"`
}

implement support for regex AND user/company cohort. Logically both conditions must be true also make example of regex with OR/AND conditions between expressions

type GovernanceRulesResponse added in v1.1.0

type GovernanceRulesResponse struct {
	Rules []GovernanceRule
	ETag  string
}

type RegexCondition added in v1.1.0

type RegexCondition struct {
	Path  string `json:"path"`
	Value string `json:"value"`
}

type RegexConditionsAnd added in v1.1.0

type RegexConditionsAnd struct {
	Conditions []RegexCondition `json:"conditions"`
}

type ResponseOverrides added in v1.1.0

type ResponseOverrides struct {
	Body    BodyTemplate      `json:"body"`
	Headers map[string]string `json:"headers"`
	Status  int               `json:"status"`
}

type Variable added in v1.1.0

type Variable struct {
	Name string `json:"name"`
	Path string `json:"path"`
}

Directories

Path Synopsis
* moesifapi-go
* moesifapi-go
* moesifapi-go
* moesifapi-go

Jump to

Keyboard shortcuts

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