Melihat pemesanan atau permintaan pemesanan untuk masa mendatang


Dokumen ini menjelaskan cara melihat pemesanan atau permintaan pemesanan untuk masa mendatang. Untuk mempelajari lebih lanjut berbagai jenis reservasi, lihat Jenis penyediaan.

Saat melihat pemesanan atau permintaan pemesanan untuk masa mendatang, Anda dapat melakukan hal berikut:

  • Lihat setelan reservasi. Peninjauan ini membantu Anda memverifikasi detail reservasi, memastikan bahwa reservasi tersebut memenuhi kebutuhan Anda, dan merencanakan kapasitas.

  • Menentukan jumlah instance yang dapat digunakan. Pemeriksaan ini membantu Anda menentukan jumlah instance Compute Engine yang dapat menggunakan kapasitas yang dipesan.

Batasan

Anda hanya dapat melihat pemesanan bersama atau permintaan pemesanan untuk masa mendatang bersama di project tempat Anda membuatnya.

Sebelum memulai

  • Jika Anda belum melakukannya, siapkan autentikasi. Autentikasi adalah proses yang digunakan untuk memverifikasi identitas Anda agar dapat mengakses Google Cloud layanan dan API. Untuk menjalankan kode atau contoh dari lingkungan pengembangan lokal, Anda dapat mengautentikasi ke Compute Engine dengan memilih salah satu opsi berikut:

    Select the tab for how you plan to use the samples on this page:

    Console

    When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.

    gcloud

    1. Install the Google Cloud CLI, then initialize it by running the following command:

      gcloud init
    2. Set a default region and zone.
    3. Go

      Untuk menggunakan contoh Go di halaman ini dalam lingkungan pengembangan lokal, instal dan lakukan inisialisasi gcloud CLI, lalu siapkan Kredensial Default Aplikasi dengan kredensial pengguna Anda.

      1. Install the Google Cloud CLI.
      2. To initialize the gcloud CLI, run the following command:

        gcloud init
      3. If you're using a local shell, then create local authentication credentials for your user account:

        gcloud auth application-default login

        You don't need to do this if you're using Cloud Shell.

      Untuk informasi selengkapnya, lihat Set up authentication for a local development environment.

      Java

      Untuk menggunakan contoh Java di halaman ini dalam lingkungan pengembangan lokal, instal dan lakukan inisialisasi gcloud CLI, lalu siapkan Kredensial Default Aplikasi dengan kredensial pengguna Anda.

      1. Install the Google Cloud CLI.
      2. To initialize the gcloud CLI, run the following command:

        gcloud init
      3. If you're using a local shell, then create local authentication credentials for your user account:

        gcloud auth application-default login

        You don't need to do this if you're using Cloud Shell.

      Untuk informasi selengkapnya, lihat Set up authentication for a local development environment.

      Node.js

      Untuk menggunakan contoh Node.js di halaman ini dalam lingkungan pengembangan lokal, instal dan lakukan inisialisasi gcloud CLI, lalu siapkan Kredensial Default Aplikasi dengan kredensial pengguna Anda.

      1. Install the Google Cloud CLI.
      2. To initialize the gcloud CLI, run the following command:

        gcloud init
      3. If you're using a local shell, then create local authentication credentials for your user account:

        gcloud auth application-default login

        You don't need to do this if you're using Cloud Shell.

      Untuk informasi selengkapnya, lihat Set up authentication for a local development environment.

      Python

      Untuk menggunakan contoh Python di halaman ini dalam lingkungan pengembangan lokal, instal dan lakukan inisialisasi gcloud CLI, lalu siapkan Kredensial Default Aplikasi dengan kredensial pengguna Anda.

      1. Install the Google Cloud CLI.
      2. To initialize the gcloud CLI, run the following command:

        gcloud init
      3. If you're using a local shell, then create local authentication credentials for your user account:

        gcloud auth application-default login

        You don't need to do this if you're using Cloud Shell.

      Untuk informasi selengkapnya, lihat Set up authentication for a local development environment.

      REST

      Untuk menggunakan contoh REST API di halaman ini dalam lingkungan pengembangan lokal, gunakan kredensial yang Anda berikan ke gcloud CLI.

        Install the Google Cloud CLI, then initialize it by running the following command:

        gcloud init

      Untuk informasi selengkapnya, lihat Mengautentikasi untuk menggunakan REST dalam Google Cloud dokumentasi autentikasi.

Peran yang diperlukan

Untuk mendapatkan izin yang diperlukan guna melihat pemesanan atau permintaan pemesanan untuk masa mendatang, minta administrator untuk memberi Anda peran IAM Compute Admin (roles/compute.admin) pada project. Untuk mengetahui informasi selengkapnya tentang cara memberikan peran, lihat Mengelola akses ke project, folder, dan organisasi.

