servicenowsdkgo

package module
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: MIT Imports: 11 Imported by: 0

README

ServiceNow SDK for Go

GitHub go.mod Go version GoDoc GitHub release (latest by date) GitHub issues GitHub Code Climate codecov

A Service-Now API client enabling Go programs to interact with Service-Now in a simple and uniform way

servicenow-sdk-go

Supported Service-Now APIs

API Status Issues
Account ✖️
ActivitySubscriptions ✖️
Agent Client Collector ✖️
Aggregate ✖️
AI Search External User Mapping ✖️
Alarm Management Open ✖️
Application Service ✖️
Appointment ✖️
Attachment ♻️ Attachment API Issues
Advanced Work Assignment (AWA) Agent ✖️
AWA Assignment ✖️
AWA Routing ✖️
Batch ✖️
Case ✖️
Custom Chat Chatbot Interoperability Framework (CCCIF) Media Resource ✖️
CdmApplicationsApi ✖️
CdmChangesetsApi ✖️
CdmEditorApi ✖️
CdmPoliciesApi ✖️
Tables ✔️ Table API Issues

Emoji Meaning
✔️ Supported
🆕 Preview
♻️ In progress
✖️ Not supported

1. Installation

Install latest

go get github.com/michaeldcanady/servicenow-sdk-go

or

Install specific version

go get github.com/michaeldcanady/servicenow-sdk-go@version

2. Getting Started

2.1 Create an AuthenticationProvider object

Create a credential object.

import (
    "github.com/michaeldcanady/servicenow-sdk-go/credentials"
)

cred := credentials.NewUsernamePasswordCredential("username", "password")
2.2 Get a ServiceNow Client and Adapter object

Create a client object.

import (
    servicenowsdkgo "github.com/michaeldcanady/servicenow-sdk-go"
)

client := servicenowsdkgo.NewServiceNowClient(cred, "instance")
2.3 Get query parameters

Build query parameter object.

import (
    "github.com/michaeldcanady/servicenow-sdk-go/table-api"
)

params := &tableapi.TableRequestBuilderGetQueryParameters{
        Limit: int32(1),
    }
2.4 Build request for table

Formulate request and provide parameters.


records, err := client.Now().Table("table name").Get(params)
if err != nil {
    panic(err)
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilRequestInfo = errors.New("requestInfo cannot be nil")
	ErrNilContext     = errors.New("ctx cannot be nil")
)

Functions

This section is empty.

Types

type NowRequestBuilder

type NowRequestBuilder struct {
	context.Context
	core.RequestBuilder
}

func NewNowRequestBuilder

func NewNowRequestBuilder(ctx context.Context, url string, client *ServiceNowClient) *NowRequestBuilder

NewNowRequestBuilder creates a new instance of the NowRequestBuilder associated with the given URL and Client. It accepts the URL and Client as parameters and returns a pointer to the created NowRequestBuiabstraction

func (*NowRequestBuilder) Attachment

Attachment returns an AttachmentRequestBuilder associated with the NowRequestBuilder. It allows you to work with attachments and manage attachments in ServiceNow.

func (*NowRequestBuilder) Table

func (rB *NowRequestBuilder) Table(tableName string) *tableapi.TableRequestBuilder

Table returns a TableRequestBuilder associated with the NowRequestBuilder. It accepts a table name as a parameter and constructs the URL for table-related requests. The returned TableRequestBuilder can be used to build and execute table-related requests.

type ServiceNowClient

type ServiceNowClient struct {
	Credential core.Credential
	BaseUrl    string //nolint:stylecheck
	Session    http.Client
}

func NewServiceNowClient

func NewServiceNowClient(credential core.Credential, instance string) *ServiceNowClient

NewServiceNowClient creates a new instance of the ServiceNow client. It accepts a UsernamePasswordCredential and an instance URL. If the instance URL does not end with ".service-now.com/api", it appends the suffix. It returns a pointer to the Client.

func (*ServiceNowClient) Now

Now returns a NowRequestBuilder associated with the Client. It prepares the NowRequestBuilder with the base URL for the ServiceNow instance.

func (*ServiceNowClient) Send

func (c *ServiceNowClient) Send(ctx context.Context, requestInfo core.IRequestInformation,
	errorMapping core.ErrorMapping) (*http.Response, error)

func (*ServiceNowClient) SendWithContext

func (c *ServiceNowClient) SendWithContext(ctx context.Context, requestInfo core.IRequestInformation, errorMapping core.ErrorMapping) (*http.Response, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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