apiclientgo

package module
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2025 License: MIT Imports: 13 Imported by: 0

README

api-client-go

The Glean Go SDK provides convenient access to the Glean REST API for Go 1.18+. It offers strongly typed request and response structs, context-based request handling, and uses the standard net/http package.

Unified SDK Architecture

This SDK combines both the Client and Indexing API namespaces into a single unified package:

  • Client API: Used for search, retrieval, and end-user interactions with Glean content
  • Indexing API: Used for indexing content, permissions, and other administrative operations

Each namespace has its own authentication requirements and access patterns. While they serve different purposes, having them in a single SDK provides a consistent developer experience across all Glean API interactions.

// Example of accessing Client namespace
s := apiclientgo.New(
	apiclientgo.WithSecurity("client-token"),
)
res, err := s.Client.Search.Query(ctx, components.SearchRequest{
	Query: "search term",
})

// Example of accessing Indexing namespace 
s := apiclientgo.New(
	apiclientgo.WithSecurity("indexing-token"),
)
res, err := s.Indexing.Documents.Index(ctx, components.DocumentRequest{
	// document data
})

Remember that each namespace requires its own authentication token type as described in the Authentication Methods section.

Table of Contents

SDK Installation

To add the SDK as a dependency to your project:

go get github.com/gleanwork/api-client-go

SDK Example Usage

Example 1
package main

import (
	"context"
	apiclientgo "github.com/gleanwork/api-client-go"
	"github.com/gleanwork/api-client-go/models/components"
	"log"
	"os"
)

func main() {
	ctx := context.Background()

	s := apiclientgo.New(
		apiclientgo.WithSecurity(os.Getenv("GLEAN_API_TOKEN")),
	)

	res, err := s.Client.Chat.Create(ctx, components.ChatRequest{
		Messages: []components.ChatMessage{
			components.ChatMessage{
				Fragments: []components.ChatMessageFragment{
					components.ChatMessageFragment{
						Text: apiclientgo.String("What are the company holidays this year?"),
					},
				},
			},
		},
	}, nil)
	if err != nil {
		log.Fatal(err)
	}
	if res.ChatResponse != nil {
		// handle response
	}
}

Example 2
package main

import (
	"context"
	apiclientgo "github.com/gleanwork/api-client-go"
	"github.com/gleanwork/api-client-go/models/components"
	"log"
	"os"
)

func main() {
	ctx := context.Background()

	s := apiclientgo.New(
		apiclientgo.WithSecurity(os.Getenv("GLEAN_API_TOKEN")),
	)

	res, err := s.Client.Chat.CreateStream(ctx, components.ChatRequest{
		Messages: []components.ChatMessage{
			components.ChatMessage{
				Fragments: []components.ChatMessageFragment{
					components.ChatMessageFragment{
						Text: apiclientgo.String("What are the company holidays this year?"),
					},
				},
			},
		},
	}, nil)
	if err != nil {
		log.Fatal(err)
	}
	if res.ChatRequestStream != nil {
		// handle response
	}
}

Authentication

Per-Client Security Schemes

This SDK supports the following security scheme globally:

Name Type Scheme Environment Variable
APIToken http HTTP Bearer GLEAN_API_TOKEN

You can configure it using the WithSecurity option when initializing the SDK client instance. For example:

package main

import (
	"context"
	apiclientgo "github.com/gleanwork/api-client-go"
	"github.com/gleanwork/api-client-go/models/components"
	"github.com/gleanwork/api-client-go/types"
	"log"
	"os"
)

func main() {
	ctx := context.Background()

	s := apiclientgo.New(
		apiclientgo.WithSecurity(os.Getenv("GLEAN_API_TOKEN")),
	)

	res, err := s.Client.Activity.Report(ctx, components.Activity{
		Events: []components.ActivityEvent{
			components.ActivityEvent{
				Action:    components.ActivityEventActionHistoricalView,
				Timestamp: types.MustTimeFromString("2000-01-23T04:56:07.000Z"),
				URL:       "https://example.com/",
			},
			components.ActivityEvent{
				Action: components.ActivityEventActionSearch,
				Params: &components.ActivityEventParams{
					Query: apiclientgo.String("query"),
				},
				Timestamp: types.MustTimeFromString("2000-01-23T04:56:07.000Z"),
				URL:       "https://example.com/search?q=query",
			},
			components.ActivityEvent{
				Action: components.ActivityEventActionView,
				Params: &components.ActivityEventParams{
					Duration: apiclientgo.Int64(20),
					Referrer: apiclientgo.String("https://example.com/document"),
				},
				Timestamp: types.MustTimeFromString("2000-01-23T04:56:07.000Z"),
				URL:       "https://example.com/",
			},
		},
	})
	if err != nil {
		log.Fatal(err)
	}
	if res != nil {
		// handle response
	}
}

Authentication Methods

Glean supports different authentication methods depending on which API namespace you're using:

Client Namespace

The Client namespace supports two authentication methods:

  1. Manually Provisioned API Tokens

    • Can be created by an Admin or a user with the API Token Creator role
    • Used for server-to-server integrations
  2. OAuth

    • Requires OAuth setup to be completed by an Admin
    • Used for user-based authentication flows
Indexing Namespace

The Indexing namespace supports only one authentication method:

  1. Manually Provisioned API Tokens
    • Can be created by an Admin or a user with the API Token Creator role
    • Used for secure document indexing operations

[!IMPORTANT] Client tokens will not work for Indexing operations, and Indexing tokens will not work for Client operations. You must use the appropriate token type for the namespace you're accessing.

For more information on obtaining the appropriate token type, please contact your Glean administrator.

Available Resources and Operations

Available methods
Client
Client.Activity
Client.Agents
  • Retrieve - Retrieve an agent
  • RetrieveSchemas - List an agent's schemas
  • List - Search agents
  • RunStream - Create an agent run and stream the response
  • Run - Create an agent run and wait for the response
Client.Announcements
Client.Answers
Client.Authentication
Client.Chat
Client.Collections
Client.Documents
Client.Entities
Client.Governance.Data.Policies
  • Retrieve - Gets specified policy
  • Update - Updates an existing policy
  • List - Lists policies
  • Create - Creates new policy
  • Download - Downloads violations CSV for policy
Client.Governance.Data.Reports
  • Create - Creates new one-time report
  • Download - Downloads violations CSV for report
  • Status - Fetches report run status
Client.Governance.Documents.Visibilityoverrides
  • List - Fetches documents visibility
  • Create - Hide or unhide docs
Client.Insights
Client.Messages
Client.Pins
Client.Shortcuts
Client.Tools
  • List - List available tools
  • Run - Execute the specified tool
Client.Verification
Indexing
Indexing.Authentication
Indexing.Datasource
  • Status - Beta: Get datasource status
Indexing.Datasources
Indexing.Documents
  • AddOrUpdate - Index document

  • Index - Index documents

  • BulkIndex - Bulk index documents

  • ProcessAll - Schedules the processing of uploaded documents

  • Delete - Delete document

  • Debug - Beta: Get document information

  • DebugMany - Beta: Get information of a batch of documents

  • CheckAccess - Check document access

  • Status - Get document upload and indexing status ⚠ Deprecated

  • Count - Get document count ⚠ Deprecated

Indexing.People
Indexing.Permissions
Indexing.Shortcuts

Retries

Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.

To change the default retry strategy for a single API call, simply provide a retry.Config object to the call by using the WithRetries option:

package main

import (
	"context"
	apiclientgo "github.com/gleanwork/api-client-go"
	"github.com/gleanwork/api-client-go/models/components"
	"github.com/gleanwork/api-client-go/retry"
	"github.com/gleanwork/api-client-go/types"
	"log"
	"models/operations"
	"os"
)

