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\Pubsub\Resource;
|
---|
19 |
|
---|
20 | use Google\Service\Pubsub\ListTopicsResponse;
|
---|
21 | use Google\Service\Pubsub\Policy;
|
---|
22 | use Google\Service\Pubsub\PublishRequest;
|
---|
23 | use Google\Service\Pubsub\PublishResponse;
|
---|
24 | use Google\Service\Pubsub\PubsubEmpty;
|
---|
25 | use Google\Service\Pubsub\SetIamPolicyRequest;
|
---|
26 | use Google\Service\Pubsub\TestIamPermissionsRequest;
|
---|
27 | use Google\Service\Pubsub\TestIamPermissionsResponse;
|
---|
28 | use Google\Service\Pubsub\Topic;
|
---|
29 | use Google\Service\Pubsub\UpdateTopicRequest;
|
---|
30 |
|
---|
31 | /**
|
---|
32 | * The "topics" collection of methods.
|
---|
33 | * Typical usage is:
|
---|
34 | * <code>
|
---|
35 | * $pubsubService = new Google\Service\Pubsub(...);
|
---|
36 | * $topics = $pubsubService->projects_topics;
|
---|
37 | * </code>
|
---|
38 | */
|
---|
39 | class ProjectsTopics extends \Google\Service\Resource
|
---|
40 | {
|
---|
41 | /**
|
---|
42 | * Creates the given topic with the given name. See the [resource name rules]
|
---|
43 | * (https://cloud.google.com/pubsub/docs/pubsub-basics#resource_names).
|
---|
44 | * (topics.create)
|
---|
45 | *
|
---|
46 | * @param string $name Required. The name of the topic. It must have the format
|
---|
47 | * `"projects/{project}/topics/{topic}"`. `{topic}` must start with a letter,
|
---|
48 | * and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`),
|
---|
49 | * underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent signs
|
---|
50 | * (`%`). It must be between 3 and 255 characters in length, and it must not
|
---|
51 | * start with `"goog"`.
|
---|
52 | * @param Topic $postBody
|
---|
53 | * @param array $optParams Optional parameters.
|
---|
54 | * @return Topic
|
---|
55 | * @throws \Google\Service\Exception
|
---|
56 | */
|
---|
57 | public function create($name, Topic $postBody, $optParams = [])
|
---|
58 | {
|
---|
59 | $params = ['name' => $name, 'postBody' => $postBody];
|
---|
60 | $params = array_merge($params, $optParams);
|
---|
61 | return $this->call('create', [$params], Topic::class);
|
---|
62 | }
|
---|
63 | /**
|
---|
64 | * Deletes the topic with the given name. Returns `NOT_FOUND` if the topic does
|
---|
65 | * not exist. After a topic is deleted, a new topic may be created with the same
|
---|
66 | * name; this is an entirely new topic with none of the old configuration or
|
---|
67 | * subscriptions. Existing subscriptions to this topic are not deleted, but
|
---|
68 | * their `topic` field is set to `_deleted-topic_`. (topics.delete)
|
---|
69 | *
|
---|
70 | * @param string $topic Required. Name of the topic to delete. Format is
|
---|
71 | * `projects/{project}/topics/{topic}`.
|
---|
72 | * @param array $optParams Optional parameters.
|
---|
73 | * @return PubsubEmpty
|
---|
74 | * @throws \Google\Service\Exception
|
---|
75 | */
|
---|
76 | public function delete($topic, $optParams = [])
|
---|
77 | {
|
---|
78 | $params = ['topic' => $topic];
|
---|
79 | $params = array_merge($params, $optParams);
|
---|
80 | return $this->call('delete', [$params], PubsubEmpty::class);
|
---|
81 | }
|
---|
82 | /**
|
---|
83 | * Gets the configuration of a topic. (topics.get)
|
---|
84 | *
|
---|
85 | * @param string $topic Required. The name of the topic to get. Format is
|
---|
86 | * `projects/{project}/topics/{topic}`.
|
---|
87 | * @param array $optParams Optional parameters.
|
---|
88 | * @return Topic
|
---|
89 | * @throws \Google\Service\Exception
|
---|
90 | */
|
---|
91 | public function get($topic, $optParams = [])
|
---|
92 | {
|
---|
93 | $params = ['topic' => $topic];
|
---|
94 | $params = array_merge($params, $optParams);
|
---|
95 | return $this->call('get', [$params], Topic::class);
|
---|
96 | }
|
---|
97 | /**
|
---|
98 | * Gets the access control policy for a resource. Returns an empty policy if the
|
---|
99 | * resource exists and does not have a policy set. (topics.getIamPolicy)
|
---|
100 | *
|
---|
101 | * @param string $resource REQUIRED: The resource for which the policy is being
|
---|
102 | * requested. See [Resource
|
---|
103 | * names](https://cloud.google.com/apis/design/resource_names) for the
|
---|
104 | * appropriate value for this field.
|
---|
105 | * @param array $optParams Optional parameters.
|
---|
106 | *
|
---|
107 | * @opt_param int options.requestedPolicyVersion Optional. The maximum policy
|
---|
108 | * version that will be used to format the policy. Valid values are 0, 1, and 3.
|
---|
109 | * Requests specifying an invalid value will be rejected. Requests for policies
|
---|
110 | * with any conditional role bindings must specify version 3. Policies with no
|
---|
111 | * conditional role bindings may specify any valid value or leave the field
|
---|
112 | * unset. The policy in the response might use the policy version that you
|
---|
113 | * specified, or it might use a lower policy version. For example, if you
|
---|
114 | * specify version 3, but the policy has no conditional role bindings, the
|
---|
115 | * response uses version 1. To learn which resources support conditions in their
|
---|
116 | * IAM policies, see the [IAM
|
---|
117 | * documentation](https://cloud.google.com/iam/help/conditions/resource-
|
---|
118 | * policies).
|
---|
119 | * @return Policy
|
---|
120 | * @throws \Google\Service\Exception
|
---|
121 | */
|
---|
122 | public function getIamPolicy($resource, $optParams = [])
|
---|
123 | {
|
---|
124 | $params = ['resource' => $resource];
|
---|
125 | $params = array_merge($params, $optParams);
|
---|
126 | return $this->call('getIamPolicy', [$params], Policy::class);
|
---|
127 | }
|
---|
128 | /**
|
---|
129 | * Lists matching topics. (topics.listProjectsTopics)
|
---|
130 | *
|
---|
131 | * @param string $project Required. The name of the project in which to list
|
---|
132 | * topics. Format is `projects/{project-id}`.
|
---|
133 | * @param array $optParams Optional parameters.
|
---|
134 | *
|
---|
135 | * @opt_param int pageSize Optional. Maximum number of topics to return.
|
---|
136 | * @opt_param string pageToken Optional. The value returned by the last
|
---|
137 | * `ListTopicsResponse`; indicates that this is a continuation of a prior
|
---|
138 | * `ListTopics` call, and that the system should return the next page of data.
|
---|
139 | * @return ListTopicsResponse
|
---|
140 | * @throws \Google\Service\Exception
|
---|
141 | */
|
---|
142 | public function listProjectsTopics($project, $optParams = [])
|
---|
143 | {
|
---|
144 | $params = ['project' => $project];
|
---|
145 | $params = array_merge($params, $optParams);
|
---|
146 | return $this->call('list', [$params], ListTopicsResponse::class);
|
---|
147 | }
|
---|
148 | /**
|
---|
149 | * Updates an existing topic by updating the fields specified in the update
|
---|
150 | * mask. Note that certain properties of a topic are not modifiable.
|
---|
151 | * (topics.patch)
|
---|
152 | *
|
---|
153 | * @param string $name Required. The name of the topic. It must have the format
|
---|
154 | * `"projects/{project}/topics/{topic}"`. `{topic}` must start with a letter,
|
---|
155 | * and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`),
|
---|
156 | * underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent signs
|
---|
157 | * (`%`). It must be between 3 and 255 characters in length, and it must not
|
---|
158 | * start with `"goog"`.
|
---|
159 | * @param UpdateTopicRequest $postBody
|
---|
160 | * @param array $optParams Optional parameters.
|
---|
161 | * @return Topic
|
---|
162 | * @throws \Google\Service\Exception
|
---|
163 | */
|
---|
164 | public function patch($name, UpdateTopicRequest $postBody, $optParams = [])
|
---|
165 | {
|
---|
166 | $params = ['name' => $name, 'postBody' => $postBody];
|
---|
167 | $params = array_merge($params, $optParams);
|
---|
168 | return $this->call('patch', [$params], Topic::class);
|
---|
169 | }
|
---|
170 | /**
|
---|
171 | * Adds one or more messages to the topic. Returns `NOT_FOUND` if the topic does
|
---|
172 | * not exist. (topics.publish)
|
---|
173 | *
|
---|
174 | * @param string $topic Required. The messages in the request will be published
|
---|
175 | * on this topic. Format is `projects/{project}/topics/{topic}`.
|
---|
176 | * @param PublishRequest $postBody
|
---|
177 | * @param array $optParams Optional parameters.
|
---|
178 | * @return PublishResponse
|
---|
179 | * @throws \Google\Service\Exception
|
---|
180 | */
|
---|
181 | public function publish($topic, PublishRequest $postBody, $optParams = [])
|
---|
182 | {
|
---|
183 | $params = ['topic' => $topic, 'postBody' => $postBody];
|
---|
184 | $params = array_merge($params, $optParams);
|
---|
185 | return $this->call('publish', [$params], PublishResponse::class);
|
---|
186 | }
|
---|
187 | /**
|
---|
188 | * Sets the access control policy on the specified resource. Replaces any
|
---|
189 | * existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and
|
---|
190 | * `PERMISSION_DENIED` errors. (topics.setIamPolicy)
|
---|
191 | *
|
---|
192 | * @param string $resource REQUIRED: The resource for which the policy is being
|
---|
193 | * specified. See [Resource
|
---|
194 | * names](https://cloud.google.com/apis/design/resource_names) for the
|
---|
195 | * appropriate value for this field.
|
---|
196 | * @param SetIamPolicyRequest $postBody
|
---|
197 | * @param array $optParams Optional parameters.
|
---|
198 | * @return Policy
|
---|
199 | * @throws \Google\Service\Exception
|
---|
200 | */
|
---|
201 | public function setIamPolicy($resource, SetIamPolicyRequest $postBody, $optParams = [])
|
---|
202 | {
|
---|
203 | $params = ['resource' => $resource, 'postBody' => $postBody];
|
---|
204 | $params = array_merge($params, $optParams);
|
---|
205 | return $this->call('setIamPolicy', [$params], Policy::class);
|
---|
206 | }
|
---|
207 | /**
|
---|
208 | * Returns permissions that a caller has on the specified resource. If the
|
---|
209 | * resource does not exist, this will return an empty set of permissions, not a
|
---|
210 | * `NOT_FOUND` error. Note: This operation is designed to be used for building
|
---|
211 | * permission-aware UIs and command-line tools, not for authorization checking.
|
---|
212 | * This operation may "fail open" without warning. (topics.testIamPermissions)
|
---|
213 | *
|
---|
214 | * @param string $resource REQUIRED: The resource for which the policy detail is
|
---|
215 | * being requested. See [Resource
|
---|
216 | * names](https://cloud.google.com/apis/design/resource_names) for the
|
---|
217 | * appropriate value for this field.
|
---|
218 | * @param TestIamPermissionsRequest $postBody
|
---|
219 | * @param array $optParams Optional parameters.
|
---|
220 | * @return TestIamPermissionsResponse
|
---|
221 | * @throws \Google\Service\Exception
|
---|
222 | */
|
---|
223 | public function testIamPermissions($resource, TestIamPermissionsRequest $postBody, $optParams = [])
|
---|
224 | {
|
---|
225 | $params = ['resource' => $resource, 'postBody' => $postBody];
|
---|
226 | $params = array_merge($params, $optParams);
|
---|
227 | return $this->call('testIamPermissions', [$params], TestIamPermissionsResponse::class);
|
---|
228 | }
|
---|
229 | }
|
---|
230 |
|
---|
231 | // Adding a class alias for backwards compatibility with the previous class name.
|
---|
232 | class_alias(ProjectsTopics::class, 'Google_Service_Pubsub_Resource_ProjectsTopics');
|
---|