client

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultPageSize is the default number of items per page.
	DefaultPageSize = 1000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AddUsersToGroupRequest

type AddUsersToGroupRequest struct {
	Emails []string `json:"emails"`
}

AddUsersToGroupRequest is the request body for adding users to a group.

type AddUsersToGroupResponse

type AddUsersToGroupResponse struct {
	Data struct {
		UserGroup Group `json:"userGroup"`
	} `json:"data"`
}

AddUsersToGroupResponse is the response from adding users to a group.

type Client

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

Client is the HTTP client for the Segment API.

func New

func New(ctx context.Context, accessToken, baseURL string) (*Client, error)

New creates a new Segment API client.

func (*Client) AddUserPermissions

func (c *Client) AddUserPermissions(ctx context.Context, userID string, permissions []PermissionInput) (*UpdatePermissionsResponse, *v2.RateLimitDescription, error)

AddUserPermissions adds permissions to a user (appends to existing). API Docs: https://docs.segmentapis.com/tag/IAM-Users#operation/addPermissionsToUser

func (*Client) AddUsersToGroup

func (c *Client) AddUsersToGroup(ctx context.Context, groupID string, emails []string) (*AddUsersToGroupResponse, *v2.RateLimitDescription, error)

AddUsersToGroup adds users to a group by email.

func (*Client) CreateInvites

func (c *Client) CreateInvites(ctx context.Context, invites []InviteRequest) (*CreateInvitesResponse, *v2.RateLimitDescription, error)

CreateInvites creates new workspace invitations.

func (*Client) DeleteInvites

func (c *Client) DeleteInvites(ctx context.Context, emails []string) (*v2.RateLimitDescription, error)

DeleteInvites removes pending invitations by email.

func (*Client) DeleteUser

func (c *Client) DeleteUser(ctx context.Context, userID string) (*v2.RateLimitDescription, error)

DeleteUser removes a user from the workspace.

func (*Client) GetGroup

func (c *Client) GetGroup(ctx context.Context, groupID string) (*GetGroupResponse, *v2.RateLimitDescription, error)

GetGroup returns a single group by ID with its permissions.

func (*Client) GetUser

func (c *Client) GetUser(ctx context.Context, userID string) (*GetUserResponse, *v2.RateLimitDescription, error)

GetUser returns a single user by ID.

func (*Client) GetWorkspace

GetWorkspace returns the workspace associated with the access token.

func (*Client) ListFunctions

func (c *Client) ListFunctions(ctx context.Context, cursor string, pageSize int, resourceType string) (*ListFunctionsResponse, *v2.RateLimitDescription, error)

ListFunctions returns all functions in the workspace.

func (*Client) ListGroupUsers

func (c *Client) ListGroupUsers(ctx context.Context, groupID string, cursor string, pageSize int) (*ListGroupUsersResponse, *v2.RateLimitDescription, error)

ListGroupUsers returns all users in a group.

func (*Client) ListGroups

func (c *Client) ListGroups(ctx context.Context, cursor string, pageSize int) (*ListGroupsResponse, *v2.RateLimitDescription, error)

ListGroups returns all groups in the workspace.

func (*Client) ListInvites

func (c *Client) ListInvites(ctx context.Context, cursor string, pageSize int) (*ListInvitesResponse, *v2.RateLimitDescription, error)

ListInvites returns all pending invites in the workspace.

func (*Client) ListRoles

ListRoles returns all roles in the workspace. Roles are system-defined by Segment (~8 built-in), so no pagination is needed.

func (*Client) ListSources

func (c *Client) ListSources(ctx context.Context, cursor string, pageSize int) (*ListSourcesResponse, *v2.RateLimitDescription, error)

ListSources returns all sources in the workspace.

func (*Client) ListSpaces

func (c *Client) ListSpaces(ctx context.Context, cursor string, pageSize int) (*ListSpacesResponse, *v2.RateLimitDescription, error)

ListSpaces returns all spaces in the workspace.

func (*Client) ListUsers

func (c *Client) ListUsers(ctx context.Context, cursor string, pageSize int) (*ListUsersResponse, *v2.RateLimitDescription, error)

ListUsers returns all users in the workspace.

func (*Client) ListWarehouses

func (c *Client) ListWarehouses(ctx context.Context, cursor string, pageSize int) (*ListWarehousesResponse, *v2.RateLimitDescription, error)

