@maxim_mazurok/gapi.client.cloudsearch-v1 0.0.20220801

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@maxim_mazurok/gapi.client.cloudsearch-v1",
3
+ "version": "0.0.20220801",
4
+ "description": "TypeScript typings for Cloud Search API v1",
5
+ "license": "MIT",
6
+ "author": {
7
+ "email": "maxim@mazurok.com",
8
+ "name": "Maxim Mazurok",
9
+ "url": "https://maxim.mazurok.com"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/Maxim-Mazurok/google-api-typings-generator.git"
14
+ },
15
+ "types": "index.d.ts",
16
+ "dependencies": {
17
+ "@types/gapi.client": "*",
18
+ "@types/gapi.client.discovery": "*"
19
+ }
20
+ }
package/readme.md ADDED
@@ -0,0 +1,152 @@
1
+ # TypeScript typings for Cloud Search API v1
2
+
3
+ Cloud Search provides cloud-based search capabilities over Google Workspace data. The Cloud Search API allows indexing of non-Google Workspace data into Cloud Search.
4
+ For detailed description please check [documentation](https://developers.google.com/cloud-search/docs/guides/).
5
+
6
+ ## Installing
7
+
8
+ Install typings for Cloud Search API:
9
+
10
+ ```
11
+ npm install @types/gapi.client.cloudsearch-v1 --save-dev
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ You need to initialize Google API client in your code:
17
+
18
+ ```typescript
19
+ gapi.load('client', () => {
20
+ // now we can use gapi.client
21
+ // ...
22
+ });
23
+ ```
24
+
25
+ Then load api client wrapper:
26
+
27
+ ```typescript
28
+ gapi.client.load('https://cloudsearch.googleapis.com/$discovery/rest?version=v1', () => {
29
+ // now we can use:
30
+ // gapi.client.cloudsearch
31
+ });
32
+ ```
33
+
34
+ ```typescript
35
+ // Deprecated, use discovery document URL, see https://github.com/google/google-api-javascript-client/blob/master/docs/reference.md#----gapiclientloadname----version----callback--
36
+ gapi.client.load('cloudsearch', 'v1', () => {
37
+ // now we can use:
38
+ // gapi.client.cloudsearch
39
+ });
40
+ ```
41
+
42
+ Don't forget to authenticate your client before sending any request to resources:
43
+
44
+ ```typescript
45
+ // declare client_id registered in Google Developers Console
46
+ var client_id = '',
47
+ scope = [
48
+ // Index and serve your organization's data with Cloud Search
49
+ 'https://www.googleapis.com/auth/cloud_search',
50
+
51
+ // Index and serve your organization's data with Cloud Search
52
+ 'https://www.googleapis.com/auth/cloud_search.debug',
53
+
54
+ // Index and serve your organization's data with Cloud Search
55
+ 'https://www.googleapis.com/auth/cloud_search.indexing',
56
+
57
+ // Search your organization's data in the Cloud Search index
58
+ 'https://www.googleapis.com/auth/cloud_search.query',
59
+
60
+ // Index and serve your organization's data with Cloud Search
61
+ 'https://www.googleapis.com/auth/cloud_search.settings',
62
+
63
+ // Index and serve your organization's data with Cloud Search
64
+ 'https://www.googleapis.com/auth/cloud_search.settings.indexing',
65
+
66
+ // Index and serve your organization's data with Cloud Search
67
+ 'https://www.googleapis.com/auth/cloud_search.settings.query',
68
+
69
+ // Index and serve your organization's data with Cloud Search
70
+ 'https://www.googleapis.com/auth/cloud_search.stats',
71
+
72
+ // Index and serve your organization's data with Cloud Search
73
+ 'https://www.googleapis.com/auth/cloud_search.stats.indexing',
74
+ ],
75
+ immediate = true;
76
+ // ...
77
+
78
+ gapi.auth.authorize(
79
+ { client_id: client_id, scope: scope, immediate: immediate },
80
+ authResult => {
81
+ if (authResult && !authResult.error) {
82
+ /* handle successful authorization */
83
+ } else {
84
+ /* handle authorization error */
85
+ }
86
+ });
87
+ ```
88
+
89
+ After that you can use Cloud Search API resources: <!-- TODO: make this work for multiple namespaces -->
90
+
91
+ ```typescript
92
+
93
+ /*
94
+ Uploads media for indexing. The upload endpoint supports direct and resumable upload protocols and is intended for large items that can not be [inlined during index requests](https://developers.google.com/cloud-search/docs/reference/rest/v1/indexing.datasources.items#itemcontent). To index large content: 1. Call indexing.datasources.items.upload with the item name to begin an upload session and retrieve the UploadItemRef. 1. Call media.upload to upload the content, as a streaming request, using the same resource name from the UploadItemRef from step 1. 1. Call indexing.datasources.items.index to index the item. Populate the [ItemContent](/cloud-search/docs/reference/rest/v1/indexing.datasources.items#ItemContent) with the UploadItemRef from step 1. For additional information, see [Create a content connector using the REST API](https://developers.google.com/cloud-search/docs/guides/content-connector#rest). **Note:** This API requires a service account to execute.
95
+ */
96
+ await gapi.client.cloudsearch.media.upload({ resourceName: "resourceName", });
97
+
98
+ /*
99
+ Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
100
+ */
101
+ await gapi.client.cloudsearch.operations.get({ name: "name", });
102
+
103
+ /*
104
+ The Cloud Search Query API provides the search method, which returns the most relevant results from a user query. The results can come from Google Workspace apps, such as Gmail or Google Drive, or they can come from data that you have indexed from a third party. **Note:** This API requires a standard end user account to execute. A service account can't perform Query API requests directly; to use a service account to perform queries, set up [Google Workspace domain-wide delegation of authority](https://developers.google.com/cloud-search/docs/guides/delegation/).
105
+ */
106
+ await gapi.client.cloudsearch.query.search({ });
107
+
108
+ /*
109
+ Provides suggestions for autocompleting the query. **Note:** This API requires a standard end user account to execute. A service account can't perform Query API requests directly; to use a service account to perform queries, set up [Google Workspace domain-wide delegation of authority](https://developers.google.com/cloud-search/docs/guides/delegation/).
110
+ */
111
+ await gapi.client.cloudsearch.query.suggest({ });
112
+
113
+ /*
114
+ Get customer settings. **Note:** This API requires an admin account to execute.
115
+ */
116
+ await gapi.client.cloudsearch.settings.getCustomer({ });
117
+
118
+ /*
119
+ Update customer settings. **Note:** This API requires an admin account to execute.
120
+ */
121
+ await gapi.client.cloudsearch.settings.updateCustomer({ });
122
+
123
+ /*
124
+ Gets indexed item statistics aggreggated across all data sources. This API only returns statistics for previous dates; it doesn't return statistics for the current day. **Note:** This API requires a standard end user account to execute.
125
+ */
126
+ await gapi.client.cloudsearch.stats.getIndex({ });
127
+
128
+ /*
129
+ Get the query statistics for customer. **Note:** This API requires a standard end user account to execute.
130
+ */
131
+ await gapi.client.cloudsearch.stats.getQuery({ });
132
+
133
+ /*
134
+ Get search application stats for customer. **Note:** This API requires a standard end user account to execute.
135
+ */
136
+ await gapi.client.cloudsearch.stats.getSearchapplication({ });
137
+
138
+ /*
139
+ Get the # of search sessions, % of successful sessions with a click query statistics for customer. **Note:** This API requires a standard end user account to execute.
140
+ */
141
+ await gapi.client.cloudsearch.stats.getSession({ });
142
+
143
+ /*
144
+ Get the users statistics for customer. **Note:** This API requires a standard end user account to execute.
145
+ */
146
+ await gapi.client.cloudsearch.stats.getUser({ });
147
+
148
+ /*
149
+ Enables `third party` support in Google Cloud Search. **Note:** This API requires an admin account to execute.
150
+ */
151
+ await gapi.client.cloudsearch.initializeCustomer({ });
152
+ ```