tableapi

package
v0.0.0-...-5f8180a Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2024 License: MIT Imports: 10 Imported by: 0

README

Table API

The Table API is an essential interface provided by ServiceNow, enabling developers to perform Create, Read, Update, and Delete (CRUD) operations on the tables within a ServiceNow instance. This guide offers comprehensive instructions on utilizing the API endpoints, with code examples in Go.

Please ensure that any strings enclosed in curly braces {} are replaced with actual values before using the examples. The documentation demonstrates two approaches for interacting with the API:

  1. Fluent Interface Pattern: This approach allows for chaining methods in a single expression.
  2. Building Request: This method involves constructing the request step by step.

Initial Setup

To begin using the API, you must first configure your environment. Below is the standard setup code utilized across all examples:

package main

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

func main() {
    // Define the base URL of your ServiceNow instance
    baseURL := "https://www.{instance}.service-now.com/api/now"

    // Implement your credential and client.
    client := // Your client setup here
...

[DELETE] Remove Record

To remove a specific record from a table:

1. Fluent Interface Pattern
...
    
    // Optional Query Parameters
    params := &tableapi.TableItemRequestBuilderDeleteQueryParameters{
        // Define Query Parameters
    }

    // Execute the delete operation
    err := client.Now().Table2("{tableName}").ByID("{sysId}").Delete(params)
    if err != nil {
        panic(err)  // Error handling
    }
}
2. Building Request

Try on Playground

...
    // Specify the path parameters
    pathParameters := map[string]string{
        "baseurl": baseURL,
        "table":   "{tableName}", // Table name for the record
        "sysId":   "{sysId}", // Sys Id of the record
    }

    // Initialize a new request builder
    requestBuilder := tableapi.NewTableItemRequestBuilder2(client, pathParameters)

    // Optional Query Parameters
    params := &tableapi.TableItemRequestBuilderDeleteQueryParameters{
        // Define Query Parameters
    }

    // Execute the delete operation
    err := requestBuilder.Delete(params)
    if err != nil {
        panic(err) // Error handling
    }
}

[GET] Retrieve Records

To fetch multiple records from a table:

1. Fluent Interface Pattern
...

    // Optional Query Parameters
    params := &tableapi.TableRequestBuilderGetQueryParameters{
        // Define Query Parameters
    }

    // Execute the retrieval operation
    response, err := client.Now().Table2("{tableName}").Get(params)
    if err != nil {
        panic(err) // Error handling
    }
}
2. Building Request

Try on Playground

...
    // Specify the path parameters
    pathParameters := map[string]string{
        "baseurl": baseURL,
        "table":   "{tableName}", // Table name for the records
    }

    // Initialize a new request builder
    requestBuilder := tableapi.NewTableRequestBuilder2(client, pathParameters)

    // Optional Query Parameters
    params := &tableapi.TableRequestBuilderGetQueryParameters{
        // Define Query Parameters
    }

    // Execute the retrieval operation
    response, err := requestBuilder.Get(params)
    if err != nil {
        panic(err)  // Error handling
    }
}

[GET] Retrieve Record

This method retrieves a specific record identified by its sys_id from a specified table.

1. Fluent Interface Pattern
...

    // Optional Query Parameters
    params := &tableapi.TableItemRequestBuilderGetQueryParameters{
        // Define Query Parameters
    }

    // Execute the retrieval operation
    record, err := client.Now().Table2("{tableName}")ByID("{sysId}").Get()
    if err != nil {
        panic(err) // Error handling
    }
}
2. Building Request

Try on Playground

...
    // Specify the path parameters
    pathParameters := map[string]string{
        "baseurl": baseURL,
        "table":   "{tableName}", // Table name for the record
        "sysId":   "{sysId}", // Sys Id of the record
    }

    // Create a new TableItemRequestBuilder with your client and path parameters.
    requestBuilder := tableapi.NewTableItemRequestBuilder2(client, pathParameters)

    // Optional Query Parameters
    params := &tableapi.TableItemRequestBuilderGetQueryParameters{
        // Define Query Parameters
    }

    // Execute the retrieval operation.
    record, err := requestBuilder.Get(params)
    if err != nil {
        panic(err) // Error handling
    }
}

[POST] Create a Record

This method inserts a new record into a specified table.

Note: that this method does not support the insertion of multiple records.

1. Fluent Interface Pattern
...
    // Define the data for the new record
    data := map[string]string{
        "short_description": "example incident",
        "description":       "incident created by servicenow-sdk-go",
    }

    // Optional Query Parameters
    param := &tableapi.TableRequestBuilderPostQueryParameters{
        // Define Query Parameters
    }

    // Execute the creation operation.
    response, err := client.Now().Table2("{tableName}").Post(data, param)
    if err != nil {
        panic(err) // Error handling
    }
}
2. Building Request

Try on Playground

