Cloud Quotas 클라이언트 라이브러리

이 페이지에서는 Cloud Quotas API용 Cloud 클라이언트 라이브러리를 시작하는 방법을 보여줍니다. 클라이언트 라이브러리를 사용하면 지원되는 언어로 Google Cloud API에 쉽게 액세스할 수 있습니다. 원시 요청을 서버에 보내 Google Cloud API를 직접 사용할 수 있지만 클라이언트 라이브러리는 작성해야 하는 코드 양을 크게 줄여 주는 간소화 기능을 제공합니다.

클라이언트 라이브러리 설명에서 Cloud 클라이언트 라이브러리 및 이전 Google API 클라이언트 라이브러리에 대해 자세히 알아보세요.

클라이언트 라이브러리 설치

C++

이 클라이언트 라이브러리의 요구사항 및 설치 종속 항목에 대한 자세한 내용은 C++ 개발 환경 설정을 참조하세요.

C#

NuGet에서 Google.Cloud.CloudQuotas.V1 패키지를 설치합니다. 일반적인 방법으로 프로젝트에 추가합니다(예: Visual Studio에서 프로젝트를 마우스 오른쪽 버튼으로 클릭하고 'Manage NuGet Packages...'(NuGet 패키지 관리) 선택). 출시 전 패키지를 사용 설정해야 합니다(예: Visual Studio NuGet 사용자 인터페이스에서 'Include prerelease(출시 전 출시 포함)' 상자 선택). 다음 샘플 중 일부는 최신 출시 전 버전 (1.0.0-beta01) Google.Cloud.CloudQuotas.V1에서만 작동할 수 있습니다.

자세한 내용은 C# 개발 환경 설정을 참조하세요.

Go

go get cloud.google.com/go/cloudquotas

자세한 내용은 Go 개발 환경 설정을 참조하세요.

Java

If you are using Maven, add the following to your pom.xml file. For more information about BOMs, see The Google Cloud Platform Libraries BOM.

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>com.google.cloud</groupId>
      <artifactId>libraries-bom</artifactId>
      <version>26.38.0</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
  </dependencies>
</dependencyManagement>

<dependencies>
  <dependency>
    <groupId>com.google.cloud</groupId>
    <artifactId>google-cloud-cloudquotas</artifactId>
  </dependency>

If you are using Gradle, add the following to your dependencies:

implementation 'com.google.cloud:google-cloud-cloudquotas:0.11.0'

If you are using sbt, add the following to your dependencies:

libraryDependencies += "com.google.cloud" % "google-cloud-cloudquotas" % "0.11.0"

자세한 내용은 자바 개발 환경 설정을 참조하세요.

Node.js

npm install @google-cloud/cloudquotas

자세한 내용은 Node.js 개발 환경 설정을 참조하세요.

PHP

composer require google/cloud

자세한 내용은 Google Cloud에서 PHP 사용을 참조하세요.

Python

pip install google-cloud-quotas

자세한 내용은 Python 개발 환경 설정을 참조하세요.

Ruby

gem install google-cloud-cloud_quotas

자세한 내용은 Ruby 개발 환경 설정을 참조하세요.

인증 설정

Google Cloud API 호출을 인증하기 위해 클라이언트 라이브러리는 애플리케이션 기본 사용자 인증 정보(ADC)를 지원합니다. 라이브러리가 정의된 위치 집합에서 사용자 인증 정보를 찾고 이러한 사용자 인증 정보를 사용하여 API에 대한 요청을 인증합니다. ADC를 사용하면 애플리케이션 코드를 수정할 필요 없이 로컬 개발 또는 프로덕션과 같은 다양한 환경에서 애플리케이션에 사용자 인증 정보를 제공할 수 있습니다.

프로덕션 환경에서 ADC를 설정하는 방법은 서비스와 컨텍스트에 따라 다릅니다. 자세한 내용은 애플리케이션 기본 사용자 인증 정보 설정을 참조하세요.

로컬 개발 환경의 경우 Google 계정과 연결된 사용자 인증 정보를 사용하여 ADC를 설정할 수 있습니다.

  1. gcloud CLI를 설치하고 초기화합니다.

    gcloud CLI를 초기화할 때 애플리케이션에 필요한 리소스에 액세스할 수 있는 권한이 있는 Google Cloud 프로젝트를 지정해야 합니다.

  2. 사용자 인증 정보 파일을 만듭니다.

    gcloud auth application-default login

    로그인 화면이 표시됩니다. 로그인 후 사용자 인증 정보는 ADC에 사용하는 로컬 사용자 인증 정보 파일에 저장됩니다.

클라이언트 라이브러리 사용

다음 예시에서는 클라이언트 라이브러리를 사용하는 방법을 보여줍니다.

C++

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

//! [all]
#include "google/cloud/cloudquotas/v1/cloud_quotas_client.h"
#include "google/cloud/location.h"
#include <iostream>
#include <string>

int main(int argc, char* argv[]) try {
  if (argc != 2) {
    std::cerr << "Usage: " << argv[0] << " project-id\n";
    return 1;
  }

  namespace cloudquotas = ::google::cloud::cloudquotas_v1;
  auto client =
      cloudquotas::CloudQuotasClient(cloudquotas::MakeCloudQuotasConnection());

  auto const parent = google::cloud::Location(argv[1], "global").FullName();
  for (auto r : client.ListQuotaPreferences(parent)) {
    if (!r) throw std::move(r).status();
    std::cout << r->DebugString() << "\n";
  }

  return 0;
} catch (google::cloud::Status const& status) {
  std::cerr << "google::cloud::Status thrown: " << status << "\n";
  return 1;
}
//! [all]

C#

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

// Generated code. DO NOT EDIT!

namespace GoogleCSharpSnippets
{
    using Google.Api.Gax;
    using Google.Cloud.CloudQuotas.V1;
    using Google.Protobuf.WellKnownTypes;
    using System;
    using System.Linq;
    using System.Threading.Tasks;

    /// <summary>Generated snippets.</summary>
    public sealed class AllGeneratedCloudQuotasClientSnippets
    {
        /// <summary>Snippet for ListQuotaInfos</summary>
        public void ListQuotaInfosRequestObject()
        {
            // Snippet: ListQuotaInfos(ListQuotaInfosRequest, CallSettings)
            // Create client
            CloudQuotasClient cloudQuotasClient = CloudQuotasClient.Create();
            // Initialize request argument(s)
            ListQuotaInfosRequest request = new ListQuotaInfosRequest
            {
                ParentAsServiceName = ServiceName.FromProjectLocationService("[PROJECT]", "[LOCATION]", "[SERVICE]"),
            };
            // Make the request
            PagedEnumerable<ListQuotaInfosResponse, QuotaInfo> response = cloudQuotasClient.ListQuotaInfos(request);

            // Iterate over all response items, lazily performing RPCs as required
            foreach (QuotaInfo item in response)
            {
                // Do something with each item
                Console.WriteLine(item);
            }

            // Or iterate over pages (of server-defined size), performing one RPC per page
            foreach (ListQuotaInfosResponse page in response.AsRawResponses())
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (QuotaInfo item in page)
                {
                    // Do something with each item
                    Console.WriteLine(item);
                }
            }

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int pageSize = 10;
            Page<QuotaInfo> singlePage = response.ReadPage(pageSize);
            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (QuotaInfo item in singlePage)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
            // End snippet
        }

        /// <summary>Snippet for ListQuotaInfosAsync</summary>
        public async Task ListQuotaInfosRequestObjectAsync()
        {
            // Snippet: ListQuotaInfosAsync(ListQuotaInfosRequest, CallSettings)
            // Create client
            CloudQuotasClient cloudQuotasClient = await CloudQuotasClient.CreateAsync();
            // Initialize request argument(s)
            ListQuotaInfosRequest request = new ListQuotaInfosRequest
            {
                ParentAsServiceName = ServiceName.FromProjectLocationService("[PROJECT]", "[LOCATION]", "[SERVICE]"),
            };
            // Make the request
            PagedAsyncEnumerable<ListQuotaInfosResponse, QuotaInfo> response = cloudQuotasClient.ListQuotaInfosAsync(request);

            // Iterate over all response items, lazily performing RPCs as required
            await response.ForEachAsync((QuotaInfo item) =>
            {
                // Do something with each item
                Console.WriteLine(item);
            });

            // Or iterate over pages (of server-defined size), performing one RPC per page
            await response.AsRawResponses().ForEachAsync((ListQuotaInfosResponse page) =>
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (QuotaInfo item in page)
                {
                    // Do something with each item
                    Console.WriteLine(item);
                }
            });

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int pageSize = 10;
            Page<QuotaInfo> singlePage = await response.ReadPageAsync(pageSize);
            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (QuotaInfo item in singlePage)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
            // End snippet
        }

        /// <summary>Snippet for ListQuotaInfos</summary>
        public void ListQuotaInfos()
        {
            // Snippet: ListQuotaInfos(string, string, int?, CallSettings)
            // Create client
            CloudQuotasClient cloudQuotasClient = CloudQuotasClient.Create();
            // Initialize request argument(s)
            string parent = "projects/[PROJECT]/locations/[LOCATION]/services/[SERVICE]";
            // Make the request
            PagedEnumerable<ListQuotaInfosResponse, QuotaInfo> response = cloudQuotasClient.ListQuotaInfos(parent);

            // Iterate over all response items, lazily performing RPCs as required
            foreach (QuotaInfo item in response)
            {
                // Do something with each item
                Console.WriteLine(item);
            }

            // Or iterate over pages (of server-defined size), performing one RPC per page
            foreach (ListQuotaInfosResponse page in response.AsRawResponses())
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (QuotaInfo item in page)
                {
                    // Do something with each item
                    Console.WriteLine(item);
                }
            }

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int pageSize = 10;
            Page<QuotaInfo> singlePage = response.ReadPage(pageSize);
            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (QuotaInfo item in singlePage)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
            // End snippet
        }

        /// <summary>Snippet for ListQuotaInfosAsync</summary>
        public async Task ListQuotaInfosAsync()
        {
            // Snippet: ListQuotaInfosAsync(string, string, int?, CallSettings)
            // Create client
            CloudQuotasClient cloudQuotasClient = await CloudQuotasClient.CreateAsync();
            // Initialize request argument(s)
            string parent = "projects/[PROJECT]/locations/[LOCATION]/services/[SERVICE]";
            // Make the request
            PagedAsyncEnumerable<ListQuotaInfosResponse, QuotaInfo> response = cloudQuotasClient.ListQuotaInfosAsync(parent);

            // Iterate over all response items, lazily performing RPCs as required
            await response.ForEachAsync((QuotaInfo item) =>
            {
                // Do something with each item
                Console.WriteLine(item);
            });

            // Or iterate over pages (of server-defined size), performing one RPC per page
            await response.AsRawResponses().ForEachAsync((ListQuotaInfosResponse page) =>
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (QuotaInfo item in page)
                {
                    // Do something with each item
                    Console.WriteLine(item);
                }
            });

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int pageSize = 10;
            Page<QuotaInfo> singlePage = await response.ReadPageAsync(pageSize);
            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (QuotaInfo item in singlePage)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
            // End snippet
        }

        /// <summary>Snippet for ListQuotaInfos</summary>
        public void ListQuotaInfosResourceNames()
        {
            // Snippet: ListQuotaInfos(ServiceName, string, int?, CallSettings)
            // Create client
            CloudQuotasClient cloudQuotasClient = CloudQuotasClient.Create();
            // Initialize request argument(s)
            ServiceName parent = ServiceName.FromProjectLocationService("[PROJECT]", "[LOCATION]", "[SERVICE]");
            // Make the request
            PagedEnumerable<ListQuotaInfosResponse, QuotaInfo> response = cloudQuotasClient.ListQuotaInfos(parent);

            // Iterate over all response items, lazily performing RPCs as required
            foreach (QuotaInfo item in response)
            {
                // Do something with each item
                Console.WriteLine(item);
            }

            // Or iterate over pages (of server-defined size), performing one RPC per page
            foreach (ListQuotaInfosResponse page in response.AsRawResponses())
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (QuotaInfo item in page)
                {
                    // Do something with each item
                    Console.WriteLine(item);
                }
            }

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int pageSize = 10;
            Page<QuotaInfo> singlePage = response.ReadPage(pageSize);
            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (QuotaInfo item in singlePage)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
            // End snippet
        }

        /// <summary>Snippet for ListQuotaInfosAsync</summary>
        public async Task ListQuotaInfosResourceNamesAsync()
        {
            // Snippet: ListQuotaInfosAsync(ServiceName, string, int?, CallSettings)
            // Create client
            CloudQuotasClient cloudQuotasClient = await CloudQuotasClient.CreateAsync();
            // Initialize request argument(s)
            ServiceName parent = ServiceName.FromProjectLocationService("[PROJECT]", "[LOCATION]", "[SERVICE]");
            // Make the request
            PagedAsyncEnumerable<ListQuotaInfosResponse, QuotaInfo> response = cloudQuotasClient.ListQuotaInfosAsync(parent);

            // Iterate over all response items, lazily performing RPCs as required
            await response.ForEachAsync((QuotaInfo item) =>
            {
                // Do something with each item
                Console.WriteLine(item);
            });

            // Or iterate over pages (of server-defined size), performing one RPC per page
            await response.AsRawResponses().ForEachAsync((ListQuotaInfosResponse page) =>
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (QuotaInfo item in page)
                {
                    // Do something with each item
                    Console.WriteLine(item);
                }
            });

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int pageSize = 10;
            Page<QuotaInfo> singlePage = await response.ReadPageAsync(pageSize);
            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (QuotaInfo item in singlePage)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
            // End snippet
        }

        /// <summary>Snippet for GetQuotaInfo</summary>
        public void GetQuotaInfoRequestObject()
        {
            // Snippet: GetQuotaInfo(GetQuotaInfoRequest, CallSettings)
            // Create client
            CloudQuotasClient cloudQuotasClient = CloudQuotasClient.Create();
            // Initialize request argument(s)
            GetQuotaInfoRequest request = new GetQuotaInfoRequest
            {
                QuotaInfoName = QuotaInfoName.FromProjectLocationServiceQuotaInfo("[PROJECT]", "[LOCATION]", "[SERVICE]", "[QUOTA_INFO]"),
            };
            // Make the request
            QuotaInfo response = cloudQuotasClient.GetQuotaInfo(request);
            // End snippet
        }

        /// <summary>Snippet for GetQuotaInfoAsync</summary>
        public async Task GetQuotaInfoRequestObjectAsync()
        {
            // Snippet: GetQuotaInfoAsync(GetQuotaInfoRequest, CallSettings)
            // Additional: GetQuotaInfoAsync(GetQuotaInfoRequest, CancellationToken)
            // Create client
            CloudQuotasClient cloudQuotasClient = await CloudQuotasClient.CreateAsync();
            // Initialize request argument(s)
            GetQuotaInfoRequest request = new GetQuotaInfoRequest
            {
                QuotaInfoName = QuotaInfoName.FromProjectLocationServiceQuotaInfo("[PROJECT]", "[LOCATION]", "[SERVICE]", "[QUOTA_INFO]"),
            };
            // Make the request
            QuotaInfo response = await cloudQuotasClient.GetQuotaInfoAsync(request);
            // End snippet
        }

        /// <summary>Snippet for GetQuotaInfo</summary>
        public void GetQuotaInfo()
        {
            // Snippet: GetQuotaInfo(string, CallSettings)
            // Create client
            CloudQuotasClient cloudQuotasClient = CloudQuotasClient.Create();
            // Initialize request argument(s)
            string name = "projects/[PROJECT]/locations/[LOCATION]/services/[SERVICE]/quotaInfos/[QUOTA_INFO]";
            // Make the request
            QuotaInfo response = cloudQuotasClient.GetQuotaInfo(name);
            // End snippet
        }

        /// <summary>Snippet for GetQuotaInfoAsync</summary>
        public async Task GetQuotaInfoAsync()
        {
            // Snippet: GetQuotaInfoAsync(string, CallSettings)
            // Additional: GetQuotaInfoAsync(string, CancellationToken)
            // Create client
            CloudQuotasClient cloudQuotasClient = await CloudQuotasClient.CreateAsync();
            // Initialize request argument(s)
            string name = "projects/[PROJECT]/locations/[LOCATION]/services/[SERVICE]/quotaInfos/[QUOTA_INFO]";
            // Make the request
            QuotaInfo response = await cloudQuotasClient.GetQuotaInfoAsync(name);
            // End snippet
        }

        /// <summary>Snippet for GetQuotaInfo</summary>
        public void GetQuotaInfoResourceNames()
        {
            // Snippet: GetQuotaInfo(QuotaInfoName, CallSettings)
            // Create client
            CloudQuotasClient cloudQuotasClient = CloudQuotasClient.Create();
            // Initialize request argument(s)
            QuotaInfoName name = QuotaInfoName.FromProjectLocationServiceQuotaInfo("[PROJECT]", "[LOCATION]", "[SERVICE]", "[QUOTA_INFO]");
            // Make the request
            QuotaInfo response = cloudQuotasClient.GetQuotaInfo(name);
            // End snippet
        }

        /// <summary>Snippet for GetQuotaInfoAsync</summary>
        public async Task GetQuotaInfoResourceNamesAsync()
        {
            // Snippet: GetQuotaInfoAsync(QuotaInfoName, CallSettings)
            // Additional: GetQuotaInfoAsync(QuotaInfoName, CancellationToken)
            // Create client
            CloudQuotasClient cloudQuotasClient = await CloudQuotasClient.CreateAsync();
            // Initialize request argument(s)
            QuotaInfoName name = QuotaInfoName.FromProjectLocationServiceQuotaInfo("[PROJECT]", "[LOCATION]", "[SERVICE]", "[QUOTA_INFO]");
            // Make the request
            QuotaInfo response = await cloudQuotasClient.GetQuotaInfoAsync(name);
            // End snippet
        }

        /// <summary>Snippet for ListQuotaPreferences</summary>
        public void ListQuotaPreferencesRequestObject()
        {
            // Snippet: ListQuotaPreferences(ListQuotaPreferencesRequest, CallSettings)
            // Create client
            CloudQuotasClient cloudQuotasClient = CloudQuotasClient.Create();
            // Initialize request argument(s)
            ListQuotaPreferencesRequest request = new ListQuotaPreferencesRequest
            {
                ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
                Filter = "",
                OrderBy = "",
            };
            // Make the request
            PagedEnumerable<ListQuotaPreferencesResponse, QuotaPreference> response = cloudQuotasClient.ListQuotaPreferences(request);

            // Iterate over all response items, lazily performing RPCs as required
            foreach (QuotaPreference item in response)
            {
                // Do something with each item
                Console.WriteLine(item);
            }

            // Or iterate over pages (of server-defined size), performing one RPC per page
            foreach (ListQuotaPreferencesResponse page in response.AsRawResponses())
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (QuotaPreference item in page)
                {
                    // Do something with each item
                    Console.WriteLine(item);
                }
            }

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int pageSize = 10;
            Page<QuotaPreference> singlePage = response.ReadPage(pageSize);
            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (QuotaPreference item in singlePage)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
            // End snippet
        }

        /// <summary>Snippet for ListQuotaPreferencesAsync</summary>
        public async Task ListQuotaPreferencesRequestObjectAsync()
        {
            // Snippet: ListQuotaPreferencesAsync(ListQuotaPreferencesRequest, CallSettings)
            // Create client
            CloudQuotasClient cloudQuotasClient = await CloudQuotasClient.CreateAsync();
            // Initialize request argument(s)
            ListQuotaPreferencesRequest request = new ListQuotaPreferencesRequest
            {
                ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
                Filter = "",
                OrderBy = "",
            };
            // Make the request
            PagedAsyncEnumerable<ListQuotaPreferencesResponse, QuotaPreference> response = cloudQuotasClient.ListQuotaPreferencesAsync(request);

            // Iterate over all response items, lazily performing RPCs as required
            await response.ForEachAsync((QuotaPreference item) =>
            {
                // Do something with each item
                Console.WriteLine(item);
            });

            // Or iterate over pages (of server-defined size), performing one RPC per page
            await response.AsRawResponses().ForEachAsync((ListQuotaPreferencesResponse page) =>
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (QuotaPreference item in page)
                {
                    // Do something with each item
                    Console.WriteLine(item);
                }
            });

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int pageSize = 10;
            Page<QuotaPreference> singlePage = await response.ReadPageAsync(pageSize);
            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (QuotaPreference item in singlePage)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
            // End snippet
        }

        /// <summary>Snippet for ListQuotaPreferences</summary>
        public void ListQuotaPreferences()
        {
            // Snippet: ListQuotaPreferences(string, string, int?, CallSettings)
            // Create client
            CloudQuotasClient cloudQuotasClient = CloudQuotasClient.Create();
            // Initialize request argument(s)
            string parent = "projects/[PROJECT]/locations/[LOCATION]";
            // Make the request
            PagedEnumerable<ListQuotaPreferencesResponse, QuotaPreference> response = cloudQuotasClient.ListQuotaPreferences(parent);

            // Iterate over all response items, lazily performing RPCs as required
            foreach (QuotaPreference item in response)
            {
                // Do something with each item
                Console.WriteLine(item);
            }

            // Or iterate over pages (of server-defined size), performing one RPC per page
            foreach (ListQuotaPreferencesResponse page in response.AsRawResponses())
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (QuotaPreference item in page)
                {
                    // Do something with each item
                    Console.WriteLine(item);
                }
            }

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int pageSize = 10;
            Page<QuotaPreference> singlePage = response.ReadPage(pageSize);
            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (QuotaPreference item in singlePage)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
            // End snippet
        }

        /// <summary>Snippet for ListQuotaPreferencesAsync</summary>
        public async Task ListQuotaPreferencesAsync()
        {
            // Snippet: ListQuotaPreferencesAsync(string, string, int?, CallSettings)
            // Create client
            CloudQuotasClient cloudQuotasClient = await CloudQuotasClient.CreateAsync();
            // Initialize request argument(s)
            string parent = "projects/[PROJECT]/locations/[LOCATION]";
            // Make the request
            PagedAsyncEnumerable<ListQuotaPreferencesResponse, QuotaPreference> response = cloudQuotasClient.ListQuotaPreferencesAsync(parent);

            // Iterate over all response items, lazily performing RPCs as required
            await response.ForEachAsync((QuotaPreference item) =>
            {
                // Do something with each item
                Console.WriteLine(item);
            });

            // Or iterate over pages (of server-defined size), performing one RPC per page
            await response.AsRawResponses().ForEachAsync((ListQuotaPreferencesResponse page) =>
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (QuotaPreference item in page)
                {
                    // Do something with each item
                    Console.WriteLine(item);
                }
            });

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int pageSize = 10;
            Page<QuotaPreference> singlePage = await response.ReadPageAsync(pageSize);
            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (QuotaPreference item in singlePage)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
            // End snippet
        }

        /// <summary>Snippet for ListQuotaPreferences</summary>
        public void ListQuotaPreferencesResourceNames()
        {
            // Snippet: ListQuotaPreferences(LocationName, string, int?, CallSettings)
            // Create client
            CloudQuotasClient cloudQuotasClient = CloudQuotasClient.Create();
            // Initialize request argument(s)
            LocationName parent = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]");
            // Make the request
            PagedEnumerable<ListQuotaPreferencesResponse, QuotaPreference> response = cloudQuotasClient.ListQuotaPreferences(parent);

            // Iterate over all response items, lazily performing RPCs as required
            foreach (QuotaPreference item in response)
            {
                // Do something with each item
                Console.WriteLine(item);
            }

            // Or iterate over pages (of server-defined size), performing one RPC per page
            foreach (ListQuotaPreferencesResponse page in response.AsRawResponses())
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (QuotaPreference item in page)
                {
                    // Do something with each item
                    Console.WriteLine(item);
                }
            }

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int pageSize = 10;
            Page<QuotaPreference> singlePage = response.ReadPage(pageSize);
            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (QuotaPreference item in singlePage)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
            // End snippet
        }

        /// <summary>Snippet for ListQuotaPreferencesAsync</summary>
        public async Task ListQuotaPreferencesResourceNamesAsync()
        {
            // Snippet: ListQuotaPreferencesAsync(LocationName, string, int?, CallSettings)
            // Create client
            CloudQuotasClient cloudQuotasClient = await CloudQuotasClient.CreateAsync();
            // Initialize request argument(s)
            LocationName parent = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]");
            // Make the request
            PagedAsyncEnumerable<ListQuotaPreferencesResponse, QuotaPreference> response = cloudQuotasClient.ListQuotaPreferencesAsync(parent);

            // Iterate over all response items, lazily performing RPCs as required
            await response.ForEachAsync((QuotaPreference item) =>
            {
                // Do something with each item
                Console.WriteLine(item);
            });

            // Or iterate over pages (of server-defined size), performing one RPC per page
            await response.AsRawResponses().ForEachAsync((ListQuotaPreferencesResponse page) =>
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (QuotaPreference item in page)
                {
                    // Do something with each item
                    Console.WriteLine(item);
                }
            });

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int pageSize = 10;
            Page<QuotaPreference> singlePage = await response.ReadPageAsync(pageSize);
            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (QuotaPreference item in singlePage)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
            // End snippet
        }

        /// <summary>Snippet for GetQuotaPreference</summary>
        public void GetQuotaPreferenceRequestObject()
        {
            // Snippet: GetQuotaPreference(GetQuotaPreferenceRequest, CallSettings)
            // Create client
            CloudQuotasClient cloudQuotasClient = CloudQuotasClient.Create();
            // Initialize request argument(s)
            GetQuotaPreferenceRequest request = new GetQuotaPreferenceRequest
            {
                QuotaPreferenceName = QuotaPreferenceName.FromProjectLocationQuotaPreference("[PROJECT]", "[LOCATION]", "[QUOTA_PREFERENCE]"),
            };
            // Make the request
            QuotaPreference response = cloudQuotasClient.GetQuotaPreference(request);
            // End snippet
        }

        /// <summary>Snippet for GetQuotaPreferenceAsync</summary>
        public async Task GetQuotaPreferenceRequestObjectAsync()
        {
            // Snippet: GetQuotaPreferenceAsync(GetQuotaPreferenceRequest, CallSettings)
            // Additional: GetQuotaPreferenceAsync(GetQuotaPreferenceRequest, CancellationToken)
            // Create client
            CloudQuotasClient cloudQuotasClient = await CloudQuotasClient.CreateAsync();
            // Initialize request argument(s)
            GetQuotaPreferenceRequest request = new GetQuotaPreferenceRequest
            {
                QuotaPreferenceName = QuotaPreferenceName.FromProjectLocationQuotaPreference("[PROJECT]", "[LOCATION]", "[QUOTA_PREFERENCE]"),
            };
            // Make the request
            QuotaPreference response = await cloudQuotasClient.GetQuotaPreferenceAsync(request);
            // End snippet
        }

        /// <summary>Snippet for GetQuotaPreference</summary>
        public void GetQuotaPreference()
        {
            // Snippet: GetQuotaPreference(string, CallSettings)
            // Create client
            CloudQuotasClient cloudQuotasClient = CloudQuotasClient.Create();
            // Initialize request argument(s)
            string name = "projects/[PROJECT]/locations/[LOCATION]/quotaPreferences/[QUOTA_PREFERENCE]";
            // Make the request
            QuotaPreference response = cloudQuotasClient.GetQuotaPreference(name);
            // End snippet
        }

        /// <summary>Snippet for GetQuotaPreferenceAsync</summary>
        public async Task GetQuotaPreferenceAsync()
        {
            // Snippet: GetQuotaPreferenceAsync(string, CallSettings)
            // Additional: GetQuotaPreferenceAsync(string, CancellationToken)
            // Create client
            CloudQuotasClient cloudQuotasClient = await CloudQuotasClient.CreateAsync();
            // Initialize request argument(s)
            string name = "projects/[PROJECT]/locations/[LOCATION]/quotaPreferences/[QUOTA_PREFERENCE]";
            // Make the request
            QuotaPreference response = await cloudQuotasClient.GetQuotaPreferenceAsync(name);
            // End snippet
        }

        /// <summary>Snippet for GetQuotaPreference</summary>
        public void GetQuotaPreferenceResourceNames()
        {
            // Snippet: GetQuotaPreference(QuotaPreferenceName, CallSettings)
            // Create client
            CloudQuotasClient cloudQuotasClient = CloudQuotasClient.Create();
            // Initialize request argument(s)
            QuotaPreferenceName name = QuotaPreferenceName.FromProjectLocationQuotaPreference("[PROJECT]", "[LOCATION]", "[QUOTA_PREFERENCE]");
            // Make the request
            QuotaPreference response = cloudQuotasClient.GetQuotaPreference(name);
            // End snippet
        }

        /// <summary>Snippet for GetQuotaPreferenceAsync</summary>
        public async Task GetQuotaPreferenceResourceNamesAsync()
        {
            // Snippet: GetQuotaPreferenceAsync(QuotaPreferenceName, CallSettings)
            // Additional: GetQuotaPreferenceAsync(QuotaPreferenceName, CancellationToken)
            // Create client
            CloudQuotasClient cloudQuotasClient = await CloudQuotasClient.CreateAsync();
            // Initialize request argument(s)
            QuotaPreferenceName name = QuotaPreferenceName.FromProjectLocationQuotaPreference("[PROJECT]", "[LOCATION]", "[QUOTA_PREFERENCE]");
            // Make the request
            QuotaPreference response = await cloudQuotasClient.GetQuotaPreferenceAsync(name);
            // End snippet
        }

        /// <summary>Snippet for CreateQuotaPreference</summary>
        public void CreateQuotaPreferenceRequestObject()
        {
            // Snippet: CreateQuotaPreference(CreateQuotaPreferenceRequest, CallSettings)
            // Create client
            CloudQuotasClient cloudQuotasClient = CloudQuotasClient.Create();
            // Initialize request argument(s)
            CreateQuotaPreferenceRequest request = new CreateQuotaPreferenceRequest
            {
                ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
                QuotaPreferenceId = "",
                QuotaPreference = new QuotaPreference(),
                IgnoreSafetyChecks =
                {
                    QuotaSafetyCheck.Unspecified,
                },
            };
            // Make the request
            QuotaPreference response = cloudQuotasClient.CreateQuotaPreference(request);
            // End snippet
        }

        /// <summary>Snippet for CreateQuotaPreferenceAsync</summary>
        public async Task CreateQuotaPreferenceRequestObjectAsync()
        {
            // Snippet: CreateQuotaPreferenceAsync(CreateQuotaPreferenceRequest, CallSettings)
            // Additional: CreateQuotaPreferenceAsync(CreateQuotaPreferenceRequest, CancellationToken)
            // Create client
            CloudQuotasClient cloudQuotasClient = await CloudQuotasClient.CreateAsync();
            // Initialize request argument(s)
            CreateQuotaPreferenceRequest request = new CreateQuotaPreferenceRequest
            {
                ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
                QuotaPreferenceId = "",
                QuotaPreference = new QuotaPreference(),
                IgnoreSafetyChecks =
                {
                    QuotaSafetyCheck.Unspecified,
                },
            };
            // Make the request
            QuotaPreference response = await cloudQuotasClient.CreateQuotaPreferenceAsync(request);
            // End snippet
        }

        /// <summary>Snippet for CreateQuotaPreference</summary>
        public void CreateQuotaPreference1()
        {
            // Snippet: CreateQuotaPreference(string, QuotaPreference, string, CallSettings)
            // Create client
            CloudQuotasClient cloudQuotasClient = CloudQuotasClient.Create();
            // Initialize request argument(s)
            string parent = "projects/[PROJECT]/locations/[LOCATION]";
            QuotaPreference quotaPreference = new QuotaPreference();
            string quotaPreferenceId = "";
            // Make the request
            QuotaPreference response = cloudQuotasClient.CreateQuotaPreference(parent, quotaPreference, quotaPreferenceId);
            // End snippet
        }

        /// <summary>Snippet for CreateQuotaPreferenceAsync</summary>
        public async Task CreateQuotaPreference1Async()
        {
            // Snippet: CreateQuotaPreferenceAsync(string, QuotaPreference, string, CallSettings)
            // Additional: CreateQuotaPreferenceAsync(string, QuotaPreference, string, CancellationToken)
            // Create client
            CloudQuotasClient cloudQuotasClient = await CloudQuotasClient.CreateAsync();
            // Initialize request argument(s)
            string parent = "projects/[PROJECT]/locations/[LOCATION]";
            QuotaPreference quotaPreference = new QuotaPreference();
            string quotaPreferenceId = "";
            // Make the request
            QuotaPreference response = await cloudQuotasClient.CreateQuotaPreferenceAsync(parent, quotaPreference, quotaPreferenceId);
            // End snippet
        }

        /// <summary>Snippet for CreateQuotaPreference</summary>
        public void CreateQuotaPreference1ResourceNames()
        {
            // Snippet: CreateQuotaPreference(LocationName, QuotaPreference, string, CallSettings)
            // Create client
            CloudQuotasClient cloudQuotasClient = CloudQuotasClient.Create();
            // Initialize request argument(s)
            LocationName parent = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]");
            QuotaPreference quotaPreference = new QuotaPreference();
            string quotaPreferenceId = "";
            // Make the request
            QuotaPreference response = cloudQuotasClient.CreateQuotaPreference(parent, quotaPreference, quotaPreferenceId);
            // End snippet
        }

        /// <summary>Snippet for CreateQuotaPreferenceAsync</summary>
        public async Task CreateQuotaPreference1ResourceNamesAsync()
        {
            // Snippet: CreateQuotaPreferenceAsync(LocationName, QuotaPreference, string, CallSettings)
            // Additional: CreateQuotaPreferenceAsync(LocationName, QuotaPreference, string, CancellationToken)
            // Create client
            CloudQuotasClient cloudQuotasClient = await CloudQuotasClient.CreateAsync();
            // Initialize request argument(s)
            LocationName parent = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]");
            QuotaPreference quotaPreference = new QuotaPreference();
            string quotaPreferenceId = "";
            // Make the request
            QuotaPreference response = await cloudQuotasClient.CreateQuotaPreferenceAsync(parent, quotaPreference, quotaPreferenceId);
            // End snippet
        }

        /// <summary>Snippet for CreateQuotaPreference</summary>
        public void CreateQuotaPreference2()
        {
            // Snippet: CreateQuotaPreference(string, QuotaPreference, CallSettings)
            // Create client
            CloudQuotasClient cloudQuotasClient = CloudQuotasClient.Create();
            // Initialize request argument(s)
            string parent = "projects/[PROJECT]/locations/[LOCATION]";
            QuotaPreference quotaPreference = new QuotaPreference();
            // Make the request
            QuotaPreference response = cloudQuotasClient.CreateQuotaPreference(parent, quotaPreference);
            // End snippet
        }

        /// <summary>Snippet for CreateQuotaPreferenceAsync</summary>
        public async Task CreateQuotaPreference2Async()
        {
            // Snippet: CreateQuotaPreferenceAsync(string, QuotaPreference, CallSettings)
            // Additional: CreateQuotaPreferenceAsync(string, QuotaPreference, CancellationToken)
            // Create client
            CloudQuotasClient cloudQuotasClient = await CloudQuotasClient.CreateAsync();
            // Initialize request argument(s)
            string parent = "projects/[PROJECT]/locations/[LOCATION]";
            QuotaPreference quotaPreference = new QuotaPreference();
            // Make the request
            QuotaPreference response = await cloudQuotasClient.CreateQuotaPreferenceAsync(parent, quotaPreference);
            // End snippet
        }

        /// <summary>Snippet for CreateQuotaPreference</summary>
        public void CreateQuotaPreference2ResourceNames()
        {
            // Snippet: CreateQuotaPreference(LocationName, QuotaPreference, CallSettings)
            // Create client
            CloudQuotasClient cloudQuotasClient = CloudQuotasClient.Create();
            // Initialize request argument(s)
            LocationName parent = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]");
            QuotaPreference quotaPreference = new QuotaPreference();
            // Make the request
            QuotaPreference response = cloudQuotasClient.CreateQuotaPreference(parent, quotaPreference);
            // End snippet
        }

        /// <summary>Snippet for CreateQuotaPreferenceAsync</summary>
        public async Task CreateQuotaPreference2ResourceNamesAsync()
        {
            // Snippet: CreateQuotaPreferenceAsync(LocationName, QuotaPreference, CallSettings)
            // Additional: CreateQuotaPreferenceAsync(LocationName, QuotaPreference, CancellationToken)
            // Create client
            CloudQuotasClient cloudQuotasClient = await CloudQuotasClient.CreateAsync();
            // Initialize request argument(s)
            LocationName parent = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]");
            QuotaPreference quotaPreference = new QuotaPreference();
            // Make the request
            QuotaPreference response = await cloudQuotasClient.CreateQuotaPreferenceAsync(parent, quotaPreference);
            // End snippet
        }

        /// <summary>Snippet for UpdateQuotaPreference</summary>
        public void UpdateQuotaPreferenceRequestObject()
        {
            // Snippet: UpdateQuotaPreference(UpdateQuotaPreferenceRequest, CallSettings)
            // Create client
            CloudQuotasClient cloudQuotasClient = CloudQuotasClient.Create();
            // Initialize request argument(s)
            UpdateQuotaPreferenceRequest request = new UpdateQuotaPreferenceRequest
            {
                UpdateMask = new FieldMask(),
                QuotaPreference = new QuotaPreference(),
                AllowMissing = false,
                ValidateOnly = false,
                IgnoreSafetyChecks =
                {
                    QuotaSafetyCheck.Unspecified,
                },
            };
            // Make the request
            QuotaPreference response = cloudQuotasClient.UpdateQuotaPreference(request);
            // End snippet
        }

        /// <summary>Snippet for UpdateQuotaPreferenceAsync</summary>
        public async Task UpdateQuotaPreferenceRequestObjectAsync()
        {
            // Snippet: UpdateQuotaPreferenceAsync(UpdateQuotaPreferenceRequest, CallSettings)
            // Additional: UpdateQuotaPreferenceAsync(UpdateQuotaPreferenceRequest, CancellationToken)
            // Create client
            CloudQuotasClient cloudQuotasClient = await CloudQuotasClient.CreateAsync();
            // Initialize request argument(s)
            UpdateQuotaPreferenceRequest request = new UpdateQuotaPreferenceRequest
            {
                UpdateMask = new FieldMask(),
                QuotaPreference = new QuotaPreference(),
                AllowMissing = false,
                ValidateOnly = false,
                IgnoreSafetyChecks =
                {
                    QuotaSafetyCheck.Unspecified,
                },
            };
            // Make the request
            QuotaPreference response = await cloudQuotasClient.UpdateQuotaPreferenceAsync(request);
            // End snippet
        }

        /// <summary>Snippet for UpdateQuotaPreference</summary>
        public void UpdateQuotaPreference()
        {
            // Snippet: UpdateQuotaPreference(QuotaPreference, FieldMask, CallSettings)
            // Create client
            CloudQuotasClient cloudQuotasClient = CloudQuotasClient.Create();
            // Initialize request argument(s)
            QuotaPreference quotaPreference = new QuotaPreference();
            FieldMask updateMask = new FieldMask();
            // Make the request
            QuotaPreference response = cloudQuotasClient.UpdateQuotaPreference(quotaPreference, updateMask);
            // End snippet
        }

        /// <summary>Snippet for UpdateQuotaPreferenceAsync</summary>
        public async Task UpdateQuotaPreferenceAsync()
        {
            // Snippet: UpdateQuotaPreferenceAsync(QuotaPreference, FieldMask, CallSettings)
            // Additional: UpdateQuotaPreferenceAsync(QuotaPreference, FieldMask, CancellationToken)
            // Create client
            CloudQuotasClient cloudQuotasClient = await CloudQuotasClient.CreateAsync();
            // Initialize request argument(s)
            QuotaPreference quotaPreference = new QuotaPreference();
            FieldMask updateMask = new FieldMask();
            // Make the request
            QuotaPreference response = await cloudQuotasClient.UpdateQuotaPreferenceAsync(quotaPreference, updateMask);
            // End snippet
        }
    }
}

Go

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

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

package cloudquotas_test

import (
	"context"

	cloudquotas "cloud.google.com/go/cloudquotas/apiv1"
	cloudquotaspb "cloud.google.com/go/cloudquotas/apiv1/cloudquotaspb"
	"google.golang.org/api/iterator"
)

func ExampleNewClient() {
	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 := cloudquotas.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	// TODO: Use client.
	_ = c
}

func ExampleNewRESTClient() {
	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 := cloudquotas.NewRESTClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	// TODO: Use client.
	_ = c
}

func ExampleClient_CreateQuotaPreference() {
	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 := cloudquotas.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &cloudquotaspb.CreateQuotaPreferenceRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/cloudquotas/apiv1/cloudquotaspb#CreateQuotaPreferenceRequest.
	}
	resp, err := c.CreateQuotaPreference(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func ExampleClient_GetQuotaInfo() {
	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 := cloudquotas.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &cloudquotaspb.GetQuotaInfoRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/cloudquotas/apiv1/cloudquotaspb#GetQuotaInfoRequest.
	}
	resp, err := c.GetQuotaInfo(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func ExampleClient_GetQuotaPreference() {
	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 := cloudquotas.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &cloudquotaspb.GetQuotaPreferenceRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/cloudquotas/apiv1/cloudquotaspb#GetQuotaPreferenceRequest.
	}
	resp, err := c.GetQuotaPreference(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func ExampleClient_ListQuotaInfos() {
	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 := cloudquotas.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &cloudquotaspb.ListQuotaInfosRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/cloudquotas/apiv1/cloudquotaspb#ListQuotaInfosRequest.
	}
	it := c.ListQuotaInfos(ctx, req)
	for {
		resp, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			// TODO: Handle error.
		}
		// TODO: Use resp.
		_ = resp
	}
}

func ExampleClient_ListQuotaPreferences() {
	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 := cloudquotas.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &cloudquotaspb.ListQuotaPreferencesRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/cloudquotas/apiv1/cloudquotaspb#ListQuotaPreferencesRequest.
	}
	it := c.ListQuotaPreferences(ctx, req)
	for {
		resp, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			// TODO: Handle error.
		}
		// TODO: Use resp.
		_ = resp
	}
}

func ExampleClient_UpdateQuotaPreference() {
	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 := cloudquotas.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &cloudquotaspb.UpdateQuotaPreferenceRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/cloudquotas/apiv1/cloudquotaspb#UpdateQuotaPreferenceRequest.
	}
	resp, err := c.UpdateQuotaPreference(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

Java

/*
 * 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 com.google.api.cloudquotas.v1.samples;

import com.google.api.cloudquotas.v1.CloudQuotasClient;
import com.google.api.cloudquotas.v1.GetQuotaInfoRequest;
import com.google.api.cloudquotas.v1.QuotaInfo;
import com.google.api.cloudquotas.v1.QuotaInfoName;

public class SyncGetQuotaInfo {

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

  public static void syncGetQuotaInfo() 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 (CloudQuotasClient cloudQuotasClient = CloudQuotasClient.create()) {
      GetQuotaInfoRequest request =
          GetQuotaInfoRequest.newBuilder()
              .setName(
                  QuotaInfoName.ofProjectLocationServiceQuotaInfoName(
                          "[PROJECT]", "[LOCATION]", "[SERVICE]", "[QUOTA_INFO]")
                      .toString())
              .build();
      QuotaInfo response = cloudQuotasClient.getQuotaInfo(request);
    }
  }
}

Node.js

// 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 by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **

'use strict';

function main(parent) {
  /**
   * 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. Parent value of QuotaPreference resources.
   *  Listing across different resource containers (such as 'projects/-') is not
   *  allowed.
   *  When the value starts with 'folders' or 'organizations', it lists the
   *  QuotaPreferences for org quotas in the container. It does not list the
   *  QuotaPreferences in the descendant projects of the container.
   *  Example parents:
   *  `projects/123/locations/global`
   */
  // const parent = 'abc123'
  /**
   *  Optional. Requested page size. Server may return fewer items than
   *  requested. If unspecified, server will pick an appropriate default.
   */
  // const pageSize = 1234
  /**
   *  Optional. A token identifying a page of results the server should return.
   */
  // const pageToken = 'abc123'
  /**
   *  Optional. Filter result QuotaPreferences by their state, type,
   *  create/update time range.
   *  Example filters:
   *  `state=PENDING OR state=PENDING_PARTIALLY_GRANTED`
   *  `state=PENDING OR state=PENDING_PARTIALLY_GRANTED AND
   *   creation_time>2022-12-03T10:30:00`
   *  If no filter is provided, returns all pending quota preferences.
   */
  // const filter = 'abc123'
  /**
   *  Optional. How to order of the results. By default, the results are ordered
   *  by create time.
   *  Example orders:
   *  `type`
   *  `state, create_time`
   */
  // const orderBy = 'abc123'

  // Imports the Cloudquotas library
  const {CloudQuotasClient} = require('@google-cloud/cloudquotas').v1;

  // Instantiates a client
  const cloudquotasClient = new CloudQuotasClient();

  async function callListQuotaPreferences() {
    // Construct request
    const request = {
      parent,
    };

    // Run request
    const iterable = await cloudquotasClient.listQuotaPreferencesAsync(request);
    for await (const response of iterable) {
      console.log(response);
    }
  }

  callListQuotaPreferences();
}

process.on('unhandledRejection', err => {
  console.error(err.message);
  process.exitCode = 1;
});
main(...process.argv.slice(2));

PHP

<?php
/*
 * Copyright 2023 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.
 */

/*
 * GENERATED CODE WARNING
 * This file was automatically generated - do not edit!
 */

require_once __DIR__ . '/../../../vendor/autoload.php';

use Google\ApiCore\ApiException;
use Google\Cloud\CloudQuotas\V1\Client\CloudQuotasClient;
use Google\Cloud\CloudQuotas\V1\GetQuotaInfoRequest;
use Google\Cloud\CloudQuotas\V1\QuotaInfo;

/**
 * Retrieve the QuotaInfo of a quota for a project, folder or organization.
 *
 * @param string $formattedName The resource name of the quota info.
 *
 *                              An example name:
 *                              `projects/123/locations/global/services/compute.googleapis.com/quotaInfos/CpusPerProjectPerRegion`
 *                              Please see {@see CloudQuotasClient::quotaInfoName()} for help formatting this field.
 */
function get_quota_info_sample(string $formattedName): void
{
    // Create a client.
    $cloudQuotasClient = new CloudQuotasClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var QuotaInfo $response */
        $response = $cloudQuotasClient->getQuotaInfo($request);
        printf('Response data: %s' . PHP_EOL, $response->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 = CloudQuotasClient::quotaInfoName(
        '[PROJECT]',
        '[LOCATION]',
        '[SERVICE]',
        '[QUOTA_INFO]'
    );

    get_quota_info_sample($formattedName);
}

Python

# -*- coding: utf-8 -*-
# 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.
#
# Generated code. DO NOT EDIT!
#
# Snippet for GetQuotaInfo
# NOTE: This snippet has been automatically generated for illustrative purposes only.
# It may require modifications to work in your environment.

# To install the latest published package dependency, execute the following:
#   python3 -m pip install google-cloud-quotas

# 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 cloudquotas_v1

def sample_get_quota_info():
    # Create a client
    client = cloudquotas_v1.CloudQuotasClient()

    # Initialize request argument(s)
    request = cloudquotas_v1.GetQuotaInfoRequest(
        name="name_value",
    )

    # Make the request
    response = client.get_quota_info(request=request)

    # Handle the response
    print(response)

Ruby

# frozen_string_literal: true

# 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.

# Auto-generated by gapic-generator-ruby. DO NOT EDIT!

require "google/cloud/cloud_quotas/v1"

##
# Snippet for the get_quota_info call in the CloudQuotas 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::CloudQuotas::V1::CloudQuotas::Client#get_quota_info.
#
def get_quota_info
  # Create a client object. The client can be reused for multiple calls.
  client = Google::Cloud::CloudQuotas::V1::CloudQuotas::Client.new

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

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

  # The returned object is of type Google::Cloud::CloudQuotas::V1::QuotaInfo.
  p result
end

추가 리소스

C++

다음 목록에는 C++용 클라이언트 라이브러리와 관련된 추가 리소스에 대한 링크가 포함되어 있습니다.

C#

다음 목록에는 C#용 클라이언트 라이브러리와 관련된 추가 리소스에 대한 링크가 포함되어 있습니다.

Go

다음 목록에는 Go용 클라이언트 라이브러리와 관련된 추가 리소스에 대한 링크가 포함되어 있습니다.

Java

다음 목록에는 자바용 클라이언트 라이브러리와 관련된 추가 리소스에 대한 링크가 포함되어 있습니다.

Node.js

다음 목록에는 Node.js용 클라이언트 라이브러리와 관련된 추가 리소스에 대한 링크가 포함되어 있습니다.

PHP

다음 목록에는 PHP용 클라이언트 라이브러리와 관련된 추가 리소스에 대한 링크가 포함되어 있습니다.

Python

다음 목록에는 Python용 클라이언트 라이브러리와 관련된 추가 리소스에 대한 링크가 포함되어 있습니다.

Ruby

다음 목록에는 Ruby용 클라이언트 라이브러리와 관련된 추가 리소스의 링크가 포함되어 있습니다.