SFTP-Server starten oder stoppen

Sie können einen SFTP-Server beenden oder starten, um seinen Status zu verwalten, den Zugriff zu steuern und die Kosten zu optimieren.

Wenn Sie einen Server beenden, wird der Zugriff deaktiviert und die Ressourcennutzung reduziert. Wenn Sie beispielsweise einen unbefugten Zugriff auf einen Server vermuten, können Sie alle aktiven Übertragungen anhalten und neue Verbindungen blockieren, indem Sie den Server beenden. Ein weiteres Beispiel: Sie können die Kosten für die Serververfügbarkeit reduzieren, indem Sie einen Server in Zeiten pausieren, in denen keine Datenübertragungen erwartet werden.

Wenn Sie einen Server starten, wird der Zugriff wiederhergestellt und Nutzer können sich mit dem Server verbinden.

Erforderliche Rollen

Bitten Sie Ihren Administrator, Ihnen die IAM-Rolle Cloud FTP Admin (roles/ftp.admin) für Ihr Projekt zuzuweisen, um die Berechtigung zu erhalten, die Sie zum Starten oder Beenden eines SFTP-Servers benötigen. Weitere Informationen zum Zuweisen von Rollen finden Sie unter Zugriff auf Projekte, Ordner und Organisationen verwalten.

Diese vordefinierte Rolle enthält die Berechtigung ftp.servers.update, die zum Starten oder Beenden eines SFTP-Servers erforderlich ist.

Sie können diese Berechtigung auch mit benutzerdefinierten Rollen oder anderen vordefinierten Rollen erhalten.

Server anhalten

Wenn Sie einen Server beenden, passiert Folgendes:

  • Der Zugriff wird verweigert und aktive Verbindungen werden getrennt. Nutzer mit einer aktiven Verbindung sehen möglicherweise eine Fehlermeldung wie die folgende:

    Connection is terminated: Connection closed by remote host
    client_loop: send disconnect: Broken pipe
    Connection closed
    
  • Es können keine neuen Verbindungen hergestellt werden.

So beenden Sie einen Server:

REST

Verwenden Sie zum Beenden eines Servers die Methode servers.stop.

Ersetzen Sie diese Werte in den folgenden Anfragedaten:

  • PROJECT_ID: die Google Cloud -Projekt-ID des Servers.
  • LOCATION_ID: der Google Cloud Standort des Servers, z. B. us-west1.
  • SERVER_ID: die Server-ID.

HTTP-Methode und URL:

POST https://ftp.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/servers/SERVER_ID:stop

Wenn Sie die Anfrage senden möchten, maximieren Sie eine der folgenden Optionen:

Die Antwort identifiziert einen Vorgang mit langer Ausführungszeit.

Clientbibliotheken

C#

Informationen zum Installieren und Verwenden der Clientbibliothek für Cloud FTP finden Sie unter Cloud FTP-Clientbibliotheken. Weitere Informationen finden Sie in der Referenzdokumentation zur Cloud FTP C# API.

Richten Sie die Standardanmeldedaten für Anwendungen ein, um sich bei Cloud FTP zu authentifizieren. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.

using Google.Cloud.Ftp.V1;
using Google.LongRunning;
using System.Threading.Tasks;

public sealed partial class GeneratedCloudFtpClientSnippets
{
    /// <summary>Snippet for StopServerAsync</summary>
    /// <remarks>
    /// This snippet has been automatically generated and should be regarded as a code template only.
    /// It will require modifications to work:
    /// - It may require correct/in-range values for request initialization.
    /// - It may require specifying regional endpoints when creating the service client as shown in
    ///   https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
    /// </remarks>
    public async Task StopServerAsync()
    {
        // Create client
        CloudFtpClient cloudFtpClient = await CloudFtpClient.CreateAsync();
        // Initialize request argument(s)
        string name = "projects/[PROJECT]/locations/[LOCATION]/servers/[SERVER]";
        // Make the request
        Operation<Server, OperationMetadata> response = await cloudFtpClient.StopServerAsync(name);

        // Poll until the returned long-running operation is complete
        Operation<Server, OperationMetadata> completedResponse = await response.PollUntilCompletedAsync();
        // Retrieve the operation result
        Server result = completedResponse.Result;

        // Or get the name of the operation
        string operationName = response.Name;
        // This name can be stored, then the long-running operation retrieved later by name
        Operation<Server, OperationMetadata> retrievedResponse = await cloudFtpClient.PollOnceStopServerAsync(operationName);
        // Check if the retrieved long-running operation has completed
        if (retrievedResponse.IsCompleted)
        {
            // If it has completed, then access the result
            Server retrievedResult = retrievedResponse.Result;
        }
    }
}