...
    // Specify the path parameters
    pathParameters := map[string]string{
        "baseurl": baseURL,
        "table":   "{tableName}", // Table name for the record
    }

    // Define the data for the new record
    data := map[string]string{
        "short_description": "example incident",
        "description":       "incident created by servicenow-sdk-go",
    }

    // Create a new TableRequestBuilder with your client and path parameters.
    requestBuilder := tableapi.NewTableRequestBuilder2(client, pathParameters)

    // Optional Query Parameters
    param := &tableapi.TableRequestBuilderPostQueryParameters{
        // Define Query Parameters
    }

    // Execute the creation operation.
    response, err := requestBuilder.Post(data, param)
    if err != nil {
        panic(err) // Error handling
    }
}

[PUT] Update a Record

Update one record in the specified table.

Note: Make sure only the fields you intend on updating are included

1. Fluent Interface Pattern
...

    // Define the data for the new record
    data := map[string]string{
        "short_description": "example incident",
        "description": "incident created by servicenow-sdk-go",
    }

    // Optional query parameters
    params := &tableapi.TableItemRequestBuilderPutQueryParameters{
        // Define Query Parameters
    }

    // Execute the update operation.
    response, err := client.Now().Table2("{tableName}").ByID("{sysID}").Put(data, params)
    if err != nil {
        panic(err) // Error handling
    }
}
2. Building Request

Try on Playground

...

    // Specify the path parameters
    pathParameters := {
        "baseurl": baseURL,
        "table": "{tableName}",
        "sysId": "{sysID}",
    }

    // Define the data for the new record
    data := map[string]string{
        "short_description": "example incident",
        "description": "incident created by servicenow-sdk-go",
    }

    // Create a new TableRequestBuilder with your client and path parameters.
    requestBuilder := tableapi.NewTableItemRequestBuilder2(client, pathParameters)

    // Optional query parameters
    params := &tableapi.TableItemRequestBuilderPutQueryParameters{
        // Define Query Parameters
    }

    // Execute the update operation.
    response, err := requestBuilder.Put(data, params)
    if err != nil {
        panic(err) // Error handling
    }
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilClient         = errors.New("client can't be nil")
	ErrNilResponse       = errors.New("response can't be nil")
	ErrNilResult         = errors.New("result property missing in response object")
	ErrWrongResponseType = errors.New("incorrect Response Type")
	ErrParsing           = errors.New("parsing nextLink url failed")
	ErrEmptyURI          = errors.New("empty URI")
	ErrNilCallback       = errors.New("callback can't be nil")
	ErrNilParameterTable = errors.New("missing \"table\" parameter")
	ErrNilParameterSysID = errors.New("missing \"sysId\" parameter")
)

Functions

This section is empty.

Types

type DisplayValue

type DisplayValue string
const (
	TRUE  DisplayValue = "true"
	FALSE DisplayValue = "false"
	ALL   DisplayValue = "all"
)

type Entry

type Entry interface {
	Value(string) *TableValue
	Set(string, interface{})
	Keys() []string
	Len() int
}

type Fragment deprecated

type Fragment = core.Fragment

Fragment represents a query fragment with a field, operator, and value.

Deprecated: deprecated since 1.4.0. Please use core.Fragment instead.

func NewFragment deprecated

func NewFragment(field string, operator RelationalOperator, value interface{}) *Fragment

NewFragment creates a new query fragment with the specified field, operator, and value.

Deprecated: deprecated since 1.4.0. Please use core.NewFragment instead.

type LogicalOperator deprecated

type LogicalOperator = core.LogicalOperator

LogicalOperator ...

Deprecated: deprecated since 1.4.0. Please use core.LogicalOperator instead.

const (
	// And ...
	//
	// Deprecated: deprecated since 1.4.0. Please use core.And instead.
	And LogicalOperator = core.And
	// Or ...
	//
	// Deprecated: deprecated since 1.4.0. Please use core.Or instead.
	Or LogicalOperator = core.Or
)

type OrderBy deprecated

type OrderBy = core.OrderBy

OrderBy represents an order-by clause.

Deprecated: deprecated since 1.4.0. Please use core.OrderBy instead.

func NewOrderBy deprecated

func NewOrderBy() *OrderBy

NewOrderBy Creates new order by.

Deprecated: deprecated since 1.4.0. Please use core.NewOrderBy instead.

type OrderDirection deprecated

type OrderDirection = core.OrderDirection

OrderDirection represents the order direction for sorting.

Deprecated: deprecated since 1.4.0. Please use core.OrderDirection instead.

const (
	// Unset ...
	//
	// Deprecated: deprecated since 1.4.0. Please use core.Unset instead.
	Unset OrderDirection = core.Unset
	// Asc ...
	//
	// Deprecated: deprecated since 1.4.0. Please use core.Asc instead.
	Asc OrderDirection = core.Asc
	// Desc ...
	//
	// Deprecated: deprecated since 1.4.0. Please use core.Desc instead.
	Desc OrderDirection = core.Desc
)

type PageIterator deprecated

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

Deprecated: deprecated in v1.5.0. Use TablePageIterator[T] instead. PageIterator represents an iterator for paginated results from a table.

func NewPageIterator deprecated

func NewPageIterator(currentPage interface{}, client core.Client) (*PageIterator, error)

Deprecated: deprecated in v1.5.0. Use NewTablePageIterator[T] instead. NewPageIterator creates a new PageIterator instance.

func (*PageIterator) Iterate

