autotask

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BaseZoneInfoURL is the URL to get zone information
	BaseZoneInfoURL = "https://webservices.autotask.net/atservicesrest/v1.0/ZoneInformation"

	// DefaultUserAgent is the default user agent for the client
	DefaultUserAgent = "Autotask Go Client"

	// APIVersion is the version of the Autotask API
	APIVersion = "v1.0"
)

Variables

This section is empty.

Functions

func AssertContains added in v1.1.1

func AssertContains(t *testing.T, haystack, needle string, message string)

AssertContains asserts that a string contains a substring

func AssertEqual added in v1.1.1

func AssertEqual(t *testing.T, expected, actual interface{}, message string)

AssertEqual asserts that two values are equal

func AssertFalse added in v1.1.1

func AssertFalse(t *testing.T, condition bool, message string)

AssertFalse asserts that a condition is false

func AssertLen added in v1.1.1

func AssertLen(t *testing.T, value interface{}, expected int, message string)

AssertLen asserts that a slice or map has the expected length

func AssertNil added in v1.1.1

func AssertNil(t *testing.T, value interface{}, message string)

AssertNil asserts that a value is nil

func AssertNotContains added in v1.1.1

func AssertNotContains(t *testing.T, haystack, needle string, message string)

AssertNotContains asserts that a string does not contain a substring

func AssertNotNil added in v1.1.1

func AssertNotNil(t *testing.T, value interface{}, message string)

AssertNotNil asserts that a value is not nil

func AssertTrue added in v1.1.1

func AssertTrue(t *testing.T, condition bool, message string)

AssertTrue asserts that a condition is true

func CreateMockEntities added in v1.1.1

func CreateMockEntities(count int, entityType string, startID int64) []interface{}

CreateMockEntities creates a list of mock entities

func CreateMockEntity added in v1.1.1

func CreateMockEntity(id int64, entityType string) map[string]interface{}

CreateMockEntity creates a mock entity with the given ID

func CreateMockListResponse added in v1.1.1

func CreateMockListResponse(items []interface{}, pageNumber, pageSize, totalCount int) map[string]interface{}

CreateMockListResponse creates a mock list response with the given items

func FetchAllPages added in v1.1.1

func FetchAllPages[T any](ctx context.Context, service EntityService, filter string) ([]T, error)

FetchAllPages is a convenience method to fetch all pages of results This is useful when you need all results and don't want to manually handle pagination

func FetchAllPagesWithCallback added in v1.1.1

func FetchAllPagesWithCallback[T any](
	ctx context.Context,
	service EntityService,
	filter string,
	callback func(items []T, pageDetails PageDetails) error,
) error

FetchAllPagesWithCallback is a convenience method to fetch all pages of results and process each page with a callback function This is useful for processing large result sets without keeping all items in memory

func IsRetryable

func IsRetryable(err error) bool

IsRetryable checks if an error should be retried

func ParseFilterString added in v1.1.0

func ParseFilterString(filterStr string) interface{}

ParseFilterString parses a filter string into a query filter or filter group Supports basic conditions and complex conditions with AND/OR operators Examples:

  • "Status=1"
  • "Status!=5"
  • "Name contains 'test'"
  • "Status=1 AND AssignedTo=123"
  • "Status=1 OR Status=2"
  • "Status=1 AND (AssignedTo=123 OR AssignedTo=456)"

func RetryWithBackoff

func RetryWithBackoff(ctx context.Context, config *RetryConfig, operation func() error) error

RetryWithBackoff implements exponential backoff with jitter

func WithRetry

func WithRetry(ctx context.Context, config *RetryConfig, operation func() error) error

WithRetry wraps an operation with retry logic

Types

type BaseEntityService

type BaseEntityService struct {
	Client     Client
	EntityName string
}

BaseEntityService is a base service that provides common functionality for all entity services.

func NewBaseEntityService

func NewBaseEntityService(client Client, entityName string) BaseEntityService

NewBaseEntityService creates a new base entity service

func (*BaseEntityService) BatchCreate

func (s *BaseEntityService) BatchCreate(ctx context.Context, entities []interface{}, result interface{}) error

BatchCreate creates multiple entities in a single request.

func (*BaseEntityService) BatchDelete

func (s *BaseEntityService) BatchDelete(ctx context.Context, ids []int64) error

BatchDelete deletes multiple entities in a single request.

func (*BaseEntityService) BatchUpdate

func (s *BaseEntityService) BatchUpdate(ctx context.Context, entities []interface{}, result interface{}) error

BatchUpdate updates multiple entities in a single request.