Go

Informationen zum Installieren und Verwenden der Clientbibliothek für Cloud FTP finden Sie unter Cloud FTP-Clientbibliotheken. Weitere Informationen finden Sie in der API-Referenzdokumentation zu Cloud FTP Go.

Richten Sie die Standardanmeldedaten für Anwendungen ein, um sich bei Cloud FTP zu authentifizieren. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.


//go:build examples

package main

import (
	"context"

	ftp "cloud.google.com/go/ftp/apiv1"
	ftppb "cloud.google.com/go/ftp/apiv1/ftppb"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := ftp.NewCloudFtpRESTClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &ftppb.StopServerRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/ftp/apiv1/ftppb#StopServerRequest.
	}
	op, err := c.StopServer(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

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

Java

Informationen zum Installieren und Verwenden der Clientbibliothek für Cloud FTP finden Sie unter Cloud FTP-Clientbibliotheken. Weitere Informationen finden Sie in der API-Referenzdokumentation zu Cloud FTP Java.

Richten Sie die Standardanmeldedaten für Anwendungen ein, um sich bei Cloud FTP zu authentifizieren. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.

import com.google.api.core.ApiFuture;
import com.google.cloud.ftp.v1.CloudFtpClient;
import com.google.cloud.ftp.v1.ServerName;
import com.google.cloud.ftp.v1.StopServerRequest;
import com.google.longrunning.Operation;

public class AsyncStopServer {

  public static void main(String[] args) throws Exception {
    asyncStopServer();
  }

  public static void asyncStopServer() throws Exception {
    // This snippet has been automatically generated and should be regarded as a code template only.
    // It will require modifications to work:
    // - It may require correct/in-range values for request initialization.
    // - It may require specifying regional endpoints when creating the service client as shown in
    // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
    try (CloudFtpClient cloudFtpClient = CloudFtpClient.create()) {
      StopServerRequest request =
          StopServerRequest.newBuilder()
              .setName(ServerName.of("[PROJECT]", "[LOCATION]", "[SERVER]").toString())
              .build();
      ApiFuture<Operation> future = cloudFtpClient.stopServerCallable().futureCall(request);
      // Do something.
      Operation response = future.get();
    }
  }
}

Node.js

Informationen zum Installieren und Verwenden der Clientbibliothek für Cloud FTP finden Sie unter Cloud FTP-Clientbibliotheken. Weitere Informationen finden Sie in der API-Referenzdokumentation zu Cloud FTP Node.js.

Richten Sie die Standardanmeldedaten für Anwendungen ein, um sich bei Cloud FTP zu authentifizieren. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.

/**
 * This snippet has been automatically generated and should be regarded as a code template only.
 * It will require modifications to work.
 * It may require correct/in-range values for request initialization.
 * TODO(developer): Uncomment these variables before running the sample.
 */
/**
 *  Required. Name of the resource.
 *  Format: `projects/{project}/locations/{location}/servers/{server}`
 */
// const name = 'abc123'

// Imports the Ftp library
const {CloudFtpClient} = require('@google-cloud/ftp').v1;

// Instantiates a client
const ftpClient = new CloudFtpClient();

async function callStopServer() {
  // Construct request
  const request = {
    name,
  };

  // Run request
  const [operation] = await ftpClient.stopServer(request);
  const [response] = await operation.promise();
  console.log(response);
}

callStopServer();

PHP

Informationen zum Installieren und Verwenden der Clientbibliothek für Cloud FTP finden Sie unter Cloud FTP-Clientbibliotheken. Weitere Informationen finden Sie in der API-Referenzdokumentation zu Cloud FTP PHP.

Richten Sie die Standardanmeldedaten für Anwendungen ein, um sich bei Cloud FTP zu authentifizieren. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.

use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Ftp\V1\Client\CloudFtpClient;
use Google\Cloud\Ftp\V1\Server;
use Google\Cloud\Ftp\V1\StopServerRequest;
use Google\Rpc\Status;

/**
 * Stops an active Server.
 *
 * @param string $formattedName Name of the resource.
 *                              Format: `projects/{project}/locations/{location}/servers/{server}`
 *                              Please see {@see CloudFtpClient::serverName()} for help formatting this field.
 */
function stop_server_sample(string $formattedName): void
{
    // Create a client.
    $cloudFtpClient = new CloudFtpClient();

    // Prepare the request message.
    $request = (new StopServerRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $cloudFtpClient->stopServer($request);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var Server $result */
            $result = $response->getResult();
            printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = CloudFtpClient::serverName('[PROJECT]', '[LOCATION]', '[SERVER]');

    stop_server_sample($formattedName);
}

Python

Informationen zum Installieren und Verwenden der Clientbibliothek für Cloud FTP finden Sie unter Cloud FTP-Clientbibliotheken. Weitere Informationen finden Sie in der Referenzdokumentation zur Cloud FTP Python API.

Richten Sie die Standardanmeldedaten für Anwendungen ein, um sich bei Cloud FTP zu authentifizieren. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import ftp_v1


def sample_stop_server():
    # Create a client
    client = ftp_v1.CloudFtpClient()

    # Initialize request argument(s)
    request = ftp_v1.StopServerRequest(
        name="name_value",
    )

    # Make the request
    operation = client.stop_server(request=request)

    print("Waiting for operation to complete...")

    response = operation.result()

    # Handle the response
    print(response)

Ruby

Informationen zum Installieren und Verwenden der Clientbibliothek für Cloud FTP finden Sie unter Cloud FTP-Clientbibliotheken. Weitere Informationen finden Sie in der API-Referenzdokumentation zu Cloud FTP Ruby.

Richten Sie die Standardanmeldedaten für Anwendungen ein, um sich bei Cloud FTP zu authentifizieren. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.

require "google/cloud/ftp/v1"

##
# Snippet for the stop_server call in the CloudFtp service
#
# This snippet has been automatically generated and should be regarded as a code
# template only. It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in https://cloud.google.com/ruby/docs/reference.
#
# This is an auto-generated example demonstrating basic usage of
# Google::Cloud::Ftp::V1::CloudFtp::Rest::Client#stop_server.
#
def stop_server
  # Create a client object. The client can be reused for multiple calls.
  client = Google::Cloud::Ftp::V1::CloudFtp::Rest::Client.new

  # Create a request. To set request fields, pass in keyword arguments.
  request = Google::Cloud::Ftp::V1::StopServerRequest.new

  # Call the stop_server method.
  result = client.stop_server request

  # The returned object is of type Gapic::Operation. You can use it to
  # check the status of an operation, cancel it, or wait for results.
  # Here is how to wait for a response.
  result.wait_until_done! timeout: 60
  if result.response?
    p result.response
  else
    puts "No response received."
  end
end

Server starten

REST

Verwenden Sie zum Starten eines Servers die Methode servers.start.

Ersetzen Sie diese Werte in den folgenden Anfragedaten:

  • PROJECT_ID: die Google Cloud Projekt-ID des Servers.
  • LOCATION_ID: der Google Cloud Standort des Servers, z. B. us-west1.
  • SERVER_ID: die Server-ID.

HTTP-Methode und URL:

POST https://ftp.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/servers/SERVER_ID:start

Wenn Sie die Anfrage senden möchten, maximieren Sie eine der folgenden Optionen:

Die Antwort identifiziert einen Vorgang mit langer Ausführungszeit. Es dauert einige Minuten, bis der Server gestartet ist.

Clientbibliotheken

C#

Informationen zum Installieren und Verwenden der Clientbibliothek für Cloud FTP finden Sie unter Cloud FTP-Clientbibliotheken. Weitere Informationen finden Sie in der API-Referenzdokumentation zu Cloud FTP C#.

Richten Sie die Standardanmeldedaten für Anwendungen ein, um sich bei Cloud FTP zu authentifizieren. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.

using Google.Cloud.Ftp.V1;
using Google.LongRunning;
using System.Threading.Tasks;

public sealed partial class GeneratedCloudFtpClientSnippets
{
    /// <summary>Snippet for StartServerAsync</summary>
    /// <remarks>
    /// This snippet has been automatically generated and should be regarded as a code template only.
    /// It will require modifications to work:
    /// - It may require correct/in-range values for request initialization.
    /// - It may require specifying regional endpoints when creating the service client as shown in
    ///   https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
    /// </remarks>
    public async Task StartServerAsync()
    {
        // Create client
        CloudFtpClient cloudFtpClient = await CloudFtpClient.CreateAsync();
        // Initialize request argument(s)
        string name = "projects/[PROJECT]/locations/[LOCATION]/servers/[SERVER]";
        // Make the request
        Operation<Server, OperationMetadata> response = await cloudFtpClient.StartServerAsync(name);

        // Poll until the returned long-running operation is complete
        Operation<Server, OperationMetadata> completedResponse = await response.PollUntilCompletedAsync();
        // Retrieve the operation result
        Server result = completedResponse.Result;

        // Or get the name of the operation
        string operationName = response.Name;
        // This name can be stored, then the long-running operation retrieved later by name
        Operation<Server, OperationMetadata> retrievedResponse = await cloudFtpClient.PollOnceStartServerAsync(operationName);
        // Check if the retrieved long-running operation has completed
        if (retrievedResponse.IsCompleted)
        {
            // If it has completed, then access the result
            Server retrievedResult = retrievedResponse.Result;
        }
    }
}

Go

Informationen zum Installieren und Verwenden der Clientbibliothek für Cloud FTP finden Sie unter Cloud FTP-Clientbibliotheken. Weitere Informationen finden Sie in der API-Referenzdokumentation zu Cloud FTP Go.

Richten Sie die Standardanmeldedaten für Anwendungen ein, um sich bei Cloud FTP zu authentifizieren. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.


//go:build examples

package main

import (
	"context"

	ftp "cloud.google.com/go/ftp/apiv1"
	ftppb "cloud.google.com/go/ftp/apiv1/ftppb"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := ftp.NewCloudFtpRESTClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &ftppb.StartServerRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/ftp/apiv1/ftppb#StartServerRequest.
	}
	op, err := c.StartServer(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

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

Java

Informationen zum Installieren und Verwenden der Clientbibliothek für Cloud FTP finden Sie unter Cloud FTP-Clientbibliotheken. Weitere Informationen finden Sie in der Referenzdokumentation zur Cloud FTP Java API.

Richten Sie die Standardanmeldedaten für Anwendungen ein, um sich bei Cloud FTP zu authentifizieren. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.

import com.google.api.core.ApiFuture;
import com.google.cloud.ftp.v1.CloudFtpClient;
import com.google.cloud.ftp.v1.ServerName;
import com.google.cloud.ftp.v1.StartServerRequest;
import com.google.longrunning.Operation;

public class AsyncStartServer {

  public static void main(String[] args) throws Exception {
    asyncStartServer();
  }

  public static void asyncStartServer() throws Exception {
    // This snippet has been automatically generated and should be regarded as a code template only.
    // It will require modifications to work:
    // - It may require correct/in-range values for request initialization.
    // - It may require specifying regional endpoints when creating the service client as shown in
    // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
    try (CloudFtpClient cloudFtpClient = CloudFtpClient.create()) {
      StartServerRequest request =
          StartServerRequest.newBuilder()
              .setName(ServerName.of("[PROJECT]", "[LOCATION]", "[SERVER]").toString())
              .build();
      ApiFuture<Operation> future = cloudFtpClient.startServerCallable().futureCall(request);
      // Do something.
      Operation response = future.get();
    }
  }
}

Node.js

Informationen zum Installieren und Verwenden der Clientbibliothek für Cloud FTP finden Sie unter Cloud FTP-Clientbibliotheken. Weitere Informationen finden Sie in der API-Referenzdokumentation zu Cloud FTP Node.js.

Richten Sie die Standardanmeldedaten für Anwendungen ein, um sich bei Cloud FTP zu authentifizieren. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.

/**
 * This snippet has been automatically generated and should be regarded as a code template only.
 * It will require modifications to work.
 * It may require correct/in-range values for request initialization.
 * TODO(developer): Uncomment these variables before running the sample.
 */
/**
 *  Required. Name of the resource
 *  Format: `projects/{project}/locations/{location}/servers/{server}`
 */
// const name = 'abc123'

// Imports the Ftp library
const {CloudFtpClient} = require('@google-cloud/ftp').v1;

// Instantiates a client
const ftpClient = new CloudFtpClient();

async function callStartServer() {
  // Construct request
  const request = {
    name,
  };

  // Run request
  const [operation] = await ftpClient.startServer(request);
  const [response] = await operation.promise();
  console.log(response);
}

callStartServer();

PHP

Informationen zum Installieren und Verwenden der Clientbibliothek für Cloud FTP finden Sie unter Cloud FTP-Clientbibliotheken. Weitere Informationen finden Sie in der API-Referenzdokumentation zu Cloud FTP PHP.

Richten Sie die Standardanmeldedaten für Anwendungen ein, um sich bei Cloud FTP zu authentifizieren. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.

use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Ftp\V1\Client\CloudFtpClient;
use Google\Cloud\Ftp\V1\Server;
use Google\Cloud\Ftp\V1\StartServerRequest;
use Google\Rpc\Status;

/**
 * Starts a stopping/stopped Server.
 *
 * @param string $formattedName Name of the resource
 *                              Format: `projects/{project}/locations/{location}/servers/{server}`
 *                              Please see {@see CloudFtpClient::serverName()} for help formatting this field.
 */
function start_server_sample(string $formattedName): void
{
    // Create a client.
    $cloudFtpClient = new CloudFtpClient();

    // Prepare the request message.
    $request = (new StartServerRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $cloudFtpClient->startServer($request);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var Server $result */
            $result = $response->getResult();
            printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = CloudFtpClient::serverName('[PROJECT]', '[LOCATION]', '[SERVER]');

    start_server_sample($formattedName);
}

Python

Informationen zum Installieren und Verwenden der Clientbibliothek für Cloud FTP finden Sie unter Cloud FTP-Clientbibliotheken. Weitere Informationen finden Sie in der API-Referenzdokumentation zu Cloud FTP Python.

Richten Sie die Standardanmeldedaten für Anwendungen ein, um sich bei Cloud FTP zu authentifizieren. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import ftp_v1


def sample_start_server():
    # Create a client
    client = ftp_v1.CloudFtpClient()

    # Initialize request argument(s)
    request = ftp_v1.StartServerRequest(
        name="name_value",
    )

    # Make the request
    operation = client.start_server(request=request)

    print("Waiting for operation to complete...")

    response = operation.result()

    # Handle the response
    print(response)

Ruby

Informationen zum Installieren und Verwenden der Clientbibliothek für Cloud FTP finden Sie unter Cloud FTP-Clientbibliotheken. Weitere Informationen finden Sie in der API-Referenzdokumentation zu Cloud FTP Ruby.

Richten Sie die Standardanmeldedaten für Anwendungen ein, um sich bei Cloud FTP zu authentifizieren. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.

require "google/cloud/ftp/v1"

##
# Snippet for the start_server call in the CloudFtp service
#
# This snippet has been automatically generated and should be regarded as a code
# template only. It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in https://cloud.google.com/ruby/docs/reference.
#
# This is an auto-generated example demonstrating basic usage of
# Google::Cloud::Ftp::V1::CloudFtp::Rest::Client#start_server.
#
def start_server
  # Create a client object. The client can be reused for multiple calls.
  client = Google::Cloud::Ftp::V1::CloudFtp::Rest::Client.new

  # Create a request. To set request fields, pass in keyword arguments.
  request = Google::Cloud::Ftp::V1::StartServerRequest.new

  # Call the start_server method.
  result = client.start_server request

  # The returned object is of type Gapic::Operation. You can use it to
  # check the status of an operation, cancel it, or wait for results.
  # Here is how to wait for a response.
  result.wait_until_done! timeout: 60
  if result.response?
    p result.response
  else
    puts "No response received."
  end
end

Nächste Schritte