func (pI *PageIterator) Iterate(callback func(pageItem *TableEntry) bool) error

Iterate iterates through pages and invokes the provided callback for each page item.

func (*PageIterator) Last

func (pI *PageIterator) Last() (PageResult, error)

Last fetches the last page of results.

type PageResult

type PageResult struct {
	Result           []*TableEntry
	NextPageLink     string
	PreviousPageLink string
	FirstPageLink    string
	LastPageLink     string
}

PageResult represents a single page of results from a table.

type Query deprecated

type Query = core.Query

Query represents a ServiceNow query and its conditions.

Deprecated: deprecated since 1.4.0. Please use core.Query instead.

func NewQuery deprecated

func NewQuery() *Query

NewQuery returns a new Query with no conditions.

Deprecated: deprecated since 1.4.0. Please use core.NewQuery instead.

type RelationalOperator deprecated

type RelationalOperator = core.RelationalOperator

Deprecated: deprecated since 1.4.0. Please use core.RelationalOperator instead.

RelationalOperator ...

const (
	// Deprecated: deprecated since 1.4.0. Please use core.Null instead.
	//
	// Null ...
	Null RelationalOperator = core.Null
	// Deprecated: deprecated since 1.4.0. Please use core.Is instead.
	//
	// Is ...
	Is RelationalOperator = core.Is
	// Deprecated: deprecated since 1.4.0. Please use core.IsNot instead.
	//
	// IsNot ...
	IsNot RelationalOperator = core.IsNot
	// Deprecated: deprecated since 1.4.0. Please use core.GreaterThan instead.
	//
	// GreaterThan ...
	GreaterThan RelationalOperator = core.GreaterThan
	// Deprecated: deprecated since 1.4.0. Please use core.GreaterOrEqual instead.
	//
	// GreaterOrEqual ...
	GreaterOrEqual RelationalOperator = core.GreaterOrEqual
	// Deprecated: deprecated since 1.4.0. Please use core.LessThan instead.
	//
	// LessThan ...
	LessThan RelationalOperator = core.LessOrEqual
	// Deprecated: deprecated since 1.4.0. Please use core.LessOrEqual instead.
	//
	// LessOrEqual ...
	LessOrEqual RelationalOperator = core.LessOrEqual
	// Deprecated: deprecated since 1.4.0. Please use core.Contains instead.
	//
	// Contains ...
	Contains RelationalOperator = core.Contains
	// Deprecated: deprecated since 1.4.0. Please use core.NotContains instead.
	//
	// NotContains ...
	NotContains RelationalOperator = core.NotContains
	// Deprecated: deprecated since 1.4.0. Please use core.StartsWith instead.
	//
	// StartsWith ...
	StartsWith RelationalOperator = core.StartsWith
	// Deprecated: deprecated since 1.4.0. Please use core.EndsWith instead.
	//
	// EndsWith ...
	EndsWith RelationalOperator = core.EndsWith
	// Deprecated: deprecated since 1.4.0. Please use core.Between instead.
	//
	// Between ...
	Between RelationalOperator = core.Between
	// Deprecated: deprecated since 1.4.0. Please use core.IsSame instead.
	//
	// IsSame ...
	IsSame RelationalOperator = core.IsSame
	// Deprecated: deprecated since 1.4.0. Please use core.IsDifferent instead.
	//
	// IsDifferent ...
	IsDifferent RelationalOperator = core.IsDifferent
	// Deprecated: deprecated since 1.4.0. Please use core.IsEmpty instead.
	//
	// IsEmpty ...
	IsEmpty RelationalOperator = core.IsEmpty
)

type TableCollectionResponse

type TableCollectionResponse = TableCollectionResponse2[TableEntry]

Deprecacted: deprecated since v1.4.0. Use "TableCollectionResponse2[T]" instead.

TableCollectionResponse represents a collection of table entries.

type TableCollectionResponse2

type TableCollectionResponse2[T Entry] struct {
	// Result is a slice of pointers to table entries.
	Result []*T
	// NextPageLink is the URL to the next page of results.
	NextPageLink string
	// PreviousPageLink is the URL to the previous page of results.
	PreviousPageLink string
	// FirstPageLink is the URL to the first page of results.
	FirstPageLink string
	// LastPageLink is the URL to the last page of results.
	LastPageLink string
}

TableCollectionResponse2 represents a collection of table entries.

func (*TableCollectionResponse2[T]) ParseHeaders

func (cR *TableCollectionResponse2[T]) ParseHeaders(headers http.Header)

ParseHeaders parses the needed headers from the response.

func (*TableCollectionResponse2[T]) ToPage

func (cR *TableCollectionResponse2[T]) ToPage() core.PageResult[T]

ToPage converts a TableCollectionResponse2 to a PageResult

type TableEntry

type TableEntry map[string]interface{}

TableEntry represents a single Service-Now Table Entry.

func NewTableEntry

func NewTableEntry() TableEntry

NewTableEntry creates a new table entry instance.

func (TableEntry) Keys

func (tE TableEntry) Keys() []string

Keys returns a slice of the tE's keys.

func (TableEntry) Len

func (tE TableEntry) Len() int

Len returns the length of the tE.

func (TableEntry) Set

