Documentation
¶
Overview ¶
Package indexing provides a developer friendly module to Google's Indexing API
More info about the API: https://developers.google.com/search/apis/indexing-api/v3/quickstart
Index ¶
Constants ¶
const ( OauthScope = "https://www.googleapis.com/auth/indexing" // AuthorizationScope is required for the Indexing API GetMetadataEndpoint = "https://indexing.googleapis.com/v3/urlNotifications/metadata" // getMetadata endpoint PublishEndpoint = "https://indexing.googleapis.com/v3/urlNotifications:publish" // publish endpoint )
const ( PublishTypeUpdate = "URL_UPDATED" PublishTypeDelete = "URL_DELETED" )
Variables ¶
This section is empty.
Functions ¶
func CreateDeleteRequest ¶
CreateDeleteRequest returns an io.Reader for the request body with "URL_DELETED".
func CreateUpdateRequest ¶
CreateUpdateRequest returns an io.Reader for the request body with "URL_UPDATED".
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClientFromJSON ¶
NewClientFromJSON creates Client from Google Developers service account JSON key file.
func NewClientFromJSONFile ¶
NewClientFromJSONFile reads file in path name and creates Client from Google Developers service account JSON key file.
func (*Client) Delete ¶
Delete notifies Google that the given URL can be removed Google's index.
See more: https://developers.google.com/search/apis/indexing-api/v3/using-api#removing
func (*Client) Get ¶
func (c *Client) Get(u string) (*UrlNotificationMetadata, error)
Get returns the last time Google received each kind of notification for a given URL.
This function sets the Oauth2 scope to OauthScope.
If the given URL is not indexed, returns error git.gorbe.io/go/google/errors.ErrNotFound
For more: https://developers.google.com/search/apis/indexing-api/v3/using-api#gettinginfo
func (*Client) IsIndexed ¶
IsINdexed returns whether the given URL u is indexed.
- If the returned error is git.gorbe.io/go/google/errors.ErrNotFound, than reports `false` (the error will be `nil`!) - if the `latestUpdate` field is not set, returns `false` - If the `latestRemove` field is not set, but the `latestUpdate` is set, returns `true` - If the latest UPDATE request was after the latest DELETE request
Only the git.gorbe.io/go/google/errors.ErrNotFound is not returned.
type UrlNotification ¶
type UrlNotificationMetadata ¶
type UrlNotificationMetadata struct { Url string `json:"url"` LatestUpdate *UrlNotification `json:"latestUpdate"` LatestRemove *UrlNotification `json:"latestRemove"` }
func ParseUrlNotificationMetadata ¶
func ParseUrlNotificationMetadata(data []byte) (*UrlNotificationMetadata, error)
func ReadUrlNotificationMetadata ¶
func ReadUrlNotificationMetadata(r io.Reader) (*UrlNotificationMetadata, error)