itglue

package module
v0.2.4-alpha Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2021 License: GPL-3.0 Imports: 7 Imported by: 0

README

Fork of go-itg

Thanks Steven

go-itg

IT Glue API Structs + Methods for the Go

This is nowhere near complete, and at least for now, I will only be adding support the functionality required for use within my organization. Feel free to send a pull request if you'd like to contribute anything that's missing.

Installation

go get github.com/Private-Universe/itglue

Usage

package main

import (
	"fmt"
	"log"

	"github.com/Private-Universe/itglue"
)

func main() {
	fmt.Println("Example IT Glue Application")
	itg := itglue.NewITGAPI("ITG.XXXXXXXXXXXXXXXXXXXXXXXX.XXXXXXXXXXXXXXXXXXXXXXXXXXXX-XXXXXXXXXXXX")

	nd, err := itg.GetOrganizationByName("Next Digital Inc.", 1) //Returns page one of an organization list
	if err != nil {
		log.Fatalf("could not get nd: %s", err)
	}
	log.Printf("%s - %s\n", nd.Data[0].ID, nd.Data[0].Attributes.Name)

}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FlexibleAsset

type FlexibleAsset struct {
	Data  struct{ FlexibleAssetData } `json:"data"`
	Meta  struct{ Metadata }          `json:"meta"`
	Links struct{ Links }             `json:"links"`
}

type FlexibleAssetData

type FlexibleAssetData struct {
	ID         string `json:"id"`
	Type       string `json:"type"`
	Attributes struct {
		OrganizationID        int    `json:"organization-id"`
		OrganizationName      string `json:"organization-name"`
		ResourceURL           string `json:"resource-url"`
		Restricted            bool   `json:"restricted"`
		MyGlue                bool   `json:"my-glue"`
		FlexibleAssetTypeID   int    `json:"flexible-asset-type-id"`
		FlexibleAssetTypeName string `json:"flexible-asset-type-name"`
		Name                  string `json:"name"`
		Traits                map[string]interface {
		} `json:"traits"`
		Archived  bool      `json:"archived"`
		CreatedAt time.Time `json:"created-at"`
		UpdatedAt time.Time `json:"updated-at"`
	} `json:"attributes"`
	Relationships struct {
	} `json:"relationships"`
}

type FlexibleAssetField

type FlexibleAssetField struct {
	Data  struct{ FlexibleAssetFieldData } `json:"data"`
	Meta  struct{ Metadata }               `json:"meta"`
	Links struct{ Links }                  `json:"links"`
}

type FlexibleAssetFieldData

type FlexibleAssetFieldData struct {
	ID         string `json:"id"`
	Type       string `json:"type"`
	Attributes struct {
		Order               int         `json:"order"`
		Name                string      `json:"name"`
		Kind                string      `json:"kind"`
		Hint                interface{} `json:"hint"`
		Decimals            int         `json:"decimals"`
		TagType             interface{} `json:"tag-type"`
		Required            bool        `json:"required"`
		UseForTitle         bool        `json:"use-for-title"`
		Expiration          bool        `json:"expiration"`
		ShowInList          bool        `json:"show-in-list"`
		NameKey             string      `json:"name-key"`
		CreatedAt           time.Time   `json:"created-at"`
		UpdatedAt           time.Time   `json:"updated-at"`
		FlexibleAssetTypeID int         `json:"flexible-asset-type-id"`
		DefaultValue        interface{} `json:"default-value"`
	} `json:"attributes"`
	Relationships struct {
		FlexibleAssetType struct {
			FlexibleAssetType
		} `json:"flexible-asset-type"`
	} `json:"relationships"`
}

type FlexibleAssetFieldList

type FlexibleAssetFieldList struct {
	Data  []struct{ FlexibleAssetFieldData } `json:"data"`
	Meta  struct{ Metadata }                 `json:"meta"`
	Links struct{ Links }                    `json:"links"`
}

type FlexibleAssetList