ListWarehouses returns all warehouses in the workspace.

func (*Client) RemoveUsersFromGroup

func (c *Client) RemoveUsersFromGroup(ctx context.Context, groupID string, emails []string) (*v2.RateLimitDescription, error)

RemoveUsersFromGroup removes users from a group by email.

func (*Client) ReplaceUserPermissions

func (c *Client) ReplaceUserPermissions(ctx context.Context, userID string, permissions []PermissionInput) (*UpdatePermissionsResponse, *v2.RateLimitDescription, error)

ReplaceUserPermissions replaces all permissions for a user (overwrites existing). API Docs: https://docs.segmentapis.com/tag/IAM-Users#operation/replacePermissionsForUser

func (*Client) ValidateCredentials

func (c *Client) ValidateCredentials(ctx context.Context) (*v2.RateLimitDescription, error)

ValidateCredentials makes a simple API call to verify the access token is valid.

type CreateInvitesRequest

type CreateInvitesRequest struct {
	Invites []InviteRequest `json:"invites"`
}

CreateInvitesRequest is the request body for creating invites.

type CreateInvitesResponse

type CreateInvitesResponse struct {
	Data struct {
		Emails []string `json:"emails"`
	} `json:"data"`
}

CreateInvitesResponse is the response from the create invites endpoint.

type ErrorResponse

type ErrorResponse struct {
	Errors []struct {
		Type    string `json:"type"`
		Message string `json:"message"`
		Field   string `json:"field,omitempty"`
	} `json:"errors"`
}

ErrorResponse represents an error response from the Segment API.

func (*ErrorResponse) Message

func (e *ErrorResponse) Message() string

Message implements the uhttp error response interface.

type Function

type Function struct {
	ID           string `json:"id"`
	WorkspaceID  string `json:"workspaceId"`
	DisplayName  string `json:"displayName"`
	Description  string `json:"description,omitempty"`
	ResourceType string `json:"resourceType"` // SOURCE or DESTINATION
}

Function represents a Segment function.

type GetGroupResponse

type GetGroupResponse struct {
	Data struct {
		UserGroup Group `json:"userGroup"`
	} `json:"data"`
}

GetGroupResponse is the response from the get group endpoint.

type GetUserResponse

type GetUserResponse struct {
	Data struct {
		User User `json:"user"`
	} `json:"data"`
}

GetUserResponse is the response from the get user endpoint.

type GetWorkspaceResponse

type GetWorkspaceResponse struct {
	Data struct {
		Workspace Workspace `json:"workspace"`
	} `json:"data"`
}

GetWorkspaceResponse is the response from the get workspace endpoint.

type Group

type Group struct {
	ID          string       `json:"id"`
	Name        string       `json:"name"`
	MemberCount int          `json:"memberCount,omitempty"`
	Permissions []Permission `json:"permissions,omitempty"`
}

Group represents a Segment IAM user group.

type Invite

type Invite struct {
	Email       string       `json:"email"`
	Permissions []Permission `json:"permissions,omitempty"`
}

Invite represents a pending workspace invitation.

type InviteRequest

type InviteRequest struct {
	Email       string            `json:"email"`
	Permissions []PermissionInput `json:"permissions,omitempty"`
}

InviteRequest represents a single invite request.

type Label

type Label struct {
	Key         string `json:"key"`
	Value       string `json:"value"`
	Description string `json:"description,omitempty"`
}

Label represents a label in a permission.

type ListFunctionsResponse

type ListFunctionsResponse struct {
	Data struct {
		Functions  []Function `json:"functions"`
		Pagination Pagination `json:"pagination"`
	} `json:"data"`
}

ListFunctionsResponse is the response from the list functions endpoint.

type ListGroupUsersResponse

type ListGroupUsersResponse struct {
	Data struct {
		Users      []User     `json:"users"`
		Pagination Pagination `json:"pagination"`
	} `json:"data"`
}

ListGroupUsersResponse is the response from the list group users endpoint.

type ListGroupsResponse

type ListGroupsResponse struct {
	Data struct {
		UserGroups []Group    `json:"userGroups"`
		Pagination Pagination `json:"pagination"`
	} `json:"data"`
}

ListGroupsResponse is the response from the list groups endpoint.

type ListInvitesResponse

type ListInvitesResponse struct {
	Data struct {
		Invites    []string   `json:"invites"` // Invites are just email strings
		Pagination Pagination `json:"pagination"`
	} `json:"data"`
}

