1<?php 2/* 3 * Copyright 2014 Google Inc. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 6 * use this file except in compliance with the License. You may obtain a copy of 7 * the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 * License for the specific language governing permissions and limitations under 15 * the License. 16 */ 17 18namespace Google\Service\BigQueryReservation\Resource; 19 20use Google\Service\BigQueryReservation\Assignment; 21use Google\Service\BigQueryReservation\BigqueryreservationEmpty; 22use Google\Service\BigQueryReservation\ListAssignmentsResponse; 23use Google\Service\BigQueryReservation\MoveAssignmentRequest; 24 25/** 26 * The "assignments" collection of methods. 27 * Typical usage is: 28 * <code> 29 * $bigqueryreservationService = new Google\Service\BigQueryReservation(...); 30 * $assignments = $bigqueryreservationService->assignments; 31 * </code> 32 */ 33class ProjectsLocationsReservationsAssignments extends \Google\Service\Resource 34{ 35 /** 36 * Creates an assignment object which allows the given project to submit jobs of 37 * a certain type using slots from the specified reservation. Currently a 38 * resource (project, folder, organization) can only have one assignment per 39 * each (job_type, location) combination, and that reservation will be used for 40 * all jobs of the matching type. Different assignments can be created on 41 * different levels of the projects, folders or organization hierarchy. During 42 * query execution, the assignment is looked up at the project, folder and 43 * organization levels in that order. The first assignment found is applied to 44 * the query. When creating assignments, it does not matter if other assignments 45 * exist at higher levels. Example: * The organization `organizationA` contains 46 * two projects, `project1` and `project2`. * Assignments for all three entities 47 * (`organizationA`, `project1`, and `project2`) could all be created and mapped 48 * to the same or different reservations. "None" assignments represent an 49 * absence of the assignment. Projects assigned to None use on-demand pricing. 50 * To create a "None" assignment, use "none" as a reservation_id in the parent. 51 * Example parent: `projects/myproject/locations/US/reservations/none`. Returns 52 * `google.rpc.Code.PERMISSION_DENIED` if user does not have 'bigquery.admin' 53 * permissions on the project using the reservation and the project that owns 54 * this reservation. Returns `google.rpc.Code.INVALID_ARGUMENT` when location of 55 * the assignment does not match location of the reservation. 56 * (assignments.create) 57 * 58 * @param string $parent Required. The parent resource name of the assignment 59 * E.g. `projects/myproject/locations/US/reservations/team1-prod` 60 * @param Assignment $postBody 61 * @param array $optParams Optional parameters. 62 * 63 * @opt_param string assignmentId The optional assignment ID. Assignment name 64 * will be generated automatically if this field is empty. This field must only 65 * contain lower case alphanumeric characters or dashes. Max length is 64 66 * characters. 67 * @return Assignment 68 */ 69 public function create($parent, Assignment $postBody, $optParams = []) 70 { 71 $params = ['parent' => $parent, 'postBody' => $postBody]; 72 $params = array_merge($params, $optParams); 73 return $this->call('create', [$params], Assignment::class); 74 } 75 /** 76 * Deletes a assignment. No expansion will happen. Example: * Organization 77 * `organizationA` contains two projects, `project1` and `project2`. * 78 * Reservation `res1` exists and was created previously. * CreateAssignment was 79 * used previously to define the following associations between entities and 80 * reservations: `` and `` In this example, deletion of the `` assignment won't 81 * affect the other assignment ``. After said deletion, queries from `project1` 82 * will still use `res1` while queries from `project2` will switch to use on- 83 * demand mode. (assignments.delete) 84 * 85 * @param string $name Required. Name of the resource, e.g. 86 * `projects/myproject/locations/US/reservations/team1-prod/assignments/123` 87 * @param array $optParams Optional parameters. 88 * @return BigqueryreservationEmpty 89 */ 90 public function delete($name, $optParams = []) 91 { 92 $params = ['name' => $name]; 93 $params = array_merge($params, $optParams); 94 return $this->call('delete', [$params], BigqueryreservationEmpty::class); 95 } 96 /** 97 * Lists assignments. Only explicitly created assignments will be returned. 98 * Example: * Organization `organizationA` contains two projects, `project1` and 99 * `project2`. * Reservation `res1` exists and was created previously. * 100 * CreateAssignment was used previously to define the following associations 101 * between entities and reservations: `` and `` In this example, ListAssignments 102 * will just return the above two assignments for reservation `res1`, and no 103 * expansion/merge will happen. The wildcard "-" can be used for reservations in 104 * the request. In that case all assignments belongs to the specified project 105 * and location will be listed. **Note** "-" cannot be used for projects nor 106 * locations. (assignments.listProjectsLocationsReservationsAssignments) 107 * 108 * @param string $parent Required. The parent resource name e.g.: 109 * `projects/myproject/locations/US/reservations/team1-prod` Or: 110 * `projects/myproject/locations/US/reservations/-` 111 * @param array $optParams Optional parameters. 112 * 113 * @opt_param int pageSize The maximum number of items to return per page. 114 * @opt_param string pageToken The next_page_token value returned from a 115 * previous List request, if any. 116 * @return ListAssignmentsResponse 117 */ 118 public function listProjectsLocationsReservationsAssignments($parent, $optParams = []) 119 { 120 $params = ['parent' => $parent]; 121 $params = array_merge($params, $optParams); 122 return $this->call('list', [$params], ListAssignmentsResponse::class); 123 } 124 /** 125 * Moves an assignment under a new reservation. This differs from removing an 126 * existing assignment and recreating a new one by providing a transactional 127 * change that ensures an assignee always has an associated reservation. 128 * (assignments.move) 129 * 130 * @param string $name Required. The resource name of the assignment, e.g. 131 * `projects/myproject/locations/US/reservations/team1-prod/assignments/123` 132 * @param MoveAssignmentRequest $postBody 133 * @param array $optParams Optional parameters. 134 * @return Assignment 135 */ 136 public function move($name, MoveAssignmentRequest $postBody, $optParams = []) 137 { 138 $params = ['name' => $name, 'postBody' => $postBody]; 139 $params = array_merge($params, $optParams); 140 return $this->call('move', [$params], Assignment::class); 141 } 142 /** 143 * Updates an existing assignment. Only the `priority` field can be updated. 144 * (assignments.patch) 145 * 146 * @param string $name Output only. Name of the resource. E.g.: 147 * `projects/myproject/locations/US/reservations/team1-prod/assignments/123`. 148 * The assignment_id must only contain lower case alphanumeric characters or 149 * dashes and the max length is 64 characters. 150 * @param Assignment $postBody 151 * @param array $optParams Optional parameters. 152 * 153 * @opt_param string updateMask Standard field mask for the set of fields to be 154 * updated. 155 * @return Assignment 156 */ 157 public function patch($name, Assignment $postBody, $optParams = []) 158 { 159 $params = ['name' => $name, 'postBody' => $postBody]; 160 $params = array_merge($params, $optParams); 161 return $this->call('patch', [$params], Assignment::class); 162 } 163} 164 165// Adding a class alias for backwards compatibility with the previous class name. 166class_alias(ProjectsLocationsReservationsAssignments::class, 'Google_Service_BigQueryReservation_Resource_ProjectsLocationsReservationsAssignments'); 167