func (tE TableEntry) Set(key string, value interface{})

Set sets the specified key to the provided value.

func (TableEntry) Value

func (tE TableEntry) Value(key string) *TableValue

Value returns a tE if a valid key is provided.

type TableGetRequestConfiguration deprecated

type TableGetRequestConfiguration struct {
	Header          interface{}
	QueryParameters *TableRequestBuilderGetQueryParameters
	Data            interface{}
	ErrorMapping    core.ErrorMapping
	// contains filtered or unexported fields
}

Deprecated: deprecated since v1.4.0. Removed from public API.

TableGetRequestConfiguration represents request configurations GET request.

type TableItemDeleteRequestConfiguration deprecated

type TableItemDeleteRequestConfiguration struct {
	Header          interface{}
	QueryParameters *TableItemRequestBuilderDeleteQueryParameters
	Data            interface{}
	ErrorMapping    core.ErrorMapping
	// contains filtered or unexported fields
}

Deprecated: deprecated since v1.4.0. Removed from public API.

TableItemDeleteRequestConfiguration represents request configurations DELETE request.

type TableItemGetRequestConfiguration deprecated

type TableItemGetRequestConfiguration struct {
	Header          interface{}
	QueryParameters *TableItemRequestBuilderGetQueryParameters
	Data            interface{}
	ErrorMapping    core.ErrorMapping
	// contains filtered or unexported fields
}

Deprecated: deprecated since v1.4.0. Removed from public API.

TableItemGetRequestConfiguration represents request configurations GET request.

type TableItemPutRequestConfiguration deprecated

type TableItemPutRequestConfiguration struct {
	Header          interface{}
	QueryParameters *TableItemRequestBuilderPutQueryParameters
	Data            interface{}
	ErrorMapping    core.ErrorMapping
	// contains filtered or unexported fields
}

Deprecated: deprecated since v1.4.0. Removed from public API.

TableItemPutRequestConfiguration represents request configurations GET request.

type TableItemRequestBuilder deprecated

type TableItemRequestBuilder struct {
	core.RequestBuilder
}

Deprecated: deprecated since v{unreleased}. Use `TableItemRequestBuilder2` instead.

func NewTableItemRequestBuilder deprecated

func NewTableItemRequestBuilder(client core.Client, pathParameters map[string]string) *TableItemRequestBuilder

Deprecated: deprecated since v{unreleased}. Use `NewTableItemRequestBuilder2` instead. NewTableItemRequestBuilder creates a new instance of the TableItemRequestBuilder associated with the given URL and Client. It accepts the URL and Client as parameters and returns a pointer to the created TableItemRequestBuilder.

func (*TableItemRequestBuilder) Delete

Delete sends an HTTP DELETE request using the specified query parameters and returns an error if the request or response encounters any issues.

Parameters:

  • params: An instance of TableItemRequestBuilderDeleteQueryParameters to include in the DELETE request.

Returns:

  • error: An error if there was an issue with the request or response, or nil if the request was successful.

func (*TableItemRequestBuilder) Get

Get sends an HTTP GET request using the specified query parameters and returns a TableItemResponse.

Parameters:

  • params: An instance of TableItemRequestBuilderGetQueryParameters to include in the GET request.

Returns:

  • *TableItemResponse: The response data as a TableItemResponse.
  • error: An error if there was an issue with the request or response.

func (*TableItemRequestBuilder) Put deprecated

Deprecated: deprecated since v1.4.0. Use `Put2` instead.

Put updates a table item using an HTTP PUT request. It takes a map of table entry data and optional query parameters to send in the request. The method returns a TableItemResponse representing the updated item or an error if the request fails.

Parameters:

  • tableEntry: A map containing the data to update the table item.
  • params: An optional pointer to TableItemRequestBuilderPutQueryParameters, which can be used to specify query parameters for the request.

Returns:

  • *TableItemResponse: A TableItemResponse containing the updated item data.
  • error: An error, if the request fails at any point, such as request information creation or JSON deserialization.

func (*TableItemRequestBuilder) Put2

func (rB *TableItemRequestBuilder) Put2(tableEntry interface{}, params *TableItemRequestBuilderPutQueryParameters) (*TableItemResponse, error)

Put2 updates a table item using an HTTP PUT request. It takes a map of table entry data and optional query parameters to send in the request. The method returns a TableItemResponse representing the updated item or an error if the request fails.

Parameters:

  • tableEntry: A map[string]string or TableEntry containing the data to update the table item.
  • params: An optional pointer to TableItemRequestBuilderPutQueryParameters, which can be used to specify query parameters for the request.

Returns:

  • *TableItemResponse: A TableItemResponse containing the updated item data.
  • error: An error, if the request fails at any point, such as request information creation or JSON deserialization.

type TableItemRequestBuilder2

type TableItemRequestBuilder2 struct {
	intTable.RequestBuilder
}

func NewTableItemRequestBuilder2

func NewTableItemRequestBuilder2(client core.Client, pathParameters map[string]string) (*TableItemRequestBuilder2, error)

NewTableItemRequestBuilder2 creates a new instance of TableItemRequestBuilder2.

func (*TableItemRequestBuilder2) Delete