func (*BaseEntityService) Count

func (s *BaseEntityService) Count(ctx context.Context, filter string) (int, error)

Count counts entities matching a filter.

func (*BaseEntityService) Create

func (s *BaseEntityService) Create(ctx context.Context, entity interface{}) (interface{}, error)

Create creates a new entity.

func (*BaseEntityService) Delete

func (s *BaseEntityService) Delete(ctx context.Context, id int64) error

Delete deletes an entity by ID.

func (*BaseEntityService) Get

func (s *BaseEntityService) Get(ctx context.Context, id int64) (interface{}, error)

Get gets an entity by ID.

func (*BaseEntityService) GetClient added in v1.1.1

func (s *BaseEntityService) GetClient() Client

GetClient returns the client used by the service

func (*BaseEntityService) GetEntityName added in v1.1.1

func (s *BaseEntityService) GetEntityName() string

GetEntityName returns the name of the entity

func (*BaseEntityService) GetNextPage

func (s *BaseEntityService) GetNextPage(ctx context.Context, pageDetails PageDetails) ([]interface{}, error)

GetNextPage gets the next page of results

func (*BaseEntityService) GetPreviousPage

func (s *BaseEntityService) GetPreviousPage(ctx context.Context, pageDetails PageDetails) ([]interface{}, error)

GetPreviousPage gets the previous page of results

func (*BaseEntityService) Pagination

func (s *BaseEntityService) Pagination(ctx context.Context, url string, result interface{}) error

Pagination handles paginated results.

func (*BaseEntityService) Query

func (s *BaseEntityService) Query(ctx context.Context, filter string, result interface{}) error

Query queries entities with a filter.

func (*BaseEntityService) Update

func (s *BaseEntityService) Update(ctx context.Context, id int64, entity interface{}) (interface{}, error)

Update updates an existing entity.

type Client

type Client interface {
	// Companies returns the companies service
	Companies() CompaniesService

	// Tickets returns the tickets service
	Tickets() TicketsService

	// Contacts returns the contacts service
	Contacts() ContactsService

	// Resources returns the resources service
	Resources() ResourcesService

	// Webhooks returns the webhooks service
	Webhooks() WebhookService

	// Projects returns the projects service
	Projects() ProjectsService

	// Tasks returns the tasks service
	Tasks() TasksService

	// TimeEntries returns the time entries service
	TimeEntries() TimeEntriesService

	// Contracts returns the contracts service
	Contracts() ContractsService

	// ConfigurationItems returns the configuration items service
	ConfigurationItems() ConfigurationItemsService

	// SetLogLevel sets the logging level
	SetLogLevel(level LogLevel)

	// SetDebugMode enables or disables debug logging
	SetDebugMode(debug bool)

	// SetLogOutput sets the output writer for the logger
	SetLogOutput(output *os.File)

	// GetZoneInfo gets the zone information for the Autotask account
	GetZoneInfo() (*ZoneInfo, error)

	// NewRequest creates a new HTTP request
	NewRequest(ctx context.Context, method, url string, body interface{}) (*http.Request, error)

	// Do sends an HTTP request and returns the response
	Do(req *http.Request, v interface{}) (*http.Response, error)
}

Client represents the main interface for the Autotask API client

func NewClient

func NewClient(username, secret, integrationCode string) Client

NewClient returns a new Autotask API client

type CompaniesService

type CompaniesService interface {
	EntityService
}

CompaniesService represents the companies service interface

type Company

