This topic describes how to drop a specified tenant by using obshell-sdk-go.
Note
We recommend that you first read Get started with obshell-sdk-go to learn how to use obshell-sdk-go.
Considerations
Make sure that obshell is running.
Make sure that the tenant to be dropped exists and is in the NORMAL state.
The node corresponding to the client for the request must be in an initialized cluster.
Sample code
package main
import (
"fmt"
"github.com/oceanbase/obshell-sdk-go/services"
)
func main() {
// Create a client instance with the node address '10.10.10.1' and port 2886.
client, err := services.NewClientWithPassword("10.10.10.1", 2886, "****")
if err != nil {
fmt.Print(err)
return
}
req := client.V1().NewDropTenantRequest("t1")
if _, err = client.V1().DropTenantSyncWithRequest(req); err != nil {
fmt.Print(err)
return
}
}
package main
import (
"fmt"
"github.com/oceanbase/obshell-sdk-go/services"
)
func main() {
// Create a client instance with the node address '10.10.10.1' and port 2886.
client, err := services.NewClientWithPassword("10.10.10.1", 2886, "****")
if err != nil {
fmt.Print(err)
return
}
req := client.V1().NewDropTenantRequest("t1")
dag, err := client.V1().DropTenantWithRequest(req)
if err != nil {
fmt.Print(err)
return
}
// Wait for the task to succeed.
if _, err = client.V1().WaitDagSucceed(dag.GenericID); err != nil {
fmt.Print(err)
return
}
}
References
For more information about the API for dropping a tenant, see Drop a tenant.
For more information about how to call API methods by using obshell-sdk-python, see Drop a tenant.