Delete sends an HTTP DELETE request using the specified query parameters and returns an error if the request or response encounters any issues.

Parameters:

  • params: An instance of TableItemRequestBuilderDeleteQueryParameters to include in the DELETE request.

Returns:

  • error: An error if there was an issue with the request or response, or nil if the request was successful.

func (*TableItemRequestBuilder2) Get

Get sends an HTTP GET request using the specified query parameters and returns a TableItemResponse.

Parameters:

  • params: An instance of TableItemRequestBuilderGetQueryParameters to include in the GET request.

Returns:

  • *TableItemResponse: The response data as a TableItemResponse.
  • error: An error if there was an issue with the request or response.

func (*TableItemRequestBuilder2) Put

Put updates a table item using an HTTP PUT request. It takes a map of table entry data and optional query parameters to send in the request. The method returns a TableItemResponse representing the updated item or an error if the request fails.

Parameters:

  • tableEntry: A map[string]string or TableEntry containing the data to update the table item.
  • params: An optional pointer to TableItemRequestBuilderPutQueryParameters, which can be used to specify query parameters for the request.

Returns:

  • *TableItemResponse: A TableItemResponse containing the updated item data.
  • error: An error, if the request fails at any point, such as request information creation or JSON deserialization.

type TableItemRequestBuilderDeleteQueryParameters

type TableItemRequestBuilderDeleteQueryParameters struct {
	// QueryNoDomain flag that indicates whether to restrict the record search to only the domains for which the logged in user is configured.
	//
	//Valid values:
	//
	//- false: Exclude the record if it is in a domain that the currently logged in user is not configured to access.
	//
	//- true: Include the record even if it is in a domain that the currently logged in user is not configured to access.
	QueryNoDomain bool `url:"sysparm_query_no_domain"`
}

TableItemRequestBuilderDeleteQueryParameters represents DELETE query parameters for a Table Item Request.

type TableItemRequestBuilderGetQueryParameters

type TableItemRequestBuilderGetQueryParameters struct {
	//DisplayValue determines the type of data returned, either the actual values from the database or the display values of the fields.
	//Display values are manipulated based on the actual value in the database and user or system settings and preferences.
	//If returning display values, the value that is returned is dependent on the field type.
	//- Choice fields: The database value may be a number, but the display value will be more descriptive.
	//
	//- Date fields: The database value is in UTC format, while the display value is based on the user's time zone.
	//
	//- Encrypted text: The database value is encrypted, while the displayed value is unencrypted based on the user's encryption context.
	//
	//- Reference fields: The database value is sys_id, but the display value is a display field of the referenced record.
	DisplayValue DisplayValue `url:"sysparm_display_value"`
	//ExcludeReferenceLink flag that indicates whether to exclude Table API links for reference fields.
	//
	//Valid values:
	//
	//- true: Exclude Table API links for reference fields.
	//
	//- false: Include Table API links for reference fields.
	ExcludeReferenceLink bool `url:"sysparm_exclude_reference_link"`
	// Fields list of fields to return in the response.
	Fields []string `url:"sysparm_fields"`
	//Flag that indicates whether to restrict the record search to only the domains for which the logged in user is configured.
	//
	//Valid values:
	//
	//- false: Exclude the record if it is in a domain that the currently logged in user is not configured to access.
	//
	//- true: Include the record even if it is in a domain that the currently logged in user is not configured to access.
	QueryNoDomain bool `url:"sysparm_query_no_domain"`
	// View	UI view for which to render the data. Determines the fields returned in the response.
	//
	//Valid values:
	//
	//- desktop
	//- mobile
	//- both
	//If you also specify the sysparm_fields parameter, it takes precedent.
	View View `url:"sysparm_view"`
}

TableItemRequestBuilderGetQueryParameters represents GET query parameters for a Table Item Request.

type TableItemRequestBuilderPutQueryParameters

type TableItemRequestBuilderPutQueryParameters struct {
	//DisplayValue determines the type of data returned, either the actual values from the database or the display values of the fields.
	//Display values are manipulated based on the actual value in the database and user or system settings and preferences.
	//If returning display values, the value that is returned is dependent on the field type.
	//- Choice fields: The database value may be a number, but the display value will be more descriptive.
	//
	//- Date fields: The database value is in UTC format, while the display value is based on the user's time zone.
	//
	//- Encrypted text: The database value is encrypted, while the displayed value is unencrypted based on the user's encryption context.
	//
	//- Reference fields: The database value is sys_id, but the display value is a display field of the referenced record.
	DisplayValue DisplayValue `url:"sysparm_display_value"`
	//ExcludeReferenceLink flag that indicates whether to exclude Table API links for reference fields.
	//
	//Valid values:
	//
	//- true: Exclude Table API links for reference fields.
	//
	//- false: Include Table API links for reference fields.
	ExcludeReferenceLink bool `url:"sysparm_exclude_reference_link"`
	// Fields list of fields to return in the response.
	Fields            []string `url:"sysparm_fields"`
	InputDisplayValue bool     `url:"sysparm_input_display_value"`
	// QueryNoDomain flag that indicates whether to restrict the record search to only the domains for which the logged in user is configured.
	//
	//Valid values:
	//
	//- false: Exclude the record if it is in a domain that the currently logged in user is not configured to access.
	//
	//- true: Include the record even if it is in a domain that the currently logged in user is not configured to access.
	QueryNoDomain bool `url:"sysparm_query_no_domain"`
	// View	UI view for which to render the data. Determines the fields returned in the response.
	//
	//Valid values:
	//
	//- desktop
	//- mobile
	//- both
	//If you also specify the sysparm_fields parameter, it takes precedent.
	View View `url:"sysparm_view"`
}

