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\Analytics\Resource;
19
20use Google\Service\Analytics\CustomMetric;
21use Google\Service\Analytics\CustomMetrics;
22
23/**
24 * The "customMetrics" collection of methods.
25 * Typical usage is:
26 *  <code>
27 *   $analyticsService = new Google\Service\Analytics(...);
28 *   $customMetrics = $analyticsService->customMetrics;
29 *  </code>
30 */
31class ManagementCustomMetrics extends \Google\Service\Resource
32{
33  /**
34   * Get a custom metric to which the user has access. (customMetrics.get)
35   *
36   * @param string $accountId Account ID for the custom metric to retrieve.
37   * @param string $webPropertyId Web property ID for the custom metric to
38   * retrieve.
39   * @param string $customMetricId The ID of the custom metric to retrieve.
40   * @param array $optParams Optional parameters.
41   * @return CustomMetric
42   */
43  public function get($accountId, $webPropertyId, $customMetricId, $optParams = [])
44  {
45    $params = ['accountId' => $accountId, 'webPropertyId' => $webPropertyId, 'customMetricId' => $customMetricId];
46    $params = array_merge($params, $optParams);
47    return $this->call('get', [$params], CustomMetric::class);
48  }
49  /**
50   * Create a new custom metric. (customMetrics.insert)
51   *
52   * @param string $accountId Account ID for the custom metric to create.
53   * @param string $webPropertyId Web property ID for the custom dimension to
54   * create.
55   * @param CustomMetric $postBody
56   * @param array $optParams Optional parameters.
57   * @return CustomMetric
58   */
59  public function insert($accountId, $webPropertyId, CustomMetric $postBody, $optParams = [])
60  {
61    $params = ['accountId' => $accountId, 'webPropertyId' => $webPropertyId, 'postBody' => $postBody];
62    $params = array_merge($params, $optParams);
63    return $this->call('insert', [$params], CustomMetric::class);
64  }
65  /**
66   * Lists custom metrics to which the user has access.
67   * (customMetrics.listManagementCustomMetrics)
68   *
69   * @param string $accountId Account ID for the custom metrics to retrieve.
70   * @param string $webPropertyId Web property ID for the custom metrics to
71   * retrieve.
72   * @param array $optParams Optional parameters.
73   *
74   * @opt_param int max-results The maximum number of custom metrics to include in
75   * this response.
76   * @opt_param int start-index An index of the first entity to retrieve. Use this
77   * parameter as a pagination mechanism along with the max-results parameter.
78   * @return CustomMetrics
79   */
80  public function listManagementCustomMetrics($accountId, $webPropertyId, $optParams = [])
81  {
82    $params = ['accountId' => $accountId, 'webPropertyId' => $webPropertyId];
83    $params = array_merge($params, $optParams);
84    return $this->call('list', [$params], CustomMetrics::class);
85  }
86  /**
87   * Updates an existing custom metric. This method supports patch semantics.
88   * (customMetrics.patch)
89   *
90   * @param string $accountId Account ID for the custom metric to update.
91   * @param string $webPropertyId Web property ID for the custom metric to update.
92   * @param string $customMetricId Custom metric ID for the custom metric to
93   * update.
94   * @param CustomMetric $postBody
95   * @param array $optParams Optional parameters.
96   *
97   * @opt_param bool ignoreCustomDataSourceLinks Force the update and ignore any
98   * warnings related to the custom metric being linked to a custom data source /
99   * data set.
100   * @return CustomMetric
101   */
102  public function patch($accountId, $webPropertyId, $customMetricId, CustomMetric $postBody, $optParams = [])
103  {
104    $params = ['accountId' => $accountId, 'webPropertyId' => $webPropertyId, 'customMetricId' => $customMetricId, 'postBody' => $postBody];
105    $params = array_merge($params, $optParams);
106    return $this->call('patch', [$params], CustomMetric::class);
107  }
108  /**
109   * Updates an existing custom metric. (customMetrics.update)
110   *
111   * @param string $accountId Account ID for the custom metric to update.
112   * @param string $webPropertyId Web property ID for the custom metric to update.
113   * @param string $customMetricId Custom metric ID for the custom metric to
114   * update.
115   * @param CustomMetric $postBody
116   * @param array $optParams Optional parameters.
117   *
118   * @opt_param bool ignoreCustomDataSourceLinks Force the update and ignore any
119   * warnings related to the custom metric being linked to a custom data source /
120   * data set.
121   * @return CustomMetric
122   */
123  public function update($accountId, $webPropertyId, $customMetricId, CustomMetric $postBody, $optParams = [])
124  {
125    $params = ['accountId' => $accountId, 'webPropertyId' => $webPropertyId, 'customMetricId' => $customMetricId, 'postBody' => $postBody];
126    $params = array_merge($params, $optParams);
127    return $this->call('update', [$params], CustomMetric::class);
128  }
129}
130
131// Adding a class alias for backwards compatibility with the previous class name.
132class_alias(ManagementCustomMetrics::class, 'Google_Service_Analytics_Resource_ManagementCustomMetrics');
133