Skip to content

Latest commit

 

History

History
397 lines (260 loc) · 11.3 KB

DatabasesApi.md

File metadata and controls

397 lines (260 loc) · 11.3 KB

Databases

All URIs are relative to https://cockroachlabs.cloud

Method HTTP request Description
CreateDatabase Post /api/v1/clusters/{cluster_id}/databases Create a new database
DeleteDatabase Delete /api/v1/clusters/{cluster_id}/databases/{name} Delete a database
EditDatabase Patch /api/v1/clusters/{cluster_id}/databases/{name} Update a database
EditDatabase2 Patch /api/v1/clusters/{cluster_id}/databases Update a database
ListDatabases Get /api/v1/clusters/{cluster_id}/databases List databases for a cluster

CreateDatabase

Database CreateDatabase(ctx, clusterId).CreateDatabaseRequest(createDatabaseRequest).Execute()

Create a new database

Can be used by the following roles assigned at the organization or cluster scope:

  • CLUSTER_ADMIN
  • CLUSTER_OPERATOR_WRITER

Example

package main

import (
    "context"
    "fmt"
    "os"
    openapiclient "./openapi"
)

func main() {
    clusterId := "clusterId_example" // string | 
    createDatabaseRequest := *openapiclient.NewCreateDatabaseRequest("Name_example") // CreateDatabaseRequest | 

    configuration := openapiclient.NewConfiguration()
    api_client := openapiclient.NewClient(configuration)
    resp, r, err := api_client.DatabasesApi.CreateDatabase(context.Background(), clusterId).CreateDatabaseRequest(createDatabaseRequest).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `DatabasesApi.CreateDatabase``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `CreateDatabase`: Database
    fmt.Fprintf(os.Stdout, "Response from `DatabasesApi.CreateDatabase`: %v\n", resp)
}

Path Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
clusterId string

Other Parameters

Other parameters are passed through a pointer to a apiCreateDatabase struct via the builder pattern

Name Type Description Notes

createDatabaseRequest | CreateDatabaseRequest | |

Return type

Database

Authorization

Bearer

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

[Back to top] [Back to API list] [Back to README]

DeleteDatabase

Database DeleteDatabase(ctx, clusterId, name).Execute()

Delete a database

Can be used by the following roles assigned at the organization or cluster scope:

  • CLUSTER_ADMIN
  • CLUSTER_OPERATOR_WRITER

Example

package main

import (
    "context"
    "fmt"
    "os"
    openapiclient "./openapi"
)

func main() {
    clusterId := "clusterId_example" // string | 
    name := "name_example" // string | 

    configuration := openapiclient.NewConfiguration()
    api_client := openapiclient.NewClient(configuration)
    resp, r, err := api_client.DatabasesApi.DeleteDatabase(context.Background(), clusterId, name).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `DatabasesApi.DeleteDatabase``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `DeleteDatabase`: Database
    fmt.Fprintf(os.Stdout, "Response from `DatabasesApi.DeleteDatabase`: %v\n", resp)
}

Path Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
clusterId string
name string

Other Parameters

Other parameters are passed through a pointer to a apiDeleteDatabase struct via the builder pattern

Name Type Description Notes

Return type

Database

Authorization

Bearer

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to README]

EditDatabase

Database EditDatabase(ctx, clusterId, name).UpdateDatabaseRequest1(updateDatabaseRequest1).Execute()

Update a database

Can be used by the following roles assigned at the organization or cluster scope:

  • CLUSTER_ADMIN
  • CLUSTER_OPERATOR_WRITER

Example

package main

import (
    "context"
    "fmt"
    "os"
    openapiclient "./openapi"
)