type Company struct {
	ID                      int64  `json:"id,omitempty"`
	CompanyName             string `json:"companyName,omitempty"`
	CompanyNumber           string `json:"companyNumber,omitempty"`
	Phone                   string `json:"phone,omitempty"`
	WebAddress              string `json:"webAddress,omitempty"`
	Active                  bool   `json:"active,omitempty"`
	Address1                string `json:"address1,omitempty"`
	Address2                string `json:"address2,omitempty"`
	City                    string `json:"city,omitempty"`
	State                   string `json:"state,omitempty"`
	PostalCode              string `json:"postalCode,omitempty"`
	Country                 string `json:"country,omitempty"`
	TerritoryID             int64  `json:"territoryID,omitempty"`
	AccountNumber           string `json:"accountNumber,omitempty"`
	TaxRegionID             int64  `json:"taxRegionID,omitempty"`
	ParentCompanyID         int64  `json:"parentCompanyID,omitempty"`
	CompanyType             int    `json:"companyType,omitempty"`
	BillToCompanyID         int64  `json:"billToCompanyID,omitempty"`
	BillToAddress1          string `json:"billToAddress1,omitempty"`
	BillToAddress2          string `json:"billToAddress2,omitempty"`
	BillToCity              string `json:"billToCity,omitempty"`
	BillToState             string `json:"billToState,omitempty"`
	BillToZipCode           string `json:"billToZipCode,omitempty"`
	BillToCountryID         int64  `json:"billToCountryID,omitempty"`
	BillToAttention         string `json:"billToAttention,omitempty"`
	BillToAddressToUse      int    `json:"billToAddressToUse,omitempty"`
	InvoiceMethod           int    `json:"invoiceMethod,omitempty"`
	InvoiceNonContractItems bool   `json:"invoiceNonContractItems,omitempty"`
	InvoiceTemplateID       int64  `json:"invoiceTemplateID,omitempty"`
	QuoteTemplateID         int64  `json:"quoteTemplateID,omitempty"`
	TaxID                   string `json:"taxID,omitempty"`
	TaxExempt               bool   `json:"taxExempt,omitempty"`
	CreatedDate             string `json:"createdDate,omitempty"`
	LastActivityDate        string `json:"lastActivityDate,omitempty"`
	DateStamp               string `json:"dateStamp,omitempty"`
}

Company represents an Autotask company

type CompanyListResponse

type CompanyListResponse struct {
	Items       []Company   `json:"items"`
	PageDetails PageDetails `json:"pageDetails,omitempty"`
}

type CompanyResponse

type CompanyResponse struct {
	Item Company `json:"item"`
}

Response types

type ConfigurationItem added in v1.1.0

type ConfigurationItem struct {
	ID                    int64  `json:"id,omitempty"`
	CompanyID             int64  `json:"companyID,omitempty"`
	ConfigurationItemType int    `json:"configurationItemType,omitempty"`
	ReferenceTitle        string `json:"referenceTitle,omitempty"`
	ReferenceNumber       string `json:"referenceNumber,omitempty"`
	SerialNumber          string `json:"serialNumber,omitempty"`
	InstallDate           string `json:"installDate,omitempty"`
	ProductID             int64  `json:"productID,omitempty"`
	Status                int    `json:"status,omitempty"`
	Location              string `json:"location,omitempty"`
	Active                bool   `json:"active,omitempty"`
	CreateDate            string `json:"createDate,omitempty"`
	LastModifiedDate      string `json:"lastModifiedDate,omitempty"`
}

ConfigurationItem represents a configuration item in Autotask

type ConfigurationItemListResponse added in v1.1.0

type ConfigurationItemListResponse struct {
	Items       []ConfigurationItem `json:"items"`
	PageDetails PageDetails         `json:"pageDetails,omitempty"`
}

type ConfigurationItemResponse added in v1.1.0

type ConfigurationItemResponse struct {
	Item ConfigurationItem `json:"item"`
}

type ConfigurationItemsService added in v1.1.0

type ConfigurationItemsService interface {
	EntityService
}

ConfigurationItemsService represents the configuration items service interface

type Contact

type Contact struct {
	ID               int64  `json:"id,omitempty"`
	FirstName        string `json:"firstName,omitempty"`
	LastName         string `json:"lastName,omitempty"`
	CompanyID        int64  `json:"companyID,omitempty"`
	Email            string `json:"emailAddress,omitempty"`
	Phone            string `json:"phone,omitempty"`
	MobilePhone      string `json:"mobilePhone,omitempty"`
	Title            string `json:"title,omitempty"`
	Active           bool   `json:"active,omitempty"`
	Address1         string `json:"address1,omitempty"`
	Address2         string `json:"address2,omitempty"`
	City             string `json:"city,omitempty"`
	State            string `json:"state,omitempty"`
	PostalCode       string `json:"postalCode,omitempty"`
	Country          string `json:"country,omitempty"`
	PrimaryContact   bool   `json:"isPrimaryContact,omitempty"`
	LastActivityDate string `json:"lastActivityDate,omitempty"`
	CreatedDate      string `json:"createDate,omitempty"`
}

Contact represents an Autotask contact

type ContactListResponse

type ContactListResponse struct {
	Items       []Contact   `json:"items"`
	PageDetails PageDetails `json:"pageDetails,omitempty"`
}

type ContactResponse

type ContactResponse struct {
	Item Contact `json:"item"`
}

type ContactsService

type ContactsService interface {
	EntityService
}

ContactsService represents the contacts service interface

type Contract added in v1.1.0

type Contract struct {
	ID                      int64   `json:"id,omitempty"`
	ContractName            string  `json:"contractName,omitempty"`
	ContractNumber          string  `json:"contractNumber,omitempty"`
	CompanyID               int64   `json:"companyID,omitempty"`
	Status                  int     `json:"status,omitempty"`
	ServiceLevelAgreementID int64   `json:"serviceLevelAgreementID,omitempty"`
	StartDate               string  `json:"startDate,omitempty"`
	EndDate                 string  `json:"endDate,omitempty"`
	ContractType            int     `json:"contractType,omitempty"`
	IsDefaultContract       bool    `json:"isDefaultContract,omitempty"`
	SetupFee                float64 `json:"setupFee,omitempty"`
	EstimatedHours          float64 `json:"estimatedHours,omitempty"`
	CreatorResourceID       int64   `json:"creatorResourceID,omitempty"`
	CreateDate              string  `json:"createDate,omitempty"`
	LastActivityDate        string  `json:"lastActivityDate,omitempty"`
}

Contract represents a contract in Autotask

type ContractListResponse added in v1.1.0

type ContractListResponse struct {
	Items       []Contract  `json:"items"`
	PageDetails PageDetails `json:"pageDetails,omitempty"`
}

type ContractResponse added in v1.1.0

type ContractResponse struct {
	Item Contract `json:"item"`
}

type ContractsService added in v1.1.0

type ContractsService interface {
	EntityService
}

ContractsService represents the contracts service interface

type EntityQueryParams

type EntityQueryParams struct {
	Filter        []interface{} `json:"filter,omitempty"` // Array of QueryFilter or FilterGroup
	Fields        []string      `json:"fields,omitempty"`
	MaxRecords    int           `json:"maxRecords,omitempty"`
	IncludeFields []string      `json:"includeFields,omitempty"`
	ExcludeFields []string      `json:"excludeFields,omitempty"`
	Page          int           `json:"page,omitempty"`
}

EntityQueryParams represents the parameters for a query request

func NewEntityQueryParams

func NewEntityQueryParams(filter interface{}) *EntityQueryParams

NewEntityQueryParams creates a new query parameters object with the given filter

func (*EntityQueryParams) BuildQueryString

func (p *EntityQueryParams) BuildQueryString() string

BuildQueryString builds the query string for the request

func (*EntityQueryParams) WithExcludeFields added in v1.1.0

func (p *EntityQueryParams) WithExcludeFields(fields ...string) *EntityQueryParams

WithExcludeFields adds fields to exclude from the response

func (*EntityQueryParams) WithFields

func (p *EntityQueryParams) WithFields(fields ...string) *EntityQueryParams

WithFields adds field selection to the query parameters

func (*EntityQueryParams) WithIncludeFields added in v1.1.0

func (p *EntityQueryParams) WithIncludeFields(fields ...string) *EntityQueryParams

WithIncludeFields adds fields to include in the response

func (*EntityQueryParams) WithMaxRecords

func (p *EntityQueryParams) WithMaxRecords(max int) *EntityQueryParams

WithMaxRecords sets the maximum number of records to return

func (*EntityQueryParams) WithPage added in v1.1.1

func (p *EntityQueryParams) WithPage(page int) *EntityQueryParams

WithPage adds page number to the query parameters

type EntityService

type EntityService interface {
	// Get retrieves an entity by ID
	Get(ctx context.Context, id int64) (interface{}, error)

	// Query retrieves entities matching the filter
	Query(ctx context.Context, filter string, result interface{}) error

	// Create creates a new entity
	Create(ctx context.Context, entity interface{}) (interface{}, error)

	// Update updates an existing entity
	Update(ctx context.Context, id int64, entity interface{}) (interface{}, error)

	// Delete deletes an entity
	Delete(ctx context.Context, id int64) error

	// Count returns the number of entities matching the filter
	Count(ctx context.Context, filter string) (int, error)

	// Pagination handles paginated results
	Pagination(ctx context.Context, url string, result interface{}) error

	// BatchCreate creates multiple entities in a single request
	BatchCreate(ctx context.Context, entities []interface{}, result interface{}) error

	// BatchUpdate updates multiple entities in a single request
	BatchUpdate(ctx context.Context, entities []interface{}, result interface{}) error

	// BatchDelete deletes multiple entities in a single request
	BatchDelete(ctx context.Context, ids []int64) error

	// GetNextPage gets the next page of results
	GetNextPage(ctx context.Context, pageDetails PageDetails) ([]interface{}, error)

	// GetPreviousPage gets the previous page of results
	GetPreviousPage(ctx context.Context, pageDetails PageDetails) ([]interface{}, error)

	// GetEntityName returns the name of the entity
	GetEntityName() string

	// GetClient returns the client used by the service
	GetClient() Client
}