Peran yang telah ditentukan ini berisi izin yang diperlukan untuk melihat pemesanan atau permintaan pemesanan untuk masa mendatang. Untuk melihat izin yang benar-benar diperlukan, luaskan bagian Izin yang diperlukan:

Izin yang diperlukan

Izin berikut diperlukan untuk melihat pemesanan atau permintaan pemesanan untuk masa mendatang:

  • Untuk melihat daftar pemesanan: compute.reservations.list pada project
  • Untuk melihat daftar permintaan pemesanan untuk masa mendatang: compute.futureReservations.list pada project
  • Untuk melihat detail pemesanan: compute.reservations.get pada project
  • Untuk melihat detail permintaan pemesanan untuk masa mendatang: compute.futureReservations.get pada project

Anda mungkin juga bisa mendapatkan izin ini dengan peran khusus atau peran bawaan lainnya.

Melihat setelan reservasi

Bagian berikut menjelaskan cara melihat setelan pemesanan atau permintaan pemesanan mendatang.

Melihat pemesanan

Untuk melihat setelan satu atau beberapa reservasi, gunakan salah satu metode berikut yang dijelaskan di bagian ini:

  • Untuk melihat ringkasan semua reservasi dalam project, lihat daftar pemesanan Anda.

  • Untuk melihat detail lengkap satu pemesanan, lihat detail pemesanan.

Untuk melihat kolom deleteAtTime dan reservationSharingPolicy (Pratinjau) dalam pemesanan, lihat detail pemesanan menggunakan Google Cloud CLI, atau lihat pemesanan menggunakan REST API. Jika Anda tidak memerlukan kolom ini, lihat pemesanan dengan memilih salah satu opsi berikut:

Konsol

  1. Di Konsol Google Cloud, buka halaman Pemesanan.

    Buka Pemesanan

    Di tab Pemesanan on demand (default), tabel mencantumkan setiap pemesanan, dan setiap kolom tabel menjelaskan properti.

  2. Opsional: Untuk menyaring daftar pemesanan, di kolom Filter , pilih properti yang ingin Anda gunakan untuk memfilter pemesanan.

  3. Untuk melihat detail pemesanan, di kolom Name, klik nama pemesanan.

    Halaman yang memberikan detail pemesanan akan terbuka.

gcloud

  • Untuk melihat daftar pemesanan, gunakan perintah gcloud compute reservations list:

    gcloud compute reservations list
    

    Outputnya mirip dengan contoh berikut:

    NAME: r-01
    IN_USE_COUNT: 0
    COUNT: 5
    ZONE: us-central1-a
    SHARE_TYPE: LOCAL
    
    NAME: r-02
    IN_USE_COUNT: 3
    COUNT: 10
    ZONE: us-central1-f
    SHARE_TYPE: LOCAL
    

    Atau, untuk menyaring daftar pemesanan menggunakan ekspresi filter, sertakan flag --filter:

    gcloud compute reservations list \
        --filter="FILTER_EXPRESSION"
    

    Ganti FILTER_EXPRESSION dengan ekspresi filter.

  • Untuk melihat detail pemesanan, gunakan perintah gcloud compute reservations describe:

    gcloud compute reservations describe RESERVATION_NAME \
        --zone=ZONE
    

    Ganti kode berikut:

    • RESERVATION_NAME: nama pemesanan yang ada.

    • ZONE: zona tempat pemesanan berada.

    Outputnya mirip dengan contoh berikut:

    creationTimestamp: '2024-10-11T03:25:23.192-07:00'
    id: '4488228526648280060'
    kind: compute#reservation
    name: r-01
    selfLink: https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-a/reservations/r-01
    shareSettings:
      shareType: LOCAL
    specificReservation:
      assuredCount: '50'
      count: '50'
      inUseCount: '25'
      instanceProperties:
        machineType: n2-standard-2
    specificReservationRequired: false
    status: READY
    zone: https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-a
    

Go

  • Untuk melihat daftar pemesanan, gunakan contoh kode berikut:

    // Copyright 2024 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.
    
    package snippets
    
    import (
    	"context"
    	"fmt"
    	"io"
    
    	compute "cloud.google.com/go/compute/apiv1"
    	computepb "cloud.google.com/go/compute/apiv1/computepb"
    	"google.golang.org/api/iterator"
    )
    
    // Get list of reservations for given project in particular zone
    func listReservations(w io.Writer, projectID, zone string) error {
    	// projectID := "your_project_id"
    	// zone := "us-west3-a"
    
    	ctx := context.Background()
    	reservationsClient, err := compute.NewReservationsRESTClient(ctx)
    	if err != nil {
    		return err
    	}
    	defer reservationsClient.Close()
    
    	req := &computepb.ListReservationsRequest{
    		Project: projectID,
    		Zone:    zone,
    	}
    
    	it := reservationsClient.List(ctx, req)
    	fmt.Fprintf(w, "Instances found in zone %s:\n", zone)
    	for {
    		instance, err := it.Next()
    		if err == iterator.Done {
    			break
    		}
    		if err != nil {
    			return err
    		}
    		fmt.Fprintf(w, "- %s %d\n", instance.GetName(), instance.GetSpecificReservation().GetCount())
    	}
    
    	return nil
    }
    
    
  • Untuk melihat detail pemesanan, gunakan contoh kode berikut:

    // Copyright 2024 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.
    
    package snippets
    
    import (
    	"context"
    	"fmt"
    	"io"
    
    	compute "cloud.google.com/go/compute/apiv1"
    	computepb "cloud.google.com/go/compute/apiv1/computepb"
    )
    
    // Get certain reservation for given project and zone
    func getReservation(w io.Writer, projectID, zone, reservationName string) (*computepb.Reservation, error) {
    	// projectID := "your_project_id"
    	// zone := "us-west3-a"
    	// reservationName := "your_reservation_name"
    
    	ctx := context.Background()
    	reservationsClient, err := compute.NewReservationsRESTClient(ctx)
    	if err != nil {
    		return nil, err
    	}
    	defer reservationsClient.Close()
    
    	req := &computepb.GetReservationRequest{
    		Project:     projectID,
    		Reservation: reservationName,
    		Zone:        zone,
    	}
    
    	reservation, err := reservationsClient.Get(ctx, req)
    	if err != nil {
    		return nil, fmt.Errorf("unable to delete reservation: %w", err)
    	}
    
    	fmt.Fprintf(w, "Reservation: %s\n", reservation.GetName())
    
    	return reservation, nil
    }
    
    

Java

  • Untuk melihat daftar pemesanan, gunakan contoh kode berikut:

    /*
     * Copyright 2024 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
     *
     *   http://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.
     */
    
    package compute.reservation;
    
    import com.google.cloud.compute.v1.Reservation;
    import com.google.cloud.compute.v1.ReservationsClient;
    import java.io.IOException;
    import java.util.ArrayList;
    import java.util.List;
    
    public class ListReservations {
    
      public static void main(String[] args) throws IOException {
        // TODO(developer): Replace these variables before running the sample.
        // Project ID or project number of the Cloud project you want to use.
        String project = "YOUR_PROJECT_ID";
        // Zone in which reservations are located.
        String zone = "us-central1-a";
    
        listReservations(project, zone);
      }
    
      // List all reservations in the given project and zone.
      public static List<Reservation> listReservations(String project, String zone) throws IOException {
        // Initialize client that will be used to send requests. This client only needs to be created
        // once, and can be reused for multiple requests.
        List<Reservation> listOfReservations = new ArrayList<>();
    
        try (ReservationsClient reservationsClient = ReservationsClient.create()) {
          for (Reservation reservation : reservationsClient.list(project, zone).iterateAll()) {
            listOfReservations.add(reservation);
            System.out.println("Reservation: " + reservation.getName());
          }
        }
        return listOfReservations;
      }
    }
  • Untuk melihat detail pemesanan, gunakan contoh kode berikut:

    /*
     * Copyright 2024 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
     *
     * http://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.
     */
    
    package compute.reservation;
    
    import com.google.cloud.compute.v1.Reservation;
    import com.google.cloud.compute.v1.ReservationsClient;
    import java.io.IOException;
    import java.util.concurrent.ExecutionException;
    import java.util.concurrent.TimeoutException;
    
    public class GetReservation {
    
      public static void main(String[] args)
          throws IOException, ExecutionException, InterruptedException, TimeoutException {
        // TODO(developer): Replace these variables before running the sample.
        // Project ID or project number of the Cloud project you want to use.
        String projectId = "YOUR_PROJECT_ID";
        // Name of the zone in which you want to create the reservation.
        String zone = "us-central1-a";
        // Name of the reservation you want to create.
        String reservationName = "test-reservation-name";
    
        getReservation(projectId, reservationName, zone);
      }
    
      // Retrieve a reservation with the given name in the given zone.
      public static Reservation getReservation(
          String projectId, String reservationName, String zone)
          throws IOException {
        // Initialize client that will be used to send requests. This client only needs to be created
        // once, and can be reused for multiple requests.
        try (ReservationsClient reservationsClient = ReservationsClient.create()) {
    
          // Get the reservation.
          Reservation reservation = reservationsClient.get(projectId, zone, reservationName);
    
          System.out.println("Reservation: " + reservation.getName());
          return reservation;
        }
      }
    }

Node.js

  • Untuk melihat daftar pemesanan, gunakan contoh kode berikut:

    /*
     * Copyright 2024 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.
     */
    
    'use strict';
    
    async function main() {
      // Import the Compute library
      const computeLib = require('@google-cloud/compute');
    
      // Instantiate a reservationsClient
      const reservationsClient = new computeLib.ReservationsClient();
    
      /**
       * TODO(developer): Update these variables before running the sample.
       */
      // The ID of the project where your reservations are located.
      const projectId = await reservationsClient.getProjectId();
      // The zone where your reservations are located.
      const zone = 'us-central1-a';
    
      async function callGetReservations() {
        const reservations = (
          await reservationsClient.list({
            project: projectId,
            zone,
          })
        )[0];
    
        console.log(JSON.stringify(reservations));
      }
    
      await callGetReservations();
    }
    
    main().catch(err => {
      console.error(err);
      process.exitCode = 1;
    });
    
  • Untuk melihat detail pemesanan, gunakan contoh kode berikut:

    /*
     * Copyright 2024 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.
     */
    
    'use strict';
    
    async function main(reservationName) {
      // Import the Compute library
      const computeLib = require('@google-cloud/compute');
    
      // Instantiate a reservationsClient
      const reservationsClient = new computeLib.ReservationsClient();
    
      /**
       * TODO(developer): Update/uncomment these variables before running the sample.
       */
      // The ID of the project where your reservation is located.
      const projectId = await reservationsClient.getProjectId();
      // The zone where your reservation is located.
      const zone = 'us-central1-a';
      // The name of the reservation to return.
      // reservationName = 'reservation-01';
    
      async function callGetReservation() {
        const requestedReservation = (
          await reservationsClient.get({
            project: projectId,
            zone,
            reservation: reservationName,
          })
        )[0];
    
        console.log(JSON.stringify(requestedReservation));
      }
    
      await callGetReservation();
    }
    
    main(...process.argv.slice(2)).catch(err => {
      console.error(err);
      process.exitCode = 1;
    });
    

Python

  • Untuk melihat daftar reservasi, gunakan contoh kode berikut:

    # Copyright 2024 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.
    
    
    # This file is automatically generated. Please do not modify it directly.
    # Find the relevant recipe file in the samples/recipes or samples/ingredients
    # directory and apply your changes there.
    
    
    from google.cloud import compute_v1
    from google.cloud.compute_v1.services.reservations.pagers import ListPager
    
    
    def list_compute_reservation(project_id: str, zone: str = "us-central1-a") -> ListPager:
        """
        Lists all compute reservations in a specified Google Cloud project and zone.
        Args:
            project_id (str): The ID of the Google Cloud project.
            zone (str): The zone of the reservations.
        Returns:
            ListPager: A pager object containing the list of reservations.
        """
    
        client = compute_v1.ReservationsClient()
    
        reservations_list = client.list(
            project=project_id,
            zone=zone,
        )
    
        for reservation in reservations_list:
            print("Name: ", reservation.name)
            print(
                "Machine type: ",
                reservation.specific_reservation.instance_properties.machine_type,
            )
        # Example response:
        # Name:  my-reservation_1
        # Machine type:  n1-standard-1
        # Name:  my-reservation_2
        # Machine type:  n1-standard-1
    
        return reservations_list
    
    
    
  • Untuk melihat detail pemesanan, gunakan contoh kode berikut:

    # Copyright 2024 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.
    
    
    # This file is automatically generated. Please do not modify it directly.
    # Find the relevant recipe file in the samples/recipes or samples/ingredients
    # directory and apply your changes there.
    
    
    from google.cloud import compute_v1
    from google.cloud.compute_v1.types import compute
    
    
    def get_compute_reservation(
        project_id: str,
        zone: str = "us-central1-a",
        reservation_name="your-reservation-name",
    ) -> compute.Reservation:
        """
        Retrieves a compute reservation from GCP.
        Args:
            project_id (str): The ID of the Google Cloud project.
            zone (str): The zone of the reservation.
            reservation_name (str): The name of the reservation to retrieve.
        Returns:
            compute.Reservation: The reservation object retrieved from Google Cloud.
        """
    
        client = compute_v1.ReservationsClient()
    
        reservation = client.get(
            project=project_id,
            zone=zone,
            reservation=reservation_name,
        )
    
        print("Name: ", reservation.name)
        print("STATUS: ", reservation.status)
        print(reservation.specific_reservation)
        # Example response:
        # Name:  your-reservation-name
        # STATUS:  READY
        # count: 3
        # instance_properties {
        #   machine_type: "n1-standard-1"
        #   local_ssds {
        #     disk_size_gb: 375
        #     interface: "NVME"
        #   }
        # ...
    
        return reservation
    
    
    

REST

  • Untuk melihat daftar pemesanan Anda, buat permintaan GET ke metode reservations.list:

    GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/reservations
    

    Ganti kode berikut:

    • PROJECT_ID: ID project tempat Anda membuat pemesanan.

    • ZONE: zona tempat pemesanan Anda berada.

    Outputnya mirip dengan contoh berikut:

    {
      "kind": "compute#reservation",
      "id": "4100668622331754141",
      "creationTimestamp": "2019-09-27T08:21:14.707-07:00",
      "selfLink": "https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-a/reservations/reservation-05",
      "zone": "https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-a",
      "name": "reservation-05",
      "specificReservation": {
        "instanceProperties": {
          "machineType": "n1-standard-2"
        },
        "count": "100",
        "inUseCount": "0",
        "assuredCount": "100"
      },
      "specificReservationRequired": false,
      "status": "READY",
      "shareSettings": {
        "shareType": "LOCAL"
      }
    },
    {
      "kind": "compute#reservation",
      "id": "2533514314332214789",
      "creationTimestamp": "2019-09-27T08:21:14.707-07:00",
      "selfLink": "https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-a/reservations/reservation-04",
      "zone": "https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-a",
      "name": "reservation-04",
      "specificReservation": {
        "instanceProperties": {
          "machineType": "n1-standard-2",
          "guestAccelerators": [
            {
              "acceleratorType": "nvidia-tesla-t4",
              "acceleratorCount": 1
            }
          ],
          "localSsds": [
            {
              "diskSizeGb": "375",
              "interface": "SCSI"
            }
          ]
        },
        "count": "50",
        "inUseCount": "25",
        "assuredCount": "50"
      },
      "specificReservationRequired": false,
      "status": "READY",
      "shareSettings": {
        "shareType": "LOCAL"
      }
    }
    

    Atau, untuk menyaring daftar pemesanan menggunakan ekspresi filter, sertakan parameter kueri filter:

    GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/reservations?filter=FILTER_EXPRESSION
    

    Ganti FILTER_EXPRESSION dengan ekspresi filter yang menggunakan nilai yang dienkode URL.

  • Untuk melihat detail pemesanan, buat permintaan GET ke metode reservations.get.

    GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/reservations/RESERVATION_NAME
    

    Ganti kode berikut:

    • PROJECT_ID: ID project tempat Anda membuat pemesanan.

    • ZONE: zona tempat pemesanan berada.

    • RESERVATION_NAME: nama pemesanan yang ada.

    Outputnya mirip dengan contoh berikut:

    {
      "kind": "compute#reservation",
      "id": "4488228526648280060",
      "creationTimestamp": "2024-10-11T03:25:23.192-07:00",
      "selfLink": "https://www.googleapis.com/compute/v1/projects/davide-experimental/zones/us-central1-a/reservations/r-01",
      "zone": "https://www.googleapis.com/compute/v1/projects/davide-experimental/zones/us-central1-a",
      "name": "r-01",
      "specificReservation": {
        "instanceProperties": {
          "machineType": "n2-standard-2"
        },
        "count": "50",
        "inUseCount": "25",
        "assuredCount": "50"
      },
      "specificReservationRequired": false,
      "status": "READY",
      "shareSettings": {
        "shareType": "LOCAL"
      }
    }
    

Melihat permintaan pemesanan untuk masa mendatang

Untuk melihat setelan satu atau beberapa permintaan pemesanan untuk masa mendatang, gunakan salah satu metode berikut yang dijelaskan di bagian ini:

  • Untuk melihat ringkasan semua permintaan pemesanan untuk masa mendatang dalam project Anda, lihat daftar permintaan Anda.

  • Untuk melihat detail lengkap dari satu permintaan pemesanan untuk masa mendatang, lihat detail permintaan.

Untuk melihat permintaan pemesanan untuk masa mendatang, pilih salah satu opsi berikut:

Konsol

  1. Di Konsol Google Cloud, buka halaman Pemesanan.

    Buka Reservations

  2. Klik tab Future reservations.

    Tabel mencantumkan setiap permintaan pemesanan untuk masa mendatang, dan setiap kolom tabel menjelaskan properti.

  3. Opsional: Untuk menyaring daftar permintaan, di kolom Filter , pilih properti yang ingin Anda gunakan untuk memfilter permintaan.

  4. Untuk melihat detail permintaan, di kolom Name, klik nama permintaan.

    Halaman yang berisi detail permintaan pemesanan untuk masa mendatang akan terbuka.

gcloud

  • Untuk melihat daftar permintaan pemesanan untuk masa mendatang, gunakan perintah gcloud beta compute future-reservations list:

    gcloud beta compute future-reservations list
    

    Outputnya mirip dengan contoh berikut:

    NAME: fr-04
    TOTAL_COUNT: 100
    START_TIME: 2025-07-20T07:00:00Z
    END_TIME: 2025-08-05T07:00:00Z
    PROCUREMENT_STATUS: FULFILLED
    ZONE: us-east1-a
    
    NAME: fr-05
    TOTAL_COUNT: 10
    START_TIME: 2025-07-20T07:00:00Z
    END_TIME: 2025-12-01T00:00:00Z
    PROCUREMENT_STATUS: PENDING_APPROVAL
    ZONE: us-west1-c
    

    Atau, untuk menyaring daftar permintaan pemesanan untuk masa mendatang menggunakan ekspresi filter, sertakan flag --filter:

    gcloud beta compute future-reservations list \
        --filter="FILTER_EXPRESSION"
    

    Ganti FILTER_EXPRESSION dengan ekspresi filter.

  • Untuk melihat detail permintaan pemesanan untuk masa mendatang, gunakan perintah gcloud beta compute future-reservations describe:

    gcloud beta compute future-reservations describe FUTURE_RESERVATION_NAME \
        --zone=ZONE
    

    Ganti kode berikut:

    • FUTURE_RESERVATION_NAME: nama permintaan pemesanan untuk masa mendatang yang ada.

    • ZONE: zona tempat permintaan pemesanan untuk masa mendatang berada.

    Outputnya mirip dengan contoh berikut:

    autoCreatedReservationsDeleteTime: '2025-05-02T01:00:00Z'
    creationTimestamp: '2025-03-23T10:08:31.613-07:00'
    id: '5212276518668495076'
    kind: compute#futureReservation
    name: fr-01
    planningStatus: SUBMITTED
    selfLink: https://www.googleapis.com/compute/beta/projects/example-project/zones/us-central1-a/futureReservations/fr-01
    selfLinkWithId: https://www.googleapis.com/compute/beta/projects/example-project/zones/us-central1-a/futureReservations/5212276518668495076
    shareSettings:
      shareType: LOCAL
    specificSkuProperties:
      instanceProperties:
        machineType: n1-standard-64
      totalCount: '800'
    status:
      existingMatchingUsageInfo:
        count: '3'
        timestamp: '2025-03-30T01:00:00Z'
      lockTime: '2025-03-30T17:09:59.297799Z'
      procurementStatus: APPROVED
    timeWindow:
      endTime: '2025-05-02T01:00:00Z'
      startTime: '2025-04-30T17:30:00Z'
    zone: https://www.googleapis.com/compute/beta/projects/example-project/zones/us-central1-a
    

REST

  • Untuk melihat daftar permintaan pemesanan untuk masa mendatang, buat permintaan GET ke metode futureReservations.list beta:

    GET https://compute.googleapis.com/compute/beta/projects/PROJECT_ID/zones/ZONE/futureReservations
    

    Ganti kode berikut:

    • PROJECT_ID: ID project tempat Anda membuat permintaan pemesanan untuk masa mendatang.

    • ZONE: zona tempat permintaan pemesanan untuk masa mendatang berada.

    Outputnya mirip dengan contoh berikut:

    {
      "id": "projects/my-project/zones/us-east1-a/futureReservations",
      "items": [
        {
          "id": "743865190848184978",
          "creationTimestamp": "2025-03-23T18:16:45.274-07:00",
          "selfLink": "https://www.googleapis.com/compute/beta/projects/my-project/zones/us-east1-a/futureReservations/fr-base",
          "selfLinkWithId": "https://www.googleapis.com/compute/beta/projects/my-project/zones/us-east1-a/futureReservations/743865190848184978",
          "zone": "https://www.googleapis.com/compute/beta/projects/my-project/zones/us-east1-a",
          "name": "fr-base",
          "specificSkuProperties": {
            "instanceProperties": {
              "machineType": "n1-standard-1"
            },
            "totalCount": "100"
          },
          "planningStatus": "SUBMITTED",
          "timeWindow": {
            "endTime": "2025-05-02T01:00:00Z",
            "startTime": "2025-04-30T17:30:00Z"
          },
          "status": {
            "procurementStatus": "FULFILLED",
            "lockTime": "2025-03-30T07:00:00Z",
            "existingMatchingUsageInfo": {
              "count": "3",
              "timestamp": "2025-03-30T01:00:00Z"
            }
          },
          "kind": "compute#futureReservation"
        },
        ...
      ],
      "selfLink": "https://www.googleapis.com/compute/beta/projects/my-project/zones/us-east1-a/futureReservations",
      "etag": "AnzKY34l-cvvV-JnniESJ0dtQvQ=/hvc4jaHpxFAZmOt1FVtKNgzZu-M=",
      "kind": "compute#futureReservationsListResponse"
    }
    

    Atau, untuk menyaring daftar permintaan pemesanan untuk masa mendatang menggunakan ekspresi filter, sertakan parameter kueri filter:

    GET https://compute.googleapis.com/compute/beta/projects/PROJECT_ID/aggregated/futureReservations?filter=FILTER_EXPRESSION
    

    Ganti FILTER_EXPRESSION dengan ekspresi filter yang menggunakan nilai yang dienkode URL.

  • Untuk melihat detail permintaan pemesanan untuk masa mendatang, buat permintaan GET ke metode futureReservations.get beta:

    GET https://compute.googleapis.com/compute/beta/projects/PROJECT_ID/zones/ZONE/futureReservations/FUTURE_RESERVATION_NAME
    

    Ganti kode berikut:

    • PROJECT_ID: ID project tempat Anda membuat permintaan pemesanan untuk masa mendatang.

    • ZONE: zona tempat permintaan pemesanan untuk masa mendatang berada.

    • FUTURE_RESERVATION_NAME: nama permintaan pemesanan untuk masa mendatang yang ada.

    Outputnya mirip dengan hal berikut ini:

    {
      "autoCreatedReservationsDeleteTime": "2025-05-02T01:00:00Z",
      "creationTimestamp": "2025-03-23T10:08:31.613-07:00",
      "id": "5212276518668495076",
      "kind": "compute#futureReservation",
      "name": "fr-01",
      "planningStatus": "SUBMITTED",
      "selfLink": "https://www.googleapis.com/compute/beta/projects/example-project/zones/us-central1-a/futureReservations/fr-01",
      "selfLinkWithId": "https://www.googleapis.com/compute/beta/projects/example-project/zones/us-central1-a/futureReservations/5212276518668495076",
      "shareSettings": {
        "shareType": "LOCAL"
      },
      "specificSkuProperties": {
        "instanceProperties": {
          "machineType": "n1-standard-64"
        },
        "totalCount": "800"
      },
      "status": {
        "lockTime": "2025-03-30T17:09:59.297799Z",
        "procurementStatus": "APPROVED",
        "existingMatchingUsageInfo": {
          "count": "3",
          "timestamp": "2025-03-30T01:00:00Z"
        }
      },
      "timeWindow": {
        "endTime": "2025-05-02T01:00:00Z",
        "startTime": "2025-04-30T17:30:00Z"
      },
      "zone": "https://www.googleapis.com/compute/beta/projects/example-project/zones/us-central1-a"
    }
    