type FlexibleAssetList struct {
	Data  []struct{ FlexibleAssetData } `json:"data"`
	Meta  struct{ Metadata }            `json:"meta"`
	Links struct{ Links }               `json:"links"`
}

type FlexibleAssetType

type FlexibleAssetType struct {
	Data  struct{ FlexibleAssetTypeData } `json:"data"`
	Meta  struct{ Metadata }              `json:"meta"`
	Links struct{ Links }                 `json:"links"`
}

type FlexibleAssetTypeData

type FlexibleAssetTypeData struct {
	ID         string `json:"id"`
	Type       string `json:"type"`
	Attributes struct {
		Name        string    `json:"name"`
		Description string    `json:"description"`
		CreatedAt   time.Time `json:"created-at"`
		UpdatedAt   time.Time `json:"updated-at"`
		Icon        string    `json:"icon"`
		Enabled     bool      `json:"enabled"`
	} `json:"attributes"`
	Relationships struct {
	} `json:"relationships"`
}

type FlexibleAssetTypeList

type FlexibleAssetTypeList struct {
	Data  []struct{ FlexibleAssetTypeData } `json:"data"`
	Meta  struct{ Metadata }                `json:"meta"`
	Links struct{ Links }                   `json:"links"`
}

type ITGAPI

type ITGAPI struct {
	Site   string //Full URL ITG API
	APIKey string //API Key
}

ITGAPI contains the ITG API URL for North America, as well as the API key. Think of it as an instance of the API client

func NewITGAPI

func NewITGAPI(apiKey string) *ITGAPI

NewITGAPI expects the API key to be passed to it Returns a pointer to an ITGAPI struct

func (*ITGAPI) BuildURL

func (itg *ITGAPI) BuildURL(restAction string) (*url.URL, error)

BuildURL expects a restaction to be passed to it Returns the full request URL containing the ITG API domain prepended to the rest action

func (*ITGAPI) DeleteFlexibleAsset

func (itg *ITGAPI) DeleteFlexibleAsset(flexibleAssetID int) ([]byte, error)

DeleteFlexibleAsset delete asset

func (*ITGAPI) DeletePassword

func (itg *ITGAPI) DeletePassword(passwordID int) ([]byte, error)

DeletePassword delete asset

func (*ITGAPI) GetFlexibleAssetFields

func (itg *ITGAPI) GetFlexibleAssetFields(flexibleAssetTypeID int, pageNumber int) (*FlexibleAssetFieldList, error)

func (*ITGAPI) GetFlexibleAssetTypes

func (itg *ITGAPI) GetFlexibleAssetTypes(pageNumber int) (*FlexibleAssetTypeList, error)

func (*ITGAPI) GetFlexibleAssets

func (itg *ITGAPI) GetFlexibleAssets(flexibleAssetTypeID int, pageNumber int) (*FlexibleAssetList, error)

GetFlexibleAssets returns flexible assets

func (*ITGAPI) GetFlexibleAssetsByID

func (itg *ITGAPI) GetFlexibleAssetsByID(flexibleAssetID int) (*FlexibleAsset, error)

GetFlexibleAssetsByID returns flexible assets

func (*ITGAPI) GetFlexibleAssetsByName

func (itg *ITGAPI) GetFlexibleAssetsByName(flexibleAssetTypeID int, flexibleAssetName string, pageNumber int) (*FlexibleAssetList, error)

GetFlexibleAssetsByName returns flexible assets

func (*ITGAPI) GetFlexibleAssetsByOrganizationID

func (itg *ITGAPI) GetFlexibleAssetsByOrganizationID(flexibleAssetTypeID int, OrganizationID int, pageNumber int) (*FlexibleAssetList, error)

GetFlexibleAssetsByOrganizationID returns flexible assets

func (*ITGAPI) GetFlexibleAssetsByOrganizationIDAndName

func (itg *ITGAPI) GetFlexibleAssetsByOrganizationIDAndName(flexibleAssetTypeID int, OrganizationID int, flexibleAssetName string, pageNumber int) (*FlexibleAssetList, error)