EntityService represents the base interface for all entity services

type ErrorResponse

type ErrorResponse struct {
	Response *http.Response
	Message  string   `json:"Message"`
	Errors   []string `json:"errors"`
}

ErrorResponse represents an error response from the Autotask API

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

Error implements the error interface

type FilterGroup added in v1.1.0

type FilterGroup struct {
	Operator LogicalOperator `json:"op"`
	Items    []interface{}   `json:"items"` // Can contain QueryFilter or nested FilterGroup
}

FilterGroup represents a group of filters with a logical operator

func NewAndFilterGroup added in v1.1.0

func NewAndFilterGroup(items ...interface{}) FilterGroup

NewAndFilterGroup creates a new filter group with AND logic

func NewOrFilterGroup added in v1.1.0

func NewOrFilterGroup(items ...interface{}) FilterGroup

NewOrFilterGroup creates a new filter group with OR logic

type ListResponse

type ListResponse struct {
	Items       []interface{} `json:"items"`
	PageDetails PageDetails   `json:"pageDetails,omitempty"`
}

ListResponse represents a generic list response from the Autotask API.

type LogLevel

type LogLevel int

LogLevel represents the logging level

const (
	LogLevelDebug LogLevel = iota
	LogLevelInfo
	LogLevelWarn
	LogLevelError
)

type Logger

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

Logger handles logging for the Autotask client

func New

func New(level LogLevel, debugMode bool) *Logger

New creates a new logger

func (*Logger) Debug

func (l *Logger) Debug(msg string, fields map[string]interface{})

Debug logs a debug message

func (*Logger) Error

func (l *Logger) Error(msg string, fields map[string]interface{})

Error logs an error message

func (*Logger) Info

func (l *Logger) Info(msg string, fields map[string]interface{})

Info logs an info message

func (*Logger) LogError

func (l *Logger) LogError(err error)

LogError logs an error

func (*Logger) LogRequest

func (l *Logger) LogRequest(method, url string, headers map[string]string)

LogRequest logs an HTTP request

func (*Logger) LogResponse

func (l *Logger) LogResponse(statusCode int, headers map[string]string)

LogResponse logs an HTTP response

func (*Logger) SetDebugMode

func (l *Logger) SetDebugMode(debug bool)

SetDebugMode enables or disables debug logging

func (*Logger) SetLevel

func (l *Logger) SetLevel(level LogLevel)

SetLevel sets the logging level

func (*Logger) SetOutput

func (l *Logger) SetOutput(output io.Writer)

SetOutput sets the output writer for the logger

func (*Logger) Warn

func (l *Logger) Warn(msg string, fields map[string]interface{})

Warn logs a warning message

type LogicalOperator added in v1.1.0

type LogicalOperator string

LogicalOperator represents the type of logical operation (AND, OR)

const (
	LogicalOperatorAnd LogicalOperator = "and"
	LogicalOperatorOr  LogicalOperator = "or"
)

type MockResponse added in v1.1.1

type MockResponse struct {
	StatusCode int
	Body       interface{}
	Headers    map[string]string
}

MockResponse represents a mock API response

type MockServer added in v1.1.1

type MockServer struct {
	Server           *httptest.Server
	Mux              *http.ServeMux
	ResponseHandlers map[string]func(w http.ResponseWriter, r *http.Request)
	Requests         []*http.Request
	RequestBodies    [][]byte
	// contains filtered or unexported fields
}

MockServer represents a mock Autotask API server for testing

func NewMockServer added in v1.1.1

func NewMockServer(t *testing.T) *MockServer

NewMockServer creates a new mock Autotask API server

func (*MockServer) AddHandler added in v1.1.1

func (m *MockServer) AddHandler(path string, handler func(w http.ResponseWriter, r *http.Request))

AddHandler adds a response handler for a specific path

func (*MockServer) Close added in v1.1.1

func (m *MockServer) Close()

Close closes the mock server

func (*MockServer) GetLastRequest added in v1.1.1

func (m *MockServer) GetLastRequest() *http.Request

GetLastRequest returns the last request made to the mock server

func (*MockServer) GetLastRequestBody added in v1.1.1

func (m *MockServer) GetLastRequestBody() []byte

GetLastRequestBody returns the body of the last request made to the mock server

func (*MockServer) NewTestClient added in v1.1.1

