/// <summary>
        /// Get detailed information about a TaskQueue.
        /// Documentation https://developers.google.com/taskqueue/v1beta2/reference/taskqueues/get
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated taskqueue service.</param>
        /// <param name="project">The project under which the queue lies.</param>
        /// <param name="taskqueue">The id of the taskqueue to get the properties of.</param>
        /// <param name="optional">Optional paramaters.</param>        /// <returns>TaskQueueResponse</returns>
        public static TaskQueue Get(taskqueueService service, string project, string taskqueue, TaskqueuesGetOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (project == null)
                {
                    throw new ArgumentNullException(project);
                }
                if (taskqueue == null)
                {
                    throw new ArgumentNullException(taskqueue);
                }

                // Building the initial request.
                var request = service.Taskqueues.Get(project, taskqueue);

                // Applying optional parameters to the request.
                request = (TaskqueuesResource.GetRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Taskqueues.Get failed.", ex);
            }
        }
Пример #2
0
        /// <summary>
        /// Lease 1 or more tasks from a TaskQueue.
        /// Documentation https://developers.google.com/taskqueue/v1beta1/reference/tasks/lease
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated taskqueue service.</param>
        /// <param name="project">The project under which the queue lies.</param>
        /// <param name="taskqueue">The taskqueue to lease a task from.</param>
        /// <param name="numTasks">The number of tasks to lease.</param>
        /// <param name="leaseSecs">The lease in seconds.</param>
        /// <returns>TasksResponse</returns>
        public static Tasks Lease(taskqueueService service, string project, string taskqueue, int numTasks, int leaseSecs)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (project == null)
                {
                    throw new ArgumentNullException(project);
                }
                if (taskqueue == null)
                {
                    throw new ArgumentNullException(taskqueue);
                }

                // Make the request.
                return(service.Tasks.Lease(project, taskqueue, numTasks, leaseSecs).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Tasks.Lease failed.", ex);
            }
        }
Пример #3
0
        /// <summary>
        /// Delete a task from a TaskQueue.
        /// Documentation https://developers.google.com/taskqueue/v1beta1/reference/tasks/delete
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated taskqueue service.</param>
        /// <param name="project">The project under which the queue lies.</param>
        /// <param name="taskqueue">The taskqueue to delete a task from.</param>
        /// <param name="task">The id of the task to delete.</param>
        public static void Delete(taskqueueService service, string project, string taskqueue, string task)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (project == null)
                {
                    throw new ArgumentNullException(project);
                }
                if (taskqueue == null)
                {
                    throw new ArgumentNullException(taskqueue);
                }
                if (task == null)
                {
                    throw new ArgumentNullException(task);
                }

                // Make the request.
                return(service.Tasks.Delete(project, taskqueue, task).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Tasks.Delete failed.", ex);
            }
        }
Пример #4
0
        /// <summary>
        /// Update tasks that are leased out of a TaskQueue.
        /// Documentation https://developers.google.com/taskqueue/v1beta2/reference/tasks/update
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated taskqueue service.</param>
        /// <param name="project">The project under which the queue lies.</param>
        /// <param name="taskqueue">NA</param>
        /// <param name="task">NA</param>
        /// <param name="newLeaseSeconds">The new lease in seconds.</param>
        /// <param name="body">A valid taskqueue v1beta2 body.</param>
        /// <returns>TaskResponse</returns>
        public static Task Update(taskqueueService service, string project, string taskqueue, string task, int newLeaseSeconds, Task body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (project == null)
                {
                    throw new ArgumentNullException(project);
                }
                if (taskqueue == null)
                {
                    throw new ArgumentNullException(taskqueue);
                }
                if (task == null)
                {
                    throw new ArgumentNullException(task);
                }

                // Make the request.
                return(service.Tasks.Update(body, project, taskqueue, task, newLeaseSeconds).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Tasks.Update failed.", ex);
            }
        }