[e3d4e0a] | 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 |
|
---|
| 18 | namespace Google\Service\Monitoring\Resource;
|
---|
| 19 |
|
---|
| 20 | use Google\Service\Monitoring\AlertPolicy;
|
---|
| 21 | use Google\Service\Monitoring\ListAlertPoliciesResponse;
|
---|
| 22 | use Google\Service\Monitoring\MonitoringEmpty;
|
---|
| 23 |
|
---|
| 24 | /**
|
---|
| 25 | * The "alertPolicies" collection of methods.
|
---|
| 26 | * Typical usage is:
|
---|
| 27 | * <code>
|
---|
| 28 | * $monitoringService = new Google\Service\Monitoring(...);
|
---|
| 29 | * $alertPolicies = $monitoringService->projects_alertPolicies;
|
---|
| 30 | * </code>
|
---|
| 31 | */
|
---|
| 32 | class ProjectsAlertPolicies extends \Google\Service\Resource
|
---|
| 33 | {
|
---|
| 34 | /**
|
---|
| 35 | * Creates a new alerting policy.Design your application to single-thread API
|
---|
| 36 | * calls that modify the state of alerting policies in a single project. This
|
---|
| 37 | * includes calls to CreateAlertPolicy, DeleteAlertPolicy and UpdateAlertPolicy.
|
---|
| 38 | * (alertPolicies.create)
|
---|
| 39 | *
|
---|
| 40 | * @param string $name Required. The project
|
---|
| 41 | * (https://cloud.google.com/monitoring/api/v3#project_name) in which to create
|
---|
| 42 | * the alerting policy. The format is: projects/[PROJECT_ID_OR_NUMBER] Note that
|
---|
| 43 | * this field names the parent container in which the alerting policy will be
|
---|
| 44 | * written, not the name of the created policy. |name| must be a host project of
|
---|
| 45 | * a Metrics Scope, otherwise INVALID_ARGUMENT error will return. The alerting
|
---|
| 46 | * policy that is returned will have a name that contains a normalized
|
---|
| 47 | * representation of this name as a prefix but adds a suffix of the form
|
---|
| 48 | * /alertPolicies/[ALERT_POLICY_ID], identifying the policy in the container.
|
---|
| 49 | * @param AlertPolicy $postBody
|
---|
| 50 | * @param array $optParams Optional parameters.
|
---|
| 51 | * @return AlertPolicy
|
---|
| 52 | * @throws \Google\Service\Exception
|
---|
| 53 | */
|
---|
| 54 | public function create($name, AlertPolicy $postBody, $optParams = [])
|
---|
| 55 | {
|
---|
| 56 | $params = ['name' => $name, 'postBody' => $postBody];
|
---|
| 57 | $params = array_merge($params, $optParams);
|
---|
| 58 | return $this->call('create', [$params], AlertPolicy::class);
|
---|
| 59 | }
|
---|
| 60 | /**
|
---|
| 61 | * Deletes an alerting policy.Design your application to single-thread API calls
|
---|
| 62 | * that modify the state of alerting policies in a single project. This includes
|
---|
| 63 | * calls to CreateAlertPolicy, DeleteAlertPolicy and UpdateAlertPolicy.
|
---|
| 64 | * (alertPolicies.delete)
|
---|
| 65 | *
|
---|
| 66 | * @param string $name Required. The alerting policy to delete. The format is:
|
---|
| 67 | * projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID] For more
|
---|
| 68 | * information, see AlertPolicy.
|
---|
| 69 | * @param array $optParams Optional parameters.
|
---|
| 70 | * @return MonitoringEmpty
|
---|
| 71 | * @throws \Google\Service\Exception
|
---|
| 72 | */
|
---|
| 73 | public function delete($name, $optParams = [])
|
---|
| 74 | {
|
---|
| 75 | $params = ['name' => $name];
|
---|
| 76 | $params = array_merge($params, $optParams);
|
---|
| 77 | return $this->call('delete', [$params], MonitoringEmpty::class);
|
---|
| 78 | }
|
---|
| 79 | /**
|
---|
| 80 | * Gets a single alerting policy. (alertPolicies.get)
|
---|
| 81 | *
|
---|
| 82 | * @param string $name Required. The alerting policy to retrieve. The format is:
|
---|
| 83 | * projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID]
|
---|
| 84 | * @param array $optParams Optional parameters.
|
---|
| 85 | * @return AlertPolicy
|
---|
| 86 | * @throws \Google\Service\Exception
|
---|
| 87 | */
|
---|
| 88 | public function get($name, $optParams = [])
|
---|
| 89 | {
|
---|
| 90 | $params = ['name' => $name];
|
---|
| 91 | $params = array_merge($params, $optParams);
|
---|
| 92 | return $this->call('get', [$params], AlertPolicy::class);
|
---|
| 93 | }
|
---|
| 94 | /**
|
---|
| 95 | * Lists the existing alerting policies for the workspace.
|
---|
| 96 | * (alertPolicies.listProjectsAlertPolicies)
|
---|
| 97 | *
|
---|
| 98 | * @param string $name Required. The project
|
---|
| 99 | * (https://cloud.google.com/monitoring/api/v3#project_name) whose alert
|
---|
| 100 | * policies are to be listed. The format is: projects/[PROJECT_ID_OR_NUMBER]
|
---|
| 101 | * Note that this field names the parent container in which the alerting
|
---|
| 102 | * policies to be listed are stored. To retrieve a single alerting policy by
|
---|
| 103 | * name, use the GetAlertPolicy operation, instead.
|
---|
| 104 | * @param array $optParams Optional parameters.
|
---|
| 105 | *
|
---|
| 106 | * @opt_param string filter Optional. If provided, this field specifies the
|
---|
| 107 | * criteria that must be met by alert policies to be included in the
|
---|
| 108 | * response.For more details, see sorting and filtering
|
---|
| 109 | * (https://cloud.google.com/monitoring/api/v3/sorting-and-filtering).
|
---|
| 110 | * @opt_param string orderBy Optional. A comma-separated list of fields by which
|
---|
| 111 | * to sort the result. Supports the same set of field references as the filter
|
---|
| 112 | * field. Entries can be prefixed with a minus sign to sort by the field in
|
---|
| 113 | * descending order.For more details, see sorting and filtering
|
---|
| 114 | * (https://cloud.google.com/monitoring/api/v3/sorting-and-filtering).
|
---|
| 115 | * @opt_param int pageSize Optional. The maximum number of results to return in
|
---|
| 116 | * a single response.
|
---|
| 117 | * @opt_param string pageToken Optional. If this field is not empty then it must
|
---|
| 118 | * contain the nextPageToken value returned by a previous call to this method.
|
---|
| 119 | * Using this field causes the method to return more results from the previous
|
---|
| 120 | * method call.
|
---|
| 121 | * @return ListAlertPoliciesResponse
|
---|
| 122 | * @throws \Google\Service\Exception
|
---|
| 123 | */
|
---|
| 124 | public function listProjectsAlertPolicies($name, $optParams = [])
|
---|
| 125 | {
|
---|
| 126 | $params = ['name' => $name];
|
---|
| 127 | $params = array_merge($params, $optParams);
|
---|
| 128 | return $this->call('list', [$params], ListAlertPoliciesResponse::class);
|
---|
| 129 | }
|
---|
| 130 | /**
|
---|
| 131 | * Updates an alerting policy. You can either replace the entire policy with a
|
---|
| 132 | * new one or replace only certain fields in the current alerting policy by
|
---|
| 133 | * specifying the fields to be updated via updateMask. Returns the updated
|
---|
| 134 | * alerting policy.Design your application to single-thread API calls that
|
---|
| 135 | * modify the state of alerting policies in a single project. This includes
|
---|
| 136 | * calls to CreateAlertPolicy, DeleteAlertPolicy and UpdateAlertPolicy.
|
---|
| 137 | * (alertPolicies.patch)
|
---|
| 138 | *
|
---|
| 139 | * @param string $name Identifier. Required if the policy exists. The resource
|
---|
| 140 | * name for this policy. The format is:
|
---|
| 141 | * projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID]
|
---|
| 142 | * [ALERT_POLICY_ID] is assigned by Cloud Monitoring when the policy is created.
|
---|
| 143 | * When calling the alertPolicies.create method, do not include the name field
|
---|
| 144 | * in the alerting policy passed as part of the request.
|
---|
| 145 | * @param AlertPolicy $postBody
|
---|
| 146 | * @param array $optParams Optional parameters.
|
---|
| 147 | *
|
---|
| 148 | * @opt_param string updateMask Optional. A list of alerting policy field names.
|
---|
| 149 | * If this field is not empty, each listed field in the existing alerting policy
|
---|
| 150 | * is set to the value of the corresponding field in the supplied policy
|
---|
| 151 | * (alert_policy), or to the field's default value if the field is not in the
|
---|
| 152 | * supplied alerting policy. Fields not listed retain their previous
|
---|
| 153 | * value.Examples of valid field masks include display_name, documentation,
|
---|
| 154 | * documentation.content, documentation.mime_type, user_labels,
|
---|
| 155 | * user_label.nameofkey, enabled, conditions, combiner, etc.If this field is
|
---|
| 156 | * empty, then the supplied alerting policy replaces the existing policy. It is
|
---|
| 157 | * the same as deleting the existing policy and adding the supplied policy,
|
---|
| 158 | * except for the following: The new policy will have the same [ALERT_POLICY_ID]
|
---|
| 159 | * as the former policy. This gives you continuity with the former policy in
|
---|
| 160 | * your notifications and incidents. Conditions in the new policy will keep
|
---|
| 161 | * their former [CONDITION_ID] if the supplied condition includes the name field
|
---|
| 162 | * with that [CONDITION_ID]. If the supplied condition omits the name field,
|
---|
| 163 | * then a new [CONDITION_ID] is created.
|
---|
| 164 | * @return AlertPolicy
|
---|
| 165 | * @throws \Google\Service\Exception
|
---|
| 166 | */
|
---|
| 167 | public function patch($name, AlertPolicy $postBody, $optParams = [])
|
---|
| 168 | {
|
---|
| 169 | $params = ['name' => $name, 'postBody' => $postBody];
|
---|
| 170 | $params = array_merge($params, $optParams);
|
---|
| 171 | return $this->call('patch', [$params], AlertPolicy::class);
|
---|
| 172 | }
|
---|
| 173 | }
|
---|
| 174 |
|
---|
| 175 | // Adding a class alias for backwards compatibility with the previous class name.
|
---|
| 176 | class_alias(ProjectsAlertPolicies::class, 'Google_Service_Monitoring_Resource_ProjectsAlertPolicies');
|
---|