func (m *MockServer) NewTestClient() Client

NewTestClient creates a new client that uses the mock server

func (*MockServer) RespondWithError added in v1.1.1

func (m *MockServer) RespondWithError(w http.ResponseWriter, statusCode int, message string, errors []string)

RespondWithError sends an error response with the given status code and message

func (*MockServer) RespondWithJSON added in v1.1.1

func (m *MockServer) RespondWithJSON(w http.ResponseWriter, statusCode int, body interface{})

RespondWithJSON sends a JSON response with the given status code and body

type PageDetails

type PageDetails struct {
	PageNumber  int    `json:"pageNumber"`
	PageSize    int    `json:"pageSize"`
	Count       int    `json:"count"`
	NextPageUrl string `json:"nextPageUrl"`
	PrevPageUrl string `json:"prevPageUrl"`
}

PageDetails represents pagination information

type PaginatedResults added in v1.1.1

type PaginatedResults[T any] struct {
	Items       []T         `json:"items"`
	PageDetails PageDetails `json:"pageDetails"`
}

PaginatedResults is a generic structure for paginated results

func FetchPage added in v1.1.1

func FetchPage[T any](
	ctx context.Context,
	service EntityService,
	filter string,
	options PaginationOptions,
) (*PaginatedResults[T], error)

FetchPage is a convenience method to fetch a specific page of results Note: According to Autotask API documentation, you should use the pagination URLs provided in the response rather than manually constructing page requests. This method is provided for convenience but may not work as expected for all cases.

type PaginationIterator added in v1.1.1

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

PaginationIterator provides an iterator pattern for paginated results

func NewPaginationIterator added in v1.1.1

func NewPaginationIterator(ctx context.Context, service EntityService, filter string, pageSize int) (*PaginationIterator, error)

NewPaginationIterator creates a new pagination iterator

func (*PaginationIterator) CurrentPage added in v1.1.1

func (p *PaginationIterator) CurrentPage() int

CurrentPage returns the current page number

func (*PaginationIterator) Error added in v1.1.1

func (p *PaginationIterator) Error() error

Error returns any error that occurred during iteration

func (*PaginationIterator) Item added in v1.1.1

func (p *PaginationIterator) Item() interface{}

Item returns the current item

func (*PaginationIterator) Next added in v1.1.1

func (p *PaginationIterator) Next() bool

Next advances the iterator to the next item Returns false when there are no more items

func (*PaginationIterator) TotalCount added in v1.1.1

func (p *PaginationIterator) TotalCount() int

TotalCount returns the total number of items across all pages

type PaginationOptions added in v1.1.1

type PaginationOptions struct {
	PageSize int
	Page     int
}

PaginationOptions contains options for pagination

func DefaultPaginationOptions added in v1.1.1

func DefaultPaginationOptions() PaginationOptions

DefaultPaginationOptions returns default pagination options

type Project added in v1.1.0

type Project struct {
	ID                    int64   `json:"id,omitempty"`
	ProjectName           string  `json:"projectName,omitempty"`
	Description           string  `json:"description,omitempty"`
	CompanyID             int64   `json:"companyID,omitempty"`
	Status                int     `json:"status,omitempty"`
	ProjectNumber         string  `json:"projectNumber,omitempty"`
	Type                  int     `json:"type,omitempty"`
	StartDate             string  `json:"startDate,omitempty"`
	EndDate               string  `json:"endDate,omitempty"`
	EstimatedHours        float64 `json:"estimatedHours,omitempty"`
	ProjectLeadResourceID int64   `json:"projectLeadResourceID,omitempty"`
	CompletedPercentage   float64 `json:"completedPercentage,omitempty"`
	DepartmentID          int64   `json:"departmentID,omitempty"`
	ContractID            int64   `json:"contractID,omitempty"`
	CreatorResourceID     int64   `json:"creatorResourceID,omitempty"`
	CreateDate            string  `json:"createDate,omitempty"`
	LastActivityDate      string  `json:"lastActivityDate,omitempty"`
}

Project represents a project in Autotask

type ProjectListResponse added in v1.1.0

type ProjectListResponse struct {
	Items       []Project   `json:"items"`
	PageDetails PageDetails `json:"pageDetails,omitempty"`
}

type ProjectResponse added in v1.1.0

type ProjectResponse struct {
	Item Project `json:"item"`
}

type ProjectsService added in v1.1.0

type ProjectsService interface {
	EntityService
}

ProjectsService represents the projects service interface

type QueryFilter

