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\RecommendationsAI\Resource;
19
20use Google\Service\RecommendationsAI\GoogleApiHttpBody;
21use Google\Service\RecommendationsAI\GoogleCloudRecommendationengineV1beta1ImportUserEventsRequest;
22use Google\Service\RecommendationsAI\GoogleCloudRecommendationengineV1beta1ListUserEventsResponse;
23use Google\Service\RecommendationsAI\GoogleCloudRecommendationengineV1beta1PurgeUserEventsRequest;
24use Google\Service\RecommendationsAI\GoogleCloudRecommendationengineV1beta1RejoinUserEventsRequest;
25use Google\Service\RecommendationsAI\GoogleCloudRecommendationengineV1beta1UserEvent;
26use Google\Service\RecommendationsAI\GoogleLongrunningOperation;
27
28/**
29 * The "userEvents" collection of methods.
30 * Typical usage is:
31 *  <code>
32 *   $recommendationengineService = new Google\Service\RecommendationsAI(...);
33 *   $userEvents = $recommendationengineService->userEvents;
34 *  </code>
35 */
36class ProjectsLocationsCatalogsEventStoresUserEvents extends \Google\Service\Resource
37{
38  /**
39   * Writes a single user event from the browser. This uses a GET request to due
40   * to browser restriction of POST-ing to a 3rd party domain. This method is used
41   * only by the Recommendations AI JavaScript pixel. Users should not call this
42   * method directly. (userEvents.collect)
43   *
44   * @param string $parent Required. The parent eventStore name, such as `projects
45   * /1234/locations/global/catalogs/default_catalog/eventStores/default_event_sto
46   * re`.
47   * @param array $optParams Optional parameters.
48   *
49   * @opt_param string ets Optional. The event timestamp in milliseconds. This
50   * prevents browser caching of otherwise identical get requests. The name is
51   * abbreviated to reduce the payload bytes.
52   * @opt_param string uri Optional. The url including cgi-parameters but
53   * excluding the hash fragment. The URL must be truncated to 1.5K bytes to
54   * conservatively be under the 2K bytes. This is often more useful than the
55   * referer url, because many browsers only send the domain for 3rd party
56   * requests.
57   * @opt_param string userEvent Required. URL encoded UserEvent proto.
58   * @return GoogleApiHttpBody
59   */
60  public function collect($parent, $optParams = [])
61  {
62    $params = ['parent' => $parent];
63    $params = array_merge($params, $optParams);
64    return $this->call('collect', [$params], GoogleApiHttpBody::class);
65  }
66  /**
67   * Bulk import of User events. Request processing might be synchronous. Events
68   * that already exist are skipped. Use this method for backfilling historical
69   * user events. Operation.response is of type ImportResponse. Note that it is
70   * possible for a subset of the items to be successfully inserted.
71   * Operation.metadata is of type ImportMetadata. (userEvents.import)
72   *
73   * @param string $parent Required. `projects/1234/locations/global/catalogs/defa
74   * ult_catalog/eventStores/default_event_store`
75   * @param GoogleCloudRecommendationengineV1beta1ImportUserEventsRequest $postBody
76   * @param array $optParams Optional parameters.
77   * @return GoogleLongrunningOperation
78   */
79  public function import($parent, GoogleCloudRecommendationengineV1beta1ImportUserEventsRequest $postBody, $optParams = [])
80  {
81    $params = ['parent' => $parent, 'postBody' => $postBody];
82    $params = array_merge($params, $optParams);
83    return $this->call('import', [$params], GoogleLongrunningOperation::class);
84  }
85  /**
86   * Gets a list of user events within a time range, with potential filtering. The
87   * method does not list unjoined user events. Unjoined user event definition:
88   * when a user event is ingested from Recommendations AI User Event APIs, the
89   * catalog item included in the user event is connected with the current
90   * catalog. If a catalog item of the ingested event is not in the current
91   * catalog, it could lead to degraded model quality. This is called an unjoined
92   * event. (userEvents.listProjectsLocationsCatalogsEventStoresUserEvents)
93   *
94   * @param string $parent Required. The parent eventStore resource name, such as
95   * `projects/locations/catalogs/default_catalog/eventStores/default_event_store`
96   * .
97   * @param array $optParams Optional parameters.
98   *
99   * @opt_param string filter Optional. Filtering expression to specify
100   * restrictions over returned events. This is a sequence of terms, where each
101   * term applies some kind of a restriction to the returned user events. Use this
102   * expression to restrict results to a specific time range, or filter events by
103   * eventType. eg: eventTime > "2012-04-23T18:25:43.511Z"
104   * eventsMissingCatalogItems eventTime<"2012-04-23T18:25:43.511Z"
105   * eventType=search We expect only 3 types of fields: * eventTime: this can be
106   * specified a maximum of 2 times, once with a less than operator and once with
107   * a greater than operator. The eventTime restrict should result in one
108   * contiguous valid eventTime range. * eventType: only 1 eventType restriction
109   * can be specified. * eventsMissingCatalogItems: specififying this will
110   * restrict results to events for which catalog items were not found in the
111   * catalog. The default behavior is to return only those events for which
112   * catalog items were found. Some examples of valid filters expressions: *
113   * Example 1: eventTime > "2012-04-23T18:25:43.511Z" eventTime <
114   * "2012-04-23T18:30:43.511Z" * Example 2: eventTime >
115   * "2012-04-23T18:25:43.511Z" eventType = detail-page-view * Example 3:
116   * eventsMissingCatalogItems eventType = search eventTime <
117   * "2018-04-23T18:30:43.511Z" * Example 4: eventTime >
118   * "2012-04-23T18:25:43.511Z" * Example 5: eventType = search * Example 6:
119   * eventsMissingCatalogItems
120   * @opt_param int pageSize Optional. Maximum number of results to return per
121   * page. If zero, the service will choose a reasonable default.
122   * @opt_param string pageToken Optional. The previous
123   * ListUserEventsResponse.next_page_token.
124   * @return GoogleCloudRecommendationengineV1beta1ListUserEventsResponse
125   */
126  public function listProjectsLocationsCatalogsEventStoresUserEvents($parent, $optParams = [])
127  {
128    $params = ['parent' => $parent];
129    $params = array_merge($params, $optParams);
130    return $this->call('list', [$params], GoogleCloudRecommendationengineV1beta1ListUserEventsResponse::class);
131  }
132  /**
133   * Deletes permanently all user events specified by the filter provided.
134   * Depending on the number of events specified by the filter, this operation
135   * could take hours or days to complete. To test a filter, use the list command
136   * first. (userEvents.purge)
137   *
138   * @param string $parent Required. The resource name of the event_store under
139   * which the events are created. The format is `projects/${projectId}/locations/
140   * global/catalogs/${catalogId}/eventStores/${eventStoreId}`
141   * @param GoogleCloudRecommendationengineV1beta1PurgeUserEventsRequest $postBody
142   * @param array $optParams Optional parameters.
143   * @return GoogleLongrunningOperation
144   */
145  public function purge($parent, GoogleCloudRecommendationengineV1beta1PurgeUserEventsRequest $postBody, $optParams = [])
146  {
147    $params = ['parent' => $parent, 'postBody' => $postBody];
148    $params = array_merge($params, $optParams);
149    return $this->call('purge', [$params], GoogleLongrunningOperation::class);
150  }
151  /**
152   * Triggers a user event rejoin operation with latest catalog data. Events will
153   * not be annotated with detailed catalog information if catalog item is missing
154   * at the time the user event is ingested, and these events are stored as
155   * unjoined events with a limited usage on training and serving. This API can be
156   * used to trigger a 'join' operation on specified events with latest version of
157   * catalog items. It can also be used to correct events joined with wrong
158   * catalog items. (userEvents.rejoin)
159   *
160   * @param string $parent Required. Full resource name of user event, such as `pr
161   * ojects/locations/catalogs/default_catalog/eventStores/default_event_store`.
162   * @param GoogleCloudRecommendationengineV1beta1RejoinUserEventsRequest $postBody
163   * @param array $optParams Optional parameters.
164   * @return GoogleLongrunningOperation
165   */
166  public function rejoin($parent, GoogleCloudRecommendationengineV1beta1RejoinUserEventsRequest $postBody, $optParams = [])
167  {
168    $params = ['parent' => $parent, 'postBody' => $postBody];
169    $params = array_merge($params, $optParams);
170    return $this->call('rejoin', [$params], GoogleLongrunningOperation::class);
171  }
172  /**
173   * Writes a single user event. (userEvents.write)
174   *
175   * @param string $parent Required. The parent eventStore resource name, such as
176   * "projects/1234/locations/global/catalogs/default_catalog/eventStores/default_
177   * event_store".
178   * @param GoogleCloudRecommendationengineV1beta1UserEvent $postBody
179   * @param array $optParams Optional parameters.
180   * @return GoogleCloudRecommendationengineV1beta1UserEvent
181   */
182  public function write($parent, GoogleCloudRecommendationengineV1beta1UserEvent $postBody, $optParams = [])
183  {
184    $params = ['parent' => $parent, 'postBody' => $postBody];
185    $params = array_merge($params, $optParams);
186    return $this->call('write', [$params], GoogleCloudRecommendationengineV1beta1UserEvent::class);
187  }
188}
189
190// Adding a class alias for backwards compatibility with the previous class name.
191class_alias(ProjectsLocationsCatalogsEventStoresUserEvents::class, 'Google_Service_RecommendationsAI_Resource_ProjectsLocationsCatalogsEventStoresUserEvents');
192