GetFlexibleAssetsByOrganizationIDAndName returns flexible assets

func (*ITGAPI) GetOrganizationByID

func (itg *ITGAPI) GetOrganizationByID(organizationID int) (*Organization, error)

GetOrganizationByID expects an ITG organization ID Returns a pointer to an Organization struct

func (*ITGAPI) GetOrganizationByName

func (itg *ITGAPI) GetOrganizationByName(organizationName string, pageNumber int) (*OrganizationList, error)

GetOrganizationByName expects an exact matching organization name and returns an OrganizationList

func (*ITGAPI) GetOrganizationStatuses

func (itg *ITGAPI) GetOrganizationStatuses(pageNumber int) (*OrganizationStatusList, error)

func (*ITGAPI) GetOrganizationTypes

func (itg *ITGAPI) GetOrganizationTypes(pageNumber int) (*OrganizationTypeList, error)

/organization_types

func (*ITGAPI) GetPasswords

func (itg *ITGAPI) GetPasswords(pageNumber int) (*PasswordList, error)

GetPasswords returns passwords

func (*ITGAPI) GetPasswordsByID

func (itg *ITGAPI) GetPasswordsByID(passwordID int) (*Password, error)

GetPasswordsByID returns passwords

func (*ITGAPI) GetUserMetrics

func (itg *ITGAPI) GetUserMetrics(pageNumber int) (*UserMetricList, error)

func (*ITGAPI) GetUsers

func (itg *ITGAPI) GetUsers(pageNumber int) (*UserList, error)

func (*ITGAPI) NewRequest

func (itg *ITGAPI) NewRequest(restAction, method string, body []byte) *Request

NewRequest is a function which takes the mandatory fields to perform a request to the CW API and returns a pointer to a Request struct

func (*ITGAPI) PatchFlexibleAsset

func (itg *ITGAPI) PatchFlexibleAsset(flexibleAssetID int, asset *FlexibleAsset) (*FlexibleAsset, error)

PatchFlexibleAsset update asset. Any trait not specified will be deleted

func (*ITGAPI) PatchPassword

func (itg *ITGAPI) PatchPassword(passwordID int, asset *Password) (*Password, error)

PatchPassword update asset. Any attributes you don't specify will remain unchanged.

func (*ITGAPI) PostFlexibleAsset

func (itg *ITGAPI) PostFlexibleAsset(asset *FlexibleAsset) (*FlexibleAsset, error)

PostFlexibleAsset create new asset

func (*ITGAPI) PostPassword

func (itg *ITGAPI) PostPassword(asset *Password) (*Password, error)

PostPassword create new asset

type Links struct{}

TBD: Implement

type Metadata

type Metadata struct {
	CurrentPage int         `json:"current-page"`
	NextPage    interface{} `json:"next-page"`
	PrevPage    interface{} `json:"prev-page"`
	TotalPages  int         `json:"total-pages"`
	TotalCount  int         `json:"total-count"`
	Filters     struct {
	} `json:"filters"`
}

type Organization

type Organization struct {
	Data struct{ OrganizationData } `json:"data"`
	Meta struct{ Metadata }         `json:"meta"`
}

Organization contains a single Organization

type OrganizationData

type OrganizationData struct {
	ID         string `json:"id"`
	Type       string `json:"type"`
	Attributes struct {
		Name                   string `json:"name"`
		Description            string `json:"description"`
		OrganizationTypeID     int    `json:"organization-type-id"`
		OrganizationTypeName   string `json:"organization-type-name"`
		OrganizationStatusID   int    `json:"organization-status-id"`
		OrganizationStatusName string `json:"organization-status-name"`
		Logo                   string `json:"logo"`
		QuickNotes             string `json:"quick-notes"`
		ShortName              string `json:"short-name"`
		CreatedAt              string `json:"created-at"`
		UpdatedAt              string `json:"updated-at"`
	} `json:"attributes"`
}

