Skip to main content

Get a wormhole entity

This page describes how to retrieve a wormhole entity.

Wormhole entities are raw information coming from external providers. Those information have not changed by Animeshon's systems and describe how the resource is stored and presented in other providers.

Wormhole exposes only basic information like names, release date, image, remote url, ... The bare minimum to determine whether 2 entities coming from different providers should or should not be linked.

tip

Animeshon's entries in the namespaces/animeshon-com/animes/123 format are considered valid wormhole entities.

Sample

The following sample shows how to retrieve a wormhole entity.

Replace [RESOURCE NAME] with a valid resource name in the namespaces/{namespace}/{collection}/{id} format.

tip

Tip: do not forget to replace CLIENT-ID and CLIENT-SECRET with valid IAM Service Account client credentials.

package main

import (
"context"
"log"

"golang.org/x/oauth2/clientcredentials"

"google.golang.org/api/option"

gapic "github.com/animeapis/api-go-client/crossrefs/v1alpha1"
crossref "github.com/animeapis/go-genproto/crossrefs/v1alpha1"
)

var (
WormholeName = "[RESOURCE NAME]"

ClientID = "[CLIENT-ID]"
ClientSecret = "[CLIENT-SECRET]"
)

var (
TokenURL = "https://accounts.animeshon.com/o/oauth2/token"
Endpoint = "crossrefs.animeapis.com:443"
)

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

config := &clientcredentials.Config{
ClientID: ClientID,
ClientSecret: ClientSecret,
TokenURL: TokenURL,
}

options := []option.ClientOption{
option.WithEndpoint(Endpoint),
option.WithTokenSource(config.TokenSource(ctx)),
}

client, err := gapic.NewReferrerClient(ctx, options...)
if err != nil {
log.Fatalf("NewClient: %s", err)
}

request := &crossref.GetWormholeRequest{
Name: WormholeName,
}

wormhole, err := client.GetWormhole(ctx, request)
if nil != err {
log.Fatalf("GetWormhole: %s", err)
}

log.Println("---------------------------------------------------------")
log.Printf("name : %s", wormhole.GetName())
for i, name := range wormhole.GetNames() {
log.Printf("name[%d]text : %s", i, name.GetText())
log.Printf("name[%d]loc : %s", i, name.GetLocalization())
}
log.Printf("imageUrl : %s", wormhole.GetImageUrl())
log.Printf("type : %s", wormhole.GetType())
log.Printf("subType : %s", wormhole.GetSubtype())
log.Printf("externalUrl : %s", wormhole.GetExternalUrl())
log.Printf("parentName : %s", wormhole.GetParentName())
log.Printf("parentExternalUrl : %s", wormhole.GetParentExternalUrl())
}
View on GitHub