type QueryFilter struct {
	Field    string        `json:"field,omitempty"`
	Operator QueryOperator `json:"op,omitempty"`
	Value    interface{}   `json:"value,omitempty"`
}

QueryFilter represents a single filter condition

func NewQueryFilter

func NewQueryFilter(field string, operator QueryOperator, value interface{}) QueryFilter

NewQueryFilter creates a new query filter with the given parameters

type QueryOperator

type QueryOperator string

QueryOperator represents the type of query operation

const (
	OperatorEquals         QueryOperator = "eq"
	OperatorNotEquals      QueryOperator = "noteq"
	OperatorBeginsWith     QueryOperator = "beginsWith"
	OperatorEndsWith       QueryOperator = "endsWith"
	OperatorContains       QueryOperator = "contains"
	OperatorNotContains    QueryOperator = "notContains"
	OperatorGreaterThan    QueryOperator = "greaterThan"
	OperatorLessThan       QueryOperator = "lessThan"
	OperatorGreaterOrEqual QueryOperator = "greaterOrEqual"
	OperatorLessOrEqual    QueryOperator = "lessOrEqual"
	OperatorIn             QueryOperator = "in"
	OperatorNotIn          QueryOperator = "notIn"
	OperatorIsNull         QueryOperator = "isNull"
	OperatorIsNotNull      QueryOperator = "isNotNull"
)

type RateLimiter

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

RateLimiter handles API rate limiting

func NewRateLimiter

func NewRateLimiter(requestsPerMinute int) *RateLimiter

NewRateLimiter creates a new rate limiter

func (*RateLimiter) Wait

func (r *RateLimiter) Wait() time.Duration

Wait waits if necessary to respect rate limits

type Resource

type Resource struct {
	ID        int64  `json:"id"`
	FirstName string `json:"firstName"`
	LastName  string `json:"lastName"`
	Email     string `json:"email"`
	Active    bool   `json:"active"`
}

Resource represents a resource in Autotask

type ResourcesService

type ResourcesService interface {
	EntityService
}

ResourcesService represents the resources service interface

type Response

type Response struct {
	Item interface{} `json:"item"`
}

Response represents a generic response from the Autotask API.

type RetryConfig

type RetryConfig struct {
	MaxRetries      int
	InitialInterval time.Duration
	MaxInterval     time.Duration
	Multiplier      float64
	Jitter          float64
}

RetryConfig configures retry behavior

func DefaultRetryConfig

func DefaultRetryConfig() *RetryConfig

DefaultRetryConfig returns a default retry configuration

type RetryableError

type RetryableError struct {
	Err      error
	Response *http.Response
}

RetryableError represents an error that can be retried

func (*RetryableError) Error

func (e *RetryableError) Error() string

func (*RetryableError) Unwrap

func (e *RetryableError) Unwrap() error

Unwrap returns the underlying error

type Task added in v1.1.0

type Task struct {
	ID                 int64   `json:"id,omitempty"`
	TaskNumber         string  `json:"taskNumber,omitempty"`
	Title              string  `json:"title,omitempty"`
	Description        string  `json:"description,omitempty"`
	Status             int     `json:"status,omitempty"`
	Priority           int     `json:"priority,omitempty"`
	ProjectID          int64   `json:"projectID,omitempty"`
	AssignedResourceID int64   `json:"assignedResourceID,omitempty"`
	StartDate          string  `json:"startDate,omitempty"`
	EndDate            string  `json:"endDate,omitempty"`
	EstimatedHours     float64 `json:"estimatedHours,omitempty"`
	RemainingHours     float64 `json:"remainingHours,omitempty"`
	CompletedDate      string  `json:"completedDate,omitempty"`
	CreateDate         string  `json:"createDate,omitempty"`
	LastActivityDate   string  `json:"lastActivityDate,omitempty"`
	PhaseID            int64   `json:"phaseID,omitempty"`
	TaskType           int     `json:"taskType,omitempty"`
	CreatorResourceID  int64   `json:"creatorResourceID,omitempty"`
}

Task represents a task in Autotask

type TaskListResponse added in v1.1.0

type TaskListResponse struct {
	Items       []Task      `json:"items"`
	PageDetails PageDetails `json:"pageDetails,omitempty"`
}

type TaskResponse added in v1.1.0

type TaskResponse struct {
	Item Task `json:"item"`
}

type TasksService added in v1.1.0

type TasksService interface {
	EntityService
}

TasksService represents the tasks service interface

type Ticket

