项目作者: rsds143

项目描述 :
DataStax Astra automation sdk for Go https://astra.datastax.com
高级语言: Go
项目地址: git://github.com/rsds143/astra-devops-sdk-go.git
创建时间: 2021-02-10T09:57:19Z
项目社区:https://github.com/rsds143/astra-devops-sdk-go

开源协议:Apache License 2.0

下载


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

  1. import "github.com/rsds143/astra-devops-sdk-go/astraops"
  2. func main() {
  3. //using an auth token
  4. verbose := true
  5. client, err := astraopsv1.AuthenticateToken("AstraCS:scrambled:scrabmled", verbose)
  6. }

Login Legacy Service Account

  1. import "github.com/rsds143/astra-devops-sdk-go/astraops"
  2. func main() {
  3. //using a legacy service account
  4. c := ClientInfo {
  5. ClientName: "me@example.com",
  6. ClientID: "3e241be3-2a5f-4cb1-b702-739e38975b1a",
  7. ClientSecret: "33c338b0-91b5-45a6-be14-416059deb820",
  8. }
  9. verbose := true
  10. client, err := astraopsv1.Authenticate(c, verbose)
  11. }

Create Database

Will block until creation

  1. createDb := CreateDb{
  2. Name: "testerdblist",
  3. Keyspace: "mykeyspace",
  4. Region: "europe-west1",
  5. CloudProvider: "GCP",
  6. CapacityUnits: 1,
  7. Tier: "serverless",
  8. User: "myuser",
  9. Password: "mypass",
  10. }
  11. //id is a uuid
  12. //db is the following type
  13. //type DataBase struct {
  14. // ID string `json:"id"`
  15. // OrgID string `json:"orgId"`
  16. // OwnerID string `json:"ownerId"`
  17. // Info Info `json:"info"`
  18. // CreationTime string `json:"creationTime"`
  19. // TerminationTime string `json:"terminationTime"`
  20. // Status string `json:"status"`
  21. // Storage Storage `json:"storage"`
  22. // AvailableActions []string `json:"availableActions"`
  23. // Message string `json:"message"`
  24. // StudioURL string `json:"studioUrl"`
  25. // GrafanaURL string `json:"grafanaUrl"`
  26. // CqlshURL string `json:"cqlshUrl"`
  27. // GraphqlURL string `json:"graphUrl"`
  28. // DataEndpointURL string `json:"dataEndpointUrl"`
  29. //}
  30. id, db, err := client.CreateDb(createDb)

Delete Database

Will block until terminating status or terminated status is returned

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

List All Databases With A Limit Of 10

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

Get Database by ID

  1. db, err := client.FindDb(id)
  2. //type DataBase struct {
  3. // ID string `json:"id"`
  4. // OrgID string `json:"orgId"`
  5. // OwnerID string `json:"ownerId"`
  6. // Info Info `json:"info"`
  7. // CreationTime string `json:"creationTime"`
  8. // TerminationTime string `json:"terminationTime"`
  9. // Status string `json:"status"`
  10. // Storage Storage `json:"storage"`
  11. // AvailableActions []string `json:"availableActions"`
  12. // Message string `json:"message"`
  13. // StudioURL string `json:"studioUrl"`
  14. // GrafanaURL string `json:"grafanaUrl"`
  15. // CqlshURL string `json:"cqlshUrl"`
  16. // GraphqlURL string `json:"graphUrl"`
  17. // DataEndpointURL string `json:"dataEndpointUrl"`
  18. }
  19. */

Get Secure Connect Bundle by ID

  1. secureBundle, err := client.GetSecureBundle(id)
  2. /*
  3. type SecureBundle struct {
  4. DownloadURL string `json:"downloadURL"`
  5. DownloadURLInternal string `json:"downloadURLInternal"`
  6. DownloadURLMigrationProxy string `json:"downloadURLMigrationProxy"`
  7. }
  8. */

Park legacy tier db (non serverless)

Will block until parking complete

  1. err := client.Park(id)

Unpark legacy tier db (non serverless)

Will block until unparking complete, this can take very long

  1. err := client.UnPark(id)

Resize

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

List all tiers available

  1. tiers, err := GetTierInfo()
  2. //returns a list of TierInfo
  3. //type TierInfo struct {
  4. // Tier string `json:"tier"`
  5. // Description string `json:"description"`
  6. // CloudProvider string `json:"cloudProvider"`
  7. // Region string `json:"region"`
  8. // RegionDisplay string `json:"regionDisplay"`
  9. // RegionContinent string `json:"regionContinent"`
  10. // Cost TierCost `json:"cost"`
  11. // DatabaseCountUsed int `json:"databaseCountUsed"`
  12. // DatabaseCountLimit int `json:"databaseCountLimit"`
  13. // CapacityUnitsUsed int `json:"capacityUnitsUsed"`
  14. // CapacityUnitsLimit int `json:"capacityUnitsLimit"`
  15. // DefaultStoragePerCapacityUnitGb int `json:"defaultStoragePerCapacityUnitGb"`
  16. //}
  17. //
  18. //tier cost has the following fields
  19. //type TierCost struct {
  20. // CostPerMinCents float64 `json:"costPerMinCents"`
  21. // CostPerHourCents float64 `json:"costPerHourCents"`
  22. // CostPerDayCents float64 `json:"costPerDayCents"`
  23. // CostPerMonthCents float64 `json:"costPerMonthCents"`
  24. // CostPerMinMRCents float64 `json:"costPerMinMRCents"`
  25. // CostPerHourMRCents float64 `json:"costPerHourMRCents"`
  26. // CostPerDayMRCents float64 `json:"costPerDayMRCents"`
  27. // CostPerMonthMRCents float64 `json:"costPerMonthMRCents"`
  28. // CostPerMinParkedCents float64 `json:"costPerMinParkedCents"`
  29. // CostPerHourParkedCents float64 `json:"costPerHourParkedCents"`
  30. // CostPerDayParkedCents float64 `json:"costPerDayParkedCents"`
  31. // CostPerMonthParkedCents float64 `json:"costPerMonthParkedCents"`
  32. // CostPerNetworkGbCents float64 `json:"costPerNetworkGbCents"`
  33. // CostPerWrittenGbCents float64 `json:"costPerWrittenGbCents"`
  34. // CostPerReadGbCents float64 `json:"costPerReadGbCents"`
  35. //}