func main() {
    clusterId := "clusterId_example" // string | 
    name := "name_example" // string | 
    updateDatabaseRequest1 := *openapiclient.NewUpdateDatabaseRequest1("NewName_example") // UpdateDatabaseRequest1 | 

    configuration := openapiclient.NewConfiguration()
    api_client := openapiclient.NewClient(configuration)
    resp, r, err := api_client.DatabasesApi.EditDatabase(context.Background(), clusterId, name).UpdateDatabaseRequest1(updateDatabaseRequest1).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `DatabasesApi.EditDatabase``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `EditDatabase`: Database
    fmt.Fprintf(os.Stdout, "Response from `DatabasesApi.EditDatabase`: %v\n", resp)
}

Path Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
clusterId string
name string

Other Parameters

Other parameters are passed through a pointer to a apiEditDatabase struct via the builder pattern

Name Type Description Notes

updateDatabaseRequest1 | UpdateDatabaseRequest1 | |

Return type

Database

Authorization

Bearer

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

[Back to top] [Back to API list] [Back to README]

EditDatabase2

Database EditDatabase2(ctx, clusterId).UpdateDatabaseRequest(updateDatabaseRequest).Execute()

Update a database

Can be used by the following roles assigned at the organization or cluster scope:

  • CLUSTER_ADMIN
  • CLUSTER_OPERATOR_WRITER

Example

package main

import (
    "context"
    "fmt"
    "os"
    openapiclient "./openapi"
)

func main() {
    clusterId := "clusterId_example" // string | 
    updateDatabaseRequest := *openapiclient.NewUpdateDatabaseRequest("Name_example", "NewName_example") // UpdateDatabaseRequest | 

    configuration := openapiclient.NewConfiguration()
    api_client := openapiclient.NewClient(configuration)
    resp, r, err := api_client.DatabasesApi.EditDatabase2(context.Background(), clusterId).UpdateDatabaseRequest(updateDatabaseRequest).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `DatabasesApi.EditDatabase2``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `EditDatabase2`: Database
    fmt.Fprintf(os.Stdout, "Response from `DatabasesApi.EditDatabase2`: %v\n", resp)
}

Path Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
clusterId string

Other Parameters

Other parameters are passed through a pointer to a apiEditDatabase2 struct via the builder pattern

Name Type Description Notes

updateDatabaseRequest | UpdateDatabaseRequest | |

Return type

Database

Authorization

Bearer

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

[Back to top] [Back to API list] [Back to README]

ListDatabases

ListDatabasesResponse ListDatabases(ctx, clusterId).PaginationPage(paginationPage).PaginationLimit(paginationLimit).PaginationAsOfTime(paginationAsOfTime).PaginationSortOrder(paginationSortOrder).Execute()

List databases for a cluster

Sort order: Database name ascending

Can be used by the following roles assigned at the organization or cluster scope:

  • CLUSTER_ADMIN
  • CLUSTER_OPERATOR_WRITER
  • CLUSTER_DEVELOPER

Example

package main

import (
    "context"
    "fmt"
    "os"
    "time"
    openapiclient "./openapi"
)

func main() {
    clusterId := "clusterId_example" // string | 
    paginationPage := "paginationPage_example" // string |  (optional)
    paginationLimit := int32(56) // int32 |  (optional)
    paginationAsOfTime := time.Now() // time.Time |  (optional)
    paginationSortOrder := "paginationSortOrder_example" // string |  - ASC: Sort in ascending order. This is the default unless otherwise specified.  - DESC: Sort in descending order. (optional)

    configuration := openapiclient.NewConfiguration()
    api_client := openapiclient.NewClient(configuration)
    resp, r, err := api_client.DatabasesApi.ListDatabases(context.Background(), clusterId).PaginationPage(paginationPage).PaginationLimit(paginationLimit).PaginationAsOfTime(paginationAsOfTime).PaginationSortOrder(paginationSortOrder).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `DatabasesApi.ListDatabases``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `ListDatabases`: ListDatabasesResponse
    fmt.Fprintf(os.Stdout, "Response from `DatabasesApi.ListDatabases`: %v\n", resp)
}

Path Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
clusterId string

Other Parameters

Other parameters are passed through a pointer to a apiListDatabases struct via the builder pattern

Name Type Description Notes

paginationPage | string | | paginationLimit | int32 | | paginationAsOfTime | time.Time | | paginationSortOrder | string | - ASC: Sort in ascending order. This is the default unless otherwise specified. - DESC: Sort in descending order. |

Return type

ListDatabasesResponse

Authorization

Bearer

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to README]