SFTP 서버 업데이트

서버의 액세스 구성을 업데이트하여 Cloud FTP 서버에 연결할 수 있는 사용자를 업데이트할 수 있습니다. 서버의 표시 이름과 같은 메타데이터를 업데이트할 수도 있습니다.

서버가 생성된 후에는 서버가 외부인지 내부인지 여부를 변경할 수 없습니다.

필요한 역할

SFTP 서버를 업데이트하는 데 필요한 권한을 얻으려면 관리자에게 프로젝트에 대한 Cloud FTP 관리자 (roles/ftp.admin) IAM 역할을 부여해 달라고 요청하세요. 역할 부여에 대한 자세한 내용은 프로젝트, 폴더, 조직에 대한 액세스 관리를 참조하세요.

이 사전 정의된 역할에는 SFTP 서버를 업데이트하는 데 필요한 ftp.servers.update 권한이 포함되어 있습니다.

커스텀 역할이나 다른 사전 정의된 역할을 사용하여 이 권한을 가져올 수도 있습니다.

외부 서버 액세스 업데이트

gcloud

외부 서버의 액세스 구성을 업데이트하려면 gcloud alpha storage ftp servers update 명령어를 실행합니다. --allowed-cidr-blocks 플래그를 제공합니다.

아래의 명령어 데이터를 사용하기 전에 다음을 바꿉니다.

  • SERVER_ID: 서버 ID입니다.
  • LOCATION_ID: 서버의 위치입니다(예: us-west1).
  • CIDR_BLOCK: 서버에 액세스할 수 있는 CIDR 블록입니다. 예를 들면 192.0.2.0/24입니다. 하나 이상의 값을 제공해야 하며, 쉼표로 구분된 목록으로 최대 500개의 CIDR 블록을 제공할 수 있습니다. 모든 IP 주소의 연결을 허용하려면 0.0.0.0/0를 사용합니다.

다음 명령어를 실행합니다.

Linux, macOS 또는 Cloud Shell

gcloud alpha storage ftp servers update SERVER_ID --location=LOCATION_ID \
    --allowed-cidr-blocks=CIDR_BLOCK

Windows(PowerShell)

