// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Code generated by protoc-gen-go_gapic. DO NOT EDIT.

package database_test

import (
	"context"

	database "cloud.google.com/go/spanner/admin/database/apiv1"
	"google.golang.org/api/iterator"
	iampb "google.golang.org/genproto/googleapis/iam/v1"
	databasepb "google.golang.org/genproto/googleapis/spanner/admin/database/v1"
)

func ExampleNewDatabaseAdminClient() {
	ctx := context.Background()
	c, err := database.NewDatabaseAdminClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use client.
	_ = c
}

func ExampleDatabaseAdminClient_ListDatabases() {
	// import databasepb "google.golang.org/genproto/googleapis/spanner/admin/database/v1"
	// import "google.golang.org/api/iterator"

	ctx := context.Background()
	c, err := database.NewDatabaseAdminClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &databasepb.ListDatabasesRequest{
		// TODO: Fill request struct fields.
	}
	it := c.ListDatabases(ctx, req)
	for {
		resp, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			// TODO: Handle error.
		}
		// TODO: Use resp.
		_ = resp
	}
}

func ExampleDatabaseAdminClient_CreateDatabase() {
	// import databasepb "google.golang.org/genproto/googleapis/spanner/admin/database/v1"

	ctx := context.Background()
	c, err := database.NewDatabaseAdminClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &databasepb.CreateDatabaseRequest{
		// TODO: Fill request struct fields.
	}
	op, err := c.CreateDatabase(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	resp, err := op.Wait(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func ExampleDatabaseAdminClient_GetDatabase() {
	// import databasepb "google.golang.org/genproto/googleapis/spanner/admin/database/v1"

	ctx := context.Background()
	c, err := database.NewDatabaseAdminClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &databasepb.GetDatabaseRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.GetDatabase(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func ExampleDatabaseAdminClient_UpdateDatabaseDdl() {
	// import databasepb "google.golang.org/genproto/googleapis/spanner/admin/database/v1"

	ctx := context.Background()
	c, err := database.NewDatabaseAdminClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &databasepb.UpdateDatabaseDdlRequest{
		// TODO: Fill request struct fields.
	}
	op, err := c.UpdateDatabaseDdl(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	err = op.Wait(ctx)
	if err != nil {
		// TODO: Handle error.
	}
}

func ExampleDatabaseAdminClient_DropDatabase() {
	ctx := context.Background()
	c, err := database.NewDatabaseAdminClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &databasepb.DropDatabaseRequest{
		// TODO: Fill request struct fields.
	}
	err = c.DropDatabase(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
}

func ExampleDatabaseAdminClient_GetDatabaseDdl() {
	// import databasepb "google.golang.org/genproto/googleapis/spanner/admin/database/v1"

	ctx := context.Background()
	c, err := database.NewDatabaseAdminClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &databasepb.GetDatabaseDdlRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.GetDatabaseDdl(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func ExampleDatabaseAdminClient_SetIamPolicy() {
	// import iampb "google.golang.org/genproto/googleapis/iam/v1"

	ctx := context.Background()
	c, err := database.NewDatabaseAdminClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &iampb.SetIamPolicyRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.SetIamPolicy(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func ExampleDatabaseAdminClient_GetIamPolicy() {
	// import iampb "google.golang.org/genproto/googleapis/iam/v1"

	ctx := context.Background()
	c, err := database.NewDatabaseAdminClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &iampb.GetIamPolicyRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.GetIamPolicy(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func ExampleDatabaseAdminClient_TestIamPermissions() {
	// import iampb "google.golang.org/genproto/googleapis/iam/v1"

	ctx := context.Background()
	c, err := database.NewDatabaseAdminClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &iampb.TestIamPermissionsRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.TestIamPermissions(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func ExampleDatabaseAdminClient_CreateBackup() {
	// import databasepb "google.golang.org/genproto/googleapis/spanner/admin/database/v1"

	ctx := context.Background()
	c, err := database.NewDatabaseAdminClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &databasepb.CreateBackupRequest{
		// TODO: Fill request struct fields.
	}
	op, err := c.CreateBackup(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	resp, err := op.Wait(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func ExampleDatabaseAdminClient_GetBackup() {
	// import databasepb "google.golang.org/genproto/googleapis/spanner/admin/database/v1"

	ctx := context.Background()
	c, err := database.NewDatabaseAdminClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &databasepb.GetBackupRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.GetBackup(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func ExampleDatabaseAdminClient_UpdateBackup() {
	// import databasepb "google.golang.org/genproto/googleapis/spanner/admin/database/v1"

	ctx := context.Background()
	c, err := database.NewDatabaseAdminClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &databasepb.UpdateBackupRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.UpdateBackup(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func ExampleDatabaseAdminClient_DeleteBackup() {
	ctx := context.Background()
	c, err := database.NewDatabaseAdminClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &databasepb.DeleteBackupRequest{
		// TODO: Fill request struct fields.
	}
	err = c.DeleteBackup(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
}

func ExampleDatabaseAdminClient_ListBackups() {
	// import databasepb "google.golang.org/genproto/googleapis/spanner/admin/database/v1"
	// import "google.golang.org/api/iterator"

	ctx := context.Background()
	c, err := database.NewDatabaseAdminClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &databasepb.ListBackupsRequest{
		// TODO: Fill request struct fields.
	}
	it := c.ListBackups(ctx, req)
	for {
		resp, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			// TODO: Handle error.
		}
		// TODO: Use resp.
		_ = resp
	}
}

func ExampleDatabaseAdminClient_RestoreDatabase() {
	// import databasepb "google.golang.org/genproto/googleapis/spanner/admin/database/v1"

	ctx := context.Background()
	c, err := database.NewDatabaseAdminClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &databasepb.RestoreDatabaseRequest{
		// TODO: Fill request struct fields.
	}
	op, err := c.RestoreDatabase(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	resp, err := op.Wait(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func ExampleDatabaseAdminClient_ListDatabaseOperations() {
	// import databasepb "google.golang.org/genproto/googleapis/spanner/admin/database/v1"
	// import "google.golang.org/api/iterator"

	ctx := context.Background()
	c, err := database.NewDatabaseAdminClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &databasepb.ListDatabaseOperationsRequest{
		// TODO: Fill request struct fields.
	}
	it := c.ListDatabaseOperations(ctx, req)
	for {
		resp, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			// TODO: Handle error.
		}
		// TODO: Use resp.
		_ = resp
	}
}

func ExampleDatabaseAdminClient_ListBackupOperations() {
	// import databasepb "google.golang.org/genproto/googleapis/spanner/admin/database/v1"
	// import "google.golang.org/api/iterator"

	ctx := context.Background()
	c, err := database.NewDatabaseAdminClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &databasepb.ListBackupOperationsRequest{
		// TODO: Fill request struct fields.
	}
	it := c.ListBackupOperations(ctx, req)
	for {
		resp, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			// TODO: Handle error.
		}
		// TODO: Use resp.
		_ = resp
	}
}
