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\GoogleAnalyticsAdmin\Resource;
19
20use Google\Service\GoogleAnalyticsAdmin\GoogleAnalyticsAdminV1alphaAccount;
21use Google\Service\GoogleAnalyticsAdmin\GoogleAnalyticsAdminV1alphaDataSharingSettings;
22use Google\Service\GoogleAnalyticsAdmin\GoogleAnalyticsAdminV1alphaListAccountsResponse;
23use Google\Service\GoogleAnalyticsAdmin\GoogleAnalyticsAdminV1alphaProvisionAccountTicketRequest;
24use Google\Service\GoogleAnalyticsAdmin\GoogleAnalyticsAdminV1alphaProvisionAccountTicketResponse;
25use Google\Service\GoogleAnalyticsAdmin\GoogleAnalyticsAdminV1alphaSearchChangeHistoryEventsRequest;
26use Google\Service\GoogleAnalyticsAdmin\GoogleAnalyticsAdminV1alphaSearchChangeHistoryEventsResponse;
27use Google\Service\GoogleAnalyticsAdmin\GoogleProtobufEmpty;
28
29/**
30 * The "accounts" collection of methods.
31 * Typical usage is:
32 *  <code>
33 *   $analyticsadminService = new Google\Service\GoogleAnalyticsAdmin(...);
34 *   $accounts = $analyticsadminService->accounts;
35 *  </code>
36 */
37class Accounts extends \Google\Service\Resource
38{
39  /**
40   * Marks target Account as soft-deleted (ie: "trashed") and returns it. This API
41   * does not have a method to restore soft-deleted accounts. However, they can be
42   * restored using the Trash Can UI. If the accounts are not restored before the
43   * expiration time, the account and all child resources (eg: Properties,
44   * GoogleAdsLinks, Streams, UserLinks) will be permanently purged.
45   * https://support.google.com/analytics/answer/6154772 Returns an error if the
46   * target is not found. (accounts.delete)
47   *
48   * @param string $name Required. The name of the Account to soft-delete. Format:
49   * accounts/{account} Example: "accounts/100"
50   * @param array $optParams Optional parameters.
51   * @return GoogleProtobufEmpty
52   */
53  public function delete($name, $optParams = [])
54  {
55    $params = ['name' => $name];
56    $params = array_merge($params, $optParams);
57    return $this->call('delete', [$params], GoogleProtobufEmpty::class);
58  }
59  /**
60   * Lookup for a single Account. (accounts.get)
61   *
62   * @param string $name Required. The name of the account to lookup. Format:
63   * accounts/{account} Example: "accounts/100"
64   * @param array $optParams Optional parameters.
65   * @return GoogleAnalyticsAdminV1alphaAccount
66   */
67  public function get($name, $optParams = [])
68  {
69    $params = ['name' => $name];
70    $params = array_merge($params, $optParams);
71    return $this->call('get', [$params], GoogleAnalyticsAdminV1alphaAccount::class);
72  }
73  /**
74   * Get data sharing settings on an account. Data sharing settings are
75   * singletons. (accounts.getDataSharingSettings)
76   *
77   * @param string $name Required. The name of the settings to lookup. Format:
78   * accounts/{account}/dataSharingSettings Example:
79   * "accounts/1000/dataSharingSettings"
80   * @param array $optParams Optional parameters.
81   * @return GoogleAnalyticsAdminV1alphaDataSharingSettings
82   */
83  public function getDataSharingSettings($name, $optParams = [])
84  {
85    $params = ['name' => $name];
86    $params = array_merge($params, $optParams);
87    return $this->call('getDataSharingSettings', [$params], GoogleAnalyticsAdminV1alphaDataSharingSettings::class);
88  }
89  /**
90   * Returns all accounts accessible by the caller. Note that these accounts might
91   * not currently have GA4 properties. Soft-deleted (ie: "trashed") accounts are
92   * excluded by default. Returns an empty list if no relevant accounts are found.
93   * (accounts.listAccounts)
94   *
95   * @param array $optParams Optional parameters.
96   *
97   * @opt_param int pageSize The maximum number of resources to return. The
98   * service may return fewer than this value, even if there are additional pages.
99   * If unspecified, at most 50 resources will be returned. The maximum value is
100   * 200; (higher values will be coerced to the maximum)
101   * @opt_param string pageToken A page token, received from a previous
102   * `ListAccounts` call. Provide this to retrieve the subsequent page. When
103   * paginating, all other parameters provided to `ListAccounts` must match the
104   * call that provided the page token.
105   * @opt_param bool showDeleted Whether to include soft-deleted (ie: "trashed")
106   * Accounts in the results. Accounts can be inspected to determine whether they
107   * are deleted or not.
108   * @return GoogleAnalyticsAdminV1alphaListAccountsResponse
109   */
110  public function listAccounts($optParams = [])
111  {
112    $params = [];
113    $params = array_merge($params, $optParams);
114    return $this->call('list', [$params], GoogleAnalyticsAdminV1alphaListAccountsResponse::class);
115  }
116  /**
117   * Updates an account. (accounts.patch)
118   *
119   * @param string $name Output only. Resource name of this account. Format:
120   * accounts/{account} Example: "accounts/100"
121   * @param GoogleAnalyticsAdminV1alphaAccount $postBody
122   * @param array $optParams Optional parameters.
123   *
124   * @opt_param string updateMask Required. The list of fields to be updated.
125   * Field names must be in snake case (e.g., "field_to_update"). Omitted fields
126   * will not be updated. To replace the entire entity, use one path with the
127   * string "*" to match all fields.
128   * @return GoogleAnalyticsAdminV1alphaAccount
129   */
130  public function patch($name, GoogleAnalyticsAdminV1alphaAccount $postBody, $optParams = [])
131  {
132    $params = ['name' => $name, 'postBody' => $postBody];
133    $params = array_merge($params, $optParams);
134    return $this->call('patch', [$params], GoogleAnalyticsAdminV1alphaAccount::class);
135  }
136  /**
137   * Requests a ticket for creating an account. (accounts.provisionAccountTicket)
138   *
139   * @param GoogleAnalyticsAdminV1alphaProvisionAccountTicketRequest $postBody
140   * @param array $optParams Optional parameters.
141   * @return GoogleAnalyticsAdminV1alphaProvisionAccountTicketResponse
142   */
143  public function provisionAccountTicket(GoogleAnalyticsAdminV1alphaProvisionAccountTicketRequest $postBody, $optParams = [])
144  {
145    $params = ['postBody' => $postBody];
146    $params = array_merge($params, $optParams);
147    return $this->call('provisionAccountTicket', [$params], GoogleAnalyticsAdminV1alphaProvisionAccountTicketResponse::class);
148  }
149  /**
150   * Searches through all changes to an account or its children given the
151   * specified set of filters. (accounts.searchChangeHistoryEvents)
152   *
153   * @param string $account Required. The account resource for which to return
154   * change history resources.
155   * @param GoogleAnalyticsAdminV1alphaSearchChangeHistoryEventsRequest $postBody
156   * @param array $optParams Optional parameters.
157   * @return GoogleAnalyticsAdminV1alphaSearchChangeHistoryEventsResponse
158   */
159  public function searchChangeHistoryEvents($account, GoogleAnalyticsAdminV1alphaSearchChangeHistoryEventsRequest $postBody, $optParams = [])
160  {
161    $params = ['account' => $account, 'postBody' => $postBody];
162    $params = array_merge($params, $optParams);
163    return $this->call('searchChangeHistoryEvents', [$params], GoogleAnalyticsAdminV1alphaSearchChangeHistoryEventsResponse::class);
164  }
165}
166
167// Adding a class alias for backwards compatibility with the previous class name.
168class_alias(Accounts::class, 'Google_Service_GoogleAnalyticsAdmin_Resource_Accounts');
169