func main() {
	ctx := context.Background()

	s := apiclientgo.New(
		apiclientgo.WithSecurity(os.Getenv("GLEAN_API_TOKEN")),
	)

	res, err := s.Client.Activity.Report(ctx, components.Activity{
		Events: []components.ActivityEvent{
			components.ActivityEvent{
				Action:    components.ActivityEventActionHistoricalView,
				Timestamp: types.MustTimeFromString("2000-01-23T04:56:07.000Z"),
				URL:       "https://example.com/",
			},
			components.ActivityEvent{
				Action: components.ActivityEventActionSearch,
				Params: &components.ActivityEventParams{
					Query: apiclientgo.String("query"),
				},
				Timestamp: types.MustTimeFromString("2000-01-23T04:56:07.000Z"),
				URL:       "https://example.com/search?q=query",
			},
			components.ActivityEvent{
				Action: components.ActivityEventActionView,
				Params: &components.ActivityEventParams{
					Duration: apiclientgo.Int64(20),
					Referrer: apiclientgo.String("https://example.com/document"),
				},
				Timestamp: types.MustTimeFromString("2000-01-23T04:56:07.000Z"),
				URL:       "https://example.com/",
			},
		},
	}, operations.WithRetries(
		retry.Config{
			Strategy: "backoff",
			Backoff: &retry.BackoffStrategy{
				InitialInterval: 1,
				MaxInterval:     50,
				Exponent:        1.1,
				MaxElapsedTime:  100,
			},
			RetryConnectionErrors: false,
		}))
	if err != nil {
		log.Fatal(err)
	}
	if res != nil {
		// handle response
	}
}

If you'd like to override the default retry strategy for all operations that support retries, you can use the WithRetryConfig option at SDK initialization:

package main

import (
	"context"
	apiclientgo "github.com/gleanwork/api-client-go"
	"github.com/gleanwork/api-client-go/models/components"
	"github.com/gleanwork/api-client-go/retry"
	"github.com/gleanwork/api-client-go/types"
	"log"
	"os"
)

func main() {
	ctx := context.Background()

	s := apiclientgo.New(
		apiclientgo.WithRetryConfig(
			retry.Config{
				Strategy: "backoff",
				Backoff: &retry.BackoffStrategy{
					InitialInterval: 1,
					MaxInterval:     50,
					Exponent:        1.1,
					MaxElapsedTime:  100,
				},
				RetryConnectionErrors: false,
			}),
		apiclientgo.WithSecurity(os.Getenv("GLEAN_API_TOKEN")),
	)

	res, err := s.Client.Activity.Report(ctx, components.Activity{
		Events: []components.ActivityEvent{
			components.ActivityEvent{
				Action:    components.ActivityEventActionHistoricalView,
				Timestamp: types.MustTimeFromString("2000-01-23T04:56:07.000Z"),
				URL:       "https://example.com/",
			},
			components.ActivityEvent{
				Action: components.ActivityEventActionSearch,
				Params: &components.ActivityEventParams{
					Query: apiclientgo.String("query"),
				},
				Timestamp: types.MustTimeFromString("2000-01-23T04:56:07.000Z"),
				URL:       "https://example.com/search?q=query",
			},
			components.ActivityEvent{
				Action: components.ActivityEventActionView,
				Params: &components.ActivityEventParams{
					Duration: apiclientgo.Int64(20),
					Referrer: apiclientgo.String("https://example.com/document"),
				},
				Timestamp: types.MustTimeFromString("2000-01-23T04:56:07.000Z"),
				URL:       "https://example.com/",
			},
		},
	})
	if err != nil {
		log.Fatal(err)
	}
	if res != nil {
		// handle response
	}
}

Error Handling

Handling errors in this SDK should largely match your expectations. All operations return a response object or an error, they will never return both.

By Default, an API error will return apierrors.APIError. When custom error responses are specified for an operation, the SDK may also return their associated error. You can refer to respective Errors tables in SDK docs for more details on possible error types for each operation.

For example, the Create function may return the following errors:

Error Type Status Code Content Type
apierrors.CollectionError 422 application/json
apierrors.APIError 4XX, 5XX */*
Example
package main

import (
	"context"
	"errors"
	apiclientgo "github.com/gleanwork/api-client-go"
	"github.com/gleanwork/api-client-go/models/apierrors"
	"github.com/gleanwork/api-client-go/models/components"
	"github.com/gleanwork/api-client-go/types"
	"log"
	"os"
)

func main() {
	ctx := context.Background()

	s := apiclientgo.New(
		apiclientgo.WithSecurity(os.Getenv("GLEAN_API_TOKEN")),
	)

	res, err := s.Client.Collections.Create(ctx, components.CreateCollectionRequest{
		Name: "<value>",
		AddedRoles: []components.UserRoleSpecification{
			components.UserRoleSpecification{
				Person: &components.Person{
					Name:         "George Clooney",
					ObfuscatedID: "abc123",
					RelatedDocuments: []components.RelatedDocuments{
						components.RelatedDocuments{
							QuerySuggestion: &components.QuerySuggestion{
								Query: "app:github type:pull author:mortimer",
								SearchProviderInfo: &components.SearchProviderInfo{
									Name:                  apiclientgo.String("Google"),
									SearchLinkURLTemplate: apiclientgo.String("https://www.google.com/search?q={query}&hl=en"),
								},
								Label:      apiclientgo.String("Mortimer's PRs"),
								Datasource: apiclientgo.String("github"),
								RequestOptions: &components.SearchRequestOptions{
									DatasourceFilter: apiclientgo.String("JIRA"),
									DatasourcesFilter: []string{
										"JIRA",
									},
									QueryOverridesFacetFilters: apiclientgo.Bool(true),
									FacetFilters: []components.FacetFilter{
										components.FacetFilter{
											FieldName: apiclientgo.String("type"),
											Values: []components.FacetFilterValue{
												components.FacetFilterValue{
													Value:        apiclientgo.String("Spreadsheet"),
													RelationType: components.RelationTypeEquals.ToPointer(),
												},
												components.FacetFilterValue{
													Value:        apiclientgo.String("Presentation"),
													RelationType: components.RelationTypeEquals.ToPointer(),
												},
											},
										},
									},
									FacetFilterSets: []components.FacetFilterSet{
										components.FacetFilterSet{
											Filters: []components.FacetFilter{
												components.FacetFilter{
													FieldName: apiclientgo.String("type"),
													Values: []components.FacetFilterValue{
														components.FacetFilterValue{
															Value:        apiclientgo.String("Spreadsheet"),
															RelationType: components.RelationTypeEquals.ToPointer(),
														},
														components.FacetFilterValue{
															Value:        apiclientgo.String("Presentation"),
															RelationType: components.RelationTypeEquals.ToPointer(),
														},
													},
												},
											},
										},
										components.FacetFilterSet{
											Filters: []components.FacetFilter{
												components.FacetFilter{
													FieldName: apiclientgo.String("type"),
													Values: []components.FacetFilterValue{
														components.FacetFilterValue{
															Value:        apiclientgo.String("Spreadsheet"),
															RelationType: components.RelationTypeEquals.ToPointer(),
														},
														components.FacetFilterValue{
															Value:        apiclientgo.String("Presentation"),
															RelationType: components.RelationTypeEquals.ToPointer(),
														},
													},
												},
											},
										},
										components.FacetFilterSet{
											Filters: []components.FacetFilter{
												components.FacetFilter{
													FieldName: apiclientgo.String("type"),
													Values: []components.FacetFilterValue{
														components.FacetFilterValue{
															Value:        apiclientgo.String("Spreadsheet"),
															RelationType: components.RelationTypeEquals.ToPointer(),
														},
														components.FacetFilterValue{
															Value:        apiclientgo.String("Presentation"),
															RelationType: components.RelationTypeEquals.ToPointer(),
														},
													},
												},
											},
										},
									},
									FacetBucketSize: 977077,
									AuthTokens: []components.AuthToken{
										components.AuthToken{
											AccessToken: "123abc",
											Datasource:  "gmail",
											Scope:       apiclientgo.String("email profile https://www.googleapis.com/auth/gmail.readonly"),
											TokenType:   apiclientgo.String("Bearer"),
											AuthUser:    apiclientgo.String("1"),
										},
									},
								},
								Ranges: []components.TextRange{
									components.TextRange{
										StartIndex: 86650,
										Document: &components.Document{
											Metadata: &components.DocumentMetadata{
												Datasource: apiclientgo.String("datasource"),
												ObjectType: apiclientgo.String("Feature Request"),
												Container:  apiclientgo.String("container"),
												ParentID:   apiclientgo.String("JIRA_EN-1337"),
												MimeType:   apiclientgo.String("mimeType"),
												DocumentID: apiclientgo.String("documentId"),
												CreateTime: types.MustNewTimeFromString("2000-01-23T04:56:07.000Z"),
												UpdateTime: types.MustNewTimeFromString("2000-01-23T04:56:07.000Z"),
												Components: []string{
													"Backend",
													"Networking",
												},
												Status: apiclientgo.String("[\"Done\"]"),
												Pins: []components.PinDocument{
													components.PinDocument{
														AudienceFilters: []components.FacetFilter{
															components.FacetFilter{
																FieldName: apiclientgo.String("type"),
																Values: []components.FacetFilterValue{
																	components.FacetFilterValue{
																		Value:        apiclientgo.String("Spreadsheet"),
																		RelationType: components.RelationTypeEquals.ToPointer(),
																	},
																	components.FacetFilterValue{
																		Value:        apiclientgo.String("Presentation"),
																		RelationType: components.RelationTypeEquals.ToPointer(),
																	},
																},
															},
														},
														DocumentID: "<id>",
													},
												},
												Collections: []components.Collection{
													components.Collection{
														Name:        "<value>",
														Description: "meaty dial elegantly while react",
														AudienceFilters: []components.FacetFilter{
															components.FacetFilter{
																FieldName: apiclientgo.String("type"),
																Values: []components.FacetFilterValue{
																	components.FacetFilterValue{
																		Value:        apiclientgo.String("Spreadsheet"),
																		RelationType: components.RelationTypeEquals.ToPointer(),
																	},
																	components.FacetFilterValue{
																		Value:        apiclientgo.String("Presentation"),
																		RelationType: components.RelationTypeEquals.ToPointer(),
																	},
																},
															},
														},
														ID: 854591,
														Items: []components.CollectionItem{
															components.CollectionItem{
																CollectionID: 697663,
																Shortcut: &components.Shortcut{
																	InputAlias: "<value>",
																},
																ItemType: components.CollectionItemItemTypeText,
															},
															components.CollectionItem{
																CollectionID: 697663,
																Shortcut: &components.Shortcut{
																	InputAlias: "<value>",
																},
																ItemType: components.CollectionItemItemTypeText,
															},
															components.CollectionItem{
																CollectionID: 697663,
																Shortcut: &components.Shortcut{
																	InputAlias: "<value>",
																},
																ItemType: components.CollectionItemItemTypeText,
															},
														},
													},
												},
												Interactions: &components.DocumentInteractions{
													Reacts: []components.Reaction{
														components.Reaction{},
														components.Reaction{},
													},
													Shares: []components.Share{
														components.Share{
															NumDaysAgo: 365776,
														},
														components.Share{
															NumDaysAgo: 365776,
														},
														components.Share{
															NumDaysAgo: 365776,
														},
													},
												},
												Verification: &components.Verification{
													State: components.StateDeprecated,
													Metadata: &components.VerificationMetadata{
														Reminders: []components.Reminder{
															components.Reminder{
																Assignee: components.Person{
																	Name:         "George Clooney",
																	ObfuscatedID: "abc123",
																},
																RemindAt: 268615,
															},
														},
														LastReminder: &components.Reminder{
															Assignee: components.Person{
																Name:         "George Clooney",
																ObfuscatedID: "abc123",
															},
															RemindAt: 423482,
														},
													},
												},
												Shortcuts: []components.Shortcut{
													components.Shortcut{
														InputAlias: "<value>",
													},
													components.Shortcut{
														InputAlias: "<value>",
													},
													components.Shortcut{
														InputAlias: "<value>",
													},
												},
												CustomData: map[string]components.CustomDataValue{
													"someCustomField": components.CustomDataValue{},
												},
											},
										},
									},
								},
								InputDetails: &components.SearchRequestInputDetails{
									HasCopyPaste: apiclientgo.Bool(true),
								},
							},
							Results: []components.SearchResult{
								components.SearchResult{
									Title:        apiclientgo.String("title"),
									URL:          "https://example.com/foo/bar",
									NativeAppURL: apiclientgo.String("slack://foo/bar"),
									Snippets: []components.SearchResultSnippet{
										components.SearchResultSnippet{
											Snippet:  "snippet",
											MimeType: apiclientgo.String("mimeType"),
										},
									},
								},
							},
						},
						components.RelatedDocuments{
							QuerySuggestion: &components.QuerySuggestion{
								Query: "app:github type:pull author:mortimer",
								SearchProviderInfo: &components.SearchProviderInfo{
									Name:                  apiclientgo.String("Google"),
									SearchLinkURLTemplate: apiclientgo.String("https://www.google.com/search?q={query}&hl=en"),
								},
								Label:      apiclientgo.String("Mortimer's PRs"),
								Datasource: apiclientgo.String("github"),
								RequestOptions: &components.SearchRequestOptions{
									DatasourceFilter: apiclientgo.String("JIRA"),
									DatasourcesFilter: []string{
										"JIRA",
									},
									QueryOverridesFacetFilters: apiclientgo.Bool(true),
									FacetFilters: []components.FacetFilter{
										components.FacetFilter{
											FieldName: apiclientgo.String("type"),
											Values: []components.FacetFilterValue{
												components.FacetFilterValue{
													Value:        apiclientgo.String("Spreadsheet"),
													RelationType: components.RelationTypeEquals.ToPointer(),
												},
												components.FacetFilterValue{
													Value:        apiclientgo.String("Presentation"),
													RelationType: components.RelationTypeEquals.ToPointer(),
												},
											},
										},
									},
									FacetFilterSets: []components.FacetFilterSet{
										components.FacetFilterSet{
											Filters: []components.FacetFilter{
												components.FacetFilter{
													FieldName: apiclientgo.String("type"),
													Values: []components.FacetFilterValue{
														components.FacetFilterValue{
															Value:        apiclientgo.String("Spreadsheet"),
															RelationType: components.RelationTypeEquals.ToPointer(),
														},
														components.FacetFilterValue{
															Value:        apiclientgo.String("Presentation"),
															RelationType: components.RelationTypeEquals.ToPointer(),
														},
													},
												},
											},
										},
										components.FacetFilterSet{
											Filters: []components.FacetFilter{
												components.FacetFilter{
													FieldName: apiclientgo.String("type"),
													Values: []components.FacetFilterValue{
														components.FacetFilterValue{
															Value:        apiclientgo.String("Spreadsheet"),
															RelationType: components.RelationTypeEquals.ToPointer(),
														},
														components.FacetFilterValue{
															Value:        apiclientgo.String("Presentation"),
															RelationType: components.RelationTypeEquals.ToPointer(),
														},
													},
												},
											},
										},
										components.FacetFilterSet{
											Filters: []components.FacetFilter{
												components.FacetFilter{
													FieldName: apiclientgo.String("type"),
													Values: []components.FacetFilterValue{
														components.FacetFilterValue{
															Value:        apiclientgo.String("Spreadsheet"),
															RelationType: components.RelationTypeEquals.ToPointer(),
														},
														components.FacetFilterValue{
															Value:        apiclientgo.String("Presentation"),
															RelationType: components.RelationTypeEquals.ToPointer(),
														},
													},
												},
											},
										},
									},
									FacetBucketSize: 977077,
									AuthTokens: []components.AuthToken{
										components.AuthToken{
											AccessToken: "123abc",
											Datasource:  "gmail",
											Scope:       apiclientgo.String("email profile https://www.googleapis.com/auth/gmail.readonly"),
											TokenType:   apiclientgo.String("Bearer"),
											AuthUser:    apiclientgo.String("1"),
										},
									},
								},
								Ranges: []components.TextRange{
									components.TextRange{
										StartIndex: 86650,
										Document: &components.Document{
											Metadata: &components.DocumentMetadata{
												Datasource: apiclientgo.String("datasource"),
												ObjectType: apiclientgo.String("Feature Request"),
												Container:  apiclientgo.String("container"),
												ParentID:   apiclientgo.String("JIRA_EN-1337"),
												MimeType:   apiclientgo.String("mimeType"),
												DocumentID: apiclientgo.String("documentId"),
												CreateTime: types.MustNewTimeFromString("2000-01-23T04:56:07.000Z"),
												UpdateTime: types.MustNewTimeFromString("2000-01-23T04:56:07.000Z"),
												Components: []string{
													"Backend",
													"Networking",
												},
												Status: apiclientgo.String("[\"Done\"]"),
												Pins: []components.PinDocument{
													components.PinDocument{
														AudienceFilters: []components.FacetFilter{
															components.FacetFilter{
																FieldName: apiclientgo.String("type"),
																Values: []components.FacetFilterValue{
																	components.FacetFilterValue{
																		Value:        apiclientgo.String("Spreadsheet"),
																		RelationType: components.RelationTypeEquals.ToPointer(),
																	},
																	components.FacetFilterValue{
																		Value:        apiclientgo.String("Presentation"),
																		RelationType: components.RelationTypeEquals.ToPointer(),
																	},
																},
															},
														},
														DocumentID: "<id>",
													},
												},
												Collections: []components.Collection{
													components.Collection{
														Name:        "<value>",
														Description: "meaty dial elegantly while react",
														AudienceFilters: []components.FacetFilter{
															components.FacetFilter{
																FieldName: apiclientgo.String("type"),
																Values: []components.FacetFilterValue{
																	components.FacetFilterValue{
																		Value:        apiclientgo.String("Spreadsheet"),
																		RelationType: components.RelationTypeEquals.ToPointer(),
																	},
																	components.FacetFilterValue{
																		Value:        apiclientgo.String("Presentation"),
																		RelationType: components.RelationTypeEquals.ToPointer(),
																	},
																},
															},
														},
														ID: 854591,
														Items: []components.CollectionItem{
															components.CollectionItem{
																CollectionID: 697663,
																Shortcut: &components.Shortcut{
																	InputAlias: "<value>",
																},
																ItemType: components.CollectionItemItemTypeText,
															},
															components.CollectionItem{
																CollectionID: 697663,
																Shortcut: &components.Shortcut{
																	InputAlias: "<value>",
																},
																ItemType: components.CollectionItemItemTypeText,
															},
															components.CollectionItem{
																CollectionID: 697663,
																Shortcut: &components.Shortcut{
																	InputAlias: "<value>",
																},
																ItemType: components.CollectionItemItemTypeText,
															},
														},
													},
												},
												Interactions: &components.DocumentInteractions{
													Reacts: []components.Reaction{
														components.Reaction{},
														components.Reaction{},
													},
													Shares: []components.Share{
														components.Share{
															NumDaysAgo: 365776,
														},
														components.Share{
															NumDaysAgo: 365776,
														},
														components.Share{
															NumDaysAgo: 365776,
														},
													},
												},
												Verification: &components.Verification{
													State: components.StateDeprecated,
													Metadata: &components.VerificationMetadata{
														Reminders: []components.Reminder{
															components.Reminder{
																Assignee: components.Person{
																	Name:         "George Clooney",
																	ObfuscatedID: "abc123",
																},
																RemindAt: 268615,
															},
														},
														LastReminder: &components.Reminder{
															Assignee: components.Person{
																Name:         "George Clooney",
																ObfuscatedID: "abc123",
															},
															RemindAt: 423482,
														},
													},
												},
												Shortcuts: []components.Shortcut{
													components.Shortcut{
														InputAlias: "<value>",
													},
													components.Shortcut{
														InputAlias: "<value>",
													},
													components.Shortcut{
														InputAlias: "<value>",
													},
												},
												CustomData: map[string]components.CustomDataValue{
													"someCustomField": components.CustomDataValue{},
												},
											},
										},
									},
								},
								InputDetails: &components.SearchRequestInputDetails{
									HasCopyPaste: apiclientgo.Bool(true),
								},
							},
							Results: []components.SearchResult{
								components.SearchResult{
									Title:        apiclientgo.String("title"),
									URL:          "https://example.com/foo/bar",
									NativeAppURL: apiclientgo.String("slack://foo/bar"),
									Snippets: []components.SearchResultSnippet{
										components.SearchResultSnippet{
											Snippet:  "snippet",
											MimeType: apiclientgo.String("mimeType"),
										},
									},
								},
							},
						},
					},
					Metadata: &components.PersonMetadata{
						Type:       components.PersonMetadataTypeFullTime.ToPointer(),
						Title:      apiclientgo.String("Actor"),
						Department: apiclientgo.String("Movies"),
						Email:      apiclientgo.String("george@example.com"),
						Location:   apiclientgo.String("Hollywood, CA"),
						Phone:      apiclientgo.String("6505551234"),
						PhotoURL:   apiclientgo.String("https://example.com/george.jpg"),
						StartDate:  types.MustNewDateFromString("2000-01-23"),
						DatasourceProfile: []components.DatasourceProfile{
							components.DatasourceProfile{
								Datasource: "github",
								Handle:     "<value>",
							},
							components.DatasourceProfile{
								Datasource: "github",
								Handle:     "<value>",
							},
						},
						QuerySuggestions: &components.QuerySuggestionList{
							Suggestions: []components.QuerySuggestion{
								components.QuerySuggestion{
									Query:      "app:github type:pull author:mortimer",
									Label:      apiclientgo.String("Mortimer's PRs"),
									Datasource: apiclientgo.String("github"),
								},
							},
						},
						InviteInfo: &components.InviteInfo{
							Invites: []components.ChannelInviteInfo{
								components.ChannelInviteInfo{},
								components.ChannelInviteInfo{},
							},
						},
						CustomFields: []components.CustomFieldData{
							components.CustomFieldData{
								Label: "<value>",
								Values: []components.CustomFieldValue{
									components.CreateCustomFieldValueCustomFieldValueStr(
										components.CustomFieldValueStr{},
									),
									components.CreateCustomFieldValueCustomFieldValueStr(
										components.CustomFieldValueStr{},
									),
									components.CreateCustomFieldValueCustomFieldValueStr(
										components.CustomFieldValueStr{},
									),
								},
							},
							components.CustomFieldData{
								Label: "<value>",
								Values: []components.CustomFieldValue{
									components.CreateCustomFieldValueCustomFieldValueStr(
										components.CustomFieldValueStr{},
									),
									components.CreateCustomFieldValueCustomFieldValueStr(
										components.CustomFieldValueStr{},
									),
									components.CreateCustomFieldValueCustomFieldValueStr(
										components.CustomFieldValueStr{},
									),
								},
							},
						},
						Badges: []components.Badge{
							components.Badge{
								Key:         apiclientgo.String("deployment_name_new_hire"),
								DisplayName: apiclientgo.String("New hire"),
								IconConfig: &components.IconConfig{
									Color:    apiclientgo.String("#343CED"),
									Key:      apiclientgo.String("person_icon"),
									IconType: components.IconTypeGlyph.ToPointer(),
									Name:     apiclientgo.String("user"),
								},
							},
						},
					},
				},
				Role: components.UserRoleVerifier,
			},
		},
		RemovedRoles: []components.UserRoleSpecification{
			components.UserRoleSpecification{
				Person: &components.Person{
					Name:         "George Clooney",
					ObfuscatedID: "abc123",
					Metadata: &components.PersonMetadata{
						Type:       components.PersonMetadataTypeFullTime.ToPointer(),
						Title:      apiclientgo.String("Actor"),
						Department: apiclientgo.String("Movies"),
						Email:      apiclientgo.String("george@example.com"),
						Location:   apiclientgo.String("Hollywood, CA"),
						Phone:      apiclientgo.String("6505551234"),
						PhotoURL:   apiclientgo.String("https://example.com/george.jpg"),
						StartDate:  types.MustNewDateFromString("2000-01-23"),
						DatasourceProfile: []components.DatasourceProfile{
							components.DatasourceProfile{
								Datasource: "github",
								Handle:     "<value>",
							},
							components.DatasourceProfile{
								Datasource: "github",
								Handle:     "<value>",
							},
						},
						QuerySuggestions: &components.QuerySuggestionList{
							Suggestions: []components.QuerySuggestion{
								components.QuerySuggestion{
									Query:      "app:github type:pull author:mortimer",
									Label:      apiclientgo.String("Mortimer's PRs"),
									Datasource: apiclientgo.String("github"),
								},
							},
						},
						InviteInfo: &components.InviteInfo{
							Invites: []components.ChannelInviteInfo{
								components.ChannelInviteInfo{},
								components.ChannelInviteInfo{},
							},
						},
						Badges: []components.Badge{
							components.Badge{
								Key:         apiclientgo.String("deployment_name_new_hire"),
								DisplayName: apiclientgo.String("New hire"),
								IconConfig: &components.IconConfig{
									Color:    apiclientgo.String("#343CED"),
									Key:      apiclientgo.String("person_icon"),
									IconType: components.IconTypeGlyph.ToPointer(),
									Name:     apiclientgo.String("user"),
								},
							},
						},
					},
				},
				Role: components.UserRoleViewer,
			},
		},
		AudienceFilters: []components.FacetFilter{
			components.FacetFilter{
				FieldName: apiclientgo.String("type"),
				Values: []components.FacetFilterValue{
					components.FacetFilterValue{
						Value:        apiclientgo.String("Spreadsheet"),
						RelationType: components.RelationTypeEquals.ToPointer(),
					},
					components.FacetFilterValue{
						Value:        apiclientgo.String("Presentation"),
						RelationType: components.RelationTypeEquals.ToPointer(),
					},
				},
			},
		},
	})
	if err != nil {

		var e *apierrors.CollectionError
		if errors.As(err, &e) {
			// handle error
			log.Fatal(e.Error())
		}

		var e *apierrors.APIError
		if errors.As(err, &e) {
			// handle error
			log.Fatal(e.Error())
		}
	}
}

Server Selection

Server Variables

The default server https://{instance}-be.glean.com contains variables and is set to https://instance-name-be.glean.com by default. To override default values, the following options are available when initializing the SDK client instance:

Variable Option Default Description
instance WithInstance(instance string) "instance-name" The instance name (typically the email domain without the TLD) that determines the deployment backend.
Example
package main

import (
	"context"
	apiclientgo "github.com/gleanwork/api-client-go"
	"github.com/gleanwork/api-client-go/models/components"
	"github.com/gleanwork/api-client-go/types"
	"log"
	"os"
)

func main() {
	ctx := context.Background()

	s := apiclientgo.New(
		apiclientgo.WithInstance("<value>"),
		apiclientgo.WithSecurity(os.Getenv("GLEAN_API_TOKEN")),
	)

	res, err := s.Client.Activity.Report(ctx, components.Activity{
		Events: []components.ActivityEvent{
			components.ActivityEvent{
				Action:    components.ActivityEventActionHistoricalView,
				Timestamp: types.MustTimeFromString("2000-01-23T04:56:07.000Z"),
				URL:       "https://example.com/",
			},
			components.ActivityEvent{
				Action: components.ActivityEventActionSearch,
				Params: &components.ActivityEventParams{
					Query: apiclientgo.String("query"),
				},
				Timestamp: types.MustTimeFromString("2000-01-23T04:56:07.000Z"),
				URL:       "https://example.com/search?q=query",
			},
			components.ActivityEvent{
				Action: components.ActivityEventActionView,
				Params: &components.ActivityEventParams{
					Duration: apiclientgo.Int64(20),
					Referrer: apiclientgo.String("https://example.com/document"),
				},
				Timestamp: types.MustTimeFromString("2000-01-23T04:56:07.000Z"),
				URL:       "https://example.com/",
			},
		},
	})
	if err != nil {
		log.Fatal(err)
	}
	if res != nil {
		// handle response
	}
}

Override Server URL Per-Client

The default server can be overridden globally using the WithServerURL(serverURL string) option when initializing the SDK client instance. For example:

package main

import (
	"context"
	apiclientgo "github.com/gleanwork/api-client-go"
	"github.com/gleanwork/api-client-go/models/components"
	"github.com/gleanwork/api-client-go/types"
	"log"
	"os"
)

func main() {
	ctx := context.Background()

	s := apiclientgo.New(
		apiclientgo.WithServerURL("https://instance-name-be.glean.com"),
		apiclientgo.WithSecurity(os.Getenv("GLEAN_API_TOKEN")),
	)

	res, err := s.Client.Activity.Report(ctx, components.Activity{
		Events: []components.ActivityEvent{
			components.ActivityEvent{
				Action:    components.ActivityEventActionHistoricalView,
				Timestamp: types.MustTimeFromString("2000-01-23T04:56:07.000Z"),
				URL:       "https://example.com/",
			},
			components.ActivityEvent{
				Action: components.ActivityEventActionSearch,
				Params: &components.ActivityEventParams{
					Query: apiclientgo.String("query"),
				},
				Timestamp: types.MustTimeFromString("2000-01-23T04:56:07.000Z"),
				URL:       "https://example.com/search?q=query",
			},
			components.ActivityEvent{
				Action: components.ActivityEventActionView,
				Params: &components.ActivityEventParams{
					Duration: apiclientgo.Int64(20),
					Referrer: apiclientgo.String("https://example.com/document"),
				},
				Timestamp: types.MustTimeFromString("2000-01-23T04:56:07.000Z"),
				URL:       "https://example.com/",
			},
		},
	})
	if err != nil {
		log.Fatal(err)
	}
	if res != nil {
		// handle response
	}
}

Custom HTTP Client

The Go SDK makes API calls that wrap an internal HTTP client. The requirements for the HTTP client are very simple. It must match this interface:

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

The built-in net/http client satisfies this interface and a default client based on the built-in is provided by default. To replace this default with a client of your own, you can implement this interface yourself or provide your own client configured as desired. Here's a simple example, which adds a client with a 30 second timeout.

import (
	"net/http"
	"time"
	"github.com/myorg/your-go-sdk"
)

var (
	httpClient = &http.Client{Timeout: 30 * time.Second}
	sdkClient  = sdk.New(sdk.WithClient(httpClient))
)

This can be a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration.

Special Types

This SDK defines the following custom types to assist with marshalling and unmarshalling data.

Date

types.Date is a wrapper around time.Time that allows for JSON marshaling a date string formatted as "2006-01-02".

Usage
d1 := types.NewDate(time.Now()) // returns *types.Date

d2 := types.DateFromTime(time.Now()) // returns types.Date

d3, err := types.NewDateFromString("2019-01-01") // returns *types.Date, error

d4, err := types.DateFromString("2019-01-01") // returns types.Date, error

d5 := types.MustNewDateFromString("2019-01-01") // returns *types.Date and panics on error

d6 := types.MustDateFromString("2019-01-01") // returns types.Date and panics on error

Development

Maturity

This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.

Contributions

While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation. We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.

SDK Created by Speakeasy

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ServerList = []string{
	"https://{instance}-be.glean.com",
}

ServerList contains the list of servers available to the SDK

Functions

func Bool

func Bool(b bool) *bool

Bool provides a helper function to return a pointer to a bool

func Float32

func Float32(f float32) *float32

Float32 provides a helper function to return a pointer to a float32

func Float64

func Float64(f float64) *float64

Float64 provides a helper function to return a pointer to a float64

func Int

func Int(i int) *int

Int provides a helper function to return a pointer to an int

func Int64

func Int64(i int64) *int64

Int64 provides a helper function to return a pointer to an int64

func Pointer

func Pointer[T any](v T) *T

Pointer provides a helper function to return a pointer to a type

func String

func String(s string) *string

String provides a helper function to return a pointer to a string

Types

type Activity

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

func (*Activity) Feedback

func (s *Activity) Feedback(ctx context.Context, feedbackQueryParameter *string, feedback1 *components.Feedback, opts ...operations.Option) (*operations.FeedbackResponse, error)

Feedback - Report client activity Report events that happen to results within a Glean client UI, such as search result views and clicks. This signal improves search quality.

func (*Activity) Report

Report document activity Report user activity that occurs on indexed documents such as viewing or editing. This signal improves search quality.

type Agents

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

func (*Agents) List

List - Search agents Search for [agents](https://developers.glean.com/agents/agents-api) by agent name.

func (*Agents) Retrieve

func (s *Agents) Retrieve(ctx context.Context, agentID string, timezoneOffset *int64, opts ...operations.Option) (*operations.GetAgentResponse, error)

Retrieve an agent Returns details of an [agent](https://developers.glean.com/agents/agents-api) created in the Agent Builder.

func (*Agents) RetrieveSchemas

func (s *Agents) RetrieveSchemas(ctx context.Context, agentID string, timezoneOffset *int64, opts ...operations.Option) (*operations.GetAgentSchemasResponse, error)

RetrieveSchemas - List an agent's schemas Return [agent](https://developers.glean.com/agents/agents-api)'s input and output schemas. You can use these schemas to detect changes to an agent's input or output structure.

func (*Agents) Run

Run - Create an agent run and wait for the response Executes an [agent](https://developers.glean.com/agents/agents-api) run and returns the final response.

func (*Agents) RunStream

RunStream - Create an agent run and stream the response Executes an [agent](https://developers.glean.com/agents/agents-api) run and returns the result as a stream of server-sent events (SSE).

type Announcements

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

func (*Announcements) Create

Create Announcement Create a textual announcement visible to some set of users based on department and location.

func (*Announcements) Delete

Delete Announcement Delete an existing user-generated announcement.

func (*Announcements) Update

Update Announcement Update a textual announcement visible to some set of users based on department and location.

type Answers

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

func (*Answers) Create

Create Answer Create a user-generated Answer that contains a question and answer.

func (*Answers) Delete

Delete Answer Delete an existing user-generated Answer.

func (*Answers) List

List Answers List Answers created by the current user.

func (*Answers) Retrieve

Retrieve - Read Answer Read the details of a particular Answer given its ID.

func (*Answers) Update

Update Answer Update an existing user-generated Answer.

type Chat

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

func (*Chat) Create

func (s *Chat) Create(ctx context.Context, chatRequest components.ChatRequest, timezoneOffset *int64, opts ...operations.Option) (*operations.ChatResponse, error)

Create - Chat Have a conversation with Glean AI.

func (*Chat) CreateStream

func (s *Chat) CreateStream(ctx context.Context, chatRequest components.ChatRequest, timezoneOffset *int64, opts ...operations.Option) (*operations.ChatStreamResponse, error)

CreateStream - Chat Have a conversation with Glean AI.

func (*Chat) Delete

func (s *Chat) Delete(ctx context.Context, deleteChatsRequest components.DeleteChatsRequest, timezoneOffset *int64, opts ...operations.Option) (*operations.DeletechatsResponse, error)

Delete - Deletes saved Chats Deletes saved Chats and all their contained conversational content.

func (*Chat) DeleteAll

func (s *Chat) DeleteAll(ctx context.Context, timezoneOffset *int64, opts ...operations.Option) (*operations.DeleteallchatsResponse, error)

DeleteAll - Deletes all saved Chats owned by a user Deletes all saved Chats a user has had and all their contained conversational content.

func (*Chat) DeleteFiles

func (s *Chat) DeleteFiles(ctx context.Context, deleteChatFilesRequest components.DeleteChatFilesRequest, timezoneOffset *int64, opts ...operations.Option) (*operations.DeletechatfilesResponse, error)

DeleteFiles - Delete files uploaded by a user for chat. Delete files uploaded by a user for Chat.

func (*Chat) List

func (s *Chat) List(ctx context.Context, timezoneOffset *int64, opts ...operations.Option) (*operations.ListchatsResponse, error)

List - Retrieves all saved Chats Retrieves all the saved Chats between Glean Assistant and the user. The returned Chats contain only metadata and no conversational content.

func (*Chat) Retrieve

func (s *Chat) Retrieve(ctx context.Context, getChatRequest components.GetChatRequest, timezoneOffset *int64, opts ...operations.Option) (*operations.GetchatResponse, error)

Retrieve - Retrieves a Chat Retrieves the chat history between Glean Assistant and the user for a given Chat.

func (*Chat) RetrieveApplication

func (s *Chat) RetrieveApplication(ctx context.Context, getChatApplicationRequest components.GetChatApplicationRequest, timezoneOffset *int64, opts ...operations.Option) (*operations.GetchatapplicationResponse, error)

RetrieveApplication - Gets the metadata for a custom Chat application Gets the Chat application details for the specified application ID.

func (*Chat) RetrieveFiles

func (s *Chat) RetrieveFiles(ctx context.Context, getChatFilesRequest components.GetChatFilesRequest, timezoneOffset *int64, opts ...operations.Option) (*operations.GetchatfilesResponse, error)

RetrieveFiles - Get files uploaded by a user for Chat. Get files uploaded by a user for Chat.

func (*Chat) UploadFiles

func (s *Chat) UploadFiles(ctx context.Context, uploadChatFilesRequest components.UploadChatFilesRequest, timezoneOffset *int64, opts ...operations.Option) (*operations.UploadchatfilesResponse, error)

UploadFiles - Upload files for Chat. Upload files for Chat.

type Client

type Client struct {
	Activity       *Activity
	Announcements  *Announcements
	Answers        *Answers
	Authentication *ClientAuthentication
	Chat           *Chat
	Agents         *Agents
	Collections    *Collections
	Documents      *ClientDocuments
	Insights       *Insights
	Messages       *Messages
	Pins           *Pins
	Search         *Search
	Entities       *Entities
	Shortcuts      *ClientShortcuts
	Verification   *Verification
	Tools          *Tools
	Governance     *Governance
	// contains filtered or unexported fields
}

type ClientAuthentication

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

func (*ClientAuthentication) CreateToken

CreateToken - Create authentication token Creates an authentication token for the authenticated user. These are specifically intended to be used with the [Web SDK](https://developers.glean.com/web).

Note: The tokens generated from this endpoint are **not** valid tokens for use with the Client API (e.g. `/rest/api/v1/*`).

type ClientDocuments

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

func (*ClientDocuments) Retrieve

Retrieve - Read documents Read the documents including metadata (does not include enhanced metadata via `/documentmetadata`) for the given list of Glean Document IDs or URLs specified in the request.

func (*ClientDocuments) RetrieveByFacets

RetrieveByFacets - Read documents by facets Read the documents including metadata (does not include enhanced metadata via `/documentmetadata`) macthing the given facet conditions.

func (*ClientDocuments) RetrievePermissions

RetrievePermissions - Read document permissions Read the emails of all users who have access to the given document.

func (*ClientDocuments) Summarize

Summarize documents Generate an AI summary of the requested documents.

type ClientShortcuts

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

func (*ClientShortcuts) Create

Create shortcut Create a user-generated shortcut that contains an alias and destination URL.

func (*ClientShortcuts) Delete

Delete shortcut Delete an existing user-generated shortcut.

func (*ClientShortcuts) List

List shortcuts List shortcuts editable/owned by the currently authenticated user.

func (*ClientShortcuts) Retrieve

Retrieve - Read shortcut Read a particular shortcut's details given its ID.

func (*ClientShortcuts) Update

Update shortcut Updates the shortcut with the given ID.

type Collections

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

func (*Collections) AddItems

AddItems - Add Collection item Add items to a Collection.

func (*Collections) Create

Create Collection Create a publicly visible (empty) Collection of documents.

func (*Collections) Delete

Delete Collection Delete a Collection given the Collection's ID.

func (*Collections) DeleteItem

DeleteItem - Delete Collection item Delete a single item from a Collection.

func (*Collections) List

List Collections List all existing Collections.

func (*Collections) Retrieve

Retrieve - Read Collection Read the details of a Collection given its ID. Does not fetch items in this Collection.

func (*Collections) Update

Update Collection Update the properties of an existing Collection.

func (*Collections) UpdateItem

UpdateItem - Update Collection item Update the URL, Glean Document ID, description of an item within a Collection given its ID.

type Data

type Data struct {
	Policies *Policies
	Reports  *Reports
	// contains filtered or unexported fields
}

type Datasource

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

func (*Datasource) Status

Status - Beta: Get datasource status

Gather information about the datasource's overall status. Currently in beta, might undergo breaking changes without prior notice.

Tip: Refer to the [Troubleshooting tutorial](https://developers.glean.com/docs/indexing_api/indexing_api_troubleshooting/) for more information.

type Datasources

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

func (*Datasources) Add

Add or update datasource Add or update a custom datasource and its schema.

func (*Datasources) RetrieveConfig

RetrieveConfig - Get datasource config Fetches the datasource config for the specified custom datasource.

type Entities

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

func (*Entities) List

List entities List some set of details for all entities that fit the given criteria and return in the requested order. Does not support negation in filters, assumes relation type EQUALS. There is a limit of 10000 entities that can be retrieved via this endpoint, except when using FULL_DIRECTORY request type for people entities.

func (*Entities) ReadPeople

ReadPeople - Read people Read people details for the given IDs.

type Glean

type Glean struct {
	SDKVersion string
	Client     *Client
	Indexing   *Indexing
	// contains filtered or unexported fields
}

Glean API: # Introduction In addition to the data sources that Glean has built-in support for, Glean also provides a REST API that enables customers to put arbitrary content in the search index. This is useful, for example, for doing permissions-aware search over content in internal tools that reside on-prem as well as for searching over applications that Glean does not currently support first class. In addition these APIs allow the customer to push organization data (people info, organization structure etc) into Glean.

# Usage guidelines This API is evolving fast. Glean will provide advance notice of any planned backwards incompatible changes along with a 6-month sunset period for anything that requires developers to adopt the new versions.

# API Clients Official API clients for the Glean Indexing API are available in multiple languages:

- [Python](https://github.com/gleanwork/api-client-python) - [TypeScript](https://github.com/gleanwork/api-client-typescript) - [Go](https://github.com/gleanwork/api-client-go) - [Java](https://github.com/gleanwork/api-client-java)

These API clients provide type-safe, idiomatic interfaces for working with Glean IndexingAPIs in your language of choice.

func New

func New(opts ...SDKOption) *Glean

New creates a new instance of the SDK with the provided options

type Governance

type Governance struct {
	Data      *Data
	Documents *GovernanceDocuments
	// contains filtered or unexported fields
}

type GovernanceDocuments

type GovernanceDocuments struct {
	Visibilityoverrides *Visibilityoverrides
	// contains filtered or unexported fields
}

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient provides an interface for supplying the SDK with a custom HTTP client

type Indexing

type Indexing struct {
	Documents      *IndexingDocuments
	Permissions    *Permissions
	Datasource     *Datasource
	People         *People
	Datasources    *Datasources
	Authentication *IndexingAuthentication
	Shortcuts      *IndexingShortcuts
	// contains filtered or unexported fields
}

type IndexingAuthentication

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

func (*IndexingAuthentication) RotateToken

RotateToken - Rotate token Rotates the secret value inside the Indexing API token and returns the new raw secret. All other properties of the token are unchanged. In order to rotate the secret value, include the token as the bearer token in the `/rotatetoken` request. Please refer to [Token rotation](https://developers.glean.com/docs/indexing_api_token_rotation/) documentation for more information.

type IndexingDocuments

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

func (*IndexingDocuments) AddOrUpdate

AddOrUpdate - Index document Adds a document to the index or updates an existing document.

func (*IndexingDocuments) BulkIndex

BulkIndex - Bulk index documents Replaces the documents in a datasource using paginated batch API calls. Please refer to the [bulk indexing](https://developers.glean.com/docs/indexing_api_bulk_indexing/#bulk-upload-model) documentation for an explanation of how to use bulk endpoints.

func (*IndexingDocuments) CheckAccess

CheckAccess - Check document access Check if a given user has access to access a document in a custom datasource

Tip: Refer to the [Troubleshooting tutorial](https://developers.glean.com/docs/indexing_api/indexing_api_troubleshooting/) for more information.

func (*IndexingDocuments) Count deprecated

Count - Get document count Fetches document count for the specified custom datasource.

Tip: Use [/debug/{datasource}/status](https://developers.glean.com/docs/indexing_api/indexing_api_troubleshooting/#debug-datasource-status) for richer information.

Deprecated: This will be removed in a future release, please migrate away from it as soon as possible.

func (*IndexingDocuments) Debug

Debug - Beta: Get document information

Gives various information that would help in debugging related to a particular document. Currently in beta, might undergo breaking changes without prior notice.

Tip: Refer to the [Troubleshooting tutorial](https://developers.glean.com/docs/indexing_api/indexing_api_troubleshooting/) for more information.

func (*IndexingDocuments) DebugMany

DebugMany - Beta: Get information of a batch of documents

Gives various information that would help in debugging related to a batch of documents. Currently in beta, might undergo breaking changes without prior notice.

Tip: Refer to the [Troubleshooting tutorial](https://developers.glean.com/docs/indexing_api/indexing_api_troubleshooting/) for more information.

func (*IndexingDocuments) Delete

Delete document Deletes the specified document from the index. Succeeds if document is not present.

func (*IndexingDocuments) Index

Index documents Adds or updates multiple documents in the index. Please refer to the [bulk indexing](https://developers.glean.com/docs/indexing_api_bulk_indexing/#choosing-indexdocuments-vs-bulkindexdocuments) documentation for an explanation of when to use this endpoint.

func (*IndexingDocuments) ProcessAll

ProcessAll - Schedules the processing of uploaded documents Schedules the immediate processing of documents uploaded through the indexing API. By default the uploaded documents will be processed asynchronously but this API can be used to schedule processing of all documents on demand.

If a `datasource` parameter is specified, processing is limited to that custom datasource. Without it, processing applies to all documents across all custom datasources. #### Rate Limits This endpoint is rate-limited to one usage every 3 hours. Exceeding this limit results in a 429 response code. Here's how the rate limit works: 1. Calling `/processalldocuments` for datasource `foo` prevents another call for `foo` for 3 hours. 2. Calling `/processalldocuments` for datasource `foo` doesn't affect immediate calls for `bar`. 3. Calling `/processalldocuments` for all datasources prevents any datasource calls for 3 hours. 4. Calling `/processalldocuments` for datasource `foo` doesn't affect immediate calls for all datasources.

For more frequent document processing, contact Glean support.

func (*IndexingDocuments) Status deprecated

Status - Get document upload and indexing status Intended for debugging/validation. Fetches the current upload and indexing status of documents.

Tip: Use [/debug/{datasource}/document](https://developers.glean.com/docs/indexing_api/indexing_api_troubleshooting/#debug-datasource-document) for richer information.

Deprecated: This will be removed in a future release, please migrate away from it as soon as possible.

type IndexingShortcuts

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

func (*IndexingShortcuts) BulkIndex

BulkIndex - Bulk index external shortcuts Replaces all the currently indexed shortcuts using paginated batch API calls. Note that this endpoint is used for indexing shortcuts not hosted by Glean. If you want to upload shortcuts that would be hosted by Glean, please use the `/uploadshortcuts` endpoint. For information on what you can do with Golinks, which are Glean-hosted shortcuts, please refer to [this](https://help.glean.com/en/articles/5628838-how-go-links-work) page.

func (*IndexingShortcuts) Upload

Upload shortcuts Creates glean shortcuts for uploaded shortcuts info. Glean would host the shortcuts, and they can be managed in the knowledge tab once uploaded.

type Insights

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

func (*Insights) Retrieve

Retrieve - Read insights Reads the aggregate information for each user, query, and content.

type Messages

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

func (*Messages) Retrieve

Retrieve - Read messages Retrieves list of messages from messaging/chat datasources (e.g. Slack, Teams).

type People

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

func (*People) BulkIndex

BulkIndex - Bulk index employees Replaces all the currently indexed employees using paginated batch API calls. Please refer to the [bulk indexing](https://developers.glean.com/docs/indexing_api_bulk_indexing/#bulk-upload-model) documentation for an explanation of how to use bulk endpoints.

func (*People) BulkIndexTeams

BulkIndexTeams - Bulk index teams Replaces all the currently indexed teams using paginated batch API calls. Please refer to the [bulk indexing](https://developers.glean.com/docs/indexing_api_bulk_indexing/#bulk-upload-model) documentation for an explanation of how to use bulk endpoints.

func (*People) Count deprecated

Count - Get user count Fetches user count for the specified custom datasource.

Tip: Use [/debug/{datasource}/status](https://developers.glean.com/docs/indexing_api/indexing_api_troubleshooting/#debug-datasource-status) for richer information.

Deprecated: This will be removed in a future release, please migrate away from it as soon as possible.

func (*People) Debug

Debug - Beta: Get user information

Gives various information that would help in debugging related to a particular user. Currently in beta, might undergo breaking changes without prior notice.

Tip: Refer to the [Troubleshooting tutorial](https://developers.glean.com/docs/indexing_api/indexing_api_troubleshooting/) for more information.

func (*People) Delete

Delete employee Delete an employee. Silently succeeds if employee is not present.

func (*People) DeleteTeam

DeleteTeam - Delete team Delete a team based on provided id.

func (*People) Index

Index employee Adds an employee or updates information about an employee

func (*People) IndexTeam

IndexTeam - Index team Adds a team or updates information about a team

func (*People) ProcessAllEmployeesAndTeams

ProcessAllEmployeesAndTeams - Schedules the processing of uploaded employees and teams Schedules the immediate processing of employees and teams uploaded through the indexing API. By default all uploaded people data will be processed asynchronously but this API can be used to schedule its processing on demand.

type Permissions

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

func (*Permissions) AuthorizeBetaUsers

AuthorizeBetaUsers - Beta users Allow the datasource be visible to the specified beta users. The default behaviour is datasource being visible to all users if it is enabled and not visible to any user if it is not enabled.

func (*Permissions) BulkIndexGroups

BulkIndexGroups - Bulk index groups Replaces the groups in a datasource using paginated batch API calls. Please refer to the [bulk indexing](https://developers.glean.com/docs/indexing_api_bulk_indexing/#bulk-upload-model) documentation for an explanation of how to use bulk endpoints.

func (*Permissions) BulkIndexMemberships

BulkIndexMemberships - Bulk index memberships for a group Replaces the memberships for a group in a datasource using paginated batch API calls. Please refer to the [bulk indexing](https://developers.glean.com/docs/indexing_api_bulk_indexing/#bulk-upload-model) documentation for an explanation of how to use bulk endpoints.

func (*Permissions) BulkIndexUsers

BulkIndexUsers - Bulk index users Replaces the users in a datasource using paginated batch API calls. Please refer to the [bulk indexing](https://developers.glean.com/docs/indexing_api_bulk_indexing/#bulk-upload-model) documentation for an explanation of how to use bulk endpoints.

func (*Permissions) DeleteGroup

DeleteGroup - Delete group Delete group from the datasource. Silently succeeds if group is not present.

func (*Permissions) DeleteMembership

DeleteMembership - Delete membership Delete membership to a group in the specified datasource. Silently succeeds if membership is not present.

func (*Permissions) DeleteUser

DeleteUser - Delete user Delete the user from the datasource. Silently succeeds if user is not present.

func (*Permissions) IndexGroup

IndexGroup - Index group Add or update a group in the datasource.

func (*Permissions) IndexMembership

IndexMembership - Index membership Add the memberships of a group in the datasource.

func (*Permissions) IndexUser

IndexUser - Index user Adds a datasource user or updates an existing user.

func (*Permissions) ProcessMemberships

ProcessMemberships - Schedules the processing of group memberships Schedules the immediate processing of all group memberships uploaded through the indexing API. By default the uploaded group memberships will be processed asynchronously but this API can be used to schedule processing of all memberships on demand.

func (*Permissions) UpdatePermissions

UpdatePermissions - Update document permissions Updates the permissions for a given document without modifying document content.

type Pins

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

func (*Pins) Create

func (s *Pins) Create(ctx context.Context, request components.PinRequest, opts ...operations.Option) (*operations.PinResponse, error)

Create pin Pin a document as a result for a given search query.Pin results that are known to be a good match.

func (*Pins) List

List pins Lists all pins.

func (*Pins) Remove

func (s *Pins) Remove(ctx context.Context, request components.Unpin, opts ...operations.Option) (*operations.UnpinResponse, error)

Remove - Delete pin Unpin a previously pinned result.

func (*Pins) Retrieve

Retrieve - Read pin Read pin details given its ID.

func (*Pins) Update

Update pin Update an existing user-generated pin.

type Policies

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

func (*Policies) Create

Create - Creates new policy Creates a new policy with specified specifications and returns its id.

func (*Policies) Download

Download - Downloads violations CSV for policy Downloads CSV violations report for a specific policy id. This does not support continuous policies.

func (*Policies) List

func (s *Policies) List(ctx context.Context, autoHide *bool, frequency *string, opts ...operations.Option) (*operations.ListpoliciesResponse, error)

List - Lists policies Lists policies with filtering.

func (*Policies) Retrieve

func (s *Policies) Retrieve(ctx context.Context, id string, version *int64, opts ...operations.Option) (*operations.GetpolicyResponse, error)

Retrieve - Gets specified policy Fetches the specified policy version, or the latest if no version is provided.

func (*Policies) Update

func (s *Policies) Update(ctx context.Context, id string, updateDlpReportRequest components.UpdateDlpReportRequest, opts ...operations.Option) (*operations.UpdatepolicyResponse, error)

Update - Updates an existing policy Updates an existing policy.

type Reports

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

func (*Reports) Create

Create - Creates new one-time report Creates a new one-time report and executes its batch job.

func (*Reports) Download

Download - Downloads violations CSV for report Downloads CSV violations report for a specific report id.

func (*Reports) Status

Status - Fetches report run status Fetches the status of the run corresponding to the report-id.

type SDKOption

type SDKOption func(*Glean)

func WithClient

func WithClient(client HTTPClient) SDKOption

WithClient allows the overriding of the default HTTP client used by the SDK

func WithInstance

func WithInstance(instance string) SDKOption

WithInstance allows setting the instance variable for url substitution

func WithRetryConfig

func WithRetryConfig(retryConfig retry.Config) SDKOption

func WithSecurity

func WithSecurity(apiToken string) SDKOption

WithSecurity configures the SDK to use the provided security details

func WithSecuritySource

func WithSecuritySource(security func(context.Context) (components.Security, error)) SDKOption

WithSecuritySource configures the SDK to invoke the Security Source function on each method call to determine authentication

func WithServerIndex

func WithServerIndex(serverIndex int) SDKOption

WithServerIndex allows the overriding of the default server by index

func WithServerURL

func WithServerURL(serverURL string) SDKOption

WithServerURL allows the overriding of the default server URL

func WithTemplatedServerURL

func WithTemplatedServerURL(serverURL string, params map[string]string) SDKOption

WithTemplatedServerURL allows the overriding of the default server URL with a templated URL populated with the provided parameters

func WithTimeout

func WithTimeout(timeout time.Duration) SDKOption

WithTimeout Optional request timeout applied to each operation

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

func (*Search) Autocomplete

Autocomplete Retrieve query suggestions, operators and documents for the given partially typed query.

func (*Search) Query

Query - Search Retrieve results from the index for the given query and filters.

func (*Search) QueryAsAdmin

QueryAsAdmin - Search the index (admin) Retrieves results for search query without respect for permissions. This is available only to privileged users.

func (*Search) Recommendations

Recommendations - Recommend documents Retrieve recommended documents for the given URL or Glean Document ID.

func (*Search) RetrieveFeed

func (s *Search) RetrieveFeed(ctx context.Context, request components.FeedRequest, opts ...operations.Option) (*operations.FeedResponse, error)

RetrieveFeed - Feed of documents and events The personalized feed/home includes different types of contents including suggestions, recents, calendar events and many more.

type Tools added in v0.4.3

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

func (*Tools) List added in v0.4.3

List available tools Returns a filtered set of available tools based on optional tool name parameters. If no filters are provided, all available tools are returned.

func (*Tools) Run added in v0.4.3

Run - Execute the specified tool Execute the specified tool with provided parameters

type Verification

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

func (*Verification) AddReminder

AddReminder - Create verification Creates a verification reminder for the document. Users can create verification reminders from different product surfaces.

func (*Verification) List

List verifications Returns the information to be rendered in verification dashboard. Includes information for each document owned by user regarding their verifications.

func (*Verification) Verify

Verify - Update verification Verify documents to keep the knowledge up to date within customer corpus.

type Visibilityoverrides

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

func (*Visibilityoverrides) Create

Create - Hide or unhide docs Sets the visibility-override state of the documents specified, effectively hiding or un-hiding documents.

func (*Visibilityoverrides) List

List - Fetches documents visibility Fetches the visibility override status of the documents passed.

Directories

Path Synopsis
internal
models

Jump to

Keyboard shortcuts

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