iam

package module
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

README

iam-go: Go SDK for IAM API

Go.dev reference Go Report Card codecov

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
package main

import (
    "context"
    "fmt"
    "log"

    "github.com/selectel/iam-go"
)

func main() {
    // A KeystoneToken to work with the Selectel IAM API.
    // It should be Service User Token
    token := "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.
    if err != 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 := range users {
        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

Documentation

Overview

Package iam is an entry point of IAM SDK and implements functionality for interacting with the Selectel IAM API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthOpts

type AuthOpts struct {
	KeystoneToken string
}

type Client

type Client struct {

	// Users instance is used to make requests against Selectel IAM API	and manage Panel Users.
	Users *users.Service

	// ServiceUsers instance is used to make requests against Selectel IAM API and manage Service Users.
	ServiceUsers *serviceusers.Service

	// Groups instance is used to make requests against Selectel IAM API and manage Groups of users.
	Groups *groups.Service

	// S3Credentials instance is used to make requests against Selectel IAM API and manage S3 Credentials.
	S3Credentials *s3credentials.Service

	// SAMLFederations instance is used to make requests against Selectel IAM API and manage SAML Federations.
	// It also contains Certificates service, which is used to manage certificates.
	SAMLFederations *saml.Service
	// contains filtered or unexported fields
}

Client stores the configuration, which is needed to make requests to the IAM API.

func New

func New(opts ...Option) (*Client, error)

New returns a new instance of Client for the v1 IAM API.

type Option

type Option func(*Client)

func WithAPIUrl

func WithAPIUrl(url string) Option

WithAPIUrl is a functional parameter for Client, used to set IAM API URL.

func WithAuthOpts

func WithAuthOpts(authOpts *AuthOpts) Option

WithAuthOpts is a functional parameter for Client, used to set on of implementations of AuthType.

func WithCustomHTTPClient

func WithCustomHTTPClient(httpClient *http.Client) Option

WithCustomHTTPClient is a functional parameter for Client, used to set a custom HTTP client.

func WithUserAgentPrefix

func WithUserAgentPrefix(prefix string) Option

WithUserAgentPrefix is a functional parameter for Client, used to set a custom prefix.

Directories

Path Synopsis
examples
internal
service
federations/saml
Package saml provides a set of functions for interacting with the Selectel SAML Federations API.
Package saml provides a set of functions for interacting with the Selectel SAML Federations API.
federations/saml/certificates
Package certificates provides a set of functions for interacting with the Selectel Federations Certificates API.
Package certificates provides a set of functions for interacting with the Selectel Federations Certificates API.
groups
Package groups provides a set of functions for interacting with the Selectel Groups API.
Package groups provides a set of functions for interacting with the Selectel Groups API.
s3credentials
Package s3credentials provides a set of functions for interacting with the Selectel S3 Credentials API.
Package s3credentials provides a set of functions for interacting with the Selectel S3 Credentials API.
serviceusers
Package serviceusers provides a set of functions for interacting with the Selectel Service Users API.
Package serviceusers provides a set of functions for interacting with the Selectel Service Users API.
users
Package Users provides a set of functions for interacting with the Selectel Users API.
Package Users provides a set of functions for interacting with the Selectel Users API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL