def update_queue( self, task_queue: Queue, project_id: str, location: Optional[str] = None, queue_name: Optional[str] = None, update_mask: Optional[FieldMask] = None, retry: Optional[Retry] = None, timeout: Optional[float] = None, metadata: Optional[Sequence[Tuple[str, str]]] = None) -> Queue: """ Updates a queue in Cloud Tasks. :param task_queue: The task queue to update. This method creates the queue if it does not exist and updates the queue if it does exist. The queue's name must be specified. :type task_queue: dict or class google.cloud.tasks_v2.types.Queue :param project_id: (Optional) The ID of the GCP project that owns the Cloud Tasks. If set to None or missing, the default project_id from the GCP connection is used. :type project_id: str :param location: (Optional) The location name in which the queue will be updated. If provided, it will be used to construct the full queue path. :type location: str :param queue_name: (Optional) The queue's name. If provided, it will be used to construct the full queue path. :type queue_name: str :param update_mask: A mast used to specify which fields of the queue are being updated. If empty, then all fields will be updated. If a dict is provided, it must be of the same form as the protobuf message. :type update_mask: dict or class google.cloud.tasks_v2.types.FieldMask :param retry: (Optional) A retry object used to retry requests. If None is specified, requests will not be retried. :type retry: google.api_core.retry.Retry :param timeout: (Optional) The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt. :type timeout: float :param metadata: (Optional) Additional metadata that is provided to the method. :type metadata: sequence[tuple[str, str]]] :rtype: google.cloud.tasks_v2.types.Queue """ client = self.get_conn() if queue_name and location: full_queue_name = CloudTasksClient.queue_path( project_id, location, queue_name) if isinstance(task_queue, Queue): task_queue.name = full_queue_name elif isinstance(task_queue, dict): task_queue['name'] = full_queue_name else: raise AirflowException('Unable to set queue_name.') return client.update_queue( queue=task_queue, update_mask=update_mask, retry=retry, timeout=timeout, metadata=metadata, )
def update_queue( self, task_queue: Queue, project_id: str = PROVIDE_PROJECT_ID, location: Optional[str] = None, queue_name: Optional[str] = None, update_mask: Optional[FieldMask] = None, retry: Union[Retry, _MethodDefault] = DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> Queue: """ Updates a queue in Cloud Tasks. :param task_queue: The task queue to update. This method creates the queue if it does not exist and updates the queue if it does exist. The queue's name must be specified. :param project_id: (Optional) The ID of the Google Cloud project that owns the Cloud Tasks. If set to None or missing, the default project_id from the Google Cloud connection is used. :param location: (Optional) The location name in which the queue will be updated. If provided, it will be used to construct the full queue path. :param queue_name: (Optional) The queue's name. If provided, it will be used to construct the full queue path. :param update_mask: A mast used to specify which fields of the queue are being updated. If empty, then all fields will be updated. If a dict is provided, it must be of the same form as the protobuf message. :param retry: (Optional) A retry object used to retry requests. If None is specified, requests will not be retried. :param timeout: (Optional) The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt. :param metadata: (Optional) Additional metadata that is provided to the method. :rtype: google.cloud.tasks_v2.types.Queue """ client = self.get_conn() if queue_name and location: full_queue_name = f"projects/{project_id}/locations/{location}/queues/{queue_name}" if isinstance(task_queue, Queue): task_queue.name = full_queue_name elif isinstance(task_queue, dict): task_queue['name'] = full_queue_name else: raise AirflowException('Unable to set queue_name.') return client.update_queue( request={ 'queue': task_queue, 'update_mask': update_mask }, retry=retry, timeout=timeout, metadata=metadata, )