TableItemRequestBuilderPutQueryParameters represents PUT query parameters for a Table Item Request.

type TableItemResponse deprecated

type TableItemResponse = TableItemResponse2[TableEntry]

Deprecated: deprecated since v1.4.0. Use `TableItemResponse2[T]` instead.

TableItemResponse represents a single table record response.

type TableItemResponse2

type TableItemResponse2[T Entry] struct {
	Result *T
}

TableItemResponse2[T] represents a T Entry single table record response.

func (*TableItemResponse2[T]) ParseHeaders

func (r *TableItemResponse2[T]) ParseHeaders(headers http.Header)

ParseHeaders parses information from headers.

type TableItemService

type TableItemService interface {
	Get(params *TableItemRequestBuilderGetQueryParameters) (*TableItemResponse, error)
	Delete(params *TableItemRequestBuilderDeleteQueryParameters) error
	Put(tableEntry interface{}, params *TableItemRequestBuilderPutQueryParameters) (*TableItemResponse, error)
}

TableItemService provides an interface for the service methods, adhering to the Interface Segregation Principle.

type TablePageIterator

type TablePageIterator[T Entry] struct {
	*core.PageIterator2[T]
}

TablePageIterator is a generic struct in Golang which is used to iterate over pages of entries. It embeds the core.PageIterator2 struct and can be used with any type that satisfies the Entry interface.

Fields:

  • core.PageIterator2[T]: This is an embedded field of type PageIterator2 from the core package. The type T represents the type of Entry that the iterator will return.

Usage: You can use this struct to iterate over pages of entries in a table. The specific type of Entry depends on what you specify for T when you create an instance of TablePageIterator.

func NewTablePageIterator

func NewTablePageIterator[T Entry](collection *TableCollectionResponse2[T], client core.Client) (*TablePageIterator[T], error)

NewTablePageIterator is a function that creates a new instance of TablePageIterator. It takes a TableCollectionResponse and a Client as input and returns a pointer to a TablePageIterator and an error.

Parameters:

  • collection: This is a pointer to a TableCollectionResponse that contains the collection of table entries.
  • client: This is a Client that will be used to make requests to the server.

Returns:

  • *TablePageIterator[T]: This is a pointer to a TablePageIterator that can be used to iterate over the pages of entries in the collection.
  • error: This is an error that will be returned if there is any error while creating the PageIterator.

Usage: You can use this function to create a new instance of TablePageIterator.

	func ExampleNewTablePageIteratorF() {
		// use an existing collection
		var collection TableCollectionResponse2[T]
		// use a new or existing client
		var client core.Client
		iter, err := NewTablePageIterator[T](collection, client)
		if err != nil {
    		log.Fatal(err)
		}
		// Use iter to iterate over the pages of entries
	}

type TablePostRequestConfiguration deprecated

type TablePostRequestConfiguration struct {
	Header          interface{}
	QueryParameters *TableRequestBuilderPostQueryParameters
	Data            map[string]string
	ErrorMapping    core.ErrorMapping
	// contains filtered or unexported fields
}

Deprecated: deprecated since v1.4.0. removed from public API.

TablePostRequestConfiguration represents request configurations POST request.

type TableRequestBuilder deprecated

type TableRequestBuilder struct {
	core.RequestBuilder
}

Deprecated: deprecated since v{unreleased}. Use `TableRequestBuilder2` instead.

func NewTableRequestBuilder deprecated

func NewTableRequestBuilder(client core.Client, pathParameters map[string]string) *TableRequestBuilder

Deprecated: deprecated since v{unreleased}. Use `NewTableRequestBuilder2` instead. NewTableRequestBuilder creates a new instance of the TableRequestBuilder associated with the given URL and Client. It accepts the URL and Client as parameters and returns a pointer to the created TableRequestBuilder.

func (*TableRequestBuilder) ById

ById returns a TableItemRequestBuilder for a specific record in the table. It accepts the sysId of the record as a parameter and constructs the URL for the record. The returned TableItemRequestBuilder can be used to build and execute requests for the specific record.

func (*TableRequestBuilder) Count

func (rB *TableRequestBuilder) Count() (int, error)

Count sends an HTTP HEAD request and retrieves the value of "X-Total-Count" from the response header, which represents the count of items.

Returns:

  • int: The count of items.
  • error: An error if there was an issue with the request or response.

func (*TableRequestBuilder) Get

Get sends an HTTP GET request using the specified query parameters and returns a TableCollectionResponse.

Parameters:

  • params: An instance of TableRequestBuilderGetQueryParameters to include in the GET request.