type Ticket struct {
	ID                      int64  `json:"id,omitempty"`
	TicketNumber            string `json:"ticketNumber,omitempty"`
	Title                   string `json:"title,omitempty"`
	Description             string `json:"description,omitempty"`
	Status                  int    `json:"status,omitempty"`
	Priority                int    `json:"priority,omitempty"`
	DueDateTime             string `json:"dueDateTime,omitempty"`
	CreateDate              string `json:"createDate,omitempty"`
	LastActivityDate        string `json:"lastActivityDate,omitempty"`
	CompanyID               int64  `json:"companyID,omitempty"`
	ContactID               int64  `json:"contactID,omitempty"`
	AccountID               int64  `json:"accountID,omitempty"`
	QueueID                 int64  `json:"queueID,omitempty"`
	AssignedResourceID      int64  `json:"assignedResourceID,omitempty"`
	AssignedResourceRoleID  int64  `json:"assignedResourceRoleID,omitempty"`
	TicketType              int    `json:"ticketType,omitempty"`
	IssueType               int    `json:"issueType,omitempty"`
	SubIssueType            int    `json:"subIssueType,omitempty"`
	ServiceLevelAgreementID int64  `json:"serviceLevelAgreementID,omitempty"`
	Source                  int    `json:"source,omitempty"`
	CreatorResourceID       int64  `json:"creatorResourceID,omitempty"`
	CompletedDate           string `json:"completedDate,omitempty"`
}

Ticket represents an Autotask ticket

type TicketListResponse

type TicketListResponse struct {
	Items       []Ticket    `json:"items"`
	PageDetails PageDetails `json:"pageDetails,omitempty"`
}

type TicketResponse

type TicketResponse struct {
	Item Ticket `json:"item"`
}

type TicketsService

type TicketsService interface {
	EntityService
}

TicketsService represents the tickets service interface

type TimeEntriesService added in v1.1.0

type TimeEntriesService interface {
	EntityService
}

TimeEntriesService represents the time entries service interface

type TimeEntry added in v1.1.0

type TimeEntry struct {
	ID               int64   `json:"id,omitempty"`
	ResourceID       int64   `json:"resourceID,omitempty"`
	TicketID         int64   `json:"ticketID,omitempty"`
	TaskID           int64   `json:"taskID,omitempty"`
	Type             int     `json:"type,omitempty"`
	DateWorked       string  `json:"dateWorked,omitempty"`
	StartDateTime    string  `json:"startDateTime,omitempty"`
	EndDateTime      string  `json:"endDateTime,omitempty"`
	HoursWorked      float64 `json:"hoursWorked,omitempty"`
	HoursToBill      float64 `json:"hoursToBill,omitempty"`
	SummaryNotes     string  `json:"summaryNotes,omitempty"`
	InternalNotes    string  `json:"internalNotes,omitempty"`
	NonBillable      bool    `json:"nonBillable,omitempty"`
	CreateDate       string  `json:"createDate,omitempty"`
	LastModifiedDate string  `json:"lastModifiedDate,omitempty"`
}

TimeEntry represents a time entry in Autotask

type TimeEntryListResponse added in v1.1.0

type TimeEntryListResponse struct {
	Items       []TimeEntry `json:"items"`
	PageDetails PageDetails `json:"pageDetails,omitempty"`
}

type TimeEntryResponse added in v1.1.0

type TimeEntryResponse struct {
	Item TimeEntry `json:"item"`
}

type WebhookEvent

type WebhookEvent struct {
	EventType string          `json:"eventType"`
	Entity    string          `json:"entity"`
	EntityID  int64           `json:"entityId"`
	Timestamp string          `json:"timestamp"`
	Data      json.RawMessage `json:"data"`
}

WebhookEvent represents a webhook event from Autotask

type WebhookHandler

type WebhookHandler func(event *WebhookEvent) error

WebhookHandler is a function type that handles webhook events

type WebhookService

type WebhookService interface {
	EntityService
	RegisterHandler(eventType string, handler WebhookHandler)
	HandleWebhook(w http.ResponseWriter, r *http.Request)
	CreateWebhook(ctx context.Context, url string, events []string) error
	DeleteWebhook(ctx context.Context, id int64) error
	ListWebhooks(ctx context.Context) ([]interface{}, error)
	SetWebhookSecret(secret string)
}

WebhookService represents the webhook service interface

type ZoneInfo

type ZoneInfo struct {
	ZoneName string `json:"zoneName"`
	URL      string `json:"url"`
	WebURL   string `json:"webUrl"`
	CI       int    `json:"ci"`
}

ZoneInfo represents the zone information for an Autotask account

Jump to

Keyboard shortcuts

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