README
¶
ServiceNow SDK for Go
A Service-Now API client enabling Go programs to interact with Service-Now in a simple and uniform way
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 | ♻️ | |
Advanced Work Assignment (AWA) Agent | ✖️ | |
AWA Assignment | ✖️ | |
AWA Routing | ✖️ | |
Batch | ♻️ | |
Case | ✖️ | |
Custom Chat Chatbot Interoperability Framework (CCCIF) Media Resource | ✖️ | |
CdmApplicationsApi | ✖️ | |
CdmChangesetsApi | ✖️ | |
CdmEditorApi | ✖️ | |
CdmPoliciesApi | ✖️ | |
Tables | ✔️ |
Emoji | Meaning |
---|---|
✔️ | Supported |
🆕 | Preview |
♻️ | In progress |
✖️ | Not supported |
Prerequisites
Before you begin, ensure that you have the following:
- Golang v1.21 or higher: If you haven't already installed Go, you can do so by following the instructions here.
1. Installation
You can install the ServiceNow SDK using the following commands:
Install the Latest Version
go get github.com/michaeldcanady/servicenow-sdk-go
Install a Specific Version
If you need a specific version, use the following command, replacing version
with the desired version:
go get github.com/michaeldcanady/servicenow-sdk-go@version
2. Getting Started
2.1 Create an AuthenticationProvider Object
To authenticate with ServiceNow, create a credential object. Here's an example using username and password:
import (
"github.com/michaeldcanady/servicenow-sdk-go/credentials"
)
cred := credentials.NewUsernamePasswordCredential("username", "password")
2.2 Initialize a ServiceNow Client
Create a client object to interact with ServiceNow APIs:
import (
servicenowsdkgo "github.com/michaeldcanady/servicenow-sdk-go"
)
client, err := servicenowsdkgo.NewServiceNowClient2(cred, "instance")
if err != nil {
panic(err)
}
2.3 Implement Your Preferred API SDK
Choose the appropriate ServiceNow API SDK for your use case and start building your applications!
- Table API: Interact with ServiceNow tables and records.
- Attachment API: Manage attachments associated with records.
- Batch API: Perform batch operations efficiently.
Select the submodule(s) that align with your requirements and start building your applications!
Documentation
¶
Index ¶
- Variables
- type NowRequestBuilder
- type ServiceNowClient
- func (c *ServiceNowClient) GetBaseURL() string
- func (c *ServiceNowClient) Now() *NowRequestBuilder
- func (c *ServiceNowClient) Send(requestInfo core.IRequestInformation, errorMapping core.ErrorMapping) (*http.Response, error)
- func (c *ServiceNowClient) SendWithContext(ctx context.Context, requestInfo core.IRequestInformation, ...) (*http.Response, error)
Constants ¶
This section is empty.
Variables ¶
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 {
core.RequestBuilder
}
func NewNowRequestBuilder ¶
func NewNowRequestBuilder(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 ¶ added in v1.1.0
func (rB *NowRequestBuilder) Attachment() *attachmentapi.AttachmentRequestBuilder
Attachment returns an AttachmentRequestBuilder associated with the NowRequestBuilder. It allows you to work with attachments and manage attachments in ServiceNow.
func (*NowRequestBuilder) Table
deprecated
func (rB *NowRequestBuilder) Table(tableName string) *tableapi.TableRequestBuilder
Deprecated: deprecated since v{unreleased}. Use `Table2` instead. 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.
func (*NowRequestBuilder) Table2 ¶
func (rB *NowRequestBuilder) Table2(tableName string) tableapi.TableRequestBuilder2[*tableapi.TableRecordImpl]
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 { // Deprecated: deprecated since v1.6.0. Credential core.Credential BaseUrl string //nolint:stylecheck Session http.Client // contains filtered or unexported fields }
func NewServiceNowClient
deprecated
func NewServiceNowClient(credential core.Credential, instance string) *ServiceNowClient
Deprecated: deprecated since v1.6.0. Please use `NewServiceNowClient2` instead. 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 NewServiceNowClient2 ¶ added in v1.6.0
func NewServiceNowClient2(credential core.Credential, instance string) (*ServiceNowClient, error)
NewServiceNowClient2 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) GetBaseURL ¶
func (c *ServiceNowClient) GetBaseURL() string
func (*ServiceNowClient) Now ¶
func (c *ServiceNowClient) Now() *NowRequestBuilder
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(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)