OrganizationData contains the schema of an Organization in IT Glue without the "data" wrapper. This allows us to reuse the schema when data is either a JSON object or an array, depending on what results are returned

type OrganizationList

type OrganizationList struct {
	Data []struct{ OrganizationData } `json:"data"`
	Meta struct{ Metadata }           `json:"meta"`
}

OrganizationList contains a slice of Organizations

type OrganizationStatus

type OrganizationStatus struct {
	Data  struct{ OrganizationStatusData } `json:"data"`
	Meta  struct{ Metadata }               `json:"meta"`
	Links struct{ Links }                  `json:"links"`
}

type OrganizationStatusData

type OrganizationStatusData struct {
	ID         string `json:"id"`
	Type       string `json:"type"`
	Attributes struct {
		Name      string    `json:"name"`
		CreatedAt time.Time `json:"created-at"`
		UpdatedAt time.Time `json:"updated-at"`
		Synced    bool      `json:"synced"`
	} `json:"attributes"`
}

type OrganizationStatusList

type OrganizationStatusList struct {
	Data  []struct{ OrganizationStatusData } `json:"data"`
	Meta  struct{ Metadata }                 `json:"meta"`
	Links struct{ Links }                    `json:"links"`
}

type OrganizationType

type OrganizationType struct {
	Data  struct{ OrganizationTypeData } `json:"data"`
	Meta  struct{ Metadata }             `json:"meta"`
	Links struct{ Links }                `json:"links"`
}

type OrganizationTypeData

type OrganizationTypeData struct {
	ID         string `json:"id"`
	Type       string `json:"type"`
	Attributes struct {
		Name      string    `json:"name"`
		CreatedAt time.Time `json:"created-at"`
		UpdatedAt time.Time `json:"updated-at"`
		Synced    bool      `json:"synced"`
	} `json:"attributes"`
}

type OrganizationTypeList

type OrganizationTypeList struct {
	Data  []struct{ OrganizationTypeData } `json:"data"`
	Meta  struct{ Metadata }               `json:"meta"`
	Links struct{ Links }                  `json:"links"`
}

type Password

type Password struct {
	Data  struct{ PasswordData } `json:"data,omitempty"`
	Meta  struct{ Metadata }     `json:"meta,omitempty"`
	Links struct{ Links }        `json:"links,omitempty"`
}

type PasswordData

type PasswordData struct {
	ID         string `json:"id,omitempty"`
	Type       string `json:"type,omitempty"`
	Attributes struct {
		OrganizationID         int         `json:"organization-id,omitempty"`
		OrganizationName       string      `json:"organization-name,omitempty"`
		ResourceURL            string      `json:"resource-url,omitempty"`
		Restricted             bool        `json:"restricted,omitempty"`
		MyGlue                 bool        `json:"my-glue,omitempty"`
		Name                   string      `json:"name,omitempty"`
		AutofillSelectors      interface{} `json:"autofill-selectors,omitempty"`
		Username               string      `json:"username,omitempty"`
		URL                    string      `json:"url,omitempty"`
		Notes                  string      `json:"notes,omitempty"`
		PasswordUpdatedAt      *time.Time  `json:"password-updated-at,omitempty"`
		UpdatedBy              int         `json:"updated-by,omitempty"`
		UpdatedByType          string      `json:"updated-by-type,omitempty"`
		ResourceID             int         `json:"resource-id,omitempty"`
		CachedResourceTypeName string      `json:"cached-resource-type-name,omitempty"`
		CachedResourceName     string      `json:"cached-resource-name,omitempty"`
		PasswordCategoryID     int         `json:"password-category-id,omitempty"`
		PasswordCategoryName   string      `json:"password-category-name,omitempty"`
		CreatedAt              *time.Time  `json:"created-at,omitempty"`
		UpdatedAt              *time.Time  `json:"updated-at,omitempty"`
		OtpEnabled             bool        `json:"otp-enabled,omitempty"`
		PasswordFolderID       int         `json:"password-folder-id,omitempty"`
		ResourceType           string      `json:"resource-type,omitempty"`
		ParentURL              string      `json:"parent-url,omitempty"`
		VaultID                int         `json:"vault-id,omitempty"`
		Archived               bool        `json:"archived,omitempty"`
		Password               string      `json:"password,omitempty"`
	} `json:"attributes,omitempty"`
	Relationships struct {
	} `json:"relationships,omitempty"`
}