gcloud alpha storage ftp servers update SERVER_ID --location=LOCATION_ID `
    --allowed-cidr-blocks=CIDR_BLOCK

Windows(cmd.exe)

gcloud alpha storage ftp servers update SERVER_ID --location=LOCATION_ID ^
    --allowed-cidr-blocks=CIDR_BLOCK
서버가 업데이트되는 데 몇 초 정도 걸립니다.

REST

외부 서버의 액세스 구성을 업데이트하려면 servers.patch 메서드를 사용합니다. updateMask 쿼리 매개변수에서 externalConfig 필드를 제공합니다.

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • PROJECT_ID: 서버의 Google Cloud 프로젝트 ID입니다.
  • LOCATION_ID: 서버의 위치입니다(예: us-west1).
  • SERVER_ID: 서버 ID입니다.
  • CIDR_BLOCK: 서버에 액세스할 수 있는 CIDR 블록입니다. 예를 들면 192.0.2.0/24입니다. 하나 이상의 값을 제공해야 하며 최대 500개의 CIDR 블록을 제공할 수 있습니다. 모든 IP 주소에서 연결을 허용하려면 0.0.0.0/0를 사용하세요.

HTTP 메서드 및 URL:

PATCH https://ftp.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/servers/SERVER_ID?updateMask=externalConfig

JSON 요청 본문:

{
  "externalConfig": {
    "allowedCidrBlocks": [
      "CIDR_BLOCK"
    ]
  }
}

요청을 보내려면 다음 옵션 중 하나를 펼칩니다.

응답은 장기 실행 작업을 식별합니다. 서버가 업데이트되는 데 몇 초 정도 걸립니다.

클라이언트 라이브러리

C#

Cloud FTP용 클라이언트 라이브러리를 설치하고 사용하는 방법은 Cloud FTP 클라이언트 라이브러리를 참고하세요. 자세한 내용은 Cloud FTP C# API 참고 문서를 확인하세요.

Cloud FTP에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

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

public sealed partial class GeneratedCloudFtpClientSnippets
{
    /// <summary>Snippet for UpdateServerAsync</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 UpdateServerAsync()
    {
        // Create client
        CloudFtpClient cloudFtpClient = await CloudFtpClient.CreateAsync();
        // Initialize request argument(s)
        Server server = new Server();
        FieldMask updateMask = new FieldMask();
        // Make the request
        Operation<Server, OperationMetadata> response = await cloudFtpClient.UpdateServerAsync(server, updateMask);

        // 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.PollOnceUpdateServerAsync(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

Cloud FTP용 클라이언트 라이브러리를 설치하고 사용하는 방법은 Cloud FTP 클라이언트 라이브러리를 참고하세요. 자세한 내용은 Cloud FTP Go API 참고 문서를 확인하세요.

Cloud FTP에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.


//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.UpdateServerRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/ftp/apiv1/ftppb#UpdateServerRequest.
	}
	op, err := c.UpdateServer(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

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

Java

Cloud FTP용 클라이언트 라이브러리를 설치하고 사용하는 방법은 Cloud FTP 클라이언트 라이브러리를 참고하세요. 자세한 내용은 Cloud FTP Java API 참고 문서를 확인하세요.

Cloud FTP에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

import com.google.api.core.ApiFuture;
import com.google.cloud.ftp.v1.CloudFtpClient;
import com.google.cloud.ftp.v1.Server;
import com.google.cloud.ftp.v1.UpdateServerRequest;
import com.google.longrunning.Operation;
import com.google.protobuf.FieldMask;

public class AsyncUpdateServer {

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

  public static void asyncUpdateServer() 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()) {
      UpdateServerRequest request =
          UpdateServerRequest.newBuilder()
              .setUpdateMask(FieldMask.newBuilder().build())
              .setServer(Server.newBuilder().build())
              .setRequestId("requestId693933066")
              .build();
      ApiFuture<Operation> future = cloudFtpClient.updateServerCallable().futureCall(request);
      // Do something.
      Operation response = future.get();
    }
  }
}

Node.js

Cloud FTP용 클라이언트 라이브러리를 설치하고 사용하는 방법은 Cloud FTP 클라이언트 라이브러리를 참조하세요. 자세한 내용은 Cloud FTP Node.js API 참고 문서를 확인하세요.

Cloud FTP에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

/**
 * 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.
 */
/**
 *  Optional. Field mask is used to specify the fields to be overwritten in the
 *  Server resource by the update.
 *  The fields specified in the update_mask are relative to the resource, not
 *  the full request. A field will be overwritten if it is in the mask. If the
 *  user does not provide a mask then all fields present in the request will be
 *  overwritten.
 */
// const updateMask = {}
/**
 *  Required. The resource being updated
 */
// const server = {}
/**
 *  Optional. An optional request ID to identify requests. Specify a unique
 *  request ID so that if you must retry your request, the server will know to
 *  ignore the request if it has already been completed. The server will
 *  guarantee that for at least 60 minutes since the first request.
 *  For example, consider a situation where you make an initial request and the
 *  request times out. If you make the request again with the same request
 *  ID, the server can check if original operation with the same request ID
 *  was received, and if so, will ignore the second request. This prevents
 *  clients from accidentally creating duplicate commitments.
 *  The request ID must be a valid UUID with the exception that zero UUID is
 *  not supported (00000000-0000-0000-0000-000000000000).
 */
// const requestId = 'abc123'

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

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

async function callUpdateServer() {
  // Construct request
  const request = {
    server,
  };

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

callUpdateServer();

PHP

Cloud FTP용 클라이언트 라이브러리를 설치하고 사용하는 방법은 Cloud FTP 클라이언트 라이브러리를 참조하세요. 자세한 내용은 Cloud FTP PHP API 참고 문서를 확인하세요.

Cloud FTP에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

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\Server\AccessType;
use Google\Cloud\Ftp\V1\UpdateServerRequest;
use Google\Rpc\Status;

/**
 * Updates the parameters of a single Server.
 *
 * @param int $serverAccessType The access type of the Server.
 */
function update_server_sample(int $serverAccessType): void
{
    // Create a client.
    $cloudFtpClient = new CloudFtpClient();

    // Prepare the request message.
    $server = (new Server())
        ->setAccessType($serverAccessType);
    $request = (new UpdateServerRequest())
        ->setServer($server);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $cloudFtpClient->updateServer($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
{
    $serverAccessType = AccessType::ACCESS_TYPE_UNSPECIFIED;

    update_server_sample($serverAccessType);
}

Python

Cloud FTP용 클라이언트 라이브러리를 설치하고 사용하는 방법은 Cloud FTP 클라이언트 라이브러리를 참조하세요. 자세한 내용은 Cloud FTP Python API 참고 문서를 확인하세요.

Cloud FTP에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

# 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_update_server():
    # Create a client
    client = ftp_v1.CloudFtpClient()

    # Initialize request argument(s)
    server = ftp_v1.Server()
    server.access_type = "INTERNAL"

    request = ftp_v1.UpdateServerRequest(
        server=server,
    )

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

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

    response = operation.result()

    # Handle the response
    print(response)

Ruby

Cloud FTP용 클라이언트 라이브러리를 설치하고 사용하는 방법은 Cloud FTP 클라이언트 라이브러리를 참조하세요. 자세한 내용은 Cloud FTP Ruby API 참고 문서를 확인하세요.

Cloud FTP에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

require "google/cloud/ftp/v1"

##
# Snippet for the update_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#update_server.
#
def update_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::UpdateServerRequest.new

  # Call the update_server method.
  result = client.update_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

내부 서버의 액세스 업데이트

gcloud

내부 서버의 액세스 구성을 업데이트하려면 gcloud alpha storage ftp servers update 명령어를 실행합니다. --consumer-accept-list 플래그를 제공하고 원하는 경우 --consumer-reject-list 플래그를 제공합니다.

아래의 명령어 데이터를 사용하기 전에 다음을 바꿉니다.

  • SERVER_ID: 서버 ID입니다.
  • LOCATION_ID: 서버의 위치입니다(예: us-west1).
  • PROJECT_TO_ALLOW: Private Service Connect를 사용하여 서버에 연결할 수 있는 소비자 프로젝트의 프로젝트 ID 또는 번호입니다. 예를 들면 example-allowed-project입니다. 프로젝트를 하나 이상 지정해야 합니다.

    최대 500개의 프로젝트를 허용할 수 있습니다. 쉼표로 구분된 목록으로 여러 프로젝트와 해당 연결 한도를 제공합니다. 예를 들면 --consumer-accept-list=projectA=20,projectB=15입니다.

  • CONNECTION_LIMIT: 소비자 프로젝트에서 만들 수 있는 Private Service Connect 엔드포인트의 최대 개수입니다. 값은 1~250개의 엔드포인트여야 합니다.
  • (선택사항) PROJECT_TO_REJECT: 서버에 연결할 수 없는 소비자 프로젝트의 프로젝트 ID 또는 번호입니다. 예를 들면 example-rejected-project입니다. 이 목록에 있는 프로젝트는 허용되는 프로젝트 목록에 포함되어 있더라도 서버에 액세스할 수 없습니다.

    최대 64개의 프로젝트를 거부할 수 있습니다. 쉼표로 구분된 목록으로 여러 프로젝트를 제공합니다.

    프로젝트를 명시적으로 거부하지 않으려면 --consumer-reject-list 플래그를 생략합니다.

다음 명령어를 실행합니다.

Linux, macOS 또는 Cloud Shell

gcloud alpha storage ftp servers update SERVER_ID --location=LOCATION_ID \
    --consumer-accept-list=PROJECT_TO_ALLOW=CONNECTION_LIMIT \
    --consumer-reject-list=PROJECT_TO_REJECT

Windows(PowerShell)

gcloud alpha storage ftp servers update SERVER_ID --location=LOCATION_ID `
    --consumer-accept-list=PROJECT_TO_ALLOW=CONNECTION_LIMIT `
    --consumer-reject-list=PROJECT_TO_REJECT

Windows(cmd.exe)

gcloud alpha storage ftp servers update SERVER_ID --location=LOCATION_ID ^
    --consumer-accept-list=PROJECT_TO_ALLOW=CONNECTION_LIMIT ^
    --consumer-reject-list=PROJECT_TO_REJECT
서버가 업데이트되는 데 몇 초 정도 걸립니다.

REST

내부 서버의 액세스 구성을 업데이트하려면 servers.patch 메서드를 사용합니다. updateMask 쿼리 매개변수에서 internalConfig 필드를 제공합니다.

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • PROJECT_ID: 서버의 Google Cloud 프로젝트 ID입니다.
  • LOCATION_ID: 서버의 위치입니다(예: us-west1).
  • SERVER_ID: 서버 ID입니다.
  • PROJECT_TO_ALLOW: Private Service Connect를 사용하여 서버에 연결할 수 있는 소비자 프로젝트의 프로젝트 ID 또는 번호입니다. 예를 들면 example-allowed-project입니다. 프로젝트를 하나 이상 지정해야 합니다.

    최대 500개의 프로젝트를 허용할 수 있습니다.

  • CONNECTION_LIMIT: 소비자 프로젝트에서 만들 수 있는 Private Service Connect 엔드포인트의 최대 개수입니다. 값은 1~250개의 엔드포인트여야 합니다.
  • (선택사항) PROJECT_TO_REJECT: 서버에 연결할 수 없는 소비자 프로젝트의 프로젝트 ID 또는 번호입니다. 예를 들면 example-rejected-project입니다. 이 목록에 있는 프로젝트는 허용되는 프로젝트 목록에 포함되어 있더라도 서버에 액세스할 수 없습니다.

    최대 64개의 프로젝트를 거부할 수 있습니다.

    프로젝트를 명시적으로 거부하지 않으려면 consumerRejectList 객체를 생략하세요.

HTTP 메서드 및 URL:

PATCH https://ftp.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/servers/SERVER_ID?updateMask=internalConfig

JSON 요청 본문:

{
  "internalConfig": {
    "consumerAcceptList": [
      {
        "project": "projects/PROJECT_TO_ALLOW",
        "connectionLimit": CONNECTION_LIMIT
      }
    ],
    "consumerRejectList": [
      {
        "project": "projects/PROJECT_TO_REJECT"
      }
    ]
  }
}

요청을 보내려면 다음 옵션 중 하나를 펼칩니다.

응답은 장기 실행 작업을 식별합니다. 서버가 업데이트되는 데 몇 초 정도 걸립니다.

클라이언트 라이브러리

C#

Cloud FTP용 클라이언트 라이브러리를 설치하고 사용하는 방법은 Cloud FTP 클라이언트 라이브러리를 참조하세요. 자세한 내용은 Cloud FTP C# API 참고 문서를 확인하세요.

Cloud FTP에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

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

public sealed partial class GeneratedCloudFtpClientSnippets
{
    /// <summary>Snippet for UpdateServerAsync</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 UpdateServerAsync()
    {
        // Create client
        CloudFtpClient cloudFtpClient = await CloudFtpClient.CreateAsync();
        // Initialize request argument(s)
        Server server = new Server();
        FieldMask updateMask = new FieldMask();
        // Make the request
        Operation<Server, OperationMetadata> response = await cloudFtpClient.UpdateServerAsync(server, updateMask);

        // 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.PollOnceUpdateServerAsync(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

Cloud FTP용 클라이언트 라이브러리를 설치하고 사용하는 방법은 Cloud FTP 클라이언트 라이브러리를 참고하세요. 자세한 내용은 Cloud FTP Go API 참고 문서를 확인하세요.

Cloud FTP에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.


//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.UpdateServerRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/ftp/apiv1/ftppb#UpdateServerRequest.
	}
	op, err := c.UpdateServer(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

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

Java

Cloud FTP용 클라이언트 라이브러리를 설치하고 사용하는 방법은 Cloud FTP 클라이언트 라이브러리를 참고하세요. 자세한 내용은 Cloud FTP Java API 참고 문서를 확인하세요.

Cloud FTP에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

import com.google.api.core.ApiFuture;
import com.google.cloud.ftp.v1.CloudFtpClient;
import com.google.cloud.ftp.v1.Server;
import com.google.cloud.ftp.v1.UpdateServerRequest;
import com.google.longrunning.Operation;
import com.google.protobuf.FieldMask;

public class AsyncUpdateServer {

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

  public static void asyncUpdateServer() 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()) {
      UpdateServerRequest request =
          UpdateServerRequest.newBuilder()
              .setUpdateMask(FieldMask.newBuilder().build())
              .setServer(Server.newBuilder().build())
              .setRequestId("requestId693933066")
              .build();
      ApiFuture<Operation> future = cloudFtpClient.updateServerCallable().futureCall(request);
      // Do something.
      Operation response = future.get();
    }
  }
}

Node.js

Cloud FTP용 클라이언트 라이브러리를 설치하고 사용하는 방법은 Cloud FTP 클라이언트 라이브러리를 참조하세요. 자세한 내용은 Cloud FTP Node.js API 참고 문서를 확인하세요.

Cloud FTP에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

/**
 * 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.
 */
/**
 *  Optional. Field mask is used to specify the fields to be overwritten in the
 *  Server resource by the update.
 *  The fields specified in the update_mask are relative to the resource, not
 *  the full request. A field will be overwritten if it is in the mask. If the
 *  user does not provide a mask then all fields present in the request will be
 *  overwritten.
 */
// const updateMask = {}
/**
 *  Required. The resource being updated
 */
// const server = {}
/**
 *  Optional. An optional request ID to identify requests. Specify a unique
 *  request ID so that if you must retry your request, the server will know to
 *  ignore the request if it has already been completed. The server will
 *  guarantee that for at least 60 minutes since the first request.
 *  For example, consider a situation where you make an initial request and the
 *  request times out. If you make the request again with the same request
 *  ID, the server can check if original operation with the same request ID
 *  was received, and if so, will ignore the second request. This prevents
 *  clients from accidentally creating duplicate commitments.
 *  The request ID must be a valid UUID with the exception that zero UUID is
 *  not supported (00000000-0000-0000-0000-000000000000).
 */
// const requestId = 'abc123'

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

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

async function callUpdateServer() {
  // Construct request
  const request = {
    server,
  };

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

callUpdateServer();

PHP

Cloud FTP용 클라이언트 라이브러리를 설치하고 사용하는 방법은 Cloud FTP 클라이언트 라이브러리를 참고하세요. 자세한 내용은 Cloud FTP PHP API 참고 문서를 확인하세요.

Cloud FTP에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

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\Server\AccessType;
use Google\Cloud\Ftp\V1\UpdateServerRequest;
use Google\Rpc\Status;

/**
 * Updates the parameters of a single Server.
 *
 * @param int $serverAccessType The access type of the Server.
 */
function update_server_sample(int $serverAccessType): void
{
    // Create a client.
    $cloudFtpClient = new CloudFtpClient();

    // Prepare the request message.
    $server = (new Server())
        ->setAccessType($serverAccessType);
    $request = (new UpdateServerRequest())
        ->setServer($server);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $cloudFtpClient->updateServer($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
{
    $serverAccessType = AccessType::ACCESS_TYPE_UNSPECIFIED;

    update_server_sample($serverAccessType);
}

Python

Cloud FTP용 클라이언트 라이브러리를 설치하고 사용하는 방법은 Cloud FTP 클라이언트 라이브러리를 참고하세요. 자세한 내용은 Cloud FTP Python API 참고 문서를 확인하세요.

Cloud FTP에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

# 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_update_server():
    # Create a client
    client = ftp_v1.CloudFtpClient()

    # Initialize request argument(s)
    server = ftp_v1.Server()
    server.access_type = "INTERNAL"

    request = ftp_v1.UpdateServerRequest(
        server=server,
    )

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

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

    response = operation.result()

    # Handle the response
    print(response)

Ruby

Cloud FTP용 클라이언트 라이브러리를 설치하고 사용하는 방법은 Cloud FTP 클라이언트 라이브러리를 참조하세요. 자세한 내용은 Cloud FTP Ruby API 참고 문서를 확인하세요.

Cloud FTP에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

require "google/cloud/ftp/v1"

##
# Snippet for the update_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#update_server.
#
def update_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::UpdateServerRequest.new

  # Call the update_server method.
  result = client.update_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

서버의 표시 이름 업데이트

gcloud

SFTP 서버의 표시 이름과 같은 메타데이터를 업데이트하려면 gcloud alpha storage ftp servers update 명령어를 실행합니다.

아래의 명령어 데이터를 사용하기 전에 다음을 바꿉니다.

  • SERVER_ID: 서버 ID입니다.
  • LOCATION_ID: 서버의 위치입니다(예: us-west1).
  • DISPLAY_NAME: 서버의 표시 이름입니다.

다음 명령어를 실행합니다.

Linux, macOS 또는 Cloud Shell

gcloud alpha storage ftp servers update SERVER_ID --location=LOCATION_ID \
    --display-name="DISPLAY_NAME"

Windows(PowerShell)

gcloud alpha storage ftp servers update SERVER_ID --location=LOCATION_ID `
    --display-name="DISPLAY_NAME"

