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\AccessApproval\Resource;
19
20use Google\Service\AccessApproval\ApprovalRequest;
21use Google\Service\AccessApproval\ApproveApprovalRequestMessage;
22use Google\Service\AccessApproval\DismissApprovalRequestMessage;
23use Google\Service\AccessApproval\ListApprovalRequestsResponse;
24
25/**
26 * The "approvalRequests" collection of methods.
27 * Typical usage is:
28 *  <code>
29 *   $accessapprovalService = new Google\Service\AccessApproval(...);
30 *   $approvalRequests = $accessapprovalService->approvalRequests;
31 *  </code>
32 */
33class FoldersApprovalRequests extends \Google\Service\Resource
34{
35  /**
36   * Approves a request and returns the updated ApprovalRequest. Returns NOT_FOUND
37   * if the request does not exist. Returns FAILED_PRECONDITION if the request
38   * exists but is not in a pending state. (approvalRequests.approve)
39   *
40   * @param string $name Name of the approval request to approve.
41   * @param ApproveApprovalRequestMessage $postBody
42   * @param array $optParams Optional parameters.
43   * @return ApprovalRequest
44   */
45  public function approve($name, ApproveApprovalRequestMessage $postBody, $optParams = [])
46  {
47    $params = ['name' => $name, 'postBody' => $postBody];
48    $params = array_merge($params, $optParams);
49    return $this->call('approve', [$params], ApprovalRequest::class);
50  }
51  /**
52   * Dismisses a request. Returns the updated ApprovalRequest. NOTE: This does not
53   * deny access to the resource if another request has been made and approved. It
54   * is equivalent in effect to ignoring the request altogether. Returns NOT_FOUND
55   * if the request does not exist. Returns FAILED_PRECONDITION if the request
56   * exists but is not in a pending state. (approvalRequests.dismiss)
57   *
58   * @param string $name Name of the ApprovalRequest to dismiss.
59   * @param DismissApprovalRequestMessage $postBody
60   * @param array $optParams Optional parameters.
61   * @return ApprovalRequest
62   */
63  public function dismiss($name, DismissApprovalRequestMessage $postBody, $optParams = [])
64  {
65    $params = ['name' => $name, 'postBody' => $postBody];
66    $params = array_merge($params, $optParams);
67    return $this->call('dismiss', [$params], ApprovalRequest::class);
68  }
69  /**
70   * Gets an approval request. Returns NOT_FOUND if the request does not exist.
71   * (approvalRequests.get)
72   *
73   * @param string $name The name of the approval request to retrieve. Format:
74   * "{projects|folders|organizations}/{id}/approvalRequests/{approval_request}"
75   * @param array $optParams Optional parameters.
76   * @return ApprovalRequest
77   */
78  public function get($name, $optParams = [])
79  {
80    $params = ['name' => $name];
81    $params = array_merge($params, $optParams);
82    return $this->call('get', [$params], ApprovalRequest::class);
83  }
84  /**
85   * Lists approval requests associated with a project, folder, or organization.
86   * Approval requests can be filtered by state (pending, active, dismissed). The
87   * order is reverse chronological.
88   * (approvalRequests.listFoldersApprovalRequests)
89   *
90   * @param string $parent The parent resource. This may be "projects/{project}",
91   * "folders/{folder}", or "organizations/{organization}".
92   * @param array $optParams Optional parameters.
93   *
94   * @opt_param string filter A filter on the type of approval requests to
95   * retrieve. Must be one of the following values: * [not set]: Requests that are
96   * pending or have active approvals. * ALL: All requests. * PENDING: Only
97   * pending requests. * ACTIVE: Only active (i.e. currently approved) requests. *
98   * DISMISSED: Only requests that have been dismissed, or requests that are not
99   * approved and past expiration. * EXPIRED: Only requests that have been
100   * approved, and the approval has expired. * HISTORY: Active, dismissed and
101   * expired requests.
102   * @opt_param int pageSize Requested page size.
103   * @opt_param string pageToken A token identifying the page of results to
104   * return.
105   * @return ListApprovalRequestsResponse
106   */
107  public function listFoldersApprovalRequests($parent, $optParams = [])
108  {
109    $params = ['parent' => $parent];
110    $params = array_merge($params, $optParams);
111    return $this->call('list', [$params], ListApprovalRequestsResponse::class);
112  }
113}
114
115// Adding a class alias for backwards compatibility with the previous class name.
116class_alias(FoldersApprovalRequests::class, 'Google_Service_AccessApproval_Resource_FoldersApprovalRequests');
117