ListInvitesResponse is the response from the list invites endpoint.

type ListRolesResponse

type ListRolesResponse struct {
	Data struct {
		Roles []Role `json:"roles"`
	} `json:"data"`
}

ListRolesResponse is the response from the list roles endpoint. Roles are system-defined by Segment (~8 built-in). No pagination needed.

type ListSourcesResponse

type ListSourcesResponse struct {
	Data struct {
		Sources    []Source   `json:"sources"`
		Pagination Pagination `json:"pagination"`
	} `json:"data"`
}

ListSourcesResponse is the response from the list sources endpoint.

type ListSpacesResponse

type ListSpacesResponse struct {
	Data struct {
		Spaces     []Space    `json:"spaces"`
		Pagination Pagination `json:"pagination"`
	} `json:"data"`
}

ListSpacesResponse is the response from the list spaces endpoint.

type ListUsersResponse

type ListUsersResponse struct {
	Data struct {
		Users      []User     `json:"users"`
		Pagination Pagination `json:"pagination"`
	} `json:"data"`
}

ListUsersResponse is the response from the list users endpoint.

type ListWarehousesResponse

type ListWarehousesResponse struct {
	Data struct {
		Warehouses []Warehouse `json:"warehouses"`
		Pagination Pagination  `json:"pagination"`
	} `json:"data"`
}

ListWarehousesResponse is the response from the list warehouses endpoint.

type Pagination

type Pagination struct {
	Current   string `json:"current,omitempty"`
	Next      string `json:"next,omitempty"`
	Previous  string `json:"previous,omitempty"`
	TotalSize int    `json:"totalEntries,omitempty"`
}

Pagination represents the pagination information in API responses.

type Permission

type Permission struct {
	RoleID    string     `json:"roleId"`
	RoleName  string     `json:"roleName,omitempty"`
	Resources []Resource `json:"resources,omitempty"`
	Labels    []Label    `json:"labels,omitempty"`
}

Permission represents a permission assigned to a user or group.

type PermissionInput

type PermissionInput struct {
	RoleID    string          `json:"roleId"`
	Resources []ResourceInput `json:"resources"`
}

PermissionInput represents a permission to be set on a user or group.

type Resource

type Resource struct {
	ID    string `json:"id"`
	Type  string `json:"type"`
	Label string `json:"label,omitempty"`
}

Resource represents a resource in a permission.

type ResourceInput

type ResourceInput struct {
	ID   string `json:"id"`
	Type string `json:"type"`
}

ResourceInput represents a resource for permission assignment.

type Role

type Role struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
}

Role represents a Segment IAM role.

type Source

type Source struct {
	ID          string `json:"id"`
	Slug        string `json:"slug"`
	Name        string `json:"name"`
	WorkspaceID string `json:"workspaceId"`
	Enabled     bool   `json:"enabled"`
}

Source represents a Segment data source.

type Space

type Space struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Slug string `json:"slug"`
}

Space represents a Segment space (Personas environment).

type UpdatePermissionsRequest

type UpdatePermissionsRequest struct {
	Permissions []PermissionInput `json:"permissions"`
}

UpdatePermissionsRequest is the request body for updating permissions.

type UpdatePermissionsResponse

type UpdatePermissionsResponse struct {
	Data struct {
		Permissions []Permission `json:"permissions"`
	} `json:"data"`
}

UpdatePermissionsResponse is the response from updating permissions.

type User

type User struct {
	ID          string       `json:"id"`
	Name        string       `json:"name"`
	Email       string       `json:"email"`
	Permissions []Permission `json:"permissions,omitempty"`
}

User represents a Segment IAM user.

type Warehouse

type Warehouse struct {
	ID          string             `json:"id"`
	WorkspaceID string             `json:"workspaceId"`
	Enabled     bool               `json:"enabled"`
	Metadata    *WarehouseMetadata `json:"metadata,omitempty"`
}

Warehouse represents a Segment data warehouse.

type WarehouseMetadata

type WarehouseMetadata struct {
	ID          string `json:"id"`
	Slug        string `json:"slug"`
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
}

WarehouseMetadata contains metadata about a warehouse.

type Workspace

type Workspace struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Slug string `json:"slug"`
}

Workspace represents a Segment workspace.

Jump to

Keyboard shortcuts

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