nrclient

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2022 License: MIT Imports: 11 Imported by: 0

README

New Relic Client

A custom package to aggregate newrelic API.

import "github.com/ennobelprakoso/pkg/go/nrclient"

nr := nrclient.New(nrclient.Option{
    NRLoginCookies: `login cookies`,
    APIKey:         "api key",
})

users, err := nr.FindUserAccount(context.Background(), "test@test.com")
if err != nil {
    log.Error(err)
    return
}

for _, u := range users {
    log.Info(u.AccountID)
    log.Info(u.AccountName)
    log.Info(u.LastAccessTime)
}

Documentation

Index

Constants

View Source
const (
	UserTypeBasic UserType = 1
	UserTypeFull  UserType = 0

	UserBaseRoleAdmin      BaseRole = "admin"
	UserBaseRoleUser       BaseRole = "user"
	UserBaseRoleRestricted BaseRole = "restricted"
)
View Source
const (
	DeleteUsers = `https://rpm.newrelic.com/user_management/accounts/%v/users/%v`
)

Variables

View Source
var (
	ErrUserNotFound = errors.New("user not found")
)

Functions

This section is empty.

Types

type BaseRole

type BaseRole string

type BulkCreateUserSummary

type BulkCreateUserSummary struct {
	Data    ParamCreateUser `json:"data"`
	Success bool            `json:"success"`
	Err     error           `json:"err"`
}

BulkCreateUserSummary struct

type NRAccount

type NRAccount struct {
	ID   int64  `json:"id"`
	Name string `json:"name"`
}

NRAccount struct

type NRClient

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

NRClient client

func New

func New(opt Option) *NRClient

New instantiate nr client

func (*NRClient) BulkCreateUser

func (nr *NRClient) BulkCreateUser(ctx context.Context, data ...ParamCreateUser) []BulkCreateUserSummary

BulkCreateUser create new user in bulk

func (*NRClient) CreateUser

func (nr *NRClient) CreateUser(ctx context.Context, param ParamCreateUser) error

CreateUser create new user

func (*NRClient) FindUserAccount

func (nr *NRClient) FindUserAccount(ctx context.Context, email string) ([]NRUser, error)

FindUserAccount find user from all available account

func (*NRClient) GetAccountList

func (nr *NRClient) GetAccountList(ctx context.Context) ([]NRAccount, error)

GetAccountList get all available nr accounts

func (*NRClient) GetAddOnRoles

func (nr *NRClient) GetAddOnRoles(ctx context.Context, nrAccountID int64) ([]NRUserRoles, error)

GetAddOnRoles get available addon roles under account

func (*NRClient) GetAllUserUnderAccount added in v1.7.0

func (nr *NRClient) GetAllUserUnderAccount(ctx context.Context, nrAccountID int64) ([]NRUser, error)

func (*NRClient) GetUserUnderAccount

func (nr *NRClient) GetUserUnderAccount(ctx context.Context, email string, nrAccountID int64) (NRUser, error)

GetUserUnderAccount get user under specific account

func (*NRClient) RemoveUserFromAccount

func (nr *NRClient) RemoveUserFromAccount(ctx context.Context, email string, nrAccountID int64) error

RemoveUserFromAccount remove user from nr account

func (*NRClient) UpdateUserAddOnRoles

func (nr *NRClient) UpdateUserAddOnRoles(ctx context.Context, nrAccountID int64, userID int64, roles []int64) error

UpdateUserAddOnRoles update user addons role

type NRUser

type NRUser struct {
	UserID         int64         `json:"user_id"`
	AccountID      int64         `json:"account_id"`
	AccountName    string        `json:"account_name,omitempty"`
	FullName       string        `json:"full_name"`
	Email          string        `json:"email"`
	LastAccessAt   int64         `json:"last_access_at"`
	LastAccessTime time.Time     `json:"last_access_time"`
	Title          interface{}   `json:"title"`
	Status         string        `json:"status"`
	Roles          []NRUserRoles `json:"roles"`
	UserTierID     int           `json:"user_tier_id"`
}

NRUser new relic user

type NRUserRoles

type NRUserRoles struct {
	ID          int64       `json:"id"`
	AccountID   interface{} `json:"account_id"`
	Name        string      `json:"name"`
	DisplayName string      `json:"display_name"`
	Type        string      `json:"type"`
	BatchIds    []int       `json:"batch_ids"`
	GrantCount  int         `json:"grant_count"`
}

NRUserRoles struct

type Option

type Option struct {
	NRLoginCookies string
	APIKey         string
	Timeout        time.Duration
}

Option nr client option

type ParamCreateUser

type ParamCreateUser struct {
	FullName   string `validate:"required"`
	Email      string `validate:"required,email"`
	AccountID  int64  `validate:"required"`
	AddOnRoles []int64
	UserType   UserType
	BaseRole   BaseRole `validate:"required"`
}

ParamCreateUser struct

type UserType

type UserType int

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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