Menentukan jumlah instance habis pakai

Untuk menentukan jumlah instance komputasi yang dapat menggunakan kapasitas yang direservasi, lakukan salah satu hal berikut:

Instance yang dapat digunakan dalam reservasi

Saat melihat detail pemesanan, Anda dapat melihat jumlah instance komputasi yang menggunakan pemesanan, dan jumlah instance yang dapat menggunakannya, dengan memeriksa kolom berikut:

  • Jumlah terjamin (assuredCount): jumlah instance yang direservasi di zona reservasi untuk project Anda, dan untuk project apa pun yang menggunakan reservasi bersama.

  • Total jumlah (count): jumlah instance yang dicadangkan yang ditentukan dalam pemesanan. Jumlah ini harus cocok dengan jumlah yang dijamin.

  • Komputer yang digunakan (inUseCount): jumlah instance yang berjalan di project Anda, atau project tempat pemesanan bersama dibagikan, yang menggunakan pemesanan.

Misalnya, jika jumlah terjamin (assuredCount) dan jumlah total (count) adalah 50, dan jumlah instance yang menggunakan reservasi (inUseCount) adalah 25, maka 25 instance lainnya dapat menggunakan reservasi sebelum sepenuhnya digunakan.

Instance yang dapat digunakan dalam permintaan reservasi untuk masa mendatang

Anda dapat menentukan jumlah instance komputasi yang akan dibuat pemesanannya oleh Compute Engine pada waktu mulai permintaan pemesanan untuk masa mendatang. Untuk draf, permintaan yang menunggu persetujuan, atau permintaan yang disetujui, Anda dapat menentukan nomor ini sebagai berikut:

  1. Lihat jumlah instance yang berjalan dan reservasi yang tidak digunakan di project Anda, dan di project mana pun yang dapat menggunakan permintaan, cocokkan properti permintaan.

  2. Kurangi jumlah instance yang sedang berjalan dan pemesanan yang tidak digunakan yang cocok dari jumlah total dalam permintaan.

Anda dapat menentukan jumlah instance yang dapat digunakan untuk satu atau beberapa permintaan sekaligus. Untuk beberapa permintaan, gunakan konsol Google Cloud atau REST API. Untuk permintaan tunggal, pilih salah satu opsi berikut:

Konsol

  1. Di Konsol Google Cloud, buka halaman Pemesanan.

    Buka Reservations

  2. Klik tab Future reservations.

    Tabel mencantumkan setiap permintaan pemesanan untuk masa mendatang, dan setiap kolom tabel mendeskripsikan properti.

  3. Untuk menentukan jumlah instance yang direncanakan Compute Engine untuk direservasi untuk permintaan pada waktu mulainya, kurangi kolom Jumlah yang cocok dari kolom Jumlah total.

    Kolom Jumlah pencocokan menampilkan salah satu peringatan berikut:

    • Jumlah pencocokan nol: tidak ada instance yang sedang berjalan atau pemesanan yang tidak digunakan yang cocok di project Anda, atau di project mana pun yang dibagikan dengan permintaan Anda.

    • Jumlah yang cocok sama dengan Total jumlah: Compute Engine tidak akan mencadangkan instance apa pun untuk permintaan Anda pada waktu mulainya.

    Jika Anda mengubah permintaan, atau membuat instance atau pemesanan baru yang cocok dengan permintaan, Compute Engine akan memperbarui kolom Jumlah yang cocok dalam waktu 30 menit.

  4. Opsional: Untuk memeriksa kapan kolom Jumlah pencocokan terakhir diperbarui dalam permintaan, lakukan tindakan berikut:

    1. Di kolom Name, klik nama permintaan.

      Halaman yang berisi detail permintaan pemesanan untuk masa mendatang akan terbuka.

    2. Di bagian Detail resource, periksa kolom Last matching usage evaluation time.

gcloud

  1. Untuk melihat detail permintaan pemesanan untuk masa mendatang, gunakan perintah gcloud beta compute future-reservations describe:

    gcloud beta compute future-reservations describe FUTURE_RESERVATION_NAME \
        --zone=ZONE
    

    Ganti kode berikut:

    • FUTURE_RESERVATION_NAME: nama permintaan pemesanan untuk masa mendatang yang ada.

    • ZONE: zona tempat permintaan pemesanan untuk masa mendatang berada.

    Dalam output, temukan kolom count dan totalCount:

    ...
    specificSkuProperties:
      ...
      totalCount: '100'
    status:
      existingMatchingUsageInfo:
        count: '50'
        timestamp: '2025-03-30T01:00:00Z'
      ...
      procurementStatus: DRAFTING
    ...
    
  2. Kurangi nilai count dari totalCount. Misalnya, jika count adalah 50 dan totalCount adalah 100, Compute Engine akan otomatis membuat pemesanan untuk 50 instance pada waktu mulai permintaan.

    Jika Anda mengubah permintaan, atau membuat instance atau reservasi baru yang cocok dengan permintaan, Compute Engine akan memperbarui kolom existingMatchingUsageInfo dalam waktu 30 menit. Untuk memverifikasi kapan kolom ini terakhir diperbarui, periksa nilai existingMatchingUsageInfo.timestamp.

REST

  1. Untuk melihat daftar permintaan pemesanan untuk masa mendatang, buat permintaan GET ke metode futureReservations.list beta. Di URL permintaan, sertakan parameter kueri filter dan tentukan untuk hanya menampilkan kolom name, specificSkuProperties, dan status:

    GET https://compute.googleapis.com/compute/beta/projects/PROJECT_ID/zones/ZONE/futureReservations?fields=items.name,items.specificSkuProperties,items.status
    

    Ganti kode berikut:

    • PROJECT_ID: ID project tempat Anda membuat permintaan pemesanan untuk masa mendatang.

    • ZONE: zona tempat permintaan pemesanan untuk masa mendatang berada.

    Pada output, temukan kolom count dan totalCount untuk setiap draf, permintaan yang menunggu persetujuan, atau permintaan yang disetujui:

    {
      "items": [
        {
          "specificSkuProperties": {
            ...
            totalCount: "100"
          },
          "name": "fr-01",
          "status": {
            "procurementStatus": "APPROVED",
            ...
            existingMatchingUsageInfo: {
              count: "50",
              "timestamp": "2025-01-22T07:54:26.295Z"
            }
          }
        },
        {
          "specificSkuProperties": {
            ...
            totalCount: "20"
          },
          "name": "fr-02",
          "status": {
            "procurementStatus": "DRAFTING",
            ...
            existingMatchingUsageInfo: {
              "count": "2",
              "timestamp": "2025-01-22T07:54:26.295Z"
            }
          }
        }
      ]
    }
    
  2. Untuk setiap permintaan, kurangi nilai count dari totalCount. Misalnya, jika count adalah 50 dan totalCount adalah 100, maka Compute Engine akan otomatis membuat reservasi untuk 50 instance pada waktu mulai permintaan.

    Jika Anda mengubah permintaan, atau membuat instance atau reservasi baru yang cocok dengan permintaan, Compute Engine akan memperbarui kolom existingMatchingUsageInfo dalam waktu 30 menit. Untuk memverifikasi kapan kolom ini terakhir diperbarui, periksa nilai existingMatchingUsageInfo.timestamp.

Langkah berikutnya