Пример #1
0
 /// <summary>Snippet for GetReservation</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetReservationResourceNames()
 {
     // Create client
     ReservationServiceClient reservationServiceClient = ReservationServiceClient.Create();
     // Initialize request argument(s)
     ReservationName name = ReservationName.FromProjectLocationReservation("[PROJECT]", "[LOCATION]", "[RESERVATION]");
     // Make the request
     Reservation response = reservationServiceClient.GetReservation(name);
 }
 /// <summary>Snippet for CreateAssignment</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void CreateAssignmentResourceNames()
 {
     // Create client
     ReservationServiceClient reservationServiceClient = ReservationServiceClient.Create();
     // Initialize request argument(s)
     ReservationName parent     = ReservationName.FromProjectLocationReservation("[PROJECT]", "[LOCATION]", "[RESERVATION]");
     Assignment      assignment = new Assignment();
     // Make the request
     Assignment response = reservationServiceClient.CreateAssignment(parent, assignment);
 }
Пример #3
0
        /// <summary>Snippet for DeleteReservationAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public async Task DeleteReservationResourceNamesAsync()
        {
            // Create client
            ReservationServiceClient reservationServiceClient = await ReservationServiceClient.CreateAsync();

            // Initialize request argument(s)
            ReservationName name = ReservationName.FromProjectLocationReservation("[PROJECT]", "[LOCATION]", "[RESERVATION]");
            // Make the request
            await reservationServiceClient.DeleteReservationAsync(name);
        }
Пример #4
0
 /// <summary>Snippet for MoveAssignment</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void MoveAssignmentResourceNames()
 {
     // Create client
     ReservationServiceClient reservationServiceClient = ReservationServiceClient.Create();
     // Initialize request argument(s)
     AssignmentName  name          = AssignmentName.FromProjectLocationReservationAssignment("[PROJECT]", "[LOCATION]", "[RESERVATION]", "[ASSIGNMENT]");
     ReservationName destinationId = ReservationName.FromProjectLocationReservation("[PROJECT]", "[LOCATION]", "[RESERVATION]");
     // Make the request
     Assignment response = reservationServiceClient.MoveAssignment(name, destinationId);
 }
Пример #5
0
 /// <summary>Snippet for GetReservation</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetReservationRequestObject()
 {
     // Create client
     ReservationServiceClient reservationServiceClient = ReservationServiceClient.Create();
     // Initialize request argument(s)
     GetReservationRequest request = new GetReservationRequest
     {
         ReservationName = ReservationName.FromProjectLocationReservation("[PROJECT]", "[LOCATION]", "[RESERVATION]"),
     };
     // Make the request
     Reservation response = reservationServiceClient.GetReservation(request);
 }
Пример #6
0
 /// <summary>Snippet for MoveAssignment</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void MoveAssignmentRequestObject()
 {
     // Create client
     ReservationServiceClient reservationServiceClient = ReservationServiceClient.Create();
     // Initialize request argument(s)
     MoveAssignmentRequest request = new MoveAssignmentRequest
     {
         AssignmentName = AssignmentName.FromProjectLocationReservationAssignment("[PROJECT]", "[LOCATION]", "[RESERVATION]", "[ASSIGNMENT]"),
         DestinationIdAsReservationName = ReservationName.FromProjectLocationReservation("[PROJECT]", "[LOCATION]", "[RESERVATION]"),
     };
     // Make the request
     Assignment response = reservationServiceClient.MoveAssignment(request);
 }
Пример #7
0
 /// <summary>Snippet for CreateAssignment</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void CreateAssignmentRequestObject()
 {
     // Create client
     ReservationServiceClient reservationServiceClient = ReservationServiceClient.Create();
     // Initialize request argument(s)
     CreateAssignmentRequest request = new CreateAssignmentRequest
     {
         ParentAsReservationName = ReservationName.FromProjectLocationReservation("[PROJECT]", "[LOCATION]", "[RESERVATION]"),
         Assignment = new Assignment(),
     };
     // Make the request
     Assignment response = reservationServiceClient.CreateAssignment(request);
 }
Пример #8
0
        /// <summary>Snippet for DeleteReservationAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public async Task DeleteReservationRequestObjectAsync()
        {
            // Create client
            ReservationServiceClient reservationServiceClient = await ReservationServiceClient.CreateAsync();

            // Initialize request argument(s)
            DeleteReservationRequest request = new DeleteReservationRequest
            {
                ReservationName = ReservationName.FromProjectLocationReservation("[PROJECT]", "[LOCATION]", "[RESERVATION]"),
            };
            // Make the request
            await reservationServiceClient.DeleteReservationAsync(request);
        }
        /// <summary>Snippet for ListAssignmentsAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public async Task ListAssignmentsRequestObjectAsync()
        {
            // Create client
            ReservationServiceClient reservationServiceClient = await ReservationServiceClient.CreateAsync();

            // Initialize request argument(s)
            ListAssignmentsRequest request = new ListAssignmentsRequest
            {
                ParentAsReservationName = ReservationName.FromProjectLocationReservation("[PROJECT]", "[LOCATION]", "[RESERVATION]"),
            };
            // Make the request
            PagedAsyncEnumerable <ListAssignmentsResponse, Assignment> response = reservationServiceClient.ListAssignmentsAsync(request);

            // Iterate over all response items, lazily performing RPCs as required
            await response.ForEachAsync((Assignment 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((ListAssignmentsResponse page) =>
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (Assignment 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 <Assignment> 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 (Assignment 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;
        }