Skip to content

Latest commit

 

History

History
78 lines (56 loc) · 2.19 KB

File metadata and controls

78 lines (56 loc) · 2.19 KB

Agntcy Identity Node SDK for Go

OpenAPI v1alpha1 Protocol Documentation Proto Spec

github.com/agntcy/identity/api/client is the v1alpha1 Agntcy Identity Node SDK for the Go programming language that contains the different REST HTTP clients.

The SDK requires a minimum version of Go 1.24.

Getting started

To get started working with the SDK setup your GO projects and add the SDK dependencies with go get. The following example demonstrates how you can use the SDK to resolve an ID into a Resolver Metadata.

Project Initialization

mkdir ~/id_example
cd ~/id_example
go mod init id_example
touch main.go

Add SDK Dependency

go get github.com/agntcy/identity/api/client

Code Example

package main

import (
    "log"

    idsdk "github.com/agntcy/identity/api/client/client/id_service"
    apimodels "github.com/agntcy/identity/api/client/models"
    httptransport "github.com/go-openapi/runtime/client"
    "github.com/go-openapi/strfmt"
)

func main() {
    // Creating a new ID API client
    client := idsdk.New(httptransport.New("<NODE_HOST>", "", nil), strfmt.Default)

    // Resolving an ID into a Resolver Metadata
    res, err := client.ResolveID(&idsdk.ResolveIDParams{
        Body: &apimodels.V1alpha1ResolveRequest{
            ID: "<VALID_ID>",
        },
    })
    if err != nil {
        log.Fatalf("%v", err)
    }

    log.Printf("Status Code: %d", res.Code())
    log.Printf("Resolver Metadata: %v", res.Payload.ResolverMetadata)
}

Run Code

go mod tidy
go run main.go

For Maintainers

To generate the SDK, first make sure that Docker is running locally and then run the following command from the root of the repository:

make generate_node_sdk

The generation will be based on the spec located in api/spec.