godo icon indicating copy to clipboard operation
godo copied to clipboard

Include DBaaS metrics credential endpoint operations

Open dwilsondo opened this issue 1 year ago • 0 comments

Adds support for:

  • GET on /v2/databases/metrics/credentials via Databases.GetMetricsCredentials - Gets the credentials required to access a user's metrics endpoints
  • PUT on /v2/databases/metrics/credentials via Databases.UpdateMetricsCredentials - Updates the credentials required to access a user's metrics endpoints
  • Includes metrics_endpoints on response to Databases.Get

Example Usage:

func main() {
	
	cl := godo.NewFromToken(os.Getenv("DIGITALOCEAN_RW_TOKEN"))
	ctx, cancel := context.WithCancel(context.Background())
	defer cancel()

	db, _, _ := cl.Databases.GetMetricsCredentials(ctx)
	fmt.Printf("Current State: %+v\n", db)

	_, _ = cl.Databases.UpdateMetricsCredentials(ctx, &godo.DatabaseUpdateMetricsCredentialsRequest{
		Credentials: &godo.DatabaseMetricsCredentials{
			BasicAuthPassword: "a_new_password",
			BasicAuthUsername: "a_new_username",
		},
	})
	
	db, _, _ = cl.Databases.GetMetricsCredentials(ctx)
	fmt.Printf("Current State: %+v\n", db)
}
Current State: &{BasicAuthUsername:a_old_username BasicAuthPassword:a_old_password}
Current State: &{BasicAuthUsername:a_new_username BasicAuthPassword:a_new_password}

dwilsondo avatar Feb 06 '24 19:02 dwilsondo