Returns:

  • *TableCollectionResponse: The response data as a TableCollectionResponse.
  • error: An error if there was an issue with the request or response.

func (*TableRequestBuilder) Post deprecated

Deprecated: deprecated since v1.4.0. Use `Post2` instead. Post sends an HTTP Post request with the provided data and query parameters and returns an `TableItemResponse`.

Parameters:

  • data: A map[string]string representing data to be included in the request body.
  • params: An instance of `*TableRequestBuilderPostQueryParameters` for query parameters.

Returns:

  • *TableResponse: The response data as a TableResponse.
  • error: An error if there was an issue with the request or response.

func (*TableRequestBuilder) Post2 deprecated

Deprecated: deprecated since v1.4.0. Use `Post3` instead.

Post2 sends an HTTP Post request with the provided data and query parameters and returns an `TableItemResponse`.

Parameters:

  • data: A map[string]string representing data to be included in the request body.
  • params: An instance of `*TableRequestBuilderPostQueryParameters` for query parameters

func (*TableRequestBuilder) Post3

func (rB *TableRequestBuilder) Post3(data interface{}, params *TableRequestBuilderPostQueryParameters) (*TableItemResponse, error)

Post3 sends an HTTP Post request with the provided data and query parameters and returns an `TableItemResponse`.

Parameters:

  • data: A map[string]string or TableEntry representing data to be included in the request body.
  • params: An instance of `*TableRequestBuilderPostQueryParameters` for query parameters

type TableRequestBuilder2

type TableRequestBuilder2 struct {
	intTable.RequestBuilder
}

TableRequestBuilder is responsible for building requests for table operations.

func NewTableRequestBuilder2

func NewTableRequestBuilder2(client core.Client, pathParameters map[string]string) (*TableRequestBuilder2, error)

NewTableRequestBuilder initializes a new TableRequestBuilder with the given client and path parameters.

func (*TableRequestBuilder2) ByID

ByID creates a TableItemRequestBuilder for a specific record in the table identified by sysID.

func (*TableRequestBuilder2) Count

func (rB *TableRequestBuilder2) Count() (int, error)

Count retrieves the total count of items in the table.

func (*TableRequestBuilder2) Get

Get retrieves a collection of table items based on the provided query parameters.

func (*TableRequestBuilder2) Post

Post creates a new table item with the provided data and query parameters.

type TableRequestBuilderGetQueryParameters

type TableRequestBuilderGetQueryParameters struct {
	//Determines the type of data returned, either the actual values from the database or the display values of the fields.
	//Display values are manipulated based on the actual value in the database and user or system settings and preferences.
	//If returning display values, the value that is returned is dependent on the field type.
	//- Choice fields: The database value may be a number, but the display value will be more descriptive.
	//
	//- Date fields: The database value is in UTC format, while the display value is based on the user's time zone.
	//
	//- Encrypted text: The database value is encrypted, while the displayed value is unencrypted based on the user's encryption context.
	//
	//- Reference fields: The database value is sys_id, but the display value is a display field of the referenced record.
	DisplayValue DisplayValue `url:"sysparm_display_value,omitempty"`
	//Flag that indicates whether to exclude Table API links for reference fields.
	//
	//Valid values:
	//
	//- true: Exclude Table API links for reference fields.
	//
	//- false: Include Table API links for reference fields.
	ExcludeReferenceLink bool `url:"sysparm_exclude_reference_link,omitempty"`
	//list of fields to return in the response.
	Fields []string `url:"sysparm_fields,omitempty"`
	//Flag that indicates whether to restrict the record search to only the domains for which the logged in user is configured.
	//
	//Valid values:
	//
	//- false: Exclude the record if it is in a domain that the currently logged in user is not configured to access.
	//
	//- true: Include the record even if it is in a domain that the currently logged in user is not configured to access.
	QueryNoDomain bool `url:"sysparm_query_no_domain,omitempty"`
	//	UI view for which to render the data. Determines the fields returned in the response.
	//
	//Valid values:
	//
	//- desktop
	//- mobile
	//- both
	//If you also specify the sysparm_fields parameter, it takes precedent.
	View                     View   `url:"sysparm_view,omitempty"`
	Limit                    int    `url:"sysparm_limit,omitempty"`
	NoCount                  bool   `url:"sysparm_no_count,omitempty"`
	Offset                   int    `url:"sysparm_offset,omitempty"`
	Query                    string `url:"sysparm_query,omitempty"`
	QueryCategory            string `url:"sysparm_query_category,omitempty"`
	SuppressPaginationHeader bool   `url:"sysparm_suppress_pagination_header,omitempty"`
}

TableRequestBuilderGetQueryParameters represents GET query parameters for a Table Item Request.

type TableRequestBuilderPostQueryParameters

