grafeas 0.3.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +3 -3
  3. data/LICENSE.md +201 -0
  4. data/MIGRATING.md +366 -0
  5. data/README.md +89 -27
  6. data/lib/grafeas.rb +36 -117
  7. data/lib/grafeas/version.rb +6 -2
  8. metadata +50 -75
  9. data/AUTHENTICATION.md +0 -177
  10. data/LICENSE +0 -201
  11. data/lib/grafeas/v1.rb +0 -155
  12. data/lib/grafeas/v1/attestation_pb.rb +0 -27
  13. data/lib/grafeas/v1/build_pb.rb +0 -23
  14. data/lib/grafeas/v1/common_pb.rb +0 -35
  15. data/lib/grafeas/v1/credentials.rb +0 -37
  16. data/lib/grafeas/v1/cvss_pb.rb +0 -67
  17. data/lib/grafeas/v1/deployment_pb.rb +0 -35
  18. data/lib/grafeas/v1/discovery_pb.rb +0 -43
  19. data/lib/grafeas/v1/doc/google/protobuf/any.rb +0 -131
  20. data/lib/grafeas/v1/doc/google/protobuf/empty.rb +0 -29
  21. data/lib/grafeas/v1/doc/google/protobuf/field_mask.rb +0 -222
  22. data/lib/grafeas/v1/doc/google/protobuf/timestamp.rb +0 -113
  23. data/lib/grafeas/v1/doc/google/rpc/status.rb +0 -39
  24. data/lib/grafeas/v1/doc/grafeas/v1/attestation.rb +0 -64
  25. data/lib/grafeas/v1/doc/grafeas/v1/build.rb +0 -44
  26. data/lib/grafeas/v1/doc/grafeas/v1/common.rb +0 -108
  27. data/lib/grafeas/v1/doc/grafeas/v1/cvss.rb +0 -104
  28. data/lib/grafeas/v1/doc/grafeas/v1/deployment.rb +0 -64
  29. data/lib/grafeas/v1/doc/grafeas/v1/discovery.rb +0 -82
  30. data/lib/grafeas/v1/doc/grafeas/v1/grafeas.rb +0 -328
  31. data/lib/grafeas/v1/doc/grafeas/v1/image.rb +0 -79
  32. data/lib/grafeas/v1/doc/grafeas/v1/package.rb +0 -125
  33. data/lib/grafeas/v1/doc/grafeas/v1/provenance.rb +0 -248
  34. data/lib/grafeas/v1/doc/grafeas/v1/upgrade.rb +0 -126
  35. data/lib/grafeas/v1/doc/grafeas/v1/vulnerability.rb +0 -223
  36. data/lib/grafeas/v1/grafeas_client.rb +0 -964
  37. data/lib/grafeas/v1/grafeas_client_config.json +0 -96
  38. data/lib/grafeas/v1/grafeas_pb.rb +0 -168
  39. data/lib/grafeas/v1/grafeas_services_pb.rb +0 -86
  40. data/lib/grafeas/v1/image_pb.rb +0 -36
  41. data/lib/grafeas/v1/package_pb.rb +0 -59
  42. data/lib/grafeas/v1/provenance_pb.rb +0 -116
  43. data/lib/grafeas/v1/upgrade_pb.rb +0 -56
  44. data/lib/grafeas/v1/vulnerability_pb.rb +0 -84
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 74d5cf12c67064ffa316b0c296f164b18549617f6ae5c125e90af7d1d5c5d130
4
- data.tar.gz: 12dd971cd3f9c4e36ba940e2e9d8ac674490bf23e24e5c056970699d82f73368
3
+ metadata.gz: 26d06c57e266558db4b17a7cf032c50c48b20b689b6167acb4c78e17f6692a77
4
+ data.tar.gz: 9821998d3c505b2da01fac80a46fd9b8d34d588863a0afff3c816ee547a02245
5
5
  SHA512:
6
- metadata.gz: e9e3aa376090948e915d0b1b2c2bc65f0b2d509e99ba0bf5156370b1312b3bbc409e9bba3f84f3c6b0e9448b64f8a2431d4d7938bb13f79eea8c18251cb424e0
7
- data.tar.gz: 5d15ea07728ddda822326a62b5ec16d4a253b3ae67506614f07950116a1eaa5759b6ddc575b15b7bea727fb93533aa0d94a9ce50539e6937f4296f98bbd48d91
6
+ metadata.gz: b03a9d053e65c207c119494598cf61480ccf679db15313cad3f9c95354ef1be4db8c2e4dea43af9974ac744083c7087daa6f0c791b26f9d650f9902506000bda
7
+ data.tar.gz: edbdea162b8b616d52fc79e042431f2661ffe340b9330b3ebbb6df0c9d4dc1d4524a47f7df52682e9030a5c2916411db6780091bbac54aa603ce1790eebbb0e4
data/.yardopts CHANGED
@@ -1,5 +1,5 @@
1
1
  --no-private
2
- --title=Container Analysis API
2
+ --title=Grafeas API
3
3
  --exclude _pb\.rb$
4
4
  --markup markdown
5
5
  --markup-provider redcarpet
@@ -7,5 +7,5 @@
7
7
  ./lib/**/*.rb
8
8
  -
9
9
  README.md
10
- AUTHENTICATION.md
11
- LICENSE
10
+ MIGRATING.md
11
+ LICENSE.md
data/LICENSE.md ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
data/MIGRATING.md ADDED
@@ -0,0 +1,366 @@
1
+ ## Migrating to grafeas 1.0
2
+
3
+ The 1.0 release of the grafeas client is a significant upgrade
4
+ based on a [next-gen code generator](https://github.com/googleapis/gapic-generator-ruby),
5
+ and includes substantial interface changes. Existing code written for earlier
6
+ versions of this library will likely require updates to use this version.
7
+ This document describes the changes that have been made, and what you need to
8
+ do to update your usage.
9
+
10
+ To summarize:
11
+
12
+ * The library has been broken out into two libraries. The new gem
13
+ `grafeas-v1` contains the actual client classes for version
14
+ V1 of the Grafeas service, and the gem `grafeas` now
15
+ simply provides a convenience wrapper. See
16
+ [Library Structure](#library-structure) for more info.
17
+ * The library uses a new configuration mechanism giving you closer control
18
+ over endpoint address, network timeouts, and retry. See
19
+ [Client Configuration](#client-configuration) for more info. Furthermore,
20
+ when creating a client object, you can customize its configuration in a
21
+ block rather than passing arguments to the constructor.
22
+ See [Creating Clients](#creating-clients) for more info.
23
+ * The library is now provider-agnostic, no longer defaulting to the endpoint
24
+ and credentials for Google's implementation. You must specify the endpoint
25
+ explicitly. If you want to use Google's Cloud Container Analysis service,
26
+ install the `google-cloud-container_analysis` gem, which provides a
27
+ Google-specific wrapper. See [Provider Independence](#provider-independence)
28
+ for more info.
29
+ * Previously, positional arguments were used to indicate required arguments.
30
+ Now, all method arguments are keyword arguments, with documentation that
31
+ specifies whether they are required or optional. Additionally, you can pass
32
+ a proto request object instead of separate arguments. See
33
+ [Passing Arguments](#passing-arguments) for more info.
34
+ * Previously, some client classes included helper methods for constructing
35
+ resource paths. These methods now take keyword rather than positional
36
+ arguments, and are also available in a separate paths module. See
37
+ [Resource Path Helpers](#resource-path-helpers) for more info.
38
+ * Previously, clients reported RPC errors by raising instances of
39
+ `Google::Gax::GaxError` and its subclasses. Now, RPC exceptions are of type
40
+ `Google::Cloud::Error` and its subclasses. See
41
+ [Handling Errors](#handling-errors) for more info.
42
+ * Some classes have moved into different namespaces. See
43
+ [Class Namespaces](#class-namespaces) for more info.
44
+
45
+ ### Library Structure
46
+
47
+ Older 0.x releases of the `grafeas` gem were all-in-one gems
48
+ that included potentially multiple clients for multiple versions of the
49
+ Grafeas service. The `Grafeas.new` factory method would
50
+ return you an instance of a `Grafeas::V1::GrafeasClient`
51
+ object for the V1 version of the service.
52
+
53
+ With the 1.0 release, the `grafeas` gem still provides factory
54
+ methods for obtaining clients. (The method signatures will have changed. See
55
+ [Creating Clients](#creating-clients) for details.) However, the actual client
56
+ classes have been moved into separate gems, one per service version. Currently,
57
+ Grafeas has one version, V1. The
58
+ `Grafeas::V1::Grafeas::Client` class, along with its
59
+ helpers and data types, is now part of the `grafeas-v1` gem.
60
+ If additional versions of the Grafeas service are released, additional gems
61
+ may be provided for their client classes.
62
+
63
+ For normal usage, you can continue to install the `grafeas` gem
64
+ (which will bring in the versioned client gems as dependencies) and continue to
65
+ use factory methods to create clients. However, you may alternatively choose to
66
+ install only one of the versioned gems. For example, if you know you will only
67
+ use implementations of `V1` of the service, you can install `grafeas-v1` by
68
+ itself, and construct instances of the `Grafeas::V1::Grafeas::Client` client
69
+ class directly.
70
+
71
+ ### Client Configuration
72
+
73
+ In older releases, if you wanted to customize performance parameters or
74
+ low-level behavior of the client (such as credentials, timeouts, or
75
+ instrumentation), you would pass a variety of keyword arguments to the client
76
+ constructor. It was also extremely difficult to customize the default settings.
77
+
78
+ With the 1.0 release, a configuration interface provides control over these
79
+ parameters, including defaults for all instances of a client, and settings for
80
+ each specific client instance. For example, to set default credentials and
81
+ timeout for all Grafeas V1 clients:
82
+
83
+ ```
84
+ Grafeas::V1::Grafeas::Client.configure do |config|
85
+ config.credentials = my_credentials
86
+ config.timeout = 10.0
87
+ end
88
+ ```
89
+
90
+ Individual RPCs can also be configured independently. For example, to set the
91
+ timeout for the `create_occurrence` call:
92
+
93
+ ```
94
+ Grafeas::V1::Grafeas::Client.configure do |config|
95
+ config.rpcs.create_occurrence.timeout = 20.0
96
+ end
97
+ ```
98
+
99
+ Finally, you can override the configuration for each client instance. See the
100
+ section on [Creating Clients](#creating-clients) for details.
101
+
102
+ ### Creating Clients
103
+
104
+ In older releases, to create a client object, you would use the
105
+ `Grafeas.new` class method. Keyword arguments were available to
106
+ select a service version and to configure parameters such as credentials and
107
+ timeouts.
108
+
109
+ With the 1.0 release, use the `Grafeas.grafeas` class
110
+ method to create a client object. You may select a service version using the
111
+ `:version` keyword argument. However, other configuration parameters should be
112
+ set in a configuration block when you create the client.
113
+
114
+ Old:
115
+ ```
116
+ client = Grafeas.new credentials: my_credentials_object
117
+ ```
118
+
119
+ New:
120
+ ```
121
+ client = Grafeas.grafeas do |config|
122
+ config.credentials = my_credentials_object
123
+ end
124
+ ```
125
+
126
+ The configuration block is optional. If you do not provide it, or you do not
127
+ set some configuration parameters, then the default configuration is used. See
128
+ [Client Configuration](#client-configuration).
129
+
130
+ ### Provider Independence
131
+
132
+ Older releases were tied to Google's Grafeas implementation, the Google Cloud
133
+ Container Analysis service. Clients were configured to use Google's endpoint
134
+ and credentials by default, though this could be overridden. You could also use
135
+ Google-specific credential specifications such as the path to a Google service
136
+ account keyfile.
137
+
138
+ With the 1.0 release, the `grafeas` gem is provider-independent, and does not
139
+ default to the Google implementation. You must specify an endpoint host, and
140
+ you must provide gRPC-based credentials (such as a
141
+ `GRPC::Core::ChannelCredentials` or a pre-constructed `GRPC::Core::Channel`
142
+ object) when creating a client object. These properties can be set using the
143
+ [configuration interface](#client-configuration) or by passing a block to the
144
+ constructor as covered in [Creating Clients](#creating-clients).
145
+
146
+ Old:
147
+ ```
148
+ client = Grafeas.new credentials: "path/to/google/keyfile.json"
149
+ ```
150
+
151
+ New:
152
+ ```
153
+ client = Grafeas.grafeas do |config|
154
+ config.endpoint = "my-grafeas.example.com"
155
+ config.credentials = my_grpc_credentials
156
+ end
157
+
158
+ # or
159
+
160
+ client = Grafeas.grafeas do |config|
161
+ config.credentials = my_existing_grpc_channel
162
+ end
163
+ ```
164
+
165
+ If you want to continue using Google's Cloud Container Analysis implementation,
166
+ we recommend using the `google-cloud-container_analysis` gem, which provides
167
+ the Google-specific default endpoint and credentials. Using the Container
168
+ Analysis client library, you can obtain a Grafeas client object connected and
169
+ authenticated with the Google backend.
170
+
171
+ New:
172
+ ```
173
+ require "google/cloud/container_analysis"
174
+
175
+ # Create a connection to the Google Container Analysis service
176
+ container_analysis = Google::Cloud::ContainerAnalysis.container_analysis do |config|
177
+ config.credentials = "/path/to/google/keyfile.json"
178
+ end
179
+
180
+ # You can obtain a Grafeas client from the Container Analysis connection
181
+ grafeas_client = container_analysis.grafeas_client
182
+ ```
183
+
184
+ ### Passing Arguments
185
+
186
+ In older releases, required arguments would be passed as positional method
187
+ arguments, while most optional arguments would be passed as keyword arguments.
188
+
189
+ With the 1.0 release, all RPC arguments are passed as keyword arguments,
190
+ regardless of whether they are required or optional. For example:
191
+
192
+ Old:
193
+ ```
194
+ client = Grafeas.new
195
+
196
+ parent = "projects/my-project"
197
+
198
+ # Parent is a positional argument, while page_size is a keyword argument.
199
+ response = client.list_occurrences parent, page_size: 10
200
+ ```
201
+
202
+ New:
203
+ ```
204
+ client = Grafeas.grafeas
205
+
206
+ parent = "projects/my-project"
207
+
208
+ # Parent and page_size are both keyword arguments
209
+ response = client.list_occurrences parent: parent, page_size: 10
210
+ ```
211
+
212
+ In the 1.0 release, it is also possible to pass a request object, either
213
+ as a hash or as a protocol buffer.
214
+
215
+ New:
216
+ ```
217
+ client = Grafeas.grafeas
218
+
219
+ request = Grafeas::V1::ListOccurrencesRequest.new(
220
+ parent: "projects/my-project",
221
+ page_size: 10
222
+ )
223
+
224
+ # Pass a request object as a positional argument:
225
+ response = client.list_occurrences request
226
+ ```
227
+
228
+ Finally, in older releases, to provide call options, you would pass a
229
+ `Google::Gax::CallOptions` object with the `:options` keyword argument. In the
230
+ 1.0 release, pass call options using a _second set_ of keyword arguments.
231
+
232
+ Old:
233
+ ```
234
+ client = Grafeas.new
235
+
236
+ parent = "projects/my-project"
237
+
238
+ options = Google::Gax::CallOptions.new timeout: 10.0
239
+
240
+ response = client.list_occurrences parent, page_size: 10, options: options
241
+ ```
242
+
243
+ New:
244
+ ```
245
+ client = Grafeas.grafeas
246
+
247
+ parent = "projects/my-project"
248
+
249
+ # Use a hash to wrap the normal call arguments (or pass a request object), and
250
+ # then add further keyword arguments for the call options.
251
+ response = client.list_occurrences(
252
+ { parent: parent, page_size: 10 },
253
+ timeout: 10.0
254
+ )
255
+ ```
256
+
257
+ ### Resource Path Helpers
258
+
259
+ The client library includes helper methods for generating the resource path
260
+ strings passed to many calls. These helpers have changed in two ways:
261
+
262
+ * In older releases, they are _class_ methods on the client class. In the 1.0
263
+ release, they are _instance_ methods on the client. They are also available
264
+ on a separate paths module that you can include elsewhere for convenience.
265
+ * In older releases, arguments to a resource path helper are passed as
266
+ _positional_ arguments. In the 1.0 release, they are passed as named _keyword_
267
+ arguments.
268
+
269
+ Following is an example involving using a resource path helper.
270
+
271
+ Old:
272
+ ```
273
+ client = Grafeas.new
274
+
275
+ # Call the helper on the client class
276
+ parent = Grafeas::V1::GrafeasClient.project_path "my-project"
277
+
278
+ response = client.list_occurrences parent
279
+ ```
280
+
281
+ New:
282
+ ```
283
+ client = Grafeas.grafeas
284
+
285
+ # Call the helper on the client instance, and use keyword arguments
286
+ parent = client.project_path project: "my-project"
287
+
288
+ response = client.list_occurrences parent: parent
289
+ ```
290
+
291
+ In the 1.0 client, you can also use the paths module as a convenience module.
292
+
293
+ New:
294
+ ```
295
+ # Bring the path helper methods into the current class
296
+ include Grafeas::V1::Grafeas::Paths
297
+
298
+ def foo
299
+ client = Grafeas.grafeas
300
+
301
+ # Call the included helper method
302
+ parent = project_path project: "my-project"
303
+
304
+ response = client.list_occurrences parent: parent
305
+
306
+ # Do something with response...
307
+ end
308
+ ```
309
+
310
+ ### Handling Errors
311
+
312
+ The client reports standard
313
+ {file:https://github.com/grpc/grpc/blob/master/doc/statuscodes.md gRPC error codes}
314
+ by raising exceptions. In older releases, these exceptions were located in the
315
+ `Google::Gax` namespace and were subclasses of the `Google::Gax::GaxError` base
316
+ exception class, defined in the `google-gax` gem. However, these classes were
317
+ different from the standard exceptions (subclasses of `Google::Cloud::Error`)
318
+ thrown by other client libraries such as `google-cloud-storage`.
319
+
320
+ The 1.0 client library now uses the `Google::Cloud::Error` exception hierarchy,
321
+ for consistency across all the Google Cloud client libraries. In general, these
322
+ exceptions have the same name as their counterparts from older releases, but
323
+ are located in the `Google::Cloud` namespace rather than the `Google::Gax`
324
+ namespace.
325
+
326
+ Old:
327
+ ```
328
+ client = Grafeas.new
329
+
330
+ parent = "projects/my-project"
331
+
332
+ begin
333
+ response = client.list_occurrences parent, page_size: 10
334
+ rescue Google::Gax::Error => e
335
+ # Handle exceptions that subclass Google::Gax::Error
336
+ end
337
+ ```
338
+
339
+ New:
340
+ ```
341
+ client = Grafeas.grafeas
342
+
343
+ parent = "projects/my-project"
344
+
345
+ begin
346
+ response = client.list_occurrences parent: parent, page_size: 10
347
+ rescue Google::Cloud::Error => e
348
+ # Handle exceptions that subclass Google::Cloud::Error
349
+ end
350
+ ```
351
+
352
+ ### Class Namespaces
353
+
354
+ In older releases, the client object was of classes with names like:
355
+ `Grafeas::V1::GrafeasClient`.
356
+ In the 1.0 release, the client object is of a different class:
357
+ `Grafeas::V1::Grafeas::Client`.
358
+ Note that most users will use the factory methods such as
359
+ `Grafeas.grafeas` to create instances of the client object,
360
+ so you may not need to reference the actual class directly.
361
+ See [Creating Clients](#creating-clients).
362
+
363
+ In older releases, there was a Google-specific credentials class named
364
+ `Grafeas::V1::Credentials`.
365
+ In the 1.0 release, this class is no longer present.
366
+ See [Provider Independence](#provider-independence).