PasswordData struct, pointers to have omitempty work for time.Time

type PasswordList

type PasswordList struct {
	Data  []struct{ PasswordData } `json:"data,omitempty"`
	Meta  struct{ Metadata }       `json:"meta,omitempty"`
	Links struct{ Links }          `json:"links,omitempty"`
}

type Request

type Request struct {
	ITG          *ITGAPI
	RestAction   string
	Method       string     //GET, POST, DELETE, etc
	Body         []byte     //In a GET request, this is an instance of the struct that the expected json data is to be unmarshaled into
	URLValues    url.Values //Parameters sent to ITG for filtering by conditions that utilize strings
	RawURLValues string     //URL values must be a string.  Raw URL values allow an int to be used, for instance in a filter
	Page         int
	PageSize     int
}

func (*Request) Do

func (req *Request) Do() error

Do is a method of the Request struct which uses the data contained within the Request instance to perform an HTTP request to ConnectWise

type User

type User struct {
	Data  struct{ UserData } `json:"data"`
	Meta  struct{ Metadata } `json:"meta"`
	Links struct{ Links }    `json:"links"`
}

type UserData

type UserData struct {
	ID         string `json:"id"`
	Type       string `json:"type"`
	Attributes struct {
		FirstName            string      `json:"first-name"`
		LastName             string      `json:"last-name"`
		Name                 string      `json:"name"`
		RoleName             string      `json:"role-name"`
		Email                string      `json:"email"`
		InvitationSentAt     time.Time   `json:"invitation-sent-at"`
		InvitationAcceptedAt time.Time   `json:"invitation-accepted-at"`
		CurrentSignInAt      time.Time   `json:"current-sign-in-at"`
		CurrentSignInIP      string      `json:"current-sign-in-ip"`
		LastSignInAt         time.Time   `json:"last-sign-in-at"`
		LastSignInIP         string      `json:"last-sign-in-ip"`
		Reputation           int         `json:"reputation"`
		CreatedAt            time.Time   `json:"created-at"`
		UpdatedAt            time.Time   `json:"updated-at"`
		MyGlueAccountID      interface{} `json:"my-glue-account-id"`
		Avatar               string      `json:"avatar"`
		MyGlue               bool        `json:"my-glue"`
	} `json:"attributes"`
}

type UserList

type UserList struct {
	Data  []struct{ UserData } `json:"data"`
	Meta  struct{ Metadata }   `json:"meta"`
	Links struct{ Links }      `json:"links"`
}

type UserMetric

type UserMetric struct {
	Data  struct{ UserMetricData } `json:"data"`
	Meta  struct{ Metadata }       `json:"meta"`
	Links struct{ Links }          `json:"links"`
}

type UserMetricData

type UserMetricData struct {
	ID         string `json:"id"`
	Type       string `json:"type"`
	Attributes struct {
		UserID         int    `json:"user-id"`
		OrganizationID int    `json:"organization-id"`
		Created        int    `json:"created"`
		Viewed         int    `json:"viewed"`
		Edited         int    `json:"edited"`
		Deleted        int    `json:"deleted"`
		Date           string `json:"date"`
		ResourceType   string `json:"resource-type"`
	} `json:"attributes"`
}

type UserMetricList

type UserMetricList struct {
	Data  []struct{ UserMetricData } `json:"data"`
	Meta  struct{ Metadata }         `json:"meta"`
	Links struct{ Links }            `json:"links"`
}

Jump to

Keyboard shortcuts

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