Giter VIP home page Giter VIP logo

gpcore-go's Introduction

GPCORE Golang Client

This is the official GPCORE Golang client. Please open an issue if you have found a problem or having a question.

Recommendations

  • Golang 1.18 or higher

Documentation

You can find the current API documentation here. Packages for Go and Node.js can be downloaded from the buf.build repository. If you want to get the raw .proto definition files, pull it from this repository or use the buf tool:

buf export buf.build/gportal/gpcore -o .

Service Account

You can create your own Service Account in the GPCORE Panel.

Once you have created the Service Account, you can add it to projects as a member. The Service Account will only have access to Projects that the Service Account is a member of.

Example usage

package main

import (
	"context"
	"log"

	authv1 "buf.build/gen/go/gportal/gpcore/protocolbuffers/go/gpcore/api/auth/v1"
	cloudv1 "buf.build/gen/go/gportal/gpcore/protocolbuffers/go/gpcore/api/cloud/v1"
	"github.com/G-PORTAL/gpcore-co/pkg/gpcore/client"
	"github.com/G-PORTAL/gpcore-co/pkg/gpcore/client/auth"
)

func main() {
	conn, err := client.NewClient(
		// You can create your own Service Account in the GPCORE Panel.
		// The Service Account can be added to projects as a member.
		&auth.ProviderKeycloakClientAuth{
			ClientID:     "47d838c3-5738-4a67-aafb-48b364fab41b", // Set your Client ID
			ClientSecret: "MdErjhYSP4Nuq3h6qcYCMdErjhYSP4Nu", // Set your Client Secret
		},
	)
	if err != nil {
		log.Fatal("failed to create client:\n", err)
	}

	ctx := context.Background()
	user, err := conn.AuthClient().GetUser(ctx, &authv1.GetUserRequest{})
	if err != nil {
		log.Fatal("failed to fetch user information:\n", err)
	}
	log.Println("User ID: ", user.User.Id)

	projects, err := conn.CloudClient().ListProjects(ctx, &cloudv1.ListProjectsRequest{})
	if err != nil {
		log.Fatal("failed to fetch project list: \n", err)
	}
	for _, project := range projects.Projects {
		log.Println("Project ID: ", project.Id)
	}
}

gpcore-go's People

Contributors

msniveau avatar birkneralex avatar renovate[bot] avatar f0086 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.