rediscloud_api

package module
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 23 Imported by: 1

README

rediscloud-go-api

This repository is a Go SDK for the Redis Cloud REST API.

Getting Started

Installing

You can use this module by using go get to add it to either your GOPATH workspace or the project's dependencies.

go get github.com/RedisLabs/rediscloud-go-api
Example

This is an example of using the SDK

package main

import (
	"context"
	"fmt"

	rediscloud_api "github.com/RedisLabs/rediscloud-go-api"
	"github.com/RedisLabs/rediscloud-go-api/service/subscriptions"
)

func main() {
	// The client will use the credentials from `REDISCLOUD_ACCESS_KEY` and `REDISCLOUD_SECRET_KEY` by default
	client, err := rediscloud_api.NewClient()
	if err != nil {
		panic(err)
	}

	id, err := client.Subscription.Create(context.TODO(), subscriptions.CreateSubscription{
		// ...
	})
	if err != nil {
		panic(err)
	}

	fmt.Printf("Created subscription: %d", id)
}

Documentation

Index

Constants

View Source
const (
	// Version is the release number of this SDK.
	Version = "0.2.0"

	// AccessKeyEnvVar is the environment variable that will be used for the access key by default.
	AccessKeyEnvVar = "REDISCLOUD_ACCESS_KEY"

	// SecretKeyEnvVar is the environment variable that will be used for the secret key by default.
	SecretKeyEnvVar = "REDISCLOUD_SECRET_KEY"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Account      *account.API
	CloudAccount *cloud_accounts.API
	Database     *databases.API
	Subscription *subscriptions.API
	Regions      *regions.API
	LatestBackup *latest_backups.API
	LatestImport *latest_imports.API
	Pricing      *pricing.API
	// fixed
	FixedPlans *plans.API
	// acl
	RedisRules *redis_rules.API
	Roles      *roles.API
	Users      *users.API
}

func NewClient

func NewClient(configs ...Option) (*Client, error)

type Log

type Log interface {
	Printf(format string, v ...interface{})
	Println(v ...interface{})
}

type Option

type Option func(*Options)

func AdditionalUserAgent

func AdditionalUserAgent(additional string) Option

AdditionalUserAgent allows extra information to be appended to the user agent sent in all requests to the API.

func Auth

func Auth(apiKey string, secretKey string) Option

Auth is used to set the authentication credentials - will otherwise default to using environment variables for the credentials.

func BaseURL

func BaseURL(url string) Option

BaseURL sets the URL to use for the API endpoint - will default to `https://api.redislabs.com/v1`.

func LogRequests

func LogRequests(enable bool) Option

LogRequests allows the logging of HTTP request and responses - will default to false (disabled).

func Logger

func Logger(log Log) Option

Logger allows for a custom implementation to handle the debug log messages - defaults to using the Go standard log package.

func Transporter

func Transporter(transporter http.RoundTripper) Option

Transporter allows the customisation of the RoundTripper used to communicate with the API - will default to the Go default.

type Options

type Options struct {
	// contains filtered or unexported fields
}

Directories

Path Synopsis
service
account
Package account is responsible for retrieving information related to the current account.
Package account is responsible for retrieving information related to the current account.
cloud_accounts
Package cloud_accounts allows CRUD operations on the Cloud Account resource.
Package cloud_accounts allows CRUD operations on the Cloud Account resource.
databases
Package databases allows CRUD operations on the Databases resource - a sub-resource of Subscriptions.
Package databases allows CRUD operations on the Databases resource - a sub-resource of Subscriptions.
regions
Package regions contains the API calls for the Active-Active Subscription regions service.
Package regions contains the API calls for the Active-Active Subscription regions service.
subscriptions
Package subscriptions allows CRUD operations on the Subscriptions resource.
Package subscriptions allows CRUD operations on the Subscriptions resource.

Jump to

Keyboard shortcuts

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