Windows(cmd.exe)

gcloud alpha storage ftp servers update SERVER_ID --location=LOCATION_ID ^
    --display-name="DISPLAY_NAME"
서버가 업데이트되는 데 몇 초 정도 걸립니다.

REST

SFTP 서버의 표시 이름과 같은 메타데이터를 업데이트하려면 servers.patch 메서드를 사용합니다. updateMask 쿼리 매개변수에서 업데이트할 필드를 쉼표로 구분된 목록으로 제공합니다. 요청 본문에서 설정할 값이 포함된 JSON 객체를 제공합니다.

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • PROJECT_ID: 서버의 Google Cloud 프로젝트 ID입니다.
  • LOCATION_ID: 서버의 위치입니다(예: us-west1).
  • SERVER_ID: 서버 ID입니다.
  • FIELDS_TO_UPDATE: 서버 리소스를 기준으로 업데이트할 필드의 쉼표로 구분된 목록입니다. 예를 들어 표시 이름을 업데이트하려면 쿼리 매개변수 updateMask=displayName를 제공합니다.
  • DISPLAY_NAME: 서버의 표시 이름입니다.

HTTP 메서드 및 URL:

PATCH https://ftp.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/servers/SERVER_ID?updateMask=FIELDS_TO_UPDATE

JSON 요청 본문:

{
  "displayName": "DISPLAY_NAME"
}

요청을 보내려면 다음 옵션 중 하나를 펼칩니다.

응답은 장기 실행 작업을 식별합니다. 서버가 업데이트되는 데 몇 초 정도 걸립니다.