kgsearch

package
v0.37.1 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2020 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Overview

Package kgsearch provides access to the Knowledge Graph Search API.

For product documentation, see: https://developers.google.com/knowledge-graph/

Creating a client

Usage example:

import "google.golang.org/api/kgsearch/v1"
...
ctx := context.Background()
kgsearchService, err := kgsearch.NewService(ctx)

In this example, Google Application Default Credentials are used for authentication.

For information on how to create and obtain Application Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials.

Other authentication options

To use an API key for authentication (note: some APIs do not support API keys), use option.WithAPIKey:

kgsearchService, err := kgsearch.NewService(ctx, option.WithAPIKey("AIza..."))

To use an OAuth token (e.g., a user token obtained via a three-legged OAuth flow), use option.WithTokenSource:

config := &oauth2.Config{...}
// ...
token, err := config.Exchange(ctx, ...)
kgsearchService, err := kgsearch.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))

See https://godoc.org/google.golang.org/api/option/ for details on options.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EntitiesSearchCall

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

func (*EntitiesSearchCall) Context

Context sets the context to be used in this call's Do method. Any pending HTTP request will be aborted if the provided context is canceled.

func (*EntitiesSearchCall) Do

Do executes the "kgsearch.entities.search" call. Exactly one of *SearchResponse or error will be non-nil. Any non-2xx status code is an error. Response headers are in either *SearchResponse.ServerResponse.Header or (if a response was returned at all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check whether the returned error was because http.StatusNotModified was returned.

func (*EntitiesSearchCall) Fields

Fields allows partial responses to be retrieved. See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more information.

func (*EntitiesSearchCall) Header

func (c *EntitiesSearchCall) Header() http.Header

Header returns an http.Header that can be modified by the caller to add HTTP headers to the request.

func (*EntitiesSearchCall) Ids

Ids sets the optional parameter "ids": The list of entity id to be used for search instead of query string. To specify multiple ids in the HTTP request, repeat the parameter in the URL as in ...?ids=A&ids=B

func (*EntitiesSearchCall) IfNoneMatch

func (c *EntitiesSearchCall) IfNoneMatch(entityTag string) *EntitiesSearchCall

IfNoneMatch sets the optional parameter which makes the operation fail if the object's ETag matches the given value. This is useful for getting updates only after the object has changed since the last request. Use googleapi.IsNotModified to check whether the response error from Do is the result of In-None-Match.

func (*EntitiesSearchCall) Indent

func (c *EntitiesSearchCall) Indent(indent bool) *EntitiesSearchCall

Indent sets the optional parameter "indent": Enables indenting of json results.

func (*EntitiesSearchCall) Languages

func (c *EntitiesSearchCall) Languages(languages ...string) *EntitiesSearchCall

Languages sets the optional parameter "languages": The list of language codes (defined in ISO 693) to run the query with, e.g. 'en'.

func (*EntitiesSearchCall) Limit

func (c *EntitiesSearchCall) Limit(limit int64) *EntitiesSearchCall

Limit sets the optional parameter "limit": Limits the number of entities to be returned.

func (*EntitiesSearchCall) Prefix

func (c *EntitiesSearchCall) Prefix(prefix bool) *EntitiesSearchCall

Prefix sets the optional parameter "prefix": Enables prefix match against names and aliases of entities

func (*EntitiesSearchCall) Query

func (c *EntitiesSearchCall) Query(query string) *EntitiesSearchCall

Query sets the optional parameter "query": The literal query string for search.

func (*EntitiesSearchCall) Types

func (c *EntitiesSearchCall) Types(types ...string) *EntitiesSearchCall

Types sets the optional parameter "types": Restricts returned entities with these types, e.g. Person (as defined in http://schema.org/Person). If multiple types are specified, returned entities will contain one or more of these types.

type EntitiesService

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

func NewEntitiesService

func NewEntitiesService(s *Service) *EntitiesService

func (*EntitiesService) Search

func (r *EntitiesService) Search() *EntitiesSearchCall

Search: Searches Knowledge Graph for entities that match the constraints. A list of matched entities will be returned in response, which will be in JSON-LD format and compatible with http://schema.org

type SearchResponse

type SearchResponse struct {

	// ItemListElement: The item list of search results.
	ItemListElement []interface{} `json:"itemListElement,omitempty"`

	// ServerResponse contains the HTTP response code and headers from the
	// server.
	googleapi.ServerResponse `json:"-"`

	// ForceSendFields is a list of field names (e.g. "ItemListElement") to
	// unconditionally include in API requests. By default, fields with
	// empty values are omitted from API requests. However, any non-pointer,
	// non-interface field appearing in ForceSendFields will be sent to the
	// server regardless of whether the field is empty or not. This may be
	// used to include empty fields in Patch requests.
	ForceSendFields []string `json:"-"`

	// NullFields is a list of field names (e.g. "ItemListElement") to
	// include in API requests with the JSON null value. By default, fields
	// with empty values are omitted from API requests. However, any field
	// with an empty value appearing in NullFields will be sent to the
	// server as null. It is an error if a field in this list has a
	// non-empty value. This may be used to include null fields in Patch
	// requests.
	NullFields []string `json:"-"`
}

SearchResponse: Response message includes the context and a list of matching results which contain the detail of associated entities.

func (*SearchResponse) MarshalJSON

func (s *SearchResponse) MarshalJSON() ([]byte, error)

type Service

type Service struct {
	BasePath  string // API endpoint base URL
	UserAgent string // optional additional User-Agent fragment

	Entities *EntitiesService
	// contains filtered or unexported fields
}

func New deprecated

func New(client *http.Client) (*Service, error)

New creates a new Service. It uses the provided http.Client for requests.

Deprecated: please use NewService instead. To provide a custom HTTP client, use option.WithHTTPClient. If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.

func NewService

func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error)

NewService creates a new Service.

Jump to

Keyboard shortcuts

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