Skip to content

Repository files navigation

iam-go: Go SDK for IAM API

Go.dev referenceGo Report Cardcodecov

Package iam-go provides Go SDK to work with the Selectel IAM API.

Jump To:

Documentation

The Go library documentation is available at go.dev.

Getting started

You can use this library to work with the following objects of the Selectel IAM API:

Installation

You can install iam-go via go get command:

go get github.com/selectel/iam-go

Authentication

To work with the Selectel IAM API you first need to:

After that initialize Client with the retrieved token.

Usage example

[!NOTE] It is highly recommended to use the WithUserAgentPrefix option to set a custom User-Agent for the client.

package main
import (
"context""fmt""log""github.com/selectel/iam-go"
)
funcmain() {
// A KeystoneToken to work with the Selectel IAM API.// It should be Service User Tokentoken:="gAAAAABeVNzu-..."// A Prefix to be added to User-Agent.prefix:="iam-custom"// Create a new IAM client.iamClient, err:=iam.New(
iam.WithAuthOpts(&iam.AuthOpts{KeystoneToken: token}),
iam.WithUserAgentPrefix(prefix),
)
// Handle the error.iferr!=nil {
log.Fatalf("Error occured: %s", err)
return
}
// Get the Users instance.usersAPI:=iamClient.Users// Prepare an empty context.ctx:=context.Background()
// Get all users.users:=usersAPI.List(ctx)
// Print info about each user.for_, user:=rangeusers {
fmt.Println("ID:", user.ID)
fmt.Println("KeystoneID:", user.Keystone.ID)
fmt.Println("AuthType:", user.AuthType)
}
}

Additional info

  • See examples for more code examples of iam-go
  • Read docs for advanced topics and guides

About

Go SDK for Selectel IAM API

Resources

Contributing

Stars

7 stars

Watchers

4 watching

Forks

Releases

Used by

Contributors

Languages