servicenow

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

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"
)

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"}
)

Functions

This section is empty.

Types

type BaseResource

type BaseResource struct {
	Id string `json:"sys_id"`
}

type Client

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

func NewClient

func NewClient(httpClient *http.Client, auth string, deployment string) *Client

func (*Client) AddUserToGroup

func (c *Client) AddUserToGroup(ctx context.Context, record GroupMemberPayload) error

func (*Client) GetGroup

func (c *Client) GetGroup(ctx context.Context, groupId string) (*Group, error)

func (*Client) GetGroupToRole

func (c *Client) GetGroupToRole(ctx context.Context, groupId string, roleId string, paginationVars PaginationVars) ([]GroupToRole, int, error)

Table `sys_group_has_role` (Group to Role).

func (*Client) GetGroups

func (c *Client) GetGroups(ctx context.Context, paginationVars PaginationVars, groupIds []string) ([]Group, int, error)

Table `sys_user_group` (Groups).

func (*Client) GetRoles

func (c *Client) GetRoles(ctx context.Context, paginationVars PaginationVars) ([]Role, int, error)

Table `sys_user_role` (Roles).

func (*Client) GetUser

func (c *Client) GetUser(ctx context.Context, userId string) (*User, error)

func (*Client) GetUserToGroup

func (c *Client) GetUserToGroup(ctx context.Context, userId string, groupId string, paginationVars PaginationVars) ([]GroupMember, int, error)

Table `sys_user_grmember` (Group Members).

func (*Client) GetUserToRole

func (c *Client) GetUserToRole(ctx context.Context, userId string, roleId string, paginationVars PaginationVars) ([]UserToRole, int, error)

Table `sys_user_has_role` (User to Role).

func (*Client) GetUsers

func (c *Client) GetUsers(ctx context.Context, paginationVars PaginationVars, userIds []string) ([]User, int, 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) RemoveUserFromGroup

func (c *Client) RemoveUserFromGroup(ctx context.Context, id string) error

func (*Client) RevokeRoleFromGroup

func (c *Client) RevokeRoleFromGroup(ctx context.Context, id string) error

func (*Client) RevokeRoleFromUser

func (c *Client) RevokeRoleFromUser(ctx context.Context, id string) error

type FilterVars

type FilterVars struct {
	Fields []string
	Query  string
	UserId string
}

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 GroupMemberPayload struct {
	User  string `json:"user"`
	Group string `json:"group"`
}

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 GroupToRolePayload struct {
	Group string `json:"group"`
	Role  string `json:"role"`
}

type GroupToRoleResponse

type GroupToRoleResponse ListResponse[GroupToRole]

type GroupsResponse

type GroupsResponse = ListResponse[Group]

type ListResponse

type ListResponse[T any] struct {
	Result []T `json:"result"`
}

type PaginationVars

type PaginationVars struct {
	Limit  int
	Offset int
}

type QueryParam

type QueryParam interface {
	// contains filtered or unexported methods
}

type Role

type Role struct {
	BaseResource
	Name      string `json:"name"`
	Grantable string `json:"grantable"`
}

type RolesResponse

type RolesResponse = ListResponse[Role]

type SingleResponse

type SingleResponse[T any] struct {
	Result T `json:"result"`
}

type User

type User struct {
	BaseResource
	Email     string `json:"email"`
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
	UserName  string `json:"user_name"`
	Roles     string `json:"roles"`
}

type UserResponse

type UserResponse = SingleResponse[User]

type UserRoles

type UserRoles struct {
	UserName  string   `json:"user_name"`
	FromRole  []string `json:"from_role"`
	FromGroup []string `json:"from_group"`
}

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 UserToRolePayload struct {
	User string `json:"user"`
	Role string `json:"role"`
}

type UserToRoleResponse

type UserToRoleResponse ListResponse[UserToRole]

type UsersResponse

type UsersResponse = ListResponse[User]

Jump to

Keyboard shortcuts

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