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\Logging\Resource;
19
20use Google\Service\Logging\ListSinksResponse;
21use Google\Service\Logging\LogSink;
22use Google\Service\Logging\LoggingEmpty;
23
24/**
25 * The "sinks" collection of methods.
26 * Typical usage is:
27 *  <code>
28 *   $loggingService = new Google\Service\Logging(...);
29 *   $sinks = $loggingService->sinks;
30 *  </code>
31 */
32class Sinks extends \Google\Service\Resource
33{
34  /**
35   * Creates a sink that exports specified log entries to a destination. The
36   * export of newly-ingested log entries begins immediately, unless the sink's
37   * writer_identity is not permitted to write to the destination. A sink can
38   * export log entries only from the resource owning the sink. (sinks.create)
39   *
40   * @param string $parent Required. The resource in which to create the sink:
41   * "projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]"
42   * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" For
43   * examples:"projects/my-project" "organizations/123456789"
44   * @param LogSink $postBody
45   * @param array $optParams Optional parameters.
46   *
47   * @opt_param bool uniqueWriterIdentity Optional. Determines the kind of IAM
48   * identity returned as writer_identity in the new sink. If this value is
49   * omitted or set to false, and if the sink's parent is a project, then the
50   * value returned as writer_identity is the same group or service account used
51   * by Cloud Logging before the addition of writer identities to this API. The
52   * sink's destination must be in the same project as the sink itself.If this
53   * field is set to true, or if the sink is owned by a non-project resource such
54   * as an organization, then the value of writer_identity will be a unique
55   * service account used only for exports from the new sink. For more
56   * information, see writer_identity in LogSink.
57   * @return LogSink
58   */
59  public function create($parent, LogSink $postBody, $optParams = [])
60  {
61    $params = ['parent' => $parent, 'postBody' => $postBody];
62    $params = array_merge($params, $optParams);
63    return $this->call('create', [$params], LogSink::class);
64  }
65  /**
66   * Deletes a sink. If the sink has a unique writer_identity, then that service
67   * account is also deleted. (sinks.delete)
68   *
69   * @param string $sinkName Required. The full resource name of the sink to
70   * delete, including the parent resource and the sink identifier:
71   * "projects/[PROJECT_ID]/sinks/[SINK_ID]"
72   * "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]"
73   * "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]"
74   * "folders/[FOLDER_ID]/sinks/[SINK_ID]" For example:"projects/my-project/sinks
75   * /my-sink"
76   * @param array $optParams Optional parameters.
77   * @return LoggingEmpty
78   */
79  public function delete($sinkName, $optParams = [])
80  {
81    $params = ['sinkName' => $sinkName];
82    $params = array_merge($params, $optParams);
83    return $this->call('delete', [$params], LoggingEmpty::class);
84  }
85  /**
86   * Gets a sink. (sinks.get)
87   *
88   * @param string $sinkName Required. The resource name of the sink:
89   * "projects/[PROJECT_ID]/sinks/[SINK_ID]"
90   * "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]"
91   * "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]"
92   * "folders/[FOLDER_ID]/sinks/[SINK_ID]" For example:"projects/my-project/sinks
93   * /my-sink"
94   * @param array $optParams Optional parameters.
95   * @return LogSink
96   */
97  public function get($sinkName, $optParams = [])
98  {
99    $params = ['sinkName' => $sinkName];
100    $params = array_merge($params, $optParams);
101    return $this->call('get', [$params], LogSink::class);
102  }
103  /**
104   * Lists sinks. (sinks.listSinks)
105   *
106   * @param string $parent Required. The parent resource whose sinks are to be
107   * listed: "projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]"
108   * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]"
109   * @param array $optParams Optional parameters.
110   *
111   * @opt_param int pageSize Optional. The maximum number of results to return
112   * from this request. Non-positive values are ignored. The presence of
113   * nextPageToken in the response indicates that more results might be available.
114   * @opt_param string pageToken Optional. If present, then retrieve the next
115   * batch of results from the preceding call to this method. pageToken must be
116   * the value of nextPageToken from the previous response. The values of other
117   * method parameters should be identical to those in the previous call.
118   * @return ListSinksResponse
119   */
120  public function listSinks($parent, $optParams = [])
121  {
122    $params = ['parent' => $parent];
123    $params = array_merge($params, $optParams);
124    return $this->call('list', [$params], ListSinksResponse::class);
125  }
126  /**
127   * Updates a sink. This method replaces the following fields in the existing
128   * sink with values from the new sink: destination, and filter.The updated sink
129   * might also have a new writer_identity; see the unique_writer_identity field.
130   * (sinks.update)
131   *
132   * @param string $sinkName Required. The full resource name of the sink to
133   * update, including the parent resource and the sink identifier:
134   * "projects/[PROJECT_ID]/sinks/[SINK_ID]"
135   * "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]"
136   * "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]"
137   * "folders/[FOLDER_ID]/sinks/[SINK_ID]" For example:"projects/my-project/sinks
138   * /my-sink"
139   * @param LogSink $postBody
140   * @param array $optParams Optional parameters.
141   *
142   * @opt_param bool uniqueWriterIdentity Optional. See sinks.create for a
143   * description of this field. When updating a sink, the effect of this field on
144   * the value of writer_identity in the updated sink depends on both the old and
145   * new values of this field: If the old and new values of this field are both
146   * false or both true, then there is no change to the sink's writer_identity. If
147   * the old value is false and the new value is true, then writer_identity is
148   * changed to a unique service account. It is an error if the old value is true
149   * and the new value is set to false or defaulted to false.
150   * @opt_param string updateMask Optional. Field mask that specifies the fields
151   * in sink that need an update. A sink field will be overwritten if, and only
152   * if, it is in the update mask. name and output only fields cannot be
153   * updated.An empty updateMask is temporarily treated as using the following
154   * mask for backwards compatibility
155   * purposes:destination,filter,includeChildrenAt some point in the future,
156   * behavior will be removed and specifying an empty updateMask will be an
157   * error.For a detailed FieldMask definition, see https://developers.google.com
158   * /protocol-buffers/docs/reference/google.protobuf#google.protobuf.FieldMaskFor
159   * example: updateMask=filter
160   * @return LogSink
161   */
162  public function update($sinkName, LogSink $postBody, $optParams = [])
163  {
164    $params = ['sinkName' => $sinkName, 'postBody' => $postBody];
165    $params = array_merge($params, $optParams);
166    return $this->call('update', [$params], LogSink::class);
167  }
168}
169
170// Adding a class alias for backwards compatibility with the previous class name.
171class_alias(Sinks::class, 'Google_Service_Logging_Resource_Sinks');
172