type TableRequestBuilderPostQueryParameters struct {
	//Determines the type of data returned, either the actual values from the database or the display values of the fields.
	//Display values are manipulated based on the actual value in the database and user or system settings and preferences.
	//If returning display values, the value that is returned is dependent on the field type.
	//- Choice fields: The database value may be a number, but the display value will be more descriptive.
	//
	//- Date fields: The database value is in UTC format, while the display value is based on the user's time zone.
	//
	//- Encrypted text: The database value is encrypted, while the displayed value is unencrypted based on the user's encryption context.
	//
	//- Reference fields: The database value is sys_id, but the display value is a display field of the referenced record.
	DisplayValue DisplayValue `url:"sysparm_display_value"`
	//Flag that indicates whether to exclude Table API links for reference fields.
	//
	//Valid values:
	//
	//- true: Exclude Table API links for reference fields.
	//
	//- false: Include Table API links for reference fields.
	ExcludeReferenceLink bool `url:"sysparm_exclude_reference_link"`
	//list of fields to return in the response.
	Fields            []string `url:"sysparm_fields"`
	InputDisplayValue bool     `url:"sysparm_input_display_value"`
	//	UI view for which to render the data. Determines the fields returned in the response.
	//
	//Valid values:
	//
	//- desktop
	//- mobile
	//- both
	//If you also specify the sysparm_fields parameter, it takes precedent.
	View View `url:"sysparm_view"`
}

TableRequestBuilderPostQueryParameters represents POST query parameters for a Table Item Request.

type TableRequestBuilderPostQueryParamters deprecated

type TableRequestBuilderPostQueryParamters struct {
	//Determines the type of data returned, either the actual values from the database or the display values of the fields.
	//Display values are manipulated based on the actual value in the database and user or system settings and preferences.
	//If returning display values, the value that is returned is dependent on the field type.
	//- Choice fields: The database value may be a number, but the display value will be more descriptive.
	//
	//- Date fields: The database value is in UTC format, while the display value is based on the user's time zone.
	//
	//- Encrypted text: The database value is encrypted, while the displayed value is unencrypted based on the user's encryption context.
	//
	//- Reference fields: The database value is sys_id, but the display value is a display field of the referenced record.
	DisplayValue DisplayValue `url:"sysparm_display_value"`
	//Flag that indicates whether to exclude Table API links for reference fields.
	//
	//Valid values:
	//
	//- true: Exclude Table API links for reference fields.
	//
	//- false: Include Table API links for reference fields.
	ExcludeReferenceLink bool `url:"sysparm_exclude_reference_link"`
	//list of fields to return in the response.
	Fields            []string `url:"sysparm_fields"`
	InputDisplayValue bool     `url:"sysparm_input_display_value"`
	//	UI view for which to render the data. Determines the fields returned in the response.
	//
	//Valid values:
	//
	//- desktop
	//- mobile
	//- both
	//If you also specify the sysparm_fields parameter, it takes precedent.
	View View `url:"sysparm_view"`
}

Deprecated: deprecated as of v1.4.0. use `TableRequestBuilderPostQueryParameters` instead

TableRequestBuilderPostQueryParamters represents POST query parameters for a Table Item Request.

type TableResponse

type TableResponse struct {
	Result TableEntry
}

type TableService

type TableService interface {
	Get(params *TableRequestBuilderGetQueryParameters) (*TableCollectionResponse, error)
	Post(data interface{}, params *TableRequestBuilderPostQueryParameters) (*TableItemResponse, error)
	Count() (int, error)
}

TableService defines the operations available for the table as a whole.

type TableValue

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

TableValue is the reflection interface to a table value.

func (*TableValue) Bool

func (tV *TableValue) Bool() (bool, error)

Bool returns tV's underlying value, as a bool.

func (*TableValue) Float

func (tV *TableValue) Float() (float64, error)

Float returns tV's underlying value, as a float64.

func (*TableValue) GetType deprecated

func (tV *TableValue) GetType() reflect.Type

Deprecated: deprecated as of 1.4.0 please utilize `Type`

GetType returns tV's underlying value type.

func (*TableValue) Int

func (tV *TableValue) Int() (int64, error)

Int returns tV's underlying value, as an int64.

func (*TableValue) String

func (tV *TableValue) String() (string, error)

String returns tV's underlying value, as a string.

func (*TableValue) ToBool deprecated

func (tV *TableValue) ToBool() (bool, error)

Deprecated: deprecated as of 1.4.0 please utilize `Bool`

ToBool returns tV's underlying value, as a bool.

func (*TableValue) ToFloat64 deprecated

func (tV *TableValue) ToFloat64() (float64, error)

Deprecated: deprecated as of 1.4.0 please utilize `ToFloat64`

ToFloat64 returns tV's underlying value, as a float64.

func (*TableValue) ToInt64 deprecated

func (tV *TableValue) ToInt64() (int64, error)

Deprecated: deprecated as of 1.4.0 please utilize `ToInt64`

ToInt64 returns tV's underlying value, as an int64.

func (*TableValue) ToString deprecated

func (tV *TableValue) ToString() (string, error)

Deprecated: deprecated as of 1.4.0 please utilize `String`

ToString returns tV's underlying value, as a string.

func (*TableValue) Type

func (tV *TableValue) Type() reflect.Type

Type returns tV's underlying value type.

type View

type View string
const (
	DESKTOP View = "desktop"
	MOBILE  View = "mobile"
	BOTH    View = "both"
)

type View2

type View2 int64
const (
	ViewDesktop View2 = iota
	ViewMobile
	ViewBoth
)

func (View2) String

func (v View2) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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