Git Product home page Git Product logo

astra-devops-sdk-go's Introduction

DEPRECATED use https://github.com/datastax/astra-client-go instead

astra-devops-sdk-go

.github/workflows/go.yaml Go Report Card Go Version Latest Version Go Reference Coverage Status

Go API bindings for the Astra DevOps API with zero external dependencies. Apache 2.0 License.

How to use

Login Token

import "github.com/rsds143/astra-devops-sdk-go/astraops"

func main() {
//using an auth token

  verbose := true
  client, err := astraopsv1.AuthenticateToken("AstraCS:scrambled:scrabmled", verbose)
}

Login Legacy Service Account

import "github.com/rsds143/astra-devops-sdk-go/astraops"

func main() {
//using a legacy service account
 c :=  ClientInfo {
	        ClientName: "[email protected]",
	        ClientID:   "3e241be3-2a5f-4cb1-b702-739e38975b1a",
	        ClientSecret: "33c338b0-91b5-45a6-be14-416059deb820",
  }
  verbose := true
  client, err := astraopsv1.Authenticate(c, verbose)
}

Create Database

Will block until creation

createDb := CreateDb{
		Name:          "testerdblist",
		Keyspace:      "mykeyspace",
		Region:        "europe-west1",
		CloudProvider: "GCP",
		CapacityUnits: 1,
		Tier:          "serverless",
		User:          "myuser",
		Password:      "mypass",
	}
//id is a uuid
//db is the following type
//type DataBase struct {
//	ID               string   `json:"id"`
//	OrgID            string   `json:"orgId"`
//	OwnerID          string   `json:"ownerId"`
//	Info             Info     `json:"info"`
//	CreationTime     string   `json:"creationTime"`
//	TerminationTime  string   `json:"terminationTime"`
//	Status           string   `json:"status"`
//	Storage          Storage  `json:"storage"`
//	AvailableActions []string `json:"availableActions"`
//	Message          string   `json:"message"`
//	StudioURL        string   `json:"studioUrl"`
//	GrafanaURL       string   `json:"grafanaUrl"`
//	CqlshURL         string   `json:"cqlshUrl"`
//	GraphqlURL       string   `json:"graphUrl"`
//	DataEndpointURL  string   `json:"dataEndpointUrl"`
//}
id, db, err := client.CreateDb(createDb)

Delete Database

Will block until terminating status or terminated status is returned

//id is database ID one gets when using ListDb or CreateDb
//preparedStateOnly is an internal field, do not use unless directed to by support
preparedStateOnly := false
err := client.Terminate(id, preparedStateOnly)

List All Databases With A Limit Of 10

dbs, err := client.ListDb("", "", "", 10)
//returns an array of DataBases

Get Database by ID

db, err := client.FindDb(id)

//type DataBase struct {
//	ID               string   `json:"id"`
//	OrgID            string   `json:"orgId"`
//	OwnerID          string   `json:"ownerId"`
//	Info             Info     `json:"info"`
//	CreationTime     string   `json:"creationTime"`
//	TerminationTime  string   `json:"terminationTime"`
//	Status           string   `json:"status"`
//	Storage          Storage  `json:"storage"`
//	AvailableActions []string `json:"availableActions"`
//	Message          string   `json:"message"`
//	StudioURL        string   `json:"studioUrl"`
//	GrafanaURL       string   `json:"grafanaUrl"`
//	CqlshURL         string   `json:"cqlshUrl"`
//	GraphqlURL       string   `json:"graphUrl"`
//	DataEndpointURL  string   `json:"dataEndpointUrl"`
}
*/

Get Secure Connect Bundle by ID

secureBundle, err := client.GetSecureBundle(id)

/*
type SecureBundle struct {
	DownloadURL               string `json:"downloadURL"`
	DownloadURLInternal       string `json:"downloadURLInternal"`
	DownloadURLMigrationProxy string `json:"downloadURLMigrationProxy"`
}
*/

Park legacy tier db (non serverless)

Will block until parking complete

err := client.Park(id)

Unpark legacy tier db (non serverless)

Will block until unparking complete, this can take very long

err := client.UnPark(id)

Resize

var int32 capacityUnits = 5
err := Resize(id, capacityUnits)

List all tiers available

tiers, err := GetTierInfo()
//returns a list of TierInfo
//type TierInfo struct {
//	Tier                            string   `json:"tier"`
//	Description                     string   `json:"description"`
//	CloudProvider                   string   `json:"cloudProvider"`
//	Region                          string   `json:"region"`
//	RegionDisplay                   string   `json:"regionDisplay"`
//	RegionContinent                 string   `json:"regionContinent"`
//	Cost                            TierCost `json:"cost"`
//	DatabaseCountUsed               int      `json:"databaseCountUsed"`
//	DatabaseCountLimit              int      `json:"databaseCountLimit"`
//	CapacityUnitsUsed               int      `json:"capacityUnitsUsed"`
//	CapacityUnitsLimit              int      `json:"capacityUnitsLimit"`
//	DefaultStoragePerCapacityUnitGb int      `json:"defaultStoragePerCapacityUnitGb"`
//}
//
//tier cost has the following fields 
//type TierCost struct {
//	CostPerMinCents         float64 `json:"costPerMinCents"`
//	CostPerHourCents        float64 `json:"costPerHourCents"`
//	CostPerDayCents         float64 `json:"costPerDayCents"`
//	CostPerMonthCents       float64 `json:"costPerMonthCents"`
//	CostPerMinMRCents       float64 `json:"costPerMinMRCents"`
//	CostPerHourMRCents      float64 `json:"costPerHourMRCents"`
//	CostPerDayMRCents       float64 `json:"costPerDayMRCents"`
//	CostPerMonthMRCents     float64 `json:"costPerMonthMRCents"`
//	CostPerMinParkedCents   float64 `json:"costPerMinParkedCents"`
//	CostPerHourParkedCents  float64 `json:"costPerHourParkedCents"`
//	CostPerDayParkedCents   float64 `json:"costPerDayParkedCents"`
//	CostPerMonthParkedCents float64 `json:"costPerMonthParkedCents"`
//	CostPerNetworkGbCents   float64 `json:"costPerNetworkGbCents"`
//	CostPerWrittenGbCents   float64 `json:"costPerWrittenGbCents"`
//	CostPerReadGbCents      float64 `json:"costPerReadGbCents"`
//}

astra-devops-sdk-go's People

Contributors

foundev avatar mastermanu avatar rsds143 avatar

Stargazers

 avatar

Watchers

 avatar

astra-devops-sdk-go's Issues

support V2 api /package refactor

should support v2 api, I haven't figured out if I should implement this totally separately or just try and be more clever than I should and reuse the code but conditional where it is needed

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.