Skip to content

akeylesslabs/akeyless-grpc-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

akeyless-grpc-go

Go package for interacting with the Akeyless API using gRPC

Table of Contents

Introduction

The akeyless/grpc library provides a convenient way to interact with the Akeyless API using gRPC.

Installation

To use akeyless_grpc in your project, run the following command go get github.com/akeylesslabs/akeyless-grpc-go

Example

package main

import (
	"context"
	"fmt"

	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials/insecure"

	akeyless_grpc "github.com/akeylesslabs/akeyless-grpc-go/akeyless_grpc"
)

func main() {

	ctx := context.Background()
	conn, err := grpc.NewClient("localhost:8085", grpc.WithTransportCredentials(insecure.NewCredentials()))

	if err != nil {
		return
	}

	client := akeyless_grpc.NewAkeylessV2ServiceClient(conn)

	authOutput, err := client.Auth(ctx, &akeyless_grpc.AuthRequest{
		Body: &akeyless_grpc.Auth{
			AccessId:   "*******",
			AccessKey:  "*******",
			AccessType: "access_key",
		},
	})

	if err != nil {
		return
	}

	listItemsResp, err := client.ListItems(ctx, &akeyless_grpc.ListItemsRequest{Body: &akeyless_grpc.ListItems{Token: authOutput.Token}})

	if err != nil {
		return
	}

	for _, item := range listItemsResp.Items {
		fmt.Println(item.ItemName)
	}

	secretResponse, err := client.GetSecretValue(ctx, &akeyless_grpc.GetSecretValueRequest{Body: &akeyless_grpc.GetSecretValue{Token: authOutput.Token, Names: []string{"/MyFirstSecret"}}})

	if err != nil {
		return
	}

	for secretName, item := range secretResponse.Data.Fields {
		fmt.Println(secretName, item.GetStringValue())
	}
}

License

This project is licensed under the Apache License 2.0. See the LICENSE file for details.

About

Go package for interacting with the Akeyless API using gRPC

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages