Documentation ¶
Index ¶
- Constants
- Variables
- func ConvertPageToken(token string) (int, error)
- func ConvertVariableToSchemaCustomField(ctx context.Context, variable *CatalogItemVariable) (*v2.TicketCustomField, error)
- func GenerateURL(baseURL string, params URLParams) (string, error)
- type BaseResource
- type Catalog
- type CatalogItem
- type CatalogItemResponse
- type CatalogItemVariable
- type CatalogItemVariablesResponse
- type CatalogItemsResponse
- type CatalogsResponse
- type CategoriesResponse
- type Category
- type Choice
- type Client
- func (c *Client) AddLabelToRequest(ctx context.Context, requestedItemId string, label string) (*BaseResource, error)
- func (c *Client) AddLabelsToRequest(ctx context.Context, requestedItemId string, labels []string) error
- func (c *Client) AddUserToGroup(ctx context.Context, record GroupMemberPayload) error
- func (c *Client) CreateLabel(ctx context.Context, label string) (*Label, error)
- func (c *Client) CreateServiceCatalogRequest(ctx context.Context, catalogItemId string, payload *OrderItemPayload) (*RequestedItem, error)
- func (c *Client) GetBaseURL() string
- func (c *Client) GetCatalogItem(ctx context.Context, catalogItemId string) (*CatalogItem, error)
- func (c *Client) GetCatalogItemVariables(ctx context.Context, catalogItemId string) ([]CatalogItemVariable, error)
- func (c *Client) GetCatalogItems(ctx context.Context, paginationVars *PaginationVars) ([]CatalogItem, string, error)
- func (c *Client) GetCatalogs(ctx context.Context, paginationVars PaginationVars) ([]Catalog, string, error)
- func (c *Client) GetGroup(ctx context.Context, groupId string) (*Group, error)
- func (c *Client) GetGroupToRole(ctx context.Context, groupId string, roleId string, ...) ([]GroupToRole, string, error)
- func (c *Client) GetGroups(ctx context.Context, paginationVars PaginationVars, groupIDs []string) ([]Group, string, error)
- func (c *Client) GetLabel(ctx context.Context, label string) (*Label, error)
- func (c *Client) GetLabelsForRequestedItem(ctx context.Context, requestedItemId string) ([]string, error)
- func (c *Client) GetRoles(ctx context.Context, paginationVars PaginationVars) ([]Role, string, error)
- func (c *Client) GetServiceCatalogRequest(ctx context.Context, requestId string) (*ServiceCatalogRequest, error)
- func (c *Client) GetServiceCatalogRequestItem(ctx context.Context, requestItemId string) (*RequestedItem, error)
- func (c *Client) GetServiceCatalogRequestItems(ctx context.Context, reqOptions ...ReqOpt) ([]RequestedItem, string, error)
- func (c *Client) GetServiceCatalogRequestedItemForRequest(ctx context.Context, serviceCatalogRequestId string) (*RequestedItem, error)
- func (c *Client) GetServiceCatalogRequestedItemStates(ctx context.Context) ([]RequestItemState, error)
- func (c *Client) GetUser(ctx context.Context, userId string) (*User, error)
- func (c *Client) GetUserToGroup(ctx context.Context, userId string, groupId string, ...) ([]GroupMember, string, error)
- func (c *Client) GetUserToRole(ctx context.Context, userId string, roleId string, ...) ([]UserToRole, string, error)
- func (c *Client) GetUsers(ctx context.Context, paginationVars PaginationVars, userIDs []string) ([]User, string, error)
- func (c *Client) GrantRoleToGroup(ctx context.Context, record GroupToRolePayload) error
- func (c *Client) GrantRoleToUser(ctx context.Context, record UserToRolePayload) error
- func (c *Client) OrderItemNow(ctx context.Context, catalogItemId string, payload *OrderItemPayload) (*RequestInfo, error)
- func (c *Client) RemoveUserFromGroup(ctx context.Context, id string) error
- func (c *Client) RevokeRoleFromGroup(ctx context.Context, id string) error
- func (c *Client) RevokeRoleFromUser(ctx context.Context, id string) error
- func (c *Client) UpdateServiceCatalogRequestItem(ctx context.Context, requestItemId string, payload *RequestedItemUpdatePayload) (*RequestedItem, error)
- type FieldOption
- type FilterVars
- type Group
- type GroupMember
- type GroupMemberPayload
- type GroupMembersResponse
- type GroupResponse
- type GroupToRole
- type GroupToRolePayload
- type GroupToRoleResponse
- type GroupsResponse
- type IDResponse
- type Label
- type LabelEntriesLabelNameResponse
- type LabelEntryName
- type LabelEntryPayload
- type LabelResponse
- type LabelsResponse
- type ListResponse
- type OrderCatalogItemResponse
- type OrderItemPayload
- type PaginationVars
- type ReqOpt
- func WithFields(fields ...string) ReqOpt
- func WithHeader(key string, val string) ReqOpt
- func WithIncludeExternalRefLink() ReqOpt
- func WithIncludeResponseBody() ReqOpt
- func WithOffset(offset int) ReqOpt
- func WithPageLimit(pageLimit int) ReqOpt
- func WithQuery(query string) ReqOpt
- func WithQueryParam(key string, value string) ReqOpt
- type RequestInfo
- type RequestItemResponse
- type RequestItemState
- type RequestItemsResponse
- type RequestedItem
- type RequestedItemStateResponse
- type RequestedItemUpdatePayload
- type ResourceRefLink
- type Role
- type RolesResponse
- type ServiceCatalogRequest
- type ServiceCatalogRequestResponse
- type SingleResponse
- type SubCategory
- type URLParams
- type User
- type UserResponse
- type UserRoles
- type UserRolesResponse
- type UserToRole
- type UserToRolePayload
- type UserToRoleResponse
- type UsersResponse
- type VariableType
- type VariableTypeNew
Constants ¶
View Source
const ( BaseURL = "https://%s.service-now.com/api" TableAPIBaseURL = BaseURL + "/now/table" GlobalApiBaseURL = BaseURL + "/global" UsersBaseUrl = TableAPIBaseURL + "/sys_user" UserBaseUrl = UsersBaseUrl + "/%s" GroupsBaseUrl = TableAPIBaseURL + "/sys_user_group" GroupBaseUrl = GroupsBaseUrl + "/%s" GroupMembersBaseUrl = TableAPIBaseURL + "/sys_user_grmember" GroupMemberDetailBaseUrl = GroupMembersBaseUrl + "/%s" RolesBaseUrl = TableAPIBaseURL + "/sys_user_role" UserRolesBaseUrl = TableAPIBaseURL + "/sys_user_has_role" UserRoleDetailBaseUrl = UserRolesBaseUrl + "/%s" GroupRolesBaseUrl = TableAPIBaseURL + "/sys_group_has_role" GroupRoleDetailBaseUrl = GroupRolesBaseUrl + "/%s" UserRoleInheritanceBaseUrl = GlobalApiBaseURL + "/user_role_inheritance" // Service Catalogs. ServiceCatalogRequestedItemBaseUrl = TableAPIBaseURL + "/sc_req_item" ServiceCatalogRequestedItemDetailsBaseUrl = ServiceCatalogRequestedItemBaseUrl + "/%s" ServiceCatalogRequestBaseUrl = TableAPIBaseURL + "/sc_request" ServiceCatalogRequestDetailsBaseUrl = ServiceCatalogRequestBaseUrl + "/%s" ServiceCatalogBaseUrl = BaseURL + "/sn_sc/servicecatalog" ServiceCatalogListCatalogsUrl = ServiceCatalogBaseUrl + "/catalogs" ServiceCatalogGetCatalogUrl = ServiceCatalogListCatalogsUrl + "/%s" ServiceCatalogCategoryBaseUrl = ServiceCatalogGetCatalogUrl + "/categories" ServiceCatalogCategoryDetailBaseUrl = ServiceCatalogCategoryBaseUrl + "/%s" ServiceCatalogItemBaseUrl = ServiceCatalogBaseUrl + "/items" ServiceCatalogItemGetUrl = ServiceCatalogItemBaseUrl + "/%s" ServiceCatalogItemVariablesUrl = ServiceCatalogItemGetUrl + "/variables" ServiceCatalogOrderItemUrl = ServiceCatalogItemGetUrl + "/order_now" LabelBaseUrl = TableAPIBaseURL + "/label" LabelEntryBaseUrl = TableAPIBaseURL + "/label_entry" // To get possible states for service catalog requested item. ChoiceBaseUrl = TableAPIBaseURL + "/sys_choice" InstanceURLTemplate = `{{.Deployment}}.service-now.com` )
Variables ¶
View Source
var ( UserFields = []string{"sys_id", "name", "roles", "user_name", "email", "first_name", "last_name", "active"} RoleFields = []string{"sys_id", "grantable", "name"} GroupFields = []string{"sys_id", "description", "name"} )
View Source
var LabelNotFoundErr = errors.New("label not found")
Functions ¶
func ConvertPageToken ¶ added in v0.0.7
func ConvertVariableToSchemaCustomField ¶ added in v0.0.4
func ConvertVariableToSchemaCustomField(ctx context.Context, variable *CatalogItemVariable) (*v2.TicketCustomField, error)
TODO(lauren) add validation?
Types ¶
type BaseResource ¶
type BaseResource struct {
Id string `json:"sys_id"`
}
type Catalog ¶ added in v0.0.4
type Catalog struct { BaseResource Title string `json:"title"` HasCategories bool `json:"has_categories,omitempty"` HasItems bool `json:"has_items,omitempty"` Description string `json:"description,omitempty"` }
type CatalogItem ¶ added in v0.0.4
type CatalogItem struct { BaseResource Catalogs []Catalog `json:"catalogs"` Category Category `json:"category,omitempty"` Description string `json:"description"` Name string `json:"name"` ShortDescription string `json:"short_description"` SysClassName string `json:"sys_class_name"` Type string `json:"type"` Variables []CatalogItemVariable `json:"variables,omitempty"` }
type CatalogItemResponse ¶ added in v0.0.4
type CatalogItemResponse = SingleResponse[CatalogItem]
type CatalogItemVariable ¶ added in v0.0.4
type CatalogItemVariable struct { Active bool `json:"active"` Label string `json:"label"` DynamicValueField string `json:"dynamic_value_field"` Type VariableTypeNew `json:"type"` Mandatory bool `json:"mandatory"` DisplayValue string `json:"displayvalue"` FriendlyType string `json:"friendly_type"` DisplayType string `json:"display_type"` RenderLabel bool `json:"render_label"` ReadOnly bool `json:"read_only"` Name string `json:"name"` Attributes string `json:"attributes"` ID string `json:"id"` Choices []Choice `json:"choices"` Value string `json:"value"` DynamicValueDotWalkPath string `json:"dynamic_value_dot_walk_path"` HelpText string `json:"help_text"` Order int `json:"order"` Reference string `json:"reference"` RefQualifier string `json:"ref_qualifier"` }
type CatalogItemVariablesResponse ¶ added in v0.0.4
type CatalogItemVariablesResponse = ListResponse[CatalogItemVariable]
type CatalogItemsResponse ¶ added in v0.0.4
type CatalogItemsResponse = ListResponse[CatalogItem]
type CatalogsResponse ¶ added in v0.0.4
type CatalogsResponse = ListResponse[Catalog]
type CategoriesResponse ¶ added in v0.0.4
type CategoriesResponse = ListResponse[Category]
type Category ¶ added in v0.0.4
type Category struct { BaseResource Title string `json:"title"` Description string `json:"description,omitempty"` FullDescription string `json:"full_description,omitempty"` ItemCount int `json:"count,omitempty"` Subcategories []SubCategory `json:"subcategories,omitempty"` }
type Client ¶
type Client struct { TicketSchemaFilters map[string]string // contains filtered or unexported fields }
func (*Client) AddLabelToRequest ¶ added in v0.0.4
func (*Client) AddLabelsToRequest ¶ added in v0.0.4
func (*Client) AddUserToGroup ¶
func (c *Client) AddUserToGroup(ctx context.Context, record GroupMemberPayload) error
func (*Client) CreateLabel ¶ added in v0.0.4
Create label will return an error if it already exists. First fetch the label to check if it already exists.
func (*Client) CreateServiceCatalogRequest ¶ added in v0.0.4
func (c *Client) CreateServiceCatalogRequest(ctx context.Context, catalogItemId string, payload *OrderItemPayload) (*RequestedItem, error)
Creating a service catalog request requires: 1. Add catalog item to cart (with all required variables). 2. Submit cart order.
func (*Client) GetBaseURL ¶ added in v0.0.4
func (*Client) GetCatalogItem ¶ added in v0.0.4
func (*Client) GetCatalogItemVariables ¶ added in v0.0.4
func (*Client) GetCatalogItems ¶ added in v0.0.4
func (c *Client) GetCatalogItems(ctx context.Context, paginationVars *PaginationVars) ([]CatalogItem, string, error)
func (*Client) GetCatalogs ¶ added in v0.0.4
func (c *Client) GetCatalogs(ctx context.Context, paginationVars PaginationVars) ([]Catalog, string, error)
Unused.
func (*Client) GetGroupToRole ¶
func (c *Client) GetGroupToRole(ctx context.Context, groupId string, roleId string, paginationVars PaginationVars) ([]GroupToRole, string, error)
Table `sys_group_has_role` (Group to Role).
func (*Client) GetGroups ¶
func (c *Client) GetGroups(ctx context.Context, paginationVars PaginationVars, groupIDs []string) ([]Group, string, error)
Table `sys_user_group` (Groups).
func (*Client) GetLabelsForRequestedItem ¶ added in v0.0.4
func (*Client) GetRoles ¶
func (c *Client) GetRoles(ctx context.Context, paginationVars PaginationVars) ([]Role, string, error)
Table `sys_user_role` (Roles).
func (*Client) GetServiceCatalogRequest ¶ added in v0.0.4
func (*Client) GetServiceCatalogRequestItem ¶ added in v0.0.4
func (*Client) GetServiceCatalogRequestItems ¶ added in v0.0.4
func (*Client) GetServiceCatalogRequestedItemForRequest ¶ added in v0.0.4
func (*Client) GetServiceCatalogRequestedItemStates ¶ added in v0.0.4
func (c *Client) GetServiceCatalogRequestedItemStates(ctx context.Context) ([]RequestItemState, error)
func (*Client) GetUserToGroup ¶
func (c *Client) GetUserToGroup(ctx context.Context, userId string, groupId string, paginationVars PaginationVars) ([]GroupMember, string, error)
Table `sys_user_grmember` (Group Members).
func (*Client) GetUserToRole ¶
func (c *Client) GetUserToRole(ctx context.Context, userId string, roleId string, paginationVars PaginationVars) ([]UserToRole, string, error)
Table `sys_user_has_role` (User to Role).
func (*Client) GetUsers ¶
func (c *Client) GetUsers(ctx context.Context, paginationVars PaginationVars, userIDs []string) ([]User, string, error)
Table `sys_user` (Users).
func (*Client) GrantRoleToGroup ¶
func (c *Client) GrantRoleToGroup(ctx context.Context, record GroupToRolePayload) error
func (*Client) GrantRoleToUser ¶
func (c *Client) GrantRoleToUser(ctx context.Context, record UserToRolePayload) error
func (*Client) OrderItemNow ¶ added in v0.0.4
func (c *Client) OrderItemNow(ctx context.Context, catalogItemId string, payload *OrderItemPayload) (*RequestInfo, error)
func (*Client) RemoveUserFromGroup ¶
func (*Client) RevokeRoleFromGroup ¶
func (*Client) RevokeRoleFromUser ¶
func (*Client) UpdateServiceCatalogRequestItem ¶ added in v0.0.5
func (c *Client) UpdateServiceCatalogRequestItem(ctx context.Context, requestItemId string, payload *RequestedItemUpdatePayload) (*RequestedItem, error)
type FieldOption ¶ added in v0.0.4
type FieldOption func(catalogItemRequestPayload *OrderItemPayload)
func WithCustomField ¶ added in v0.0.4
func WithCustomField(id string, value interface{}) FieldOption
type FilterVars ¶
type Group ¶
type Group struct { BaseResource Name string `json:"name"` Description string `json:"description"` Roles string `json:"roles"` }
type GroupMember ¶
type GroupMember struct { BaseResource User string `json:"user"` Group string `json:"group"` }
type GroupMemberPayload ¶
type GroupMembersResponse ¶
type GroupMembersResponse = ListResponse[GroupMember]
type GroupResponse ¶
type GroupResponse = SingleResponse[Group]
type GroupToRole ¶
type GroupToRole struct { BaseResource Inherits string `json:"inherits"` Group string `json:"group"` Role string `json:"role"` }
type GroupToRolePayload ¶
type GroupToRoleResponse ¶
type GroupToRoleResponse ListResponse[GroupToRole]
type GroupsResponse ¶
type GroupsResponse = ListResponse[Group]
type IDResponse ¶ added in v0.0.4
type IDResponse = SingleResponse[BaseResource]
type LabelEntriesLabelNameResponse ¶ added in v0.0.4
type LabelEntriesLabelNameResponse = ListResponse[LabelEntryName]
type LabelEntryName ¶ added in v0.0.4
type LabelEntryName struct {
LabelName string `json:"label.name"`
}
type LabelEntryPayload ¶ added in v0.0.4
type LabelResponse ¶ added in v0.0.4
type LabelResponse = SingleResponse[Label]
type LabelsResponse ¶ added in v0.0.4
type LabelsResponse = ListResponse[Label]
type ListResponse ¶
type ListResponse[T any] struct { Result []T `json:"result"` }
type OrderCatalogItemResponse ¶ added in v0.0.4
type OrderCatalogItemResponse = SingleResponse[RequestInfo]
type OrderItemPayload ¶ added in v0.0.4
type PaginationVars ¶
type ReqOpt ¶ added in v0.0.4
func WithFields ¶ added in v0.0.4
func WithHeader ¶ added in v0.0.4
func WithIncludeExternalRefLink ¶ added in v0.0.4
func WithIncludeExternalRefLink() ReqOpt
func WithIncludeResponseBody ¶ added in v0.0.4
func WithIncludeResponseBody() ReqOpt
func WithOffset ¶ added in v0.0.4
func WithPageLimit ¶ added in v0.0.4
func WithQueryParam ¶ added in v0.0.4
type RequestInfo ¶ added in v0.0.4
type RequestItemResponse ¶ added in v0.0.4
type RequestItemResponse = SingleResponse[RequestedItem]
type RequestItemState ¶ added in v0.0.4
type RequestItemsResponse ¶ added in v0.0.4
type RequestItemsResponse = ListResponse[RequestedItem]
type RequestedItem ¶ added in v0.0.4
type RequestedItem struct { BaseResource State string `json:"state"` Description string `json:"description"` Number string `json:"number"` TaskEffectiveNumber string `json:"task_effective_number"` Request ResourceRefLink `json:"request"` CatItem ResourceRefLink `json:"cat_item"` Catalogs []Catalog `json:"catalogs,omitempty"` Category Category `json:"category,omitempty"` ScCatalog string `json:"sc_catalog,omitempty"` RequestedFor *ResourceRefLink `json:"requested_for,omitempty"` SysUpdatedOn string `json:"sys_updated_on"` SysUpdatedBy string `json:"sys_updated_by"` ClosedAt string `json:"closed_at"` OpenedBy ResourceRefLink `json:"opened_by"` SysCreatedOn string `json:"sys_created_on"` SysCreatedBy string `json:"sys_created_by"` Active string `json:"active"` OpenedAt string `json:"opened_at"` ShortDescription string `json:"short_description"` Approval string `json:"approval"` AssignedTo string `json:"assigned_to"` }
type RequestedItemStateResponse ¶ added in v0.0.4
type RequestedItemStateResponse = ListResponse[RequestItemState]
type RequestedItemUpdatePayload ¶ added in v0.0.5
type RequestedItemUpdatePayload struct {
Description string `json:"description"`
}
type ResourceRefLink ¶ added in v0.0.4
TODO(lauren) remove unecessary fields. Service Catalog request models.
type Role ¶
type Role struct { BaseResource Name string `json:"name"` Grantable string `json:"grantable"` }
type RolesResponse ¶
type RolesResponse = ListResponse[Role]
type ServiceCatalogRequest ¶ added in v0.0.4
type ServiceCatalogRequest struct { BaseResource Parent string `json:"parent"` State string `json:"state"` RequestState string `json:"request_state"` Number string `json:"number"` TaskEffectiveNumber string `json:"task_effective_number"` UponReject string `json:"upon_reject"` OpenedBy *ResourceRefLink `json:"opened_by,omitempty"` RequestedFor *ResourceRefLink `json:"requested_for,omitempty"` SysCreatedOn string `json:"sys_created_on"` SysUpdatedOn string `json:"sys_updated_on"` OpenedAt string `json:"opened_at"` ClosedAt string `json:"closed_at"` ApprovalSet string `json:"approval_set"` SysUpdatedBy string `json:"sys_updated_by"` SysCreatedBy string `json:"sys_created_by"` Approval string `json:"approval"` ShortDescription string `json:"short_description"` Description string `json:"description"` CloseNotes string `json:"close_notes"` AssignedTo string `json:"assigned_to"` Comments string `json:"comments"` CommentsAndWorkNotes string `json:"comments_and_work_notes"` UponApproval string `json:"upon_approval"` }
type ServiceCatalogRequestResponse ¶ added in v0.0.4
type ServiceCatalogRequestResponse = SingleResponse[ServiceCatalogRequest]
type SingleResponse ¶
type SingleResponse[T any] struct { Result T `json:"result"` }
type SubCategory ¶ added in v0.0.4
type UserResponse ¶
type UserResponse = SingleResponse[User]
type UserRolesResponse ¶
type UserRolesResponse = SingleResponse[UserRoles]
type UserToRole ¶
type UserToRole struct { BaseResource Inherited string `json:"inherited"` User string `json:"user"` Role string `json:"role"` }
type UserToRolePayload ¶
type UserToRoleResponse ¶
type UserToRoleResponse ListResponse[UserToRole]
type UsersResponse ¶
type UsersResponse = ListResponse[User]
type VariableType ¶ added in v0.0.4
type VariableType int
const ( TypeUnspecified VariableType = iota TypeYesNo TypeMultiLineText TypeMultipleChoice TypeNumericScale // TODO(lauren) add baton custom field type for number TypeSelectBox TypeSingleLineText TypeCheckBox TypeReference TypeDate TypeDateTime TypeLabel TypeBreak TypeMacro // skip TypeUIPage // skip TypeWideSingleLineText TypeMacroWithLabel // skip TypeLookupSelectBox TypeContainerStart TypeContainerEnd TypeListCollector TypeLookupMultipleChoice TypeHTML TypeSplit TypeMasked TypeEmail TypeURL TypeIPAddress TypeDuration TypeRequestedFor TypeRichTextLabel TypeAttachment )
TODO(lauren) not sure how to handle all of these These correspond to variable type id.
type VariableTypeNew ¶ added in v0.0.4
type VariableTypeNew interface{}
Click to show